473,511 Members | 16,660 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Server Data on Insert property

I try to use the Server Data on Insert property to return a column value
swhich is set in a trigger.
But it does not work. Why not? What am I doing wrong?
(BTW I'm using Oracle version 10)

My VB source is:

Dim mConn As New ADODB.Connection
Dim rs As New ADODB.Recordset

mConn.ConnectionString = "Provider=OraOLEDB.Oracle;User
ID=jan;Password=test;Data Source=test;"
mConn.Open

rs.ActiveConnection = mConn
rs.CursorLocation = adUseServer
rs.Properties("Server Data on Insert").Value = True

rs.Open "select * from test where id < -1", mConn, adOpenForwardOnly,
adLockOptimistic
rs.AddNew "name", "newname"
rs.Update

MsgBox rs("id")

mConn.Close

The test table has an ID column which is filled in a trigger by getting a
sequence nextvalue.

I am using this source because I use this way of insert all over the
application with a SqlServer database. The ID column in de Sql2000 database
is an Identity column which immediately returns it's new value after the
AddNew.
I am looking for a way to make my application working at an Oracle database
without a lot of source modifications.
I found this article:
http://www.tju.cn/docs/odb10.1.0.2/w...0115/using.htm where the
'Server Data on Insert' property is described.

If anybody wants to test it in his own database, this is the definition of
the table:

CREATE TABLE Test (
id NUMBER,
name VARCHAR2(20)
);

CREATE SEQUENCE seqTest;

CREATE TRIGGER newTest
BEFORE INSERT ON Test
FOR EACH ROW
WHEN (NEW.id IS NULL)
BEGIN
SELECT seqTest.NEXTVAL INTO :new.id FROM DUAL;
END;
Jul 19 '05 #1
2 6133
I found the solution myself:

The connection.cursorlocation should be adUseServer and you must use
adOpenKeyset at the Open method.

So this is working:

Dim mConn As New ADODB.Connection
Dim rs As New ADODB.Recordset

mConn.ConnectionString = "Provider=OraOLEDB.Oracle;User
ID=jan;Password=test;Data Source=test;
mConn.CursorLocation = adUseServer
mConn.Open

rs.Open "select * from test where id < -1", mConn, adOpenKeyset,
adLockOptimistic
rs.AddNew "name", "newname"
rs.Update

MsgBox rs("id")

mConn.Close

"Jan van Veldhuizen" <ja*@van-veldhuizen.nl> wrote in message
news:41***********************@news.xs4all.nl...
I try to use the Server Data on Insert property to return a column value
swhich is set in a trigger.
But it does not work. Why not? What am I doing wrong?
(BTW I'm using Oracle version 10)

My VB source is:

Dim mConn As New ADODB.Connection
Dim rs As New ADODB.Recordset

mConn.ConnectionString = "Provider=OraOLEDB.Oracle;User
ID=jan;Password=test;Data Source=test;"
mConn.Open

rs.ActiveConnection = mConn
rs.CursorLocation = adUseServer
rs.Properties("Server Data on Insert").Value = True

rs.Open "select * from test where id < -1", mConn, adOpenForwardOnly,
adLockOptimistic
rs.AddNew "name", "newname"
rs.Update

MsgBox rs("id")

mConn.Close

The test table has an ID column which is filled in a trigger by getting a
sequence nextvalue.

I am using this source because I use this way of insert all over the
application with a SqlServer database. The ID column in de Sql2000
database is an Identity column which immediately returns it's new value
after the AddNew.
I am looking for a way to make my application working at an Oracle
database without a lot of source modifications.
I found this article:
http://www.tju.cn/docs/odb10.1.0.2/w...0115/using.htm where the
'Server Data on Insert' property is described.

If anybody wants to test it in his own database, this is the definition of
the table:

CREATE TABLE Test (
id NUMBER,
name VARCHAR2(20)
);

CREATE SEQUENCE seqTest;

CREATE TRIGGER newTest
BEFORE INSERT ON Test
FOR EACH ROW
WHEN (NEW.id IS NULL)
BEGIN
SELECT seqTest.NEXTVAL INTO :new.id FROM DUAL;
END;

Jul 19 '05 #2
And the fun is:

there's only *ONE* difference with the SqlServer behaviour here: SqlServer
requires a ClientSide cursor for this functionality.
So I still am able to make minor changes to my source to let it work with
both databases.

"Jan van Veldhuizen" <ja*@van-veldhuizen.nl> wrote in message
news:41***********************@news.xs4all.nl...
I found the solution myself:

The connection.cursorlocation should be adUseServer and you must use
adOpenKeyset at the Open method.

So this is working:

Dim mConn As New ADODB.Connection
Dim rs As New ADODB.Recordset

mConn.ConnectionString = "Provider=OraOLEDB.Oracle;User
ID=jan;Password=test;Data Source=test;
mConn.CursorLocation = adUseServer
mConn.Open

rs.Open "select * from test where id < -1", mConn, adOpenKeyset,
adLockOptimistic
rs.AddNew "name", "newname"
rs.Update

MsgBox rs("id")

mConn.Close

"Jan van Veldhuizen" <ja*@van-veldhuizen.nl> wrote in message
news:41***********************@news.xs4all.nl...
I try to use the Server Data on Insert property to return a column value
swhich is set in a trigger.
But it does not work. Why not? What am I doing wrong?
(BTW I'm using Oracle version 10)

My VB source is:

Dim mConn As New ADODB.Connection
Dim rs As New ADODB.Recordset

mConn.ConnectionString = "Provider=OraOLEDB.Oracle;User
ID=jan;Password=test;Data Source=test;"
mConn.Open

rs.ActiveConnection = mConn
rs.CursorLocation = adUseServer
rs.Properties("Server Data on Insert").Value = True

rs.Open "select * from test where id < -1", mConn, adOpenForwardOnly,
adLockOptimistic
rs.AddNew "name", "newname"
rs.Update

MsgBox rs("id")

mConn.Close

The test table has an ID column which is filled in a trigger by getting a
sequence nextvalue.

I am using this source because I use this way of insert all over the
application with a SqlServer database. The ID column in de Sql2000
database is an Identity column which immediately returns it's new value
after the AddNew.
I am looking for a way to make my application working at an Oracle
database without a lot of source modifications.
I found this article:
http://www.tju.cn/docs/odb10.1.0.2/w...0115/using.htm where the
'Server Data on Insert' property is described.

If anybody wants to test it in his own database, this is the definition
of the table:

CREATE TABLE Test (
id NUMBER,
name VARCHAR2(20)
);

CREATE SEQUENCE seqTest;

CREATE TRIGGER newTest
BEFORE INSERT ON Test
FOR EACH ROW
WHEN (NEW.id IS NULL)
BEGIN
SELECT seqTest.NEXTVAL INTO :new.id FROM DUAL;
END;


Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
12081
by: iqbal | last post by:
Hi all, We have an application through which we are bulk inserting rows into a view. The definition of the view is such that it selects columns from a table on a remote server. I have added the...
18
10248
by: Robin Lawrie | last post by:
Hi again, another problem! I've moved from an Access database to SQL server and am now having trouble inserting dates and times into seperate fields. I'm using ASP and the code below to get the...
8
3542
by: Harris Boyce | last post by:
Hello, I'm trying to use the FOR XML EXPLICIT clause with SQL Server to deserialize data from my database into a strongly-typed collection object that I will use throughout my application. I...
2
607
by: A P | last post by:
Whats wrong with my code? <%@ Page Language="VB" %> <script runat="server"> ' Insert page code here ' Function GetDetails() As System.Data.DataSet
2
6927
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
1
1719
by: ByB | last post by:
Hello, I am working on an Access VBA application, working in client/server mode, with a shared SQL Server base. I have to INSERT some data in the base, and the know what is the ID that SQL...
5
1769
by: Brad Pears | last post by:
Hi guys!!! Thanks for all your input on previous OO posts. I know it will be all the same people responding again and I really appreciate your insight etc.. as you all appear to know what you are...
2
644
by: Jan van Veldhuizen | last post by:
I try to use the Server Data on Insert property to return a column value swhich is set in a trigger. But it does not work. Why not? What am I doing wrong? (BTW I'm using Oracle version 10) My...
0
7242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7138
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7355
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7081
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7510
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1576
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
447
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.