TUniStoredProc ReturnParams not working
Posted: Wed 24 Sep 2014 18:58
Using:
Delphi XE2 Enterprise Update 4 HotFix 1
UniDAC 5.5.11
Firebird 2.5.3
There is a TUniStoredProc with:
SQLInsert and SQLUpdate properties are set,
SQLInsert points to a Firebird stored procedure which returns a parameter,
BeforeUpdating event handler has code to add a new output parameter with the same name as in the database Insert stored procedure,
ReturnParams is set to True,
StrictUpdate is set to False.
However after an insert is done on the stored procedure dataset, the output parameter is not found in the list.
Method of doing the insert:
The TUniStoredProc is open in browse mode at runtime, then an Insert is called, field values are set and then Post is called.
The problem is that the returned output parameter is not found in the Params collection ie.
The TUniStoredProc SQL property (via Stored Procedure editor):
The TUniStoredProc SQLInsert property:
The Firebird Insert stored procedure:
The Firebird table DDL:
The TUniStoredProc BeforeUpdateExecute event Delphi code:
I would be glad if you could tell me how to resolve the error (or investigate if its a bug).
Thanks in advance.
--
Steve Faleiro
Delphi XE2 Enterprise Update 4 HotFix 1
UniDAC 5.5.11
Firebird 2.5.3
There is a TUniStoredProc with:
SQLInsert and SQLUpdate properties are set,
SQLInsert points to a Firebird stored procedure which returns a parameter,
BeforeUpdating event handler has code to add a new output parameter with the same name as in the database Insert stored procedure,
ReturnParams is set to True,
StrictUpdate is set to False.
However after an insert is done on the stored procedure dataset, the output parameter is not found in the list.
Method of doing the insert:
The TUniStoredProc is open in browse mode at runtime, then an Insert is called, field values are set and then Post is called.
The problem is that the returned output parameter is not found in the Params collection ie.
Code: Select all
Params.FindParam('OROW_ID') = nil //is true.. ! Code: Select all
EXECUTE PROCEDURE PATIENT_SEL(:IROW_ID)Code: Select all
EXECUTE PROCEDURE PATIENT_I(:ROW_ID, :FNAME, :LNAME, :IDTYPE, :IDNO,
:HOSPIDNO, :DOB, :GENDER, :REGDATE, :ADDR1, :ADDR2, :ADDR3, :CITY,
:PROVINCE, :ADMINZONE, :LASTVSTDATE)Code: Select all
CREATE PROCEDURE PATIENT_I (
ROW_ID Integer,
FNAME VarChar(80),
LNAME VarChar(80),
IDTYPE Integer,
IDNO VarChar(48),
HOSPIDNO VarChar(48),
DOB Date,
GENDER VarChar(1),
REGDATE Date,
ADDR1 VarChar(100),
ADDR2 VarChar(100),
ADDR3 VarChar(100),
CITY VarChar(100),
PROVINCE VarChar(100),
ADMINZONE VarChar(100),
LASTVSTDATE Timestamp)
returns (
OROW_ID Integer) AS
BEGIN
INSERT INTO PATIENT (
FNAME,
LNAME,
IDTYPE,
IDNO,
HOSPIDNO,
DOB,
GENDER,
REGDATE,
ADDR1,
ADDR2,
ADDR3,
CITY,
PROVINCE,
ADMINZONE,
LASTVSTDATE)
VALUES (
:FNAME,
:LNAME,
:IDTYPE,
:IDNO,
:HOSPIDNO,
:DOB,
:GENDER,
:REGDATE,
:ADDR1,
:ADDR2,
:ADDR3,
:CITY,
:PROVINCE,
:ADMINZONE,
:LASTVSTDATE) RETURNING ROW_ID INTO :OROW_ID;
The Firebird table DDL:
Code: Select all
CREATE TABLE PATIENT
(
ROW_ID INTEGER NOT NULL,
FNAME VARCHAR( 80) COLLATE UTF8,
LNAME VARCHAR( 80) COLLATE UTF8,
IDTYPE INTEGER,
IDNO VARCHAR( 48) COLLATE UTF8,
HOSPIDNO VARCHAR( 48) COLLATE UTF8,
DOB DATE,
GENDER VARCHAR( 1) COLLATE UTF8,
REGDATE DATE,
ADDR1 VARCHAR( 100) COLLATE UTF8,
ADDR2 VARCHAR( 100) COLLATE UTF8,
ADDR3 VARCHAR( 100) COLLATE UTF8,
CITY VARCHAR( 100) COLLATE UTF8,
PROVINCE VARCHAR( 100) COLLATE UTF8,
ADMINZONE VARCHAR( 100) COLLATE UTF8,
LASTVSTDATE TIMESTAMP,
CONSTRAINT PK_PATIENT PRIMARY KEY (ROW_ID)
);
Code: Select all
procedure Tdatamod.uspPATIENT_SELBeforeUpdateExecute(Sender: TDataSet; StatementTypes: TStatementTypes;
Params: TDAParams);
begin
if stInsert in StatementTypes then
begin
Params.Add;
Params[Params.Count - 1].Name := 'OROW_ID';
Params[Params.Count - 1].ParamType := ptOutput;
Params[Params.Count - 1].DataType := ftInteger;
end;
end;
Thanks in advance.
--
Steve Faleiro