Subject | Re: [ib-support] Select |
---|---|
Author | Helen Borrie |
Post date | 2002-05-13T04:53:02Z |
At 12:42 PM 13-05-02 +1200, Sandeep wrote:
I guess it is not OK. <g> The only situation here where you would get a
change in varA to null would be if "select valueA from tableA where fieldA
= 1" found a row and valueA was null. If it doesn't find a row at all,
that won't reset the variable. All your code is saying is "if there is
such a row, then push the value of valueA into varA. If you want it to be
null in the event that no row is found, code it by initialising varA to
null *before* calling select...into
Helen
All for Open and Open for All
Firebird Open SQL Database · http://firebirdsql.org ·
http://users.tpg.com.au/helebor/
_______________________________________________________
>I have a stor proc as followIf you were expecting something to change varA under these conditions then
>
>...
>select valueA from tableA where fieldA = 2 into :varA;
>
>select valueA from tableA where fieldA = 1 into :varA;
>...
>
>if first statement finds something then varA is set to that value. And if
>the second statement doesn't find anything then I expected it to be set
>to null, but that's not the case. It has the value assigned in first select
>statement.
>
>Is this OK ?
I guess it is not OK. <g> The only situation here where you would get a
change in varA to null would be if "select valueA from tableA where fieldA
= 1" found a row and valueA was null. If it doesn't find a row at all,
that won't reset the variable. All your code is saying is "if there is
such a row, then push the value of valueA into varA. If you want it to be
null in the event that no row is found, code it by initialising varA to
null *before* calling select...into
Helen
All for Open and Open for All
Firebird Open SQL Database · http://firebirdsql.org ·
http://users.tpg.com.au/helebor/
_______________________________________________________