Home » SQL & PL/SQL » SQL & PL/SQL » want to display fields using dbms_output.put_line
want to display fields using dbms_output.put_line [message #379390] Tue, 06 January 2009 05:26 Go to next message
radhavijaym
Messages: 65
Registered: December 2008
Location: singapore
Member
hi,
i created a procedure
i printing values from a table trough dbms_output.put_line

i want my output to be in this format

custname number partyname
abc 123 ABC
pqr 345 qww
drr 444 ooo
ppp 999 iii

...

i wnat my output to this format
i want header (custname,number,party name ) to display only once .
i m getting output like this

custname number partyname
abc 132 abc
custname number partyname
wewqrwqrewrre 213214 hrioweyro
custname number partyname
wutytrywetre 24325545 lkkewf

im getting like this idont want like this
so please help me how to do this
  • Attachment: Docbnb.pdf
    (Size: 357.90KB, Downloaded 442 times)

[Updated on: Tue, 06 January 2009 05:29]

Report message to a moderator

Re: want to display fields using dbms_output.put_line [message #379392 is a reply to message #379390] Tue, 06 January 2009 05:30 Go to previous messageGo to next message
S.Rajaram
Messages: 1027
Registered: October 2006
Location: United Kingdom
Senior Member
Unfortunately my crystal ball is broken Sad . So I am unable to see the code you are executing. If you don't mind could you post the actual code along with the output and the expected output required. Also please follow the forum guidelines on how to format your post.

Regards

Raj

[Edit: ] If you don't mind could you post it inline rather an attachment.

[Updated on: Tue, 06 January 2009 05:31]

Report message to a moderator

Re: want to display fields using dbms_output.put_line [message #379393 is a reply to message #379390] Tue, 06 January 2009 05:33 Go to previous messageGo to next message
Michel Cadot
Messages: 64109
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Guess: do no print the header for each line.

Post your code.
Before Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter), use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Regards
Michel
Re: want to display fields using dbms_output.put_line [message #379504 is a reply to message #379392] Tue, 06 January 2009 18:31 Go to previous message
Barbara Boehmer
Messages: 8631
Registered: November 2002
Location: California, USA
Senior Member
Peering into my crystal ball, I see a procedure with a loop and a dbms_output.put_line that displays the column headings within the loop. Move that line outside the loop, as in the example below.

SCOTT@orcl_11g> CREATE OR REPLACE PROCEDURE demo_proc
  2  AS
  3  BEGIN
  4    DBMS_OUTPUT.PUT_LINE ('DEPTNO DNAME	    LOC'); -- HEADINGS HERE
  5    FOR r IN (SELECT deptno, dname, loc FROM dept)
  6    LOOP
  7  	 -- NO HEADINGS HERE
  8  	 DBMS_OUTPUT.PUT_LINE
  9  	   (RPAD (r.deptno, 7) ||
 10  	    RPAD (r.dname, 15) ||
 11  	    RPAD (r.loc,   14));
 12    END LOOP;
 13  END;
 14  /

Procedure created.

SCOTT@orcl_11g> SET SERVEROUTPUT ON
SCOTT@orcl_11g> EXEC demo_proc
DEPTNO DNAME          LOC
10     ACCOUNTING     NEW YORK
20     RESEARCH       DALLAS
30     SALES          CHICAGO
40     OPERATIONS     BOSTON

PL/SQL procedure successfully completed.

SCOTT@orcl_11g>

Previous Topic: String functions on Long column
Next Topic: Job alert
Goto Forum:
  


Current Time: Mon Dec 05 06:42:51 CST 2016

Total time taken to generate the page: 0.14935 seconds