Subject | Re: [ib-support] Beginner fiddeling with Stored Procedure |
---|---|
Author | Helen Borrie |
Post date | 2002-03-08T02:08:49Z |
Kai:
At 10:32 PM 07-03-02 +0100, you wrote:
SET SISTESENDNR = :NEWNUMBER
When your code refers to the variable, omit the ':'.
When it refers to the value stored in the variable, use the ':'.
In an SQL statement, always refer to the variable by its value, i.e.
:NEWNUMBER, so that SQL knows to treat it as a value and not an identifier.
Hence, this would work:
NEWNUMBER = :NEWNUMBER + 1
and these are wrong:
NEWNUMBER = NEWNUMBER + 1 (the engine looks for a column called NEWNUMBER)
:NEWNUMBER = :NEWNUMBER + 1 (you can't assign to a value, only to a variable)
But this is OK because it is testing a value:
if (:NEWNUMBER +1 > :MAXNUMBER) then .....
cheers,
Helen
All for Open and Open for All
Firebird Open SQL Database · http://firebirdsql.org ·
http://users.tpg.com.au/helebor/
_______________________________________________________
At 10:32 PM 07-03-02 +0100, you wrote:
> UPDATE POST_EANSENDshould be
> SET SISTESENDNR = NEWNUMBER // This is the offending line.
SET SISTESENDNR = :NEWNUMBER
> WHERE ID = 1;The rule I use when working with variables in SPs is this:
> SUSPEND;
>
>END
>
>The error message I'm getting is this: "Dynamic ... error code = -206 Column
>unknown NEWNUMBER At line 25, Column 21 (se my comment in the code for this
>line)
When your code refers to the variable, omit the ':'.
When it refers to the value stored in the variable, use the ':'.
In an SQL statement, always refer to the variable by its value, i.e.
:NEWNUMBER, so that SQL knows to treat it as a value and not an identifier.
Hence, this would work:
NEWNUMBER = :NEWNUMBER + 1
and these are wrong:
NEWNUMBER = NEWNUMBER + 1 (the engine looks for a column called NEWNUMBER)
:NEWNUMBER = :NEWNUMBER + 1 (you can't assign to a value, only to a variable)
But this is OK because it is testing a value:
if (:NEWNUMBER +1 > :MAXNUMBER) then .....
cheers,
Helen
All for Open and Open for All
Firebird Open SQL Database · http://firebirdsql.org ·
http://users.tpg.com.au/helebor/
_______________________________________________________