Subject | Returning ID on insert |
---|---|
Author | Bob Lazarchik |
Post date | 2002-05-06T12:16Z |
Hi:
I am using Delphi 6 C/S and Firebird 1.0.0.338. I have a table that contains a primary key, the value of which is supplied by a generator at insert time. When I insert a new record I need the value of the primary Key returned to me ( I am using it as a pointer from a record in another table ). I wrote the stored procedure below but I get a parameter mismatch error from Delphi. Could anyone explain to me the proper way to return an autogenerated value from an insert procecure.
My Code:
Create PROCEDURE INTEGERVALUES_I
(
IV_VALUE INTEGER,
IV_DEFAULT INTEGER,
IV_MIN INTEGER,
IV_MAX INTEGER
)
RETURNS
(
IV_ID INTEGER // this is the value I need returned. It is created by a generator before insert
)
AS
BEGIN
INSERT INTO INTEGERVALUES (
IV_VALUE,
IV_DEFAULT,
IV_MIN,
IV_MAX)
VALUES (
:IV_VALUE,
:IV_DEFAULT,
:IV_MIN,
:IV_MAX);
END
TIA
Bob Lazarchik
[Non-text portions of this message have been removed]
I am using Delphi 6 C/S and Firebird 1.0.0.338. I have a table that contains a primary key, the value of which is supplied by a generator at insert time. When I insert a new record I need the value of the primary Key returned to me ( I am using it as a pointer from a record in another table ). I wrote the stored procedure below but I get a parameter mismatch error from Delphi. Could anyone explain to me the proper way to return an autogenerated value from an insert procecure.
My Code:
Create PROCEDURE INTEGERVALUES_I
(
IV_VALUE INTEGER,
IV_DEFAULT INTEGER,
IV_MIN INTEGER,
IV_MAX INTEGER
)
RETURNS
(
IV_ID INTEGER // this is the value I need returned. It is created by a generator before insert
)
AS
BEGIN
INSERT INTO INTEGERVALUES (
IV_VALUE,
IV_DEFAULT,
IV_MIN,
IV_MAX)
VALUES (
:IV_VALUE,
:IV_DEFAULT,
:IV_MIN,
:IV_MAX);
END
TIA
Bob Lazarchik
[Non-text portions of this message have been removed]