Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

pl/sql stored procedure syntax

Original Message
Name: fleetmack
Date: February 21, 2008 at 17:15:34 Pacific
Subject: pl/sql stored procedure syntax
OS: oracle 10gR2
CPU/Ram: fast
Model/Manufacturer: 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!


Report Offensive Message For Removal


Response Number 1
Name: TheOskMan
Date: March 31, 2008 at 06:25:52 Pacific
Subject: pl/sql stored procedure syntax
Reply: (edit)
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.


Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: pl/sql stored procedure syntax

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




How to make a FOLDER private

ad cross domain/forest grp nestin

Recreating vista boot files?

Cisco IOS very quick question

hard drive ram


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC