Block structure [message #275543] |
Sun, 21 October 2007 09:12 |
mrparr
Messages: 9 Registered: October 2007
|
Junior Member |
|
|
In using a block structure, how can I design a PL/SQl program that will enable a screen display of all my records? I am a beginner and trying to figure out what to put in the declare statement and the executable statement. I have created a table and even placed five sample records. I need to show an output.
SQL> select*
2 from records;
EMPLOYEE_CODE EMPLOYEE_SSN FIRST_NAME LAST_NAME EMPLOYEE_ HOURLY_RATE
------------- ------------ ---------- ---------- --------- -----------
ANNUAL_SALARY
-------------
1 123541236 John Brown 01-JAN-05 11
20750
2 789541254 Cynthia Green 05-FEB-06 11
21865
3 654321122 Steve White 16-MAR-04 12
23001
EMPLOYEE_CODE EMPLOYEE_SSN FIRST_NAME LAST_NAME EMPLOYEE_ HOURLY_RATE
------------- ------------ ---------- ---------- --------- -----------
ANNUAL_SALARY
-------------
4 123785555 Gail Black 20-MAY-07 12
24156
5 4047852 Fred Jones 03-APR-07 13
25291
|
|
|
|
Re: Block structure [message #275548 is a reply to message #275543] |
Sun, 21 October 2007 10:48 |
|
Littlefoot
Messages: 21818 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
If I understood the question, DBMS_OUTPUT package used in a cursor loop is what you are looking for. This is a sample code:BEGIN
FOR cur_r IN (SELECT employee_code, employee_ssn, first_name
FROM records)
LOOP
dbms_output.put_line(cur_r.employee_code ||' '||
cur_r.employee_ssn ||' '||
cur_r.first_name
);
END LOOP;
END; Don't forget to SET SERVEROUTPUT ON before executing the script (if SQL*Plus is a tool you use; if not, find how to enable the output in your tool).
|
|
|