Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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!

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.

![]() |
![]() |
![]() |

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