Exit from sqlplus / plsql script

Hello,
I'm executing the following script (named test_script.sql)
SET serveroutput ON
DEFINE temp=&1
DECLARE
BEGIN
dbms_output.put_line('Value: &temp');
END;
using the command line
sqlplus <username>/<password> @/tmp/test_script.sql "Hello"
I want this this script to exit automatically. Unfortunately, it shows a screen with a line number on the left, waiting for user input. I have to enter the '/'-sign or the '.'-sign to stop this. Then the "SQL>" prompt appears and I have to enter "exit" to quit. Far away from exiting automatically...
Adding "exit" to the end of the script doesn't work. The script still waits for user input with a number to the left. When entering '/', it says "Encountered the symbol "EXIT" The symbol "EXIT" was ignored."
Can anybody help?

END;
exit
<br>
<br>
Doesn't work..?
Message was edited by:
        jeneesh
Again,..
Too late..                                                                                                                                                                                                                                                       

Similar Messages

  • Exiting from SQLPLUS on failure returned from a function

    I am working on Oracle 11g (R2). I want to call a function in package and if that function returns zero then I want to quit/exit from SQLPLUS prompt.
    I will be calling that function of package from an .sql file.
    How can i do this?
    I can also call raise_application_error() from that function. Without using WHENEVER SQLERROR EXIT, is there any way of doing this?

    Thanks, but if i am calling that function from a .sql file, can i verify the return value and exit from sqlplus prompt.

  • Exiting from sqlplus prompt if file not found

    I often execute .sql files from my shell scripts. If the .sql file is not present then sqlplus command logs onto sql prompt but stays there saying file not found.
    Is there a way I can make sqlplus exit if the file is not found.
    I believe one of the option should be specifying some condition in the .sql file.

    Hi,
    Tricky problem! WHENEVER OSERROR EXIT is the right command, but where can you put it?
    If foo.sql doesn't exist, then clearly you can't put it in foo.sql.
    Even putting in in login.sql doesn't seem to work.
    What you can do is write a script that you know will exist, and always run that to launch your real script.
    For example, you can write a script called try_to_run.sql, like this:
    WHENEVER  OSERROR  EXIT
    @&1Pass the name of your real script as &1, like this:
    sqlplus  scott/tiger@dbanme  @try_to_run  real_scriptor, if real_script.sql takes arguments:
    sqlplus  scott/tiger@dbanme  @try_to_run  "real_script arg1  arg2  arg3"

  • Exiting from sqlplus when there is any errors while compiling pl/sql progra

    I am connecting to sqlplus from unix and I am executing a pl/sql script . Now if I get some error while compiling a procedure, package, function or any sql statement I want to exit sqlplus.
    whenever sqlerror works only for sql statements but not for plsql
    I dont want to query user_errors table and then throw some exception depending on the same .
    Is there any command available or any easier way to solve this problem ?

    Those errors we get only when there is conflict in same etc.
    Now consider the example here
    sample.sql
    whenever sqlerror exit failure ;
    declare
            s1 long;
    begin
            s1 := 'create or replace procedure proc1 as '||
              'declare '||
              'begin '||
                  'end; '||
              'end;';
            execute immediate s1;
    end;
    select 1 from dual;When I run the script
    SQL> @sample.sql
    ERROR:
    ORA-24344: success with compilation error
    ORA-06512: at line 9
    Warning: PL/SQL compilation errors.
             1
             1Actually I want to get out before it executes select means once it throws error in pl/sql.

  • Exiting from SQL script

    Hi,
    How do you exit from an sql script?
    e.g
    DECLARE
    VAR1 = VARCHAR2(10);
    VAR2 = VARCHAR2(10);
    BEGIN
    VAR1 := 'hello';
    VAR2 := 'world';
    IF VAR1 != VAR2
    THEN
    DBMS_OUTPUT.PUT_LINE('Variables not equal');
    ## Exit here! <------- HOW?????
    END IF;
    END;
    Cheers,
    Warren

    If I understand correctly, you have a series of anonymous PL/SQL blocks in a script. If some test fails in one of them, then you do not want to run the rest of the script.
    If exiting sqlplus is an acceptable means of failing, then you can do something like:
    WHENEVER SQLERROR EXIT 1;
    DECLARE
    v1 VARCHAR2(20);
    v2 VARCHAR2(20);
    BEGIN
       v1 := 'ABCDE';
       v2 := 'FBCDE';
       IF v1 <> v2 THEN
          DBMS_OUTPUT.Put_Line('Variables Not Equal');
          RAISE NO_DATA_FOUND;
       END IF;
    END;
    DECLARE
    v3 VARCHAR2(20);
    BEGIN
       v3 := 'Second Block';
    END;
    /in your script. As shown, the script will exit sqlplus without executing the second block. You can use any sql error instead of no data found.
    Another possibility if exiting sqlplus is not acceptable would be to do something like this in your script:
    VARIABLE failed NUMBER;
    DECLARE
    v1 VARCHAR2(20);
    v2 VARCHAR2(20);
    BEGIN
       :failed := 0;
       v1 := 'ABCDE';
       v2 := 'FBCDE';
       IF v1 <> v2 THEN
          DBMS_OUTPUT.Put_Line('Variables Not Equal');
          :failed := 1;
          RETURN;
       END IF;
    END;
    DECLARE
    v3 VARCHAR2(20);
    BEGIN
       IF :failed = 0 THEN
          v3 := 'Second Block';
       END IF;
    END;
    /Note, the IF :failed = 0/END IF block should cover all the code in each subsequent anonymous block.
    A third approach would be to re-write the series of anonymous blocks as a package, then create a small driver script to call each procedure in turn unless one returns an error.
    TTFN
    John

  • How can I exit my UNIX script when my PLSQL script in it calls an error?

    hello.
    I hope someone can help with my error handling and exiting-in-the-right-place problem.
    I have several PLSQL scripts that are called from a UNIX script to insert/update employee records in ORACLE Financials.
    At the end of the UNIX script, depending on whether an entry has been created in the errors table should depend on whether the UNIX script stops or not. Trouble is, its stopping too early everytime even though the the record has been inserted correctly. Please can someone either advise on what I'm doing wrong or suggest an alternative..
    This the end of the PLSQL script that inserts the entry into errors table if theres an error..
    WHEN OTHERS    THEN       ROLLBACK;
          err_msg := SUBSTR (SQLERRM, 1, 350);
          insert into kpmg_error_check (concurrent_id,module,narrative,status,creation_date,created_by)
                                values(0,'TEMPLOYEE_DTLS.sql',err_msg,'ERROR',SYSDATE,'Feldman');
         commit; This is the end of the UNIX script that looks at the table..
    echo " "
    echo "**** `date +%H:%M:%S` - Checking if TEMPLOYEE_DTLS.sql ran OK"
    error_check=`sqlplus -s $user_id @$SU_TOP/sql/SUTEMPCHK.sql 1`
    if `echo $error_check` -ge 1
    then
    # Load failed
    echo " "
    echo "**** `date +%H:%M:%S` - TEMPLOYEE_DTLS has failed - check table KPMG_ERROR_CHECK for details.."
    exit 1
    else
    # Load finished OK, if input data file exists, move and rename it
    echo " "
    echo "**** `date +%H:%M:%S` - TEMPLOYEE_DTLS has finished OK.."
    fiThis is the entire SUTEMPCHK.sql script that the UNIX script uses..
    -- Check if any errors have occurred
    SELECT count(1) FROM kpmg_error_check WHERE concurrent_id = &1
    EXITIs it that the above is always returning '1' and so always thinks theres an entry in the errors table?
    Is there an easier way?
    many thanks,
    Steven

    Hi,
    You have to iterate through all pages.marginPreferences:
    var
      myDocument = app.activeDocument,
      allPagesMaPref = myDocument.pages.everyItem().marginPreferences,
      curPageMaPref;
    while ( curPageMaPref = allPagesMaPref.pop() )
      with (curPageMaPref) {
      columnCount = 1;
      //columnGutter can be a number or a measurement string.
      columnGutter = "0";
      bottom = "0"
      //When document.documentPreferences.facingPages == true,
      //"left" means inside; "right" means outside.
      left = "40"
      right = "0"
      top = "0"
      inside = "0"
    Jarek

  • Conditional Exit from the script

    Hi,
    I have to code the script like the below
    --Step 1
    begin
    If <Table1 doesnot exist> then
    Display "User Defined Error Message: Table1 doesnot exit"
    EXIT FROM THE SCRIPT(Below sql should not run)
    endif
    end
    --Step 2
    spool abc.txt;
    select "should not run" from Table1;
    spool off;Step 2 should not run if table1 doesnot exist.
    Can someone please tell how to conditionally exit the script.
    Thanks & Regards,C
    CDPrasad
    Edited by: cdprasad on Aug 12, 2010 1:35 PM
    Edited by: cdprasad on Aug 12, 2010 1:36 PM
    Edited by: cdprasad on Aug 12, 2010 1:38 PM
    Edited by: cdprasad on Aug 12, 2010 1:38 PM

    Hi,
    David is right; SQL*Plus is the wrong tool for this job.
    If you really want to to this in SQL*Plus, you can achieve a crude type of branching by using sub-sripts. Instead of an IF statement, you use START or @ to run one or another of those sub-scripts, based on a substitution variable, which in turn is set by a query.
    For example:
    --     abc.sql - Test if table1 exists, and
    --                     (1) if it exists, run abc_query.sql to do a query
    --                     (2) if it does not exist, run abc_error.sql to display an error message
    --     Preliminary query, to define next_script:
    COLUMN     next_script_col        NEW_VALUE next_script
    SELECT     CASE      COUNT (*)
             WHEN  0  THEN  'abc_error'
                       ELSE  'abc_query'
         END     AS next_script_col
    FROM     all_tables
    WHERE     table_name     = 'TABLE1'
    AND     owner          = 'SCOTT'
    --     Now that we know what to do, do it:
    @&next_scriptYou would run the above script (abc.sql) and it would decide whether to run the script containing you query, or the script that prints an error message.
    Why does table1 sometimes disappear? In a good database design, tables are permanent structures, and get dropped only when they are obsolete. Perhaps you should be TRUNCATing the table, not dropping it.

  • How to exit from SQL*Plus based on the return value of a SQL select stment?

    Hi
    I have a SQL script executed from SQL*Plus. I would like to know if SQL*Plus
    supports any kind of branching or exiting from script execution based on a
    returned value of a SQL select statement. I am on 9i.
    Regards,
    Tamas Szecsy

    in sqlplus, you have whenever
    ex:
    whenever sqlerror exit failure
    insert into ...
    -- if this fails, then you will be out
    insert into ...
    -- if this fails, then you will be out
    whenever sqlerror continue
    insert into ...
    -- if this fails, this continues
    insert into ...and you have PL/SQL
    declare x number;
    begin
    select count(*) into x from emp;
    if (x=14) then null; end if;
    end;
    /note that you can mix those in some case
    -- exit if there is no row in emp
    whenever sqlerror exit 1
    var dummy number
    exec select count(*) into :dummy from emp having count(*)!=0

  • Calling stored procedure from unix shell script

    Hello,
    I am facing a problem while calling a stored procedure from UNIX shell script. I want to return a output variable from the stored procedure to the UNIX environment.
    Here is the code-
    #!/bin/sh
    OUTPUT=`sqlplus cmag/magnum@dw <<ENDOFSQL
    set serveroutput on;
    var prd_out varchar2(100);
    exec create_pm_window(:prd_out);
    exit;
    ENDOFSQL`
    echo " output is - $OUTPUT"
    The problem is :prd_out is not getting copied to shell variable OUTPUT.
    I have a dbms_output.put_line in the stored proc create_pm_window and I can see that prd_out is getting populated.
    Any help is really appreciated.
    Thanks'
    Rakhee

    First step :
    make sure the PL/SQL works as expected.
    Does the following display the expected output executed from SQL*Plus ?
    set serverout on
    declare
    prd_out varchar2(100);
    begin
    create_pm_window(prd_out);
    dbms_output.put_line('output is '||prd_out);
    end;
    I don't have your procedure, but using a dummy procedure like :
    Scott@my10g SQL>create procedure foo(p_out in out varchar2)   
      2  is
      3  begin
      4  select 'Hello '||instance_name into p_out from v$instance;
      5  end;
      6  /
    Procedure created. and a toto.sh script as :OUTPUT=`sqlplus -s scott/tiger <<EOF
    set pages 0 lines 120 trimout on trimspool on tab off echo off verify off feed off serverout on
    var mavar varchar2(100);
    exec foo(:mavar);
    print mavar;
    exit;
    EOF`
    echo "OUT = ${OUTPUT}"
    exitIt works fine :[oracle@Nicosa-oel ~]$ ./toto.sh
    OUT = Hello my10g

  • Exit from a pl/sql block

    Hi all. I'm on oracle 9i.
    I have a problem: I launch my sql file, which has a part made of some SQL commands and then inside it there is a part that is a PL/SQL block.
    What I want is that if a certain if condition is verified it must exit from PL/SQL block and also it must exit from all the file!
    Here is a part of code:
    drop table test1;
    create table test1
    as select * from test2;
    create table prova_test1
    as select * from test_1
    where 1=2;
    DECLARE
    conta number := 0;
    valore number := 0;
    contap number := 0;
    valorep number := 0;
    istruzione varchar2(2000) := null;
    BEGIN
    select count(1), sum(val) into contap,valorep
    from prova_test1;
    select count(1), sum(val) into conta,valore
    from test_1;
    if conta <> contap or valore <> valorep then
    istruzione := 'exit';
    execute immediate istruzione;
    else
    others sql statements.....
    end if;
    end;
    So what I want is that if the condition is verified it must exit from pl/sql block and also from all the process.
    How can I achieve that??
    Thanks for collaboration,
    Fabrizio

    Fabrizio Delli Priscoli wrote:
    whenever sqlerror exit 99
    whenever oserror exit 98
    Number 99 or 98, are SQLCODE returned from my exception?No, they are NOT SQLCODE.
    SQLCODE is an oracle database error code.
    Now,
    sqlerror is how 'Sql*Plus' (the one that is calling the pl/sql block) would handle ANY SQL ERROR coming out of pl/sql block OR other parts of the sql you are running within the SQL*Plus construct.
    99 and 98 are the error numbers that SQL*Plus is returning to the script or code that is calling SQL*Plus. In this case, probably the 'shell script' that calls this SQL*Plus construct.
    So, you would handle that error in the shell script.
    Maybe something like this: (this is the shell script that is calling a sqlplus session).
    1>>$LOGFILE 2>>$LOGFILE sqlplus -s $DBCONN <<EOF
    whenever sqlerror exit 99
    whenever oserror exit 98
    set serveroutput on
    set feedback off
    BEGIN
    some_code;
    END;
    exit
    EOF
    ret_value=$(echo $?)
    case "$ret_value" in
        99) mail -s "Error: Some sqlerror on the script on $(date)" $SOME_EMAIL <$LOGFILE ;;
        98) mail -s "Error: Some oserror on the script on $(date)" $SOME_EMAIL <$LOGFILE ;;
    esac

  • How pass a parameter with forward slash to plsql script

    Hi,
    I am trying pass a parameter to plsql script from command line using sqlplus, and the parameter is a file directory and has '/'. Seems the system couldn't recognize the value.
    here is my code in DECLARE:
    l_FileDir VARCHAR2(200) := &&FileDir ;
    I pass value '/usr/tmp' (with the single quote in the string)
    Can someone tell me how I do it?
    Thanks,
    Kate
    Edited by: user12100435 on Feb 25, 2010 8:31 AM

    user12100435 wrote:
    I think you are right. The issue is not file-separator character issue. because the exact same script run in another envoironment. And it's not file directory or permission issue because if I use hardcoded value, the code works fine.
    The error message is invalid File directory.
    Here is the related part of the code.
    -- open file handler
    IF UTL_FILE.IS_OPEN(l_FileHandler) THEN
    UTL_FILE.FCLOSE(l_FileHandler);
    ELSE
    l_FileHandler := UTL_FILE.FOPEN ( location => l_FileDir,
    filename => l_FileName,
    open_mode => 'W',
    max_linesize => 32767 );
    END IF;Ok, based on your input so far, I have cooked up a simple testcase.
    Make sure you are doing something similar to this -
    test@XE>
    test@XE> -- show the contents of the anonymous PL/SQL script
    test@XE> -- You are probably passing two parameters - the file location and the file name
    test@XE> --
    test@XE> ! cat test5.sql
    DECLARE
      l_FileHandler UTL_FILE.FILE_TYPE;
      l_FileDir     VARCHAR2(200) := '&1' ; 
      l_FileName    VARCHAR2(200) := '&2' ; 
    BEGIN
      -- open file handler
      IF UTL_FILE.IS_OPEN(l_FileHandler) THEN
        UTL_FILE.FCLOSE(l_FileHandler);
      ELSE
        l_FileHandler := UTL_FILE.FOPEN ( location => l_FileDir,
                                          filename => l_FileName,
                                          open_mode => 'W',
                                          max_linesize => 32767 );
        UTL_FILE.PUT_LINE(file => l_FileHandler, buffer => 'Hello, World!');
        UTL_FILE.FCLOSE(file => l_FileHandler);
      END IF;
    END;
    test@XE>
    test@XE> -- execute it
    test@XE> @test5.sql '/usr/tmp' 'first.txt'
    old   3:   l_FileDir     VARCHAR2(200) := '&1' ;
    new   3:   l_FileDir     VARCHAR2(200) := '/usr/tmp' ;
    old   4:   l_FileName    VARCHAR2(200) := '&2' ;
    new   4:   l_FileName    VARCHAR2(200) := 'first.txt' ;
    DECLARE
    ERROR at line 1:
    ORA-29280: invalid directory path
    ORA-06512: at "SYS.UTL_FILE", line 33
    ORA-06512: at "SYS.UTL_FILE", line 436
    ORA-06512: at line 10
    test@XE>
    test@XE> -- Create a directory object that points to "/usr/tmp"
    test@XE> create directory log_dir as '/usr/tmp';
    Directory created.
    test@XE>
    test@XE> -- now invoke the script
    test@XE> -- Note - I pass the value "LOG_DIR" in uppercase. That's the name of my directory object.
    test@XE> --
    test@XE> @test5.sql 'LOG_DIR' 'first.txt'
    old   3:   l_FileDir     VARCHAR2(200) := '&1' ;
    new   3:   l_FileDir     VARCHAR2(200) := 'LOG_DIR' ;
    old   4:   l_FileName    VARCHAR2(200) := '&2' ;
    new   4:   l_FileName    VARCHAR2(200) := 'first.txt' ;
    PL/SQL procedure successfully completed.
    test@XE>
    test@XE> -- Since my Oracle client is on the same machine as the Oracle server, I can check
    test@XE> -- this file "/usr/tmp/first.txt" quite easily
    test@XE>
    test@XE> ! cat /usr/tmp/first.txt
    Hello, World!
    test@XE>
    test@XE> isotope

  • Reading variables from a shell script

    i was wondering if it is possible to enter variables from a shell script that an sql file can use:
    ex:
    shell script file
    #!/bin/ksh
    stty -echo
    read pwd?"Enter password for user: "
    echo
    stty echo
    read var?"Please enter value for variable: "
    echo
    $ORACLE_HOME/bin/sqlplus user/$pwd @TEST.sql
    sql file TEST.sql
    set serveroutput on
    set verify off
    spool out.log
    update table set parameter_value = '$var' where parameter_name = 'X';
    commit;
    exit;
    spool off;
    i tried that and it seems its updating my table with "var" and not what the user entered that is the bind variable $var
    am i missing something?

    if user hits enter (which means null) can the program
    not end and ask the user to enter another value?Try this way :
    while :
    do
            echo -n "Please enter value for variable: "
            read VAR
            if [ "$VAR" ]; then
                    break
            else
                    continue
            fi
    done

  • Call PL/SQL Procedure (not stored) from SQLPLUS

    Hello,
    the following code creates a stored procedure and allows to call the procedure from SQLPLUS using EXEC.
    CREATE or REPLACE PROCEDURE welcome IS
    BEGIN
        dbms_output.put_line('Welcome user ' || user);
    END;
    exec welcome;I would like to do the same without storing the procedure. The procedure should be defined in an PL/SQL-Script and called in a SQLPLUS loop. On the one hand I do not have the privileges to create stored procdures. On the other hand I want to use put_line in the loop. Without passing control to SQLPLUS (e.g. the loop-master) all output is kept in the buffer and no information are shown during processing the data.
    Regards, Rainer

    netaktiv wrote:
    There should be a repair job updating many hundredthousends records. A script should be created and called only once and the calling user should be informed about the processing status. There is no need for heavy output, but after 5000 or 10000 records I would like to display a message saying nnnnn records processed.Then you need another mechanism to report the current status to the user.
    You cannot use the current session to do that. Sessions are serialised. That means they can do only service a single request at a time. So if the session executes procedure foo that updates 100's of 1000's of rows - then that is what the process will be doing. The procedure can only report back to the client after it has completed. It cannot interact directly with the client during the executing of that procedure.
    This means that if you want to actually send a notification to the client, you need to do that via a separate session. E.g. the 1st session executes procedure foo that performs the update. That procedure sends a notification (using DBMS_ALERT or DBMS_PIPE for example) to the 2nd session - where the 2nd session receives the asynchronous notification and reports that to the user.
    Another method would be for the update procedure to register a long operation using DBMS_APPLICATION_INFO. This enables another session to view the status and progress of the update procedure via virtual (v$) performance views.
    Another method would be for the client session not to start the update procedure itself. Instead it can schedule a background job (using DBMS_JPB or DBMS_SCHEDULER interfaces) - and then monitor the status of the job.
    Also suggest that you spend some time familiarising yourself with application developer fundamentals and concepts for Oracle. There are guides for both at http://tahiti.orcacle.com for the Oracle version you use. You cannot correctly use Oracle if you do not understand how Oracle works and what the application development features are. And your current approach using DBMS_OUTPUT is pretty much flawed and not how Oracle sessions should report their processing status to a client.

  • How do we exit from a sub procedure

    Hi,
    I am calling a sub procedure from my plsql procedure. If an error occurs in the sub-procedure, it should exit from the appilcation.
    return gets the control back to the called procedure. but is there a way to stop the execution totally?
    Thanks,
    Narayan

    Raise an exception that is not handled in the sub-procedure nor in the main procedure.

  • How to get ddls from sqlplus like that of TOAD

    Hi,
    I have to work on a terminal machine for a client where the TOAD is not installed. For my regular DBA activities I need to take the DDL many times.
    I am very much used to the style of DDL scripts which TOAD 9.6.x.x gives for any object in a schema.
    Can someone suggest how I can I get exactly TOAD-like scripts (which provide not just the create statements)
    For e.g.
    *1.From sqlplus when I do*
    select dbms_metadata.get_ddl('TABLE','APE1_ACCUMULATORS') from dual;
    I get only the below
    CREATE TABLE XLTDBO92.APE1_ACCUMULATORS
    CYCLE_CODE NUMBER(4) CONSTRAINT APE1ACCU_CYCLE_CODE_NN NOT NULL,
    CYCLE_INSTANCE NUMBER(2) CONSTRAINT APE1ACCU_CYCLE_INSTANCE_NN NOT NULL,
    CUSTOMER_SEGMENT NUMBER(4) CONSTRAINT APE1ACCU_CUSTOMER_SEGMENT_NN NOT NULL,
    CUSTOMER_ID NUMBER(9) CONSTRAINT APE1ACCU_CUSTOMER_ID_NN NOT NULL,
    ACCUM_TYPE_ID NUMBER(9) CONSTRAINT APE1ACCU_ACCUM_TYPE_ID_NN NOT NULL,
    OWNER_ID
    *2.But from TOAD 9.6.x.x when i click on "create scripts" I will get*
    DROP TABLE XLTDBO92.APE1_ACCUMULATORS CASCADE CONSTRAINTS;
    CREATE TABLE XLTDBO92.APE1_ACCUMULATORS
    CYCLE_CODE NUMBER(4) CONSTRAINT APE1ACCU_CYCLE_CODE_NN NOT NULL,
    CYCLE_INSTANCE NUMBER(2) CONSTRAINT APE1ACCU_CYCLE_INSTANCE_NN NOT NULL,
    CUSTOMER_SEGMENT NUMBER(4) CONSTRAINT APE1ACCU_CUSTOMER_SEGMENT_NN NOT NULL,
    CUSTOMER_ID NUMBER(9) CONSTRAINT APE1ACCU_CUSTOMER_ID_NN NOT NULL,
    ACCUM_TYPE_ID NUMBER(9) CONSTRAINT APE1ACCU_ACCUM_TYPE_ID_NN NOT NULL,
    OWNER_ID
    DROP SYNONYM XLTDB92.APE1_ACCUMULATORS;
    CREATE SYNONYM XLTDB92.APE1_ACCUMULATORS FOR XLTDBO92.APE1_ACCUMULATORS;
    GRANT DELETE, INSERT, SELECT, UPDATE ON XLTDBO92.APE1_ACCUMULATORS TO XLTDBO92_ALL;
    So my question is:
    How to such scripts from sqlplus as well ,irrespective of the type of the object?_
    Note:I am posting a new thread because my previous question was answered even though i was not able to type in completely. My mistake as it was posted in before i could finish the question.
    Regds,
    Kunwar

    If the DDL returned by dbms_metadata is not to your liking then write your own scrips to generate DDL or cover scripts to generate all related items that you want.
    In the case of synonyms and grants this is very easy using rdbms dictionary views, but if you generate a table's DDL you may also want and need the PK, UK, FK, secondary indexes, comments, and policies on the table as well as synonyms and grants. Everything that if you drop the tables goes away.
    There is a dbms_metaddata procedure get_dependent_ddl to generate dependend objects on a table that may be of interest.
    HTH -- Mark D Powell --

Maybe you are looking for