|
I don't know Oracle, BUT I assume it has MANY
functional equivalents to DB2. For DB2 UDB V8.1 or
DB2 iSeries V5R2 you could create an identity column
value for table and then retrieve the generated value
into a host variable in the prepared statement as
shown below. You can also create your own generation
function to create a column value in DB2. All very
flexible.
Set the variable IVAR to the value assigned to the
identity column in the EMPLOYEE table. The value
returned from the function in the VALUES statement
should be 1.
CREATE TABLE EMPLOYEE
(EMPNO INTEGER GENERATED ALWAYS AS IDENTITY,
NAME CHAR(30),
SALARY DECIMAL(5,2),
DEPT SMALLINT)
INSERT INTO EMPLOYEE
(NAME, SALARY, DEPTNO)
VALUES('Rupert', 989.99, 50)
VALUES IDENTITY_VAL_LOCAL() INTO :IVAR
==================================
MORE INFORMATION ON THIS TOPIC
==================================
Ask your Web development questions--or help out your peers by answering them--in our live discussion forums.
The Best Web Links: tips, tutorials and more.
Check out this live Q&A with Dave Slater and Jim Mason, How to best get started with WebSphere Development Tools.
|