How to use serveroutput commands in plsql

Hi,
I have to create spool file inside my procedure how is it possible to use it? Is there any way.
Will dynamic statements will work
E.g CREATE OR REPLACE PROCEDURE SP_PROC1
AS
BEGIN
SET SERVEROUPUT ON;
SPOOL D:\ABCD.LOG;
SET SERVEROUTPUT OFF;
SPOOL OFF;
END;
Thanks

Yes, its possible.
First open the file for writing:
Then write to the file.
(You replace the string used in dbms_output.put_line with utl_file.put_line );
Finally close the file when finished.
If on windows , terminate your session (Otherwise you may not be able to see the data in the file).
Here is some code which I use.
procedure open_log_file(p_file_out out utl_file.file_type,
                        p_sourcedir in varchar2,
                        p_filename   in varchar2,
                        p_filemode   in varchar2)
is
v_filemode varchar2(1) := p_filemode;
begin
p_file_out := UTL_FILE.FOPEN( p_SOURCEDIR, p_filename, v_filemode );
end open_log_file;
procedure log_to_file(p_file_in in utl_file.file_type,
                      p_text    in varchar2)
as
begin
    UTL_FILE.PUT_LINE(  p_file_in,p_text);
end log_to_file;
procedure close_log_file(p_file_in in utl_file.file_type)
is
v_file utl_file.file_type := p_file_in;
begin
if utl_file.is_open(v_file)
then
    utl_file.fclose(v_file);
end if;
end close_log_file;

Similar Messages

  • How to use LIKE operator in plsql

    Hi
    I wanted to select certain rows using like operator in plsql(Input should be given by the user). I have given my experiment here .I couldn't get any result.
    As per sql syntax while using LIKE operator we should give search criteria within single quote.where as in plsql if we give within single quote its takes as string so no output is comming.what is solution ? How to use like operator in plsql?
    sql syntax
    SQL>SELECT customer_name FROM customer_header
    WHERE customer_name LIKE 'B%' ; customer_name
    Bala murali
    Babu
    Basker
    plsql syntax
    PROCEDURE pro_custheader_like ( v_cname IN varchar2
         ,answer OUT type_refcur_customer) IS
         BEGIN
         OPEN answer FOR
         SELECT customer_name FROM customer_header
              WHERE customer_name LIKE ( ' v_cname ' );
    END pro_custheader_like;
    execution command
    sql>variable answer refcursor;
    sql>set serveroutput on
    sql>exec package_name.pro_custheader_like( 'R',:answer);
    plsql successfully completed
    sql>print :answer
    no row selected
    by
    balamuralikrishnan.s

    plsql syntax
    PROCEDURE pro_custheader_like ( v_cname IN
    varchar2
    ,answer OUT
    type_refcur_customer) IS
    N
         OPEN answer FOR
         SELECT customer_name FROM customer_header
    WHERE customer_name LIKE ( v_cname );
    END pro_custheader_like;
    Try it without any quotes. And, let us know your feedback.
    Regards.
    Satyaki De.
    Message was edited by:
    Satyaki_De

  • How to execute unix command in plsql block( urgent)

    Hi All,
    i want rename the unix folder to New name on update non_employee table . So, please give me idea how to use unix command here.... Please suggest me ASAP ... Its urgent
    CREATE or REPLACE TRIGGER NON_EMPLOYEE_AftUpd_trg
    AFTER UPDATE ON NON_EMPLOYEE
    FOR EACH ROW
    BEGIN
    IF :new.DIST_LIVELINK_PATH <> :old.DIST_LIVELINK_PATH THEN
    rename unixfolder1 to :new.dist_livelink_path.
    end IF;
    END;

    The solution will depend a lot on your Oracle version, which you forgot to mention ;)
    btw shouldn't that be (in pseudocode)
    rename :old.dist_livelink_path to :new.dist_livelink_pathotherwise it will always fail after the first time?
    In Unix that would require the mv command.

  • How to use STSADM commands in sharepoint 2007

    How to use STSADM commands in sharepoint 2007

    Hi,
    There is no such STSADM commands to get the user groups.  There are two separate STSADM commands get either users or groups for particular site.
    STSADM -o enumusers <<url>>
    STSADM -o enumgroups <url>
    For complete reference, please refer to the following article.
    http://blogs.technet.com/b/josebda/archive/2008/03/15/complete-reference-of-all-stsadm-operations-with-parameters-in-moss-2007-sp1.aspx
    One such console application available to get the user groups.  Please refer to the below article.
    List all SharePoint groups a user belongs to
    Please don't forget to mark it as answered, if your problem resolved or helpful.

  • How to use $PROFILES$CONC_COPIES in plsql

    Can you give me an example of using $PROFILES$.CONC_COPIES in plsql? I need to change a plsql program to product 2 set of output reports each time when the job is run. User doesn't to change user profile option number of Concurrent copies. Thanks.

    I thought you said you knew how to use/create profiles in your previous post...
    This is the quick rundown: Just as with regular profiles, you first need to make sure that your content has the profile trigger metadata field assigned when it's created. This is done within designer under "Switch region content" definition of your contribution region. Assign the "Profile Trigger Value" under "Default Metadata" and then assign that idoc to the activation condition of your content profile rule.

  • How we use merge command in pro*C

    merge command not support the pro*C pl/sql block how we use in pro*C (without creating any pl block on database )

    hello shalab,
    u can use dynamic sql method one.for execution merge query.
    syntax is
    EXEC SQL EXECUTE IMMEDIATE :stmt
    u have to copy your query into one string.
    like this
    strcpy(stmt,"merge into emp_new a ");
    strcat(stmt," using emp b ");
    strcat(stmt,"on ( a.empno = b.empno) ");
    strcat(stmt," when matched then ");
    strcat(stmt," update set sal= sal*10 ");
    strcat(stmt," when not matched then ");
    strcat(stmt," insert (a.empno, a.ename) values ");
    strcat(stmt," (b.empno, b.ename); ");
    then execute like this.
    EXEC SQL EXECUTE IMMEDIATE :stmt

  • How to use host command for creating folders

    i want to create a folder called abc in my C drive using forms 6i.
    how can i do it using Host command?

    Host('MD C:\ABC');Francois

  • How to use Filter commands in WAD?

    Hello community,
    I am desperately trying to use the command wizzard in order to set a Filter to a chrarcateristic in an 7.0 web template:
    I have been trying these commands so far but it simply doesnt work:
    SET_SELECTION_STATE_SIMPLE
    SET_SELECTION_STATE
    My problem is: When I select the charcateristic which I want to Filter, I get always the Error message, that the characteristic is not a valied characteristic or structure of the Query. But this is not true, the Characteristic is in the query. I have tried for hours now but no success.
    Thanks for any help or advice.
    Carl

    Hi Carl,
    I had the same situation. All you have to do is to update your support package. After that it will work properly.
    I have - Support Package 7, Revision 571
    Regards
    Erwin
    Edited by: Erwin  Buda on Dec 5, 2008 9:47 PM

  • How to use 'bash' command in java?

    Hi,
    I am using Linux operating system
    when i run the following code, 'test.sh' not started
    ================================================================
    String cmd = "bash \"/home/kulandaivelu/Desktop/works/other's works/test.sh\"";
    Runtime.getRuntime().exec(cmd).waitFor();
    ================================================================
    but it started when i use same command(bash "/home/kulandaivelu/Desktop/works/other's works/test.sh") in terminal
    anyone let me know what mistake i made in the code piece..
    Thanks in Advance
    Kulandaivelu

    Hi,
    thanks a lot..
    I used the following code.. it worked well..
    ===============================================================
    String cmd[] = {"bash","/home/kulandaivelu/Desktop/works other's/test.sh"};
    Runtime.getRuntime().exec(cmd).waitFor();
    ===============================================================
    Thanks a lot again..

  • How to use split command in upload program

    Thanks for all ...for their quick response for my previous query.
    Iam continuing with the same upload program,now i have transfered the data from internal table to application server,now iam trying to upload this to database,while doing this iam using split command for spliting the records,but its not at all spliting,can u give me a solution for this.

    OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
      if sy-subrc <> 0.
        PERFORM messaging USING 'E' '001' text-e10 p_file space space.
      else.
        DO.
          READ DATASET P_file INTO WA .
          IF SY-SUBRC <> 0.
            EXIT.
          ENDIF.
          REPLACE ALL OCCURRENCES OF '"' IN WA WITH ''.
          CONDENSE WA NO-GAPS.
          SPLIT WA AT CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
          INTO wa_infile.
          append wa_infile to it_infile.
          clear wa_infile.
        ENDDO.
      endif.
    try this...
    vijay

  • How to use oraxml command-line in LINUX

    Hi:
    I gave the classpath for xmlparserv2.jar and try to excute some of the commands like
    %oraxml -help
    I got oraxml: command not found
    How can I use it?
    Please help
    ALI_02

    You can't.
    They are two totally different operating systems.

  • How to use  modify command?

    i want to modify table t_bseg which is used n BTE interface_00001050
    i want to modify only 1 specific line, how can i modify this line without using index because i get 0 when i use sy-tabix?
    ( i want to modify this line using the table keys ) .
    thanks

    Hi,
    MODIFY TABLE <itab> FROM <wa> [TRANSPORTING <f1> <f 2> ...].
    Check this link:
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ac8358411d1829f0000e829fbfe/content.htm
    Regards
    Adil

  • How to use ADT command line to build an iOS application including ActionScript native extension file

    Hi All,
    I have ANE files packaged in my iOS application. I can export them to release build through FB no problem.
    But How can I include those ANE files through ADT command line? Can I do like other library files?
    Thanks in advance for any helps.

    I was stupid that did not find the right syntax.
    -extdir extensionsDir will do the trick.

  • How to use the command key with shortcuts/CS6?

    Since ID2 I  am using the combination Command+Escape to define a shortcut.
    Buy this time Escape could not be tagged.
    I was trying to remember if those years ago I modified escape key in some place (system preferences/keyboard) but neither could find a path to reconstruct this.
    Also check the escape key in other shorcuts to avoid problem but no way.
    Searched the forum but could not find something helpful
    http://forums.adobe.com/message/2977659

    [Jongware] wrote:
    I guess that makes it an InDesign problem ...
    Searching yesterday found it is an old topic, but not related to Adobe but to Apple: including thriller plots like that they are preserving the combination command+escape for future projects...
    https://discussions.apple.com/thread/3438952?start=0&tstart=0
    https://discussions.apple.com/thread/3569274?start=0&tstart=0
    Also it has been resolved by programmers with very interesting formulae like the «Escape Key Liberator» (sic):
    http://manytricks.com/blog/?p=1664
    In my situation it was enough to reset the Apple Keyboard shortcuts...
    Thank for your reply.

  • How to use dll commands using or in database triggers...

    I want to use a dll command such as drop table table_name in the database trigger, is it possible ???
    If yes then please write me the codings, Thanks.....

    > I want to use a dll command such as drop table table_name in the database trigger, is
    it possible ???
    The question is not whether it is possible - and if you are indeed an OCP as you seem to claim with you handle, you should know the answer to this.
    The question is whether it is at all sensible from a functional perspective and a transaction processing perspective, to do this. And again, the answer to this should be quite clear as a DDL cannot be part of that trigger's transaction. Which means when that transaction is rolled back, the damage has been done - as the DDL executed by the trigger cannot be rolled back.
    > If yes then please write me the codings,
    So you are saying that you are incapable of writing any code? Then what on earth are you doing in a programmer's forum? Ask your supervisor/boss to give the problem to a real programmer to solve.

Maybe you are looking for

  • How many photos can I share from my iphone 4S

    I am not able to use my laptop at work or install iCloud onto my work computer, so I want to email myself the photos on my iphone, though there is no function to show how much space is remaining for sharing depending on which platform I would like. N

  • Can I expand the memory of my ipod touch 4G from 32GB to 64 GB?

    I expand the memory of my ipod touch 4G from 32GB to 64 GB?

  • Can't watch Netflix on 10.4.11 (iMac G5)?

    I have an older Mac (I believe it's the G5), Mac OSX version 10.4.11. I want to be able to stream Netflix from the internet, but it says I need these minimum requirements: Mac An Intel-based Mac with OS 10.4.11 or later Safari 4 or higher; or Firefox

  • Problem with default file access permission

    Hi, I am accessing a common area '/NFS_DATA' by both my java and oracle codes by the users 'javaUsr' and 'oraUsr' respectively. As per the requirement, the oracle code (oraUsr) needs to create some file in the specified location and then the java cod

  • Macbook pro iphoto 6.0.2 won't recognize iphoto library (backup from DVD)

    Just purchased a Macbook Pro with iphoto 6.0.2. Had a G4 powerbook with iphoto 4.0.2 and backed up that iphoto library to 2 DVD's. I loaded the photos and albums from the 2 DVDs to the iphoto library on the macbook. when I launch the iphoto 6.0.2 it