Home » SQL & PL/SQL » SQL & PL/SQL » reg select into
reg select into [message #21596] Fri, 16 August 2002 03:00 Go to next message
Victoria
Messages: 152
Registered: July 2002
Senior Member
Hi,
i have written my procedure like this........

FOR ARTS_rec IN ARTS_cursor LOOP
SELECT 1 FROM URT_CITY CITY
WHERE
.......
IF SQL%FOUND THEN
ARTS_rec.m25 := ARTS_rec.m25||RPAD('Y',31,' ');
ELSE
ARTS_rec.m25 := ARTS_rec.m25||RPAD('N',31,' ');
END IF;

UTL_FILE.PUT_LINE(v_file_handle,
ARTS_rec.a||ARTS_rec.b||ARTS_rec.m25 );
END LOOP;

here am getting an error
LINE/COL ERROR
-------- -----------------------------------------------------------------
318/7 PLS-00428: an INTO clause is expected in this SELECT statement
318/7 PL/SQL: SQL Statement ignored...

so i have used

something like this,

FOR ARTS_rec IN ARTS_cursor LOOP
SELECT count(*) into cnt FROM URT_CITY CITY
WHERE
.......
IF cnt >0 THEN
ARTS_rec.m25 := ARTS_rec.m25||RPAD('Y',31,' ');
ELSE
ARTS_rec.m25 := ARTS_rec.m25||RPAD('N',31,' ');
END IF;

UTL_FILE.PUT_LINE(v_file_handle,
ARTS_rec.a||ARTS_rec.b||ARTS_rec.m25 );
END LOOP;

can any one tell me whats wrong with the first one???i have been told not to use the second one...pls help me
Thanks
Victoria
Re: reg select into [message #21605 is a reply to message #21596] Fri, 16 August 2002 08:06 Go to previous messageGo to next message
Nick
Messages: 64
Registered: February 2000
Member
You should not use second one coz it takes a count(*) and count is always avoided and that too in a loop.

When you are calling any select call you should either use cursor outside the BEGIN .....
or

Select 'x' into vVar
where Conditions.....

You can use this in both the locations first statement and second one too.
Re: reg select into [message #21609 is a reply to message #21596] Fri, 16 August 2002 08:52 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
http://www.orafaq.net/msgboard/plsql/messages/9987.htm
Previous Topic: SQL and PL/SQL Limitations
Next Topic: SQL and PL/SQL Limitations
Goto Forum:
  


Current Time: Thu Apr 25 19:23:46 CDT 2024