While working on a production issue, I stumbled on something, that I thought was, strange in a SELECT statement in PB.
Essentially, I have a simple SQL that selects into a Variable. I guess, the original developer (I am only maintaining this code) expected only one row in this case.
....
//
Date ld_CutOff
....
SELECT TO_DATE(PARM_VALUE, 'DD-MON')
INTO :ld_CutOff
FROM SYSPARM
WHERE PARM_NAME = 'CUTOFF_DATE' ;
....
Now the table has more than 1 that match the criteria. Thus, the SQL errored (Select Returned more than 1 row) as expected. (Based on prior experience in PB and PL/SQL,) I expected the host variable to be null (01/01/1900 in this case). To my surprise, the SQL actually set the variable to 1st Date value (or is the last value?) returned by the SQL.
(FYI, I turned on the SQL Trace: it seems it keeps fetching all the rows, so I guess it will be last row value that's put in the local variable?)
I am fixing the SQL, but I am just curious to know more about the way PB handles this. Is this a normal behavior for PB/SQL or am I expecting PL/SQL behavior in PB?? The versions I am using: PB 10.2.1 (Build 9671) and Oracle 10g. Thanks a lot for any comments or suggestions.
Sam