Re: Select Into problem

From: Jomarlen <jomarlen_at_aol.com>
Date: 1998/03/10
Message-ID: <19980310002500.TAA12977_at_ladder02.news.aol.com>#1/1


>BEGIN
>--Gets the current user
>user_name := GET_APPLICATION_PROPERTY(USERNAME);
>criteria := CHR(39) || user_name || CHR(39);
>--Checks to see if user is in the admin table
>SELECT COUNT(*) INTO counter FROM TABLEA
> WHERE user_id = criteria;
>
>

Your problem is

criteria := CHR(39) || user_name || CHR(39);

You don't need the quotes.

Your query effectively becomes
......
 Where user_id = ''SIR'' -- obviously never true

When of course what you want is
.......
 Where user_id = 'SIR'

You actually don't need the variable
.........
  Where user_id = USER

will work just fine.

By the way, your code would be much more efficient if you created a cursor and then fetched from it. Even better again, created a stored function. Received on Tue Mar 10 1998 - 00:00:00 CET

Original text of this message