save my last run SQL command
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 8 of 8

Thread: save my last run SQL command

  1. #1
    Join Date
    Feb 2006
    Posts
    86

    save my last run SQL command

    hi
    i have a requirement where i want to save or spool my last run SQl command in a txt file .
    for Example:
    i run first command : INSERT INTO ABC VALUES ('A');
    now when i run second command : UPDATE ABC SET TYPE='B';
    i want to save/spool my last SQl command (insert statement)
    in a txt file or anywhere else.

    so is there any SQL script for that.
    pls help me out

    thanx

  2. #2
    Join Date
    Jul 2002
    Location
    Lake Worth, FL
    Posts
    1,478

    Cool


    Use the SPOOL command.
    "The person who says it cannot be done should not interrupt the person doing it." --Chinese Proverb

  3. #3
    Join Date
    Sep 2002
    Location
    England
    Posts
    7,333
    Code:
    SQL> select * from dual;
    
    D
    -
    X
    
    SQL> spool last_statement.txt
    SQL> list
      1* select * from dual
    SQL> spool off

  4. #4
    Join Date
    Sep 2006
    Posts
    3
    SQL> spool c:\ocp_project\last_record.txt
    SQL> INSERT INTO ABC VALUES ('A');
    1 record inserted


    SQL> UPDATE ABC SET TYPE='B';

    updated

    SQL> spool off;

    check the file in the specified dir.

  5. #5
    Join Date
    Feb 2006
    Posts
    86

    implicit or autospool of last run SQL command

    thanx
    that i know. but i am looking for auto spool of my sql command.
    i have not to save any specific or single command explicitly.

    my requirement is that whenever i run a SQL command at sql prompt
    my last SQL command or ,alternatively, the current command should get spooled implicitly or automatically to a txt file.
    i dont want to spool manually by writting spool command after each of my SQL command.

    is there any script for that.

    looking for help.

    thanx

  6. #6
    Join Date
    Sep 2005
    Posts
    278

    binoyshill:

    my requirement is that whenever i run a SQL command at sql prompt
    my last SQL command or ,alternatively, the current command should get spooled implicitly or automatically to a txt file.
    Looks that something to do with auditing.

    Why dont you audit all the successful statements of the session and transfer the data to a text files from Data Dictionaries.

  7. #7
    Join Date
    Feb 2006
    Posts
    86
    which Data Dictionary should i look for.
    since iam not into DBa sort of things so its bit difficult for me to do
    audit.

    tell me other way to implicit spool of commands into text file
    thancx

  8. #8
    Join Date
    Jul 2002
    Location
    Lake Worth, FL
    Posts
    1,478

    Cool


    Or you can use a tool like Oracle SQL*Worksheet, Oracle SQL Developer, TOAD, etc... which automatically keep SQL statement history.

    "The person who says it cannot be done should not interrupt the person doing it." --Chinese Proverb

Posting Permissions

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



Click Here to Expand Forum to Full Width