Subject | Re: [firebird-support] Problem with my first stored procedure |
---|---|
Author | Dimitry Sibiryakov |
Post date | 2005-04-19T06:05:38Z |
On 19 Apr 2005 at 13:57, Grant Brown wrote:
Read FIB manual.
redundant.
Procedures that update a record or insert new one if it does not
exists usually look like this:
BEGIN
PK_VAR = NULL;
FOR SELECT PK_FIELD FROM A_TABLE WHERE ..... INTO :PK_VAR AS CURSOR
T DO
UPDATE A_TABLE SET ... WHERE CURRENT OF CURSOR Tl
IF(PK_VAR IS NULL) THEN
INSERT INTO A_TABLE ....;
END
--
SY, Dimitry Sibiryakov.
>When I try calling the following function I get ant exception when theYou could show us the error message...
>Prepare statement is executed.
>Could someone show me what I am doing wrong ?Almost everything.
>SaveStoredProc.SQL is declared asYour procedure has only _three_ input parameters. Remove the last.
>
>EXECUTE PROCEDURE P_SAVE_DATA_LIST_ITEM (?FDTYPE, ?ITEM01,
>?CUR_DETECT_ID, ?RESULTID)
> Params[0].Value := DT;Using variants is not good practice, I'd say.
> Params[1].Value := ItemText;
> Params[2].Value := DetectID;
> Prepare;AFAIR, output parameters are accessed through Fields[] property.
> ExecProc;
> DetectID := Params[3].Value;
Read FIB manual.
> if Transaction.InTransaction then Transaction.Commit;Transaction here is in transaction for sure, so the check is
redundant.
Procedures that update a record or insert new one if it does not
exists usually look like this:
BEGIN
PK_VAR = NULL;
FOR SELECT PK_FIELD FROM A_TABLE WHERE ..... INTO :PK_VAR AS CURSOR
T DO
UPDATE A_TABLE SET ... WHERE CURRENT OF CURSOR Tl
IF(PK_VAR IS NULL) THEN
INSERT INTO A_TABLE ....;
END
>SiteDoc - Easy to Use - Powerful ResultsWhat to hell is this? Spam, I suppose.
>
>This email and any attached files (of whatsoever nature) are
>confidential, may be privileged and intended solely for the use of the
>intended recipient and are subject to copyright and the Privacy Act
>(Cth) Any confidentiality or privilege is not lost or waived because
>of any error in sending this email to you. If you have received this
>email in error, please advise by return email, delete it from your
>system and destroy any copies. Our company is not responsible for any
>viruses or harmful programs passed on down via email. You should have
>installed, up to date virus scanning software. The views expressed in
>this email are those of the sender and should not necessarily be taken
>as those of the company.
--
SY, Dimitry Sibiryakov.