Karen, I too like the SELECT ... INTO ... option but I would include INDICATOR variables to test for NULL values.
ind_var Stores an INTEGER value (-1 or 0) that indicates whether the preceding into_var received a null value or a non-null value; this is an optional indicator variable. If you omit indicator variables, R:BASE displays a message and assigns a negative integer to SQLCODE if it encounters a null value. The command continues to process rows. Jim Bentley American Celiac Society [email protected] tel: 1-504-737-3293 >________________________________ > From: Mike Byerley <[email protected]> >To: RBASE-L Mailing List <[email protected]> >Sent: Tuesday, May 15, 2012 5:33 PM >Subject: [RBASE-L] - Re: Difference between "select into" and "set var" > >That''s not very mysterious. no rows were returned to make an assignment to >the variable. >I would still use Select personally and test for SqlCode after the select to >determine if rows were returned. > > >----- Original Message ----- >From: <[email protected]> >To: "RBASE-L Mailing List" <[email protected]> >Sent: Tuesday, May 15, 2012 5:00 PM >Subject: [RBASE-L] - Difference between "select into" and "set var" > > >:I am porting over someone else's old DOS code to the windows version. When >: I do this, I like to update the syntax. You know, converting "compute" to >: a "select ... into", etc. However, I found a difference if you convert a >: "set var" to a "select into", and thought I would mention it so it doesn't >: trip someone else up. >: >: In these 2 examples, the where clause is going to fail: >: >: set var vInteger int = 10 >: select hourid into vInteger from hours where client = 'zzzz' >: show var vInteger >: -- The result of this is vInteger remains 10 >: >: set var vInteger int = 10 >: set var vInteger = hourid from hours where client = 'zzzz' >: show var vInteger >: -- The result of this is vInteger being a NULL >: >: The "set var" code I ran into was run from a declare cursor. The variable >: was not initialized to null, but it didn't matter with the "set var". But >: as soon as I replaced it with a "select ... into", I found I have to >: initialize the variable first or else it will retain the last cursor's >value! So >: at this point, I'm sticking with the "set var" just to be on the safe >side. >: >: Karen > > > > >

