473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 6131
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
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
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
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
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
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
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
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
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.