Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> ODBC Cache for Automaticaly generated number columns?

ODBC Cache for Automaticaly generated number columns?

From: Patrick Williams <patrick.williams_at_natinst.com>
Date: 1998/10/15
Message-ID: <705hko$n5q@statesman.natinst.com>#1/1

I would like to be able to read an automatically generated unique primary key just after it has been created using ODBC on a Windows platform. I have used the table, sequence and trigger definitions below to generate the unique value.

This works fine. The problem arises when I insert a row into the table, TEST, and want to get the ID column for the row just inserted. I always get a NULL value returned. The ODBC driver does not read the generated value in the database but seems to keeps a cache of the values inserted, and returns NULL because a value was not used for ID when creating the row.

Is there a way around this problem?

CREATE TABLE TEST
(
ID NUMBER PRIMARY KEY,
VAL NUMBER
)
/

CREATE SEQUENCE SEQ_TEST START WITH 1
/

CREATE TRIGGER BIU_TEST BEFORE INSERT OR UPDATE ON TEST FOR EACH ROW
BEGIN
IF INSERTING THEN
SELECT SEQ_TEST.NextVal INTO :new.ID FROM DUAL; ELSIF UPDATING THEN
:new.ID := :old.ID;
END IF;
END; Received on Thu Oct 15 1998 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US