Subject | Re: [firebird-support] Strange SP behaviour |
---|---|
Author | Lucas Franzen |
Post date | 2006-06-22T13:30:25Z |
Johannes,
without really having a look, what's happening, some notes:
LOOP.
Then you ask if vcID IS NULL.
That might be the problem, since you don't initialize vcID inside your
loop, so that if your select (select c_id from table_c ) doesn't return
anything then vC_ID is not NULL, it has the value of the last loop
execution.
In general: If you select sth. that doesn't exist than the return value
is nothing (so your variable :vC_ID won't be touched). And nothing is
NOT equal to NULL.
Luc.
without really having a look, what's happening, some notes:
> ALTER PROCEDURE CREATE_C_ENTRY (VA_ID VARCHAR(10))vC_ID = NULL; /* add this line */
> RETURNS (RC_ID INTEGER,
> RA_ID VARCHAR(10),
> RE_CODE VARCHAR(10))
> AS
>
> declare variable vE_CODE varchar(10);
> declare variable vC_ID integer;
> BEGIN
> for select e_code from table_a where id = :vA_ID into :vE_CODE do begin
> select c_id from table_c where a_id = :vA_ID and e_code = :vE_CODE into :vC_ID;vC_ID is selected INSIDE in a single select which is inside a FOR SELECT
>
> if (vC_ID is null) then begin
LOOP.
Then you ask if vcID IS NULL.
That might be the problem, since you don't initialize vcID inside your
loop, so that if your select (select c_id from table_c ) doesn't return
anything then vC_ID is not NULL, it has the value of the last loop
execution.
In general: If you select sth. that doesn't exist than the return value
is nothing (so your variable :vC_ID won't be touched). And nothing is
NOT equal to NULL.
Luc.