Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2009
    Posts
    1

    Unanswered: creating a procedure for a package (dbms_output.put_line)

    i want to use printf instead of dbms_output.put_line in my Pl/SQL program.
    plz chk .its not working

    create procedure printf (a varchar2) as
    begin
    set a = dbms_output.put_line;
    end;
    /

  2. #2
    Join Date
    Mar 2007
    Posts
    623
    What does 'plz chk .its not working' mean? As the code you posted is not valid in Oracle, I doubt it shows this terrible text.

    Anyway, as PL/SQL code runs on Oracle server, it has no ability to display anything. It may at most fill DBMS_OUTPUT buffer by calling its PUT_LINE method. The client program may display its content then, if it is able and configured to do so.
    In SQL*Plus, it is possible after setting SERVEROUTPUT ON.
    In SQL Developer, it is available on "DBMS Output" tab after enabled by a button.
    The same principle is available in TOAD; the tab may be named slightly differently though.
    I have no idea, whether it is implemented in any other client (Forms reports, JDBC, OCCI, ...). It may be done manually by calling DBMS_OUTPUT.GET_LINE You may find more about it in Oracle documentation.
    By the way, what are clients you plan to use?

    [Add: As PRINTF is supposed to call DBMS_OUTPUT, what is the difference then? Do you suppose, it will display more than DBMS_OUTPUT.PUT_LINE? Anyway, you should call PUT_LINE correctly there. ]
    Last edited by flyboy; 12-21-09 at 03:48.

  3. #3
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    You should have written:
    Code:
    create procedure printf (a varchar2) as
    begin
    dbms_output.put_line(a);
    end;
    Personally, I wouldn't name it "printf" as that suggests it does the sort of formatting that C's printf does; it doesn't.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •