Computing.Net > Forums > Database > pl/sql stored procedure syntax

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

pl/sql stored procedure syntax

Reply to Message Icon

Name: fleetmack
Date: February 21, 2008 at 17:15:34 Pacific
OS: oracle 10gR2
CPU/Ram: fast
Product: big
Comment:

I will first off admit - this is for school. I cannot figure out for the life of me why it won't work. I'm not expecting anyone to give me the answer (but would gladly take it!) but rather am looking for someone to point me in the right direction.

I am to write a stored procedure that displays the first name concatenated with the last name from a particular table. I am to use an implicit FOR loop.

Now I wrote a cursor to get the data and that works fine:
DECLARE
CURSOR NNAME IS
SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME
FROM CH10EMPLOYEE;
BEGIN
FOR RCLIENT IN NNAME LOOP
DBMS_OUTPUT.PUT_LINE(RCLIENT.FIRST_NAME||' '||RCLIENT.LAST_NAME);
END LOOP;
END;
/

I cannot, however, for the life of me, get this to develop into a procedure. I've never written one before. Here is what I am trying, but it is not working:

SET SERVEROUTPUT ON;
EXEC DBMS_OUTPUT.ENABLE(1000000);
CREATE OR REPLACE PROCEDURE GETEMPLOYEES()
(
AS
(DECLARE
CURSOR NNAME IS
SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME
FROM CH10EMPLOYEE);
BEGIN
FOR RCLIENT IN NNAME LOOP
DBMS_OUTPUT.PUT_LINE(RCLIENT.FIRST_NAME||' '||RCLIENT.LAST_NAME);
END LOOP;
END;
/

ANY help would be GREATLY appreciated! Thanks!



Sponsored Link
Ads by Google

Response Number 1
Name: TheOskMan
Date: March 31, 2008 at 06:25:52 Pacific
Reply:

HI

TEST:

FOR RCLIENT IN (SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAMEFROM CH10EMPLOYEE;)
LOOP
dbms_output.put_line( RCLIENT.FIRST_NAME||' '||RCLIENT.LAST_NAME); END LOOP;

Regards,
Oscar.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Database Forum Home


Sponsored links

Ads by Google


Results for: pl/sql stored procedure syntax

executing shell script from pl/sql procedure www.computing.net/answers/dbase/executing-shell-script-from-plsql-procedure/741.html

SQL2005 stored procedure question www.computing.net/answers/dbase/sql2005-stored-procedure-question/199.html

stored procedure www.computing.net/answers/dbase/stored-procedure/524.html