PL/SQL statement [message #606348] |
Wed, 22 January 2014 10:50 |
|
SteveShephard
Messages: 41 Registered: August 2012
|
Member |
|
|
Hi All,
I am trying to write a PL/SQL routine using the select into statement to run an internal command. However the problem I have is the query returns multiple values and therefore the whole statement errors (exact fetch returns move than requested number of rows)
Here is the kind of thing I am writing at the moment. I think I need to use a cursor and loop through but not sure where and how to put this into the statement?
DECLARE
name_ VARCHAR2(100);
BEGIN
select name into name_ from employee where name like = 'A%';
MY_COMMAND.START(name_);
END;
Any help would be really appreciated.
Many thanks
Steve
|
|
|
|
Re: PL/SQL statement [message #606350 is a reply to message #606348] |
Wed, 22 January 2014 12:34 |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
SteveShephard wrote on Wed, 22 January 2014 22:20I think I need to use a cursor and loop through but not sure where and how to put this into the statement?
DECLARE
name_ VARCHAR2(100);
BEGIN
select name into name_ from employee where name like = 'A%';
MY_COMMAND.START(name_);
END;
Per Oracle :
"The nice thing about the cursor FOR loop is that Oracle Database opens the cursor, declares a record by using %ROWTYPE against the cursor, fetches each row into a record, and then closes the loop when all the rows have been fetched (or the loop terminates for any other reason)."
So, you could try something like :
FOR indx IN (select * from employee where .....)
LOOP
MY_COMMAND.START(indx.column);
END LOOP;
|
|
|
|
|
|
|
Re: PL/SQL statement [message #606410 is a reply to message #606401] |
Thu, 23 January 2014 07:24 |
|
Michel Cadot
Messages: 68641 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
As you are in 11g you should use LISTAGG instead.
WM_CONCAT is not documented (so not supported for your case) and requires that Oracle Workspace Manager is installed.
|
|
|