IF statement in SQL*Plus - how to do it

Hi,
In SQL*Plus script, I would like to keep conditional checking (IF statement) and proceed. For example, whatever is done in PL/SQL block below, want to do the same in SQL*Plus script, I know partly it can be done using VARIABLE keyword, conditional checking can be done using DECODE in SELECT statement, but I want to carry out a more complex requirement, hence I want to use IF statement somehow in SQL*Plus.
Another question, how to do spooling in PL/SQL script, it can be done using UTL_FILE, any other option is there to achieve this.
declare
v_ind_count int;
begin
select count(1) into v_ind_count from user_indexes where index_name = 'index_object_name';
IF v_ind_count > 0
THEN
dbms_output.put_line('index found');
ELSE
dbms_output.put_line('index does not exist');
END IF;
end;
/

Hello,
SQL*PLUS has no scripting language. It can only execute SQL and PL/SQL scripts. There are some commands like SPOOL or SET but no commands for conditional statements. You should describe your requirements, maybe we can find a way.
Or you can search the forum, maybe your question has already been answered
[Google for SQL*PLUS + condition|https://www.google.de/search?q=site%3Aforums.oracle.com+"SQL*PLUS"+condition]
# {message:id=4189517}
# {message:id=4105290}
how to do spooling in PL/SQL scriptFrom within PL/SQL you can use dbms_output, the spool has to be started by the calling SQL script when it is executed in SQL*PLUS. Or you can use utl_file, but then you can only write to a server directory, not into a client file. To give an advice we need more information about what you want to do.
Regards
Marcus

Similar Messages

  • Copying and pasting sql statement in sql*plus

    how do you paste sql statement in sql*plus...I have tried the following options, getting the windows interface for this following the documentation below but that didnt work
    http://download.oracle.com/docs/html/A88829_01/ch3.htm
    then i tried creating a simple .txt file with my sql statement and tried running it using @name(where name is the name of the file) and it is giving me the following error SP2-0310: unable to open file "firstscriot.sql

    Hi,
    Using the command-line interface, copying is a pain. Right click on the title bar at the top of the window, then click on "Edit" and "Mark". After you highlight the text you want to copy, you can press the Enter key to copy it.
    To paste, simply right-click. It doesn't matter how the copy buffer got filled (the cumbersome process I described above, using Control-C in Notepad, or whatever).

  • Error in statement with sql plus

    Hi,
    I have written this sql statement:
    SELECT  rtrim('Cambio di: '
            || (CASE WHEN nvl(A.DESCRIZIONE_EMITTENTE ,' ') <> nvl(B.DESCRIZIONE_EMITTENTE ,' ') THEN 'Descrizione emittente, ' ELSE '' END)
            || (CASE WHEN nvl(A.INDIRIZZO_SEDE_EMITTENTE,' ') <> nvl(B.INDIRIZZO_SEDE_EMITTENTE,' ') THEN 'Indirizzo sede emittente, ' ELSE '' END)
            || (CASE WHEN nvl(A.SOTTOGRUPPO_ATTIVITA_ECONOMICA,' ') <> nvl(B.SOTTOGRUPPO_ATTIVITA_ECONOMICA,' ') THEN 'Sottogruppo attività economica, ' ELSE '' END)
            || (CASE WHEN nvl(A.RAMO_ATTIVITA_ECONOMICA, ' ') <> nvl(B.RAMO_ATTIVITA_ECONOMICA,' ') THEN 'Ramo attività economica, ' ELSE '' END)
            || (CASE WHEN nvl(A.GRUPPO_EMITTENTE, ' ') <> nvl(B.GRUPPO_EMITTENTE, ' ') THEN 'Gruppo emittente, ' ELSE '' END)
            || (CASE WHEN nvl(A.CAPITALE_SOCIALE_EMITTENTE, 0) <> nvl(B.CAPITALE_SOCIALE_EMITTENTE, 0) THEN 'Capitale sociale emittente, ' ELSE '' END)
            || (CASE WHEN nvl(A.SECTOR, ' ') <> nvl(B.SECTOR, ' ') THEN 'Sector, ' ELSE '' END)
            ,', ') TIPO_VARIAZIONE,
           A.ISICOD ,
           A.EMICOD , 
           A.DESCRIZIONE_EMITTENTE AS DESCRIZIONE_EMITTENTE_T, B.DESCRIZIONE_EMITTENTE AS DESCRIZIONE_EMITTENTE_T1,
           A.INDIRIZZO_SEDE_EMITTENTE AS INDIRIZZO_SEDE_EMITTENTE_T, B.INDIRIZZO_SEDE_EMITTENTE AS INDIRIZZO_SEDE_EMITTENTE_T1,
           A.SOTTOGRUPPO_ATTIVITA_ECONOMICA AS SOTT_ATTIVITA_ECONOMICA_T, B.SOTTOGRUPPO_ATTIVITA_ECONOMICA AS SOTT_ATTIVITA_ECONOMICA_T1,
           A.RAMO_ATTIVITA_ECONOMICA AS RAMO_ATTIVITA_ECONOMICA_T, B.RAMO_ATTIVITA_ECONOMICA AS RAMO_ATTIVITA_ECONOMICA_T1,
           A.GRUPPO_EMITTENTE AS GRUPPO_EMITTENTE_T, B.GRUPPO_EMITTENTE AS GRUPPO_EMITTENTE_T1,
           A.CAPITALE_SOCIALE_EMITTENTE AS CAPITALE_SOCIALE_EMITTENTE_T, B.CAPITALE_SOCIALE_EMITTENTE AS CAPITALE_SOCIALE_EMITTENTE_T1,
           A.SECTOR AS SECTOR_T, B.SECTOR AS SECTOR_T1,
            A.START_DATE AS DATA_AGG_T, B.START_DATE AS DATA_AGG_T1
    FROM SPR_KLERS_IEM A, SPR_KLERS_IEM B
    WHERE A.START_DATE=TRUNC(SYSDATE)
          AND A.ISICOD=B.ISICOD
          AND A.EMICOD=B.EMICOD
          AND B.START_DATE = decode(trim(to_char(sysdate, 'Day')), 'Monday',trunc(sysdate-3), trunc(sysdate-1))
          AND
            nvl(A.DESCRIZIONE_EMITTENTE ,' ') != nvl(B.DESCRIZIONE_EMITTENTE ,' ')
            OR
            nvl(A.INDIRIZZO_SEDE_EMITTENTE,' ') != nvl(B.INDIRIZZO_SEDE_EMITTENTE,' ')
            OR
            nvl(A.SOTTOGRUPPO_ATTIVITA_ECONOMICA,' ') != nvl(B.SOTTOGRUPPO_ATTIVITA_ECONOMICA,' ')
            OR
            nvl(A.RAMO_ATTIVITA_ECONOMICA, ' ') != nvl(B.RAMO_ATTIVITA_ECONOMICA,' ')
            OR
            nvl(A.GRUPPO_EMITTENTE, ' ') != nvl(B.GRUPPO_EMITTENTE, ' ')
            OR
            nvl(A.CAPITALE_SOCIALE_EMITTENTE, 0) != nvl(B.CAPITALE_SOCIALE_EMITTENTE, 0)
            OR
            nvl(A.SECTOR, ' ') != nvl(B.SECTOR, ' ')
            )If I execut it from toad I obtain the correct result but if I execute the statement from sql/plus I obtain these errors:
    SP2-0734: unknown command beginning "nvl(A.DESC..." - rest of line ignored.
    SP2-0042: unknown command "OR" - rest of line ignored.
    SP2-0734: unknown command beginning "nvl(A.INDI..." - rest of line ignored.
    SP2-0042: unknown command "OR" - rest of line ignored.
    SP2-0044: For a list of known commands enter HELP
    and to leave enter EXIT.
    SP2-0734: unknown command beginning "nvl(A.SOTT..." - rest of line ignored.
    SP2-0042: unknown command "OR" - rest of line ignored.
    SP2-0734: unknown command beginning "nvl(A.RAMO..." - rest of line ignored.
    SP2-0042: unknown command "OR" - rest of line ignored.
    SP2-0044: For a list of known commands enter HELP
    and to leave enter EXIT.
    SP2-0734: unknown command beginning "nvl(A.GRUP..." - rest of line ignored.
    SP2-0042: unknown command "OR" - rest of line ignored.
    SP2-0734: unknown command beginning "nvl(A.CAPI..." - rest of line ignored.
    SP2-0042: unknown command "OR" - rest of line ignored.
    SP2-0044: For a list of known commands enter HELP
    and to leave enter EXIT.
    SP2-0734: unknown command beginning "nvl(A.SECT..." - rest of line ignored.
    SP2-0042: unknown command ")" - rest of line ignored.
    ERROR at line 26:
    ORA-00936: missing expression Why this behaviour? The statement is the same and from toad works!
    I do not succed to understand.
    Pleas could someone help me?
    Thanks a lot, bye bye.

    Your are forget = between nvl
    SELECT rtrim('Cambio di: '
    || (CASE WHEN nvl(A.DESCRIZIONE_EMITTENTE ,' ')= nvl(B.DESCRIZIONE_EMITTENTE ,' ') THEN 'Descrizione emittente, ' ELSE '' END)
    || (CASE WHEN nvl(A.INDIRIZZO_SEDE_EMITTENTE,' ') = nvl(B.INDIRIZZO_SEDE_EMITTENTE,' ') THEN 'Indirizzo sede emittente, ' ELSE '' END)
    || (CASE WHEN nvl(A.SOTTOGRUPPO_ATTIVITA_ECONOMICA,' ') = nvl(B.SOTTOGRUPPO_ATTIVITA_ECONOMICA,' ') THEN 'Sottogruppo attivit&agrave; economica, ' ELSE '' END)
    || (CASE WHEN nvl(A.RAMO_ATTIVITA_ECONOMICA, ' ') = nvl(B.RAMO_ATTIVITA_ECONOMICA,' ') THEN 'Ramo attivit&agrave; economica, ' ELSE '' END)
    || (CASE WHEN nvl(A.GRUPPO_EMITTENTE, ' ') = nvl(B.GRUPPO_EMITTENTE, ' ') THEN 'Gruppo emittente, ' ELSE '' END)
    || (CASE WHEN nvl(A.CAPITALE_SOCIALE_EMITTENTE, 0)= nvl(B.CAPITALE_SOCIALE_EMITTENTE, 0) THEN 'Capitale sociale emittente, ' ELSE '' END)
    || (CASE WHEN nvl(A.SECTOR, ' ') = nvl(B.SECTOR, ' ') THEN 'Sector, ' ELSE '' END)
    ,', ') TIPO_VARIAZIONE,
    A.ISICOD ,
    A.EMICOD ,
    A.DESCRIZIONE_EMITTENTE AS DESCRIZIONE_EMITTENTE_T, B.DESCRIZIONE_EMITTENTE AS DESCRIZIONE_EMITTENTE_T1,
    A.INDIRIZZO_SEDE_EMITTENTE AS INDIRIZZO_SEDE_EMITTENTE_T, B.INDIRIZZO_SEDE_EMITTENTE AS INDIRIZZO_SEDE_EMITTENTE_T1,
    A.SOTTOGRUPPO_ATTIVITA_ECONOMICA AS SOTT_ATTIVITA_ECONOMICA_T, B.SOTTOGRUPPO_ATTIVITA_ECONOMICA AS SOTT_ATTIVITA_ECONOMICA_T1,
    A.RAMO_ATTIVITA_ECONOMICA AS RAMO_ATTIVITA_ECONOMICA_T, B.RAMO_ATTIVITA_ECONOMICA AS RAMO_ATTIVITA_ECONOMICA_T1,
    A.GRUPPO_EMITTENTE AS GRUPPO_EMITTENTE_T, B.GRUPPO_EMITTENTE AS GRUPPO_EMITTENTE_T1,
    A.CAPITALE_SOCIALE_EMITTENTE AS CAPITALE_SOCIALE_EMITTENTE_T, B.CAPITALE_SOCIALE_EMITTENTE AS CAPITALE_SOCIALE_EMITTENTE_T1,
    A.SECTOR AS SECTOR_T, B.SECTOR AS SECTOR_T1,
    A.START_DATE AS DATA_AGG_T, B.START_DATE AS DATA_AGG_T1
    FROM SPR_KLERS_IEM A, SPR_KLERS_IEM B
    WHERE A.START_DATE=TRUNC(SYSDATE)
    AND A.ISICOD=B.ISICOD
    AND A.EMICOD=B.EMICOD
    AND B.START_DATE = decode(trim(to_char(sysdate, 'Day')), 'Monday',trunc(sysdate-3), trunc(sysdate-1))
    AND
    nvl(A.DESCRIZIONE_EMITTENTE ,' ') != nvl(B.DESCRIZIONE_EMITTENTE ,' ')
    OR
    nvl(A.INDIRIZZO_SEDE_EMITTENTE,' ') != nvl(B.INDIRIZZO_SEDE_EMITTENTE,' ')
    OR
    nvl(A.SOTTOGRUPPO_ATTIVITA_ECONOMICA,' ') != nvl(B.SOTTOGRUPPO_ATTIVITA_ECONOMICA,' ')
    OR
    nvl(A.RAMO_ATTIVITA_ECONOMICA, ' ') != nvl(B.RAMO_ATTIVITA_ECONOMICA,' ')
    OR
    nvl(A.GRUPPO_EMITTENTE, ' ') != nvl(B.GRUPPO_EMITTENTE, ' ')
    OR
    nvl(A.CAPITALE_SOCIALE_EMITTENTE, 0) != nvl(B.CAPITALE_SOCIALE_EMITTENTE, 0)
    OR
    nvl(A.SECTOR, ' ') != nvl(B.SECTOR, ' ')
    {code}
    Edited by: Salim Chelabi  on 2008-12-09 09:10                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • I am in sql plus how do I find out what database I am in?

    I am in sql plus how do I find out what database I am in? is there a sql command for that...

    select name from v$database;
    or
    select sys_context('userenv', 'DB_NAME') from dual;

  • Re entering sql statements in sql plus

    Hi,
    How to enter and can edit sql statements in sqlplus without re typing sql statements which were previously executed.

    Hi,
    ravi02 wrote:
    Hi,
    How to enter and can edit sql statements in sqlplus without re typing sql statements which were previously executed.Depending on your OS and your version of SQL*Plus, you can recall past SQL*Plus commands the same way you recall past OS commands. On my Windows system, I press the up-arrow key to get old SQL*Plus commands. Then I can press ENTER to run the command verbatim, or I can type over the command (using back-arrow, backspace and delete keys, if I want) to change the command before pressing ENTER.
    That's only good for single-line commands. If you have a statement that needs more than 1 line, type it in a file using any text editor, and the use the SQL*Plus @ command to run it.
    For example, if my SQL statements are saved in file called my_script.sql, which is on the foo\bar folder of the d: drive, I can say
    @d:\foo\bar\my_scriptto run all the commands in the file.
    Depending on your OS, you can do somehting similar.

  • Would like to write SQL code to generate a 'spool' statement in SQL Plus.

    Hi,
    We're using Oracle 11.1.
    I'm spooling data to a file from a SQL Plus shell script .
    The format of the file name they're giving me has the current date on the end, so something like:
    filenameMMDDYYYY.txtWhen I write my spool statement I'd like to do it so that I give it the file name with a formatted sysdate at the end.
    I think I need to generate SQL to do this but I don't have experience in generating SQL.
    How would I do this in a SQL Plus Linux shell script?

    set termout off
    col dt new_value dt
    select to_char(sysdate,'YYYYMMDDHH24MISS') dt from dual;
    set termout on
    spool file_&dt
    Handle:      816567
    Status Level:      Newbie
    Registered:      Nov 29, 2010
    Total Posts:      73
    Total Questions:      30 (20 unresolved)
    so many questions & so few answers.
    Edited by: sb92075 on May 12, 2011 4:27 PM

  • SQL*Plus - how to suppress the SQL in a spool file

    This is my SQL*Plus script. I thought I had solved the problem, but it is back now and I don't know what I am missing. But I don't want the query at the top of the file.
    SET SERVEROUTPUT ON
    SET MARKUP HTML ON -SILENT
    SET ECHO OFF
    SET PAGESIZE 33
    SET TERMOUT OFF
    Spool C:\DuaneWilson.xls
    SELECT *
    FROM RPT_DS1_CNT_CAT_vw
    WHERE ROWNUM <=100
    ORDER BY CVBI_KEY;
    SET MARKUP HTML OFF
    SET ECHO ON
    SET PAGESIZE 20
    SET TERMOUT ON
    SET SERVEROUTPUT OFF

    It turns out when I run the script with the @ or Start with the file name, there is no SQL put out to the file. But when I just copy the text out of the file and run it at the prompt, the SQL appears in the output file. In reference to the -SILENT, I put that in after the MARKUP statement and got an error. Maybe I don't know where that goes. And I am not sure why there is a difference if it is run as a script or just pasted to the buffer. At least it should be the same in the output file, I would think.

  • Error creating view with CASE -- WHEN statement in SQL*Plus

    I am using Oracle 8i 8.1.7
    I have an Oracle view which uses CASE...WHEN statements.
    The view compiles fine in DBA studio.
    Using TOAD I saved the view as an *.sql file.
    However, when I try to create the view in SQL*Plus I get the following error:
    SP2-0734: unknown command beginning "CASE WHEN ..." - rest of line ignored.
    According to the documentation CASE -- WHEN has been implemented since since Oracle 8i rel. 2 (8.1.6)

    Well I'm using 8.1.6.3 and CASE and DECODE both work for me:
    SQL> create or replace view v_accs as select account_name, txn,
    2 decode(credit, 0, 'DB', 'CR') t_type
    3 from accs;
    View created.
    SQL> select * from v_accs;
    ACCOUNT_NA TXN T_
    APC 1 DB
    ABC 2 DB
    HJJ 3 DB
    HJH 4 CR
    HJK 5 CR
    APC 6 DB
    APC 7 DB
    ABC 8 DB
    ABC 9 DB
    HJJ 10 DB
    HJJ 11 DB
    HJH 12 DB
    HJH 13 DB
    HJK 14 DB
    HJK 15 CR
    15 rows selected.
    SQL> create or replace view v_accs as select account_name, txn,
    2 case when credit = 0 then 'DB' else 'CR'end as t_type
    3* from accs
    View created.
    SQL> select * from v_accs;
    ACCOUNT_NA TXN T_
    APC 1 DB
    ABC 2 DB
    HJJ 3 DB
    HJH 4 CR
    HJK 5 CR
    APC 6 DB
    APC 7 DB
    ABC 8 DB
    ABC 9 DB
    HJJ 10 DB
    HJJ 11 DB
    HJH 12 DB
    HJH 13 DB
    HJK 14 DB
    HJK 15 CR
    15 rows selected.
    SQL>
    rgds, APC

  • How to run multiple scripts in sql*plus?

    I would like to run 2 scripts in sql*plus, how do I do this? I tried the following, but it won't run.
    create table student_new
    AS
    select *
    from student
    insert into student_new
    (last_name, first_name
    values
    (Crop, Jenny)
    The above are the two scripts I want to run, what am I doing wrong.
    Thanks

    Do you have a solution to run multiple scripts continuosly, one after the other as one script.
    Say I have file1.sql file2.sql, file3.sql.
    I want to create a script run.sql, where this will run file1.sql,file2.sql,file3.sql one after other without any one running one after the other like follows:
    run.sql should have
    begin
    @file1.sql
    @file2.sql
    @file3.sql
    dbms_output.put_line(select sysdate from dual);
    end;
    If I run run.sql all the three scripts should be executed successfully and then display the current time . All these files have update statements(50,000 updates each file).
    Very urgetn. Can some one hlpe, please.
    Thanks in advance.

  • PL/SQL cursors vs. SQL*plus Select statement

    Hi folks, hope you're doing well,
    Here is a question that kept me wondering:
    Why would I use cursors when i can achieve the same thing with a SQL+ Select statement which is much easier to formulate than a cursor (e.g. you need no declaration, loops etc)?.
    Thanks so much,
    -a

    There is no such thing as a SQL*Plus SELECT statement. The SELECT command is part of the SQL Language - not part of the SQL*Plus (very limited small vocabulary) macro language.
    All SQL SELECTs (from client languages) winds up in the SQL Engine as SQL cursors. A SQL Cursor is basically the:
    - SQL source code
    - SQL "compiled" code (instructions on how to fetch the rows)
    On the client side, client cursors (not to be confused with SQL cursors) are used. A client cursor is created in the client language when it makes SQL calls via the database client driver (called the OCI/Oracle Call Interface for Oracle clients).
    Typically this is what a client does. It makes a connection to the database and gets a database handler in return. The database handler is the "communication channel" from the client to the db. In Oracle, the database handler in the client refers to the Oracle session (for that client) on db server.
    A SQL statement (source code) is used by the client. This can be a SELECT statement you type in at the SQL*Plus command line. It can be a SELECT statement for the PL/SQL cursor command in a stored procedure.
    The client creates a SQL handle for this SQL statement, by calling the Oracle client driver. Note that this SQL handle is a client handle - a client cursor for that SQL statement.
    E.g.
    a) sqlHandle = CreateSQL( databaseHandle, 'SELECT ... FROM ...')
    b) sqlHandle.Parse
    c) sqlHandle.Execute
    After the SQL handle (client cursor) has been executed, the client can fetch rows from it.
    This is what SQL*Plus does automatically for you, without you having to write the code to do it. SQL*Plus CONNECT command create a database connection handle. You enter a SELECT statement and SQL*Plus creates a SQL handle (client cursor), executes it, fetches from it, displays the rows, and closes the SQL handle when done.
    The same applies to PL/SQL. You can use a SELECT statement just like that in PL/SQL. E.g.
    declare
      i integer;
    begin
      select count(*) into i from emp where deptid = 123;
    end;This is called an implicit cursor. PL/SQL creates (just like SQL*Plus) an implicit client cursor. It creates and disposes of that client SQL handle for you - you do not need to do it.
    Or, you can create an explicit cursor. E.g. declare
      cursor c is select count(*) from emp where deptid = 123;
      i integer;
    begin
      open c;
      fetch c into i;
      close c;
    end;The question as to when to use implicit (client) cursors versus explicit (client) cursors depends on your requirements. Do you need to cycle through the results of the SQL? Etc.
    And keep in mind that in either case, the SQL Engine creates a SQL cursor anyway on its side.

  • How to bind DATE variables in SQL*Plus

    I have a stored procedure in a package that has a DATE OUT parameter
    myPackage.myProcedure( outDate OUT DATE )
    I am trying to test this from SQL*Plus
    How do I specify a Bind variable for the outDate? The VARIABLE command does not allow DATE types?
    If this was a CHAR type I could have done
    VARIABLE myChar CHAR
    BEGIN
    myPackage.myProcedure( :myChar )
    END;
    PRINT myChar
    How do I do this with DATE data types instead? I am using Oracle 8.1.7.

    you should use VARCHR2 type with the minimum length that can store a value defined by your NLS_DATE_FORMAT
    string. The returned date will be converted to a VARCAHR2 type and the size and format will depend on
    your NLS_DATE_FORMAT setting.
    =============================================================================
    SQL> variable dt VARCHAR2(20)
    SQL> create or replace procedure ret_date(dt OUT DATE) is
    2 begin
    3 dt := SYSDATE ;
    4 end ;
    5 /
    Procedure created.
    SQL> exec ret_date(:dt) ;
    PL/SQL procedure successfully completed.
    SQL> print dt
    DT
    13-OCT-02
    SQL> select sysdate from dual ;
    SYSDATE
    13-OCT-02
    SQL> alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS' ;
    Session altered.
    SQL> exec ret_date(:dt) ;
    PL/SQL procedure successfully completed.
    SQL> print dt
    DT
    13-OCT-2002 10:43:23
    SQL>
    ================================================================

  • Restricting the user to operate DML's from SQL PLUS Environment

    how to Restrict the user to operate DML statements from SQL PLUS Environment.

    Once you restrict SCOTT user to not be able to do an INSERT command, the SQL*Plus returns an error for user SCOTT when he tries to execute an INSERT statement.
    Note however, that this is enforced by SQL*Plus, not the database!
    Look into the use of product_user_profile from Oracle documentation for more information.
    SQL> insert into product_user_profile values('SQL*Plus', 'SCOTT', 'INSERT', NULL, NULL, 'DISABLED', NULL, NULL) ;
    1 row created.
    SQL> commit ;
    Commit complete.
    SQL> disconnect
    Disconnected from Oracle9i Enterprise Edition Release 9.2.0.3.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.3.0 - Production
    SQL>
    SQL> connect scott
    Enter password:
    Connected.
    SQL>
    SQL> insert into emp select * from emp ;
    SP2-0544: invalid command: insert
    SQL>
    SQL>

  • Set Column width in query (not using SQL*Plus)

    How can I Set Column width in query
    I understand you can set column width using
    column col1 FORMAT A5
    select col1 from table1;But this only works in SQL*Plus
    I want to be able to do this in a regular SQL query window (not in SQL*Plus), how can I do it.....
    I am using a 'SQL window' in PL/SQL Developer IDE
    and when I use this syntax it says:
    ORA-00900: Invalid SQL statement
    Any suggestions are appreciated...
    thanks,
    M.

    Did you try using RPAD or LPAD functions? They fill the unfilled part of a string with character you provide... either on right or left side depending on what function you use.
    e.g.
    SELECT RPAD('Smith', 10, ' ') Name FROM dual;http://www.adp-gmbh.ch/ora/sql/rpad.html
    Edited by: Zaafran Ahmed on Nov 10, 2010 11:50 AM

  • SQL*PLUS Worksheet Width

    I'm (bery) new to Oracle. I'm trying to figure out how to make the output results of a select statement in SQL*Plus Worksheet not wrap. Is there a way to do this?
    Thank you
    JohnD

    hi friends,
    I have used SET LINESIZE 1000 to increase width and display all column details in a row.
    But now it is not scrolling till the last column details displayed on screen.Suppose there are 12 columns in my table and i could see only 8 which are displayed on my screen.
    How can i scroll to right till the last column?
    Thank you,
    Regards,
    Raghv

  • Calling stored proc (with 2 IN and 3 OUT) - from SQL Plus

    This is the signature of my stored proc:
    CREATE OR REPLACE PROCEDURE myschema.myproc
       p_usr_name     IN  VARCHAR2,    
       p_send_tmstmp  IN  DATE,    
       p_ret_value    OUT NUMBER,
       p_err_code     OUT VARCHAR2
    )If I need to call it from sql plus, how do I need to pass the arg?
    This is what I am doing
    execute myschema.myproc('abc123','02-MAY-2008');
    What is wrong here? If someone could help. Thx!

    Try something like this
    var usr_name    varchar2(30)  
    var send_tmstmp varchar2(11)  
    var ret_value   number
    var err_code    varchar2(10)
    begin
    :usr_name    := 'abc123';
    :usr_name := '02-MAY-2008';
    myschema.myproc ( p_usr_name           => :usr_name,
                      p_send_tmstmp        => TO_DATE( :usr_name, 'DD-MON-YYYY' ),
                      p_ret_value          => :ret_value,
                      p_err_code           => :err_code);
    end;
    print ret_value;
    print err_code;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for

  • Interface builder is unable to open documents of type iPad XIB

    Hi, I got a application from my teammate, and it is for both iphone and ipad devices (which it is developed under iPhone SDK 3.2). I have iPhone SDK 3.1.3 installed in my mac book. When i tried to compile the application for iphone simulator i got th

  • Force user to connect to specific Persistent Chat server

    We plan to have 2 persistent chat servers in a single pool that will span 2 sites. 1 Persistent Chat server in Site A 1 Persistent Chat server in Site B Is there a way to force users in Site A to connect to the Persistent Chat server in Site A and fo

  • Unable to open encrypted files moved from PC to Mac

    I am running Acrobat Pro XI on a PC (Windows version 8.1) and Have Acrobat Pro XI (Mac version) on a new MacBook Pro Retina 13".  I am able to "transfer" files from the PC to the Mac via Dropbox.  However, only the unencrypted files will open on the

  • Flash bombs every time I copy an image

    I have a problem. I want to go inside a movie clip and play with the animation. But when I select the contents of frame 1 and hit "copy", Flash bombs every time! What's going on?

  • Default retry time for B2B

    hi all, i found out that the B2B will retry after waiting 2 hours counting from the previous failure. example : 10.09am failed ( HTTP timeout ), then next retry is 12.09pm. is there any place that i can change it from 2hours to 30mins? thanks kin wah