Re: SELECT... INTO... problem

From: <pete_karanikas_at_hotmail.com>
Date: 2000/05/25
Message-ID: <8gkanm$uv$1_at_nnrp1.deja.com>#1/1


TurkBear,
[Quoted] [Quoted] Actually, you're right. The p_count is getting set. I'm trying to write a procedure that will print out an error if there are no objects with the desired object_name found... ie. p_count=0. It goes a little "something" like this:

CREATE or REPLACE PROCEDURE countit
object_search_string varchar2(25) default NULL; is
p_count integer;
BEGIN
select count(a.object_name) into p_count from user_objects a,
where a.object_name like '|| object_search_string ||';

IF p_count = 0 THEN

   htp.p( 'Your search returned no results, try again' ); END IF; ...

END; The count seems to work... but the problem is that the IF statement ALWAYS executes... so I just assumed that the p_count wasn't getting set. Is my IF statement screwed up?

Thanks,
Pete

In article <392d8be0.25070088_at_news.news-ituk.to>,   See Message body for real address wrote:
>
> Please post your procedure - it should work:
>
> I built the following
>
> ------------------------------------------------------------
> Create or Replace procedure Countit is
> nbr integer;
> begin
> select count(*) into nbr from my_employees;
> dbms_output.put_line('There are '||nbr||' employees in the table');
> end;
>




>
> This returns the following
>
> SQL> Exec Countit
>
> There are 790 employees in the table
>
> pete_karanikas_at_hotmail.com wrote:
>
> >Why won't this work? (it's within a procedure)
> >
> >select count(*) into p_count
> >from user_tables;
> >
> >The p_count has been declared as an INTEGER and is always returned
 as a
> >value of 0.
> >
> >Any ideas?
> >
> >Pete
> >
> >
> >Sent via Deja.com http://www.deja.com/
> >Before you buy.
>
> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----== Over 80,000 Newsgroups - 16 Different Servers! =-----
>

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Thu May 25 2000 - 00:00:00 CEST

Original text of this message