Re: Select Into problem

From: Steve Cosner <stevec_at_zimmer.csufresno.edu>
Date: 1998/03/07
Message-ID: <6ds1m2$i2i_at_info.csufresno.edu>#1/1


Get rid of the "chr(39)" apostrophes in "criteria". You are looking for the 5-character value 'SIR' in your user_id column, but your table contains the 3-character value, SIR. You only need to surround your values with apostrophes when you enter literal values from the pl/sql source code.

Steve Cosner



http://members.aol.com/stevec5088
Downloadable utility form -- Display and update any table.

In article <1998Mar6.141635.9992_at_vmsmail.gov.bc.ca>, Mark Cudmore <mcudmore_at_kamloops.env.gov.bc.ca> wrote:
>I have the following code in a Post_query trigger for the block
>
>DECLARE
>user_name varchar2(08);
>criteria varchar2(10);
>counter number(2);
>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;
>
>MESSAGE('Counter: ' || TO_CHAR(counter));
>
>END;
>
>Here is the contents of the table...
>
>USER_ID
>--------
>SIR
>
>Now when I log on to the application with the user name of SIR, I should
>return a count of 1 through the above select into. I am checking to see if
>that user_id exists in the column. For the life of my I can't figure out
>why "counter" is returning zero, when I am expecting one??? I've been
>staring at that piece of code all afternoon, so I if you have any
>suggestions, let fly!!
>
>--
>Mark Cudmore
>email: mcudmore_at_kamloops.env.gov.bc.ca
>
>
>
Received on Sat Mar 07 1998 - 00:00:00 CET

Original text of this message