Exported DDL don't run in SQL Plus

Greetings,
I'm using SQL Developer to export the DDL from my DB to a script .sql.
When I try to run it into SQL Plus I get errors because of the <cr> caracters from the INSERT INTO statements generated.
Example:
Insert into CNAE_110_CLASSE (CODIGO_SEC,CODIGO_DIV,CODIGO_GRP,CODIGO_CLA,DESCRICAO_CLA,CCOMPRE_CLA,TCOMPRE_CLA,NCOMPRE_CLA,NOTAS_CLA) values ('D','19','191','19100','CURTIMENTO E OUTRAS PREPARAÇOES DE COURO','# A fabricaçao de couros curtidos, envernizados, metalizados, camurças, atanados, cromos, etc.','# A regeneraçao, tingimento e pintura de couro','# As atividades de secagem e salga de couros e peles desenvolvidas em matadouros (15.11)<cr>
# A confecçao de vestuário de couro (18.12)',null);
This returns:
SP2-0734: unknown command beginning "A confecçao ..." - rest of line ignored.
I'm using Oracle 10g XE and SQL Developer 1.2.0.29.98 on a Fedora CORE 6 linux.
Does someone has a clue to solve this? Is it a bug or I forgot to configure something?
Thanks in advance.

The label <<outer>> does not work in SQL Developer, neither does labels on loops.Yes, they do.
I imagine you've got this example in an SQL worksheet. There are a few issues with the worksheet delimiting statements, and apparently this is one of them.
The workaround here is very simple: encapsulating the lot in another anonymous block. Like this, impossible the <<outer>> falls off...
Enjoy,
K.

Similar Messages

  • SQL-Command to long to run with SQL*Plus

    Hello to everyone,
    I'm creating a dynamic SQL Script to run with SQL*Plus.
    The Script contains only INSERT Command.
    The point is that the SQL*Plus supports only SQL-Strings (Commands)
    not longer than 2500 Characters.
    I've considered to split the String in Insert- and Update-Command(s),
    but I've would like first to know if there any simpler way to run these
    Commands on SQL*Plus.
    thanx in Advance
    bm

    SQL> create table t(x varchar2(4000));
    Table created.
    SQL> insert into t values (
    '1234567890........0........0........0........0........0........0........0........0......100' ||
    '1234567890........0........0........0........0........0........0........0........0......200' ||
    '1234567890........0........0........0........0........0........0........0........0......300' ||
    '1234567890........0........0........0........0........0........0........0........0......400' ||
    '1234567890........0........0........0........0........0........0........0........0......500' ||
    '1234567890........0........0........0........0........0........0........0........0......600' ||
    '1234567890........0........0........0........0........0........0........0........0......700' ||
    '1234567890........0........0........0........0........0........0........0........0......800' ||
    '1234567890........0........0........0........0........0........0........0........0......900' ||
    '1234567890........0........0........0........0........0........0........0........0.....1000' ||
    '1234567890........0........0........0........0........0........0........0........0.....1100' ||
    '1234567890........0........0........0........0........0........0........0........0.....1200' ||
    '1234567890........0........0........0........0........0........0........0........0.....1300' ||
    '1234567890........0........0........0........0........0........0........0........0.....1400' ||
    '1234567890........0........0........0........0........0........0........0........0.....1500' ||
    '1234567890........0........0........0........0........0........0........0........0.....1600' ||
    '1234567890........0........0........0........0........0........0........0........0.....1700' ||
    '1234567890........0........0........0........0........0........0........0........0.....1800' ||
    '1234567890........0........0........0........0........0........0........0........0.....1900' ||
    '1234567890........0........0........0........0........0........0........0........0.....2000' ||
    '1234567890........0........0........0........0........0........0........0........0.....2100' ||
    '1234567890........0........0........0........0........0........0........0........0.....2200' ||
    '1234567890........0........0........0........0........0........0........0........0.....2300' ||
    '1234567890........0........0........0........0........0........0........0........0.....2400' ||
    '1234567890........0........0........0........0........0........0........0........0.....2500' ||
    '1234567890........0........0........0........0........0........0........0........0.....2600' ||
    '1234567890........0........0........0........0........0........0........0........0.....2700' ||
    '1234567890........0........0........0........0........0........0........0........0.....2800' ||
    '1234567890........0........0........0........0........0........0........0........0.....2900' ||
    '1234567890........0........0........0........0........0........0........0........0.....3000'
    1 row created.try to break your query in multiple lines in order to avoid
    SP2-0027: Input is too long (> 2499 characters) - line ignored

  • Procedure runs in SQL Plus, but not when called from my Oracle Form

    Hi. I have this code to send an email alert as the user updates a record on my base table from my Oracle Form. I use dbms_scheduler so that it's submitted as a background job and so the email processing does not delay my Oracle Form from saving quickly. If I submit this code in SQL Plus it executes and I receive the email as expected.
    begin
    dbms_scheduler.create_job ( 
         job_name            => 'IMMEDIATE_JOB', 
         job_type            => 'PLSQL_BLOCK', 
         job_action          => 'begin TTMS.dropperVacationConflict_Notify (62547, ''01-SEP-11'', ''02-SEP-11''); end;', 
         number_of_arguments => 0, 
         start_date          => sysdate +1/24/59, -- sysdate + 1 minute 
         enabled             => TRUE, 
         auto_drop           => TRUE, 
         comments            => 'Immediate, one-time run');
    end;However if I submit this code from a Post-Update trigger in my form the code runs without error, but my email is never received (the same parameter values would be passed to this trigger):
    begin
    -- Submit the email notification in the background so as to not slow down the screen while saving.   
    dbms_scheduler.create_job ( 
         job_name            => 'IMMEDIATE_JOB', 
         job_type            => 'PLSQL_BLOCK', 
         job_action          => 'begin TTMS.dropperVacationConflict_Notify (:dropper_vacations.dropper_id, :dropper_vacations.begin_dt, :dropper_vacations.end_dt); end;', 
         number_of_arguments => 0, 
         start_date          => sysdate +1/24/59, -- sysdate + 1 minute 
         enabled             => TRUE, 
         auto_drop           => TRUE, 
         comments            => 'Immediate, one-time run');
    end;     Any ideas why this might be happening?

    Wow, so I changed the two procedures so that I'm only passing in one number parameter and one char parameter...
    CREATE OR REPLACE procedure TTMS.job_vacationconflict_notify (p_dropper_id number, p_other char) IS
    CREATE OR REPLACE PROCEDURE TTMS.dropperVacationEmailURL_new (in_dropper_id number, in_other char) ISIf I execute it like this it works and I get the email:
    TTMS.job_vacationconflict_notify(62547, 99999);or like this it works and I get the email:
    TTMS.job_vacationconflict_notify(62547, '99999');But if I execute it like this (I get no errors) the email is not sent:
    TTMS.job_vacationconflict_notify(62547, 'ababa');So this problem really has nothing to do with date formats. It seems to have to do with whether parameter two has characters in it!!! What the heck.
    Any ideas on this?
    Here is the procedure I'm calling:
    CREATE OR REPLACE procedure TTMS.job_vacationconflict_notify (p_dropper_id number, p_other char) IS
    begin
      dbms_scheduler.create_job ( 
         job_name            => 'IMMEDIATE_JOB', 
         job_type            => 'PLSQL_BLOCK', 
         job_action          => 'begin TTMS.dropperVacationemailurl_new ('||p_dropper_id||','||p_other||'); end;', 
         number_of_arguments => 0, 
         start_date          => sysdate +1/24/59, -- sysdate + 1 minute 
         enabled             => TRUE, 
         auto_drop           => TRUE, 
         comments            => 'Immediate, one-time run');
    end;
    /And the above procedure is calling this procedure which should be sending the email alert:
    CREATE OR REPLACE PROCEDURE TTMS.dropperVacationEmailURL_new (in_dropper_id number, in_other char) IS
          myguid varchar2(15):=null;
          pcm_contact varchar2(3):=null;
          guid_contact varchar2(15):=null;
          conflict_cnt number(8):=0;
          -- Various declarations
          PSENDER VARCHAR2(200);            --  From
          PRECIPIENT VARCHAR2(200);         --  To
          P_CC_RECIPIENT VARCHAR2(200);     --  CC
          P_BCC_RECIPIENT VARCHAR2(200);    --  BCC
          PSUBJECT VARCHAR2(200);           --  Subject
          PMESSAGE VARCHAR2(6000);          --  Message Body
          PPARAMETER NUMBER;                --  Parameter Value
          guid_valid varchar2(15);          --  Used to grab the validation value of
          -- Grab name details of e-mail targets
          cursor targets is
          select guid, initcap(first_name) first_name, initcap(first_name)||' '||initcap(last_name) fullname
          from pwc_employee
          where upper(guid) = upper(guid_contact);
    BEGIN
            select count(*)
            into conflict_cnt
            from dropper_bundle_assign
            where
                dropper_sched = in_dropper_id and
                trunc(sched) <> '31-DEC-29' AND        
                trunc(sched) between '01-SEP-11' and '02-SEP-11' and
                trunc(sched) > trunc(sysdate);
            select distinct pcm
            into pcm_contact
            from dropper_bundle_assign
            where
                  dropper_sched = in_dropper_id and
                  trunc(sched) <> '31-DEC-29' AND        
                  trunc(sched) between '01-SEP-11' and '02-SEP-11' and
                  trunc(sched) > trunc(sysdate);
            select guid
            into guid_contact
            from pwc_employee
            where initials = pcm_contact;
        -- Ensure required parameters have been passed
        if guid_contact is not null
           and in_dropper_id is not null then
               Begin
                    select guid
                    into guid_valid
                    from pwc_employee
                    where upper(guid) = upper(guid_contact);
               Exception
                    when no_data_found then
                    raise_application_error(-20000,'Invalid Recipient.  Please check the employee table.  Please try again.');
               End;
               -- In the event there are multiple targets then we will loop thru and send individual emails
               for thisone in targets loop
                    PSENDER := lower(user)||'@us.ibm.com';
                    PRECIPIENT := lower(thisone.guid)||'@us.ibm.com';
                    P_CC_RECIPIENT := lower(thisone.guid)||'@us.ibm.com';
                    P_BCC_RECIPIENT := 'ssbuechl'||'@us.ibm.com';
                    PPARAMETER := TO_NUMBER(lower(in_dropper_id));
                    PSUBJECT := 'TEST: Dropper Vacation '||in_other||' Conflict Notification for dropper '||in_dropper_id||' - Action Required';
                    PMESSAGE := thisone.first_name||'-<br><br>There is an induction conflict due to a new or updated dropper vacation.<br><br>Click here to the dropper''s vacation conflicts: <u><a href="http://9.35.32.205:7777/forms/frmservlet?config=TTMSMENU&form=dropper_vacations&otherparams=p_dropper='||PPARAMETER||'">Dropper Id: '||PPARAMETER||'</a></u> (note: use your Oracle credentials when prompted for log-on information).<br><br>Thanks.';
                    SEND_MAIL ( PSENDER, PRECIPIENT, P_CC_RECIPIENT, P_BCC_RECIPIENT, PSUBJECT, PMESSAGE );  -- Procedure to physically send the e-mail notification
               end loop;
        else
              raise_application_error(-20001,'Recipient and Parameter Value are required. Please try again.');
        end if;
    exception
        when no_data_found then
             raise_application_error(-20002,'Note: Email will not be sent because no PCM was identified as the manager or the PCM does not have a record in the Employee table.  See ITS for assistance.');
         when too_many_rows then
             raise_application_error(-20003,'Note: Email will not be sent because multiple PCMs manage this dropper. Please notify each PCM manually.');
    END dropperVacationEmailURL_new;
    /Edited by: sharpe on Aug 17, 2011 4:38 PM
    Edited by: sharpe on Aug 17, 2011 5:03 PM

  • Does SQL Developer have any way to run the SQL*PLUS COPY FROM command?

    set arraysize 100;
    set copycommit 100;
    COPY FROM SCOTT/TIGER@OtherDBinstance -
    CREATE COMPANY -
    USING SELECT * from COMPANY;

    Thanks. I have been using the create table ABC as select * from ABC@otherdb but this often runs into temp segment issues for very large tables. The SQL*PLUS version allows me to have the copy commit save after each xxxxx lines and this seems to be able to handle any size table. Can copy commit be used from SQL Developer?

  • Running a SQL*Plus command from Java

    I have a requirement to run SQL* Plus commands from Java. The results as they would appear in SQL*Plus window or spool file should be captured and stored in a table.
    For example,
    SQL> select * from dual;
    D
    X
    1 row selected;
    SQL>
    All the lines above should be stored for later use.
    Could any one give pointers?
    Thanks,
    Ravi

    <p>
    Hi,
    </p>
    <p>
    <strong><font face="Courier New">
    public class RuntimeExecApp {
     public static void main(String args[]) throws IOException
      Runtime r = Runtime.getRuntime();
      r.exec(&quot;C:\\Oracle\\sqlplus.exe&quot;);
    }</font></strong>
    </p>
    <p>
    Kuba 
    </p>
    Message was edited by:
    KUBA

  • Script having Chinese characters throws error when run from SQL PLUS

    Dear All,
    I have a script file(.sql) which contains Chinese characters ....
    I have saved the file in unicode Format.
    When I run this file using @D:\filename from SQL PLUS it throws an error "unknown Command at line 1"...
    My database is Oracle 10g...
    Can anyone suggest anything???
    Thanks In Advance
    Dev
    Edited by: Devarsh on Oct 21, 2009 8:16 AM

    I think you may need to set your local NLS_LANG setting for your client (SQL*Plus) to recognize the characters.
    You may also consider posting your question on the Globalization forum which pertains more to these types of questions.
    Globalization Support

  • Can i comment out lines of code in a .sql script file to be run in SQL PLUS

    Hi All,
    I have commented out part of the script, and when i ran the script (.sql) file in Sql*Plus
    I am getting some errors like
    SP2-0734: unknown command beginning
    how to avoid these errors?
    any help is appreciated
    Thanks
    R.R

    >
    select * from dual; -- me too!Nope, not this one...
    test@ORA10G>
    test@ORA10G> host type c:\test.sql
    select * from dual; -- me too!
    test@ORA10G>
    test@ORA10G> -- doesn't work
    test@ORA10G>
    test@ORA10G> @c:\test.sql
      2
    test@ORA10G>
    test@ORA10G> @c:\test.sql
      2  /
    select * from dual; -- me too!
    ERROR at line 1:
    ORA-00911: invalid character
    test@ORA10G>
    test@ORA10G> -- now this works...
    test@ORA10G> host type c:\test.sql
    select * from dual -- me too!
    test@ORA10G>
    test@ORA10G> @c:\test.sql
    D
    X
    test@ORA10G>
    test@ORA10G> -- and so does this...
    test@ORA10G> host type c:\test.sql
    select * from dual -- me too!
    test@ORA10G>
    test@ORA10G> @c:\test.sql
    D
    X
    test@ORA10G>
    test@ORA10G>pratz

  • Way to abort a script running in SQL*Plus?

    Hi everyone,
    It looks like by default SQL*Plus continues executing despite commands that fail? Is there a way to change this behavior, so that it returns immediately from the script called (possibly several level deep, when scripts called other scripts, etc...)?
    Thanks, --DD                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Excellent! Thanks guys. --DD                                                                                                                                                                                                                                   

  • Listener running but SQL*Plus not connecting

    Hi -
    I've just installed 8.0.5 on RedHat 5.1 but I seem to be having
    connection problems.
    After some fiddling I seem to have the listener running on 1521
    quite happily but when I try to run svrmgrl or sqlplus I get the
    error 'ORA-12571: TNS:packet writer failure'.
    The excellent 'Oracle8 A Beginners Guide' says that this is a
    Net8 error but as far as I can tell, Net8 is running on TCP/IP as
    you might expect, but 'as far as I can tell' isn't very far at
    all really. I'm just digging through the Administrators Guide
    documentation but as far as I can see, everything's fine.
    Any ideas?
    Simon
    null

    This is a known problem for Oracle on Linux. Try setting write
    permissions for the unix domain sockets in
    /var/tmp/.oracle/
    Simon Greenwood (guest) wrote:
    : Hi -
    : I've just installed 8.0.5 on RedHat 5.1 but I seem to be having
    : connection problems.
    : After some fiddling I seem to have the listener running on 1521
    : quite happily but when I try to run svrmgrl or sqlplus I get
    the
    : error 'ORA-12571: TNS:packet writer failure'.
    : The excellent 'Oracle8 A Beginners Guide' says that this is a
    : Net8 error but as far as I can tell, Net8 is running on TCP/IP
    as
    : you might expect, but 'as far as I can tell' isn't very far at
    : all really. I'm just digging through the Administrators Guide
    : documentation but as far as I can see, everything's fine.
    : Any ideas?
    : Simon
    Get Technical!
    http://technet.oracle.com
    null

  • Running sql scripts in 8iLite's SQL*Plus 8.0

    i am trying to "open"-in an ascii file containing a bunch of DDL commands, namely "create table". the file looks like this:
    create table PART(
    P_PARTKEY number not null,
    P_NAME varchar2(25) not null,
    P_MFGR char(25) not null,
    P_BRAND char(10) not null,
    P_TYPE varchar2(25) not null,
    P_SIZE number not null,
    primary key (P_PARTKEY));
    create table SUPPLIER(
    S_SUPPKEY number not null,
    S_NAME char(25) not null,
    S_ADDRESS varchar2(40) not null,
    S_PHONE char(15) not null,
    primary key (S_SUPPKEY));
    When I "File-Open" the file and run it, SQL*Plus barfs up a "syntax error at line 1" report. However, if i "cut-n-paste" in the "create table"s and "run" them one at a time, the tables get created successfully.
    I thought that there may a true syntax error. so for giggles, i "File-Open"ed in the Poldemo.sql file that the installer provides the end-user as an example. I get the same results--syntax error at line 1.
    what am i doing wrong?
    thanks for your help in advance.

    never mind guys. i figured out that the "start" command is what i should use

  • SQL*Plus Change to File While Being Run

    Anyone,
    Once you execute a file run in SQL*Plus does the entire file get cached by SQLPlus? (i.e. @C:\temp\myfile.sql)
    If I change the file C:\temp\myfile.sql while the session is running (long runing script) will it take effect or not?
    I was able to open the file make a change and save but not sure if SQLPlus will pick up my change when it gets to the point in the script where I made the change. Since it was already running.
    Thanks,
    Miller

    That is a very bad idea to begin with.
    If you made a change at the location that has not yet reached by the SQL*Plus script processing, you could see those changes (again depending upon where and how you do them).
    But in most circumstances, the results will be unpredictable (most likely with error messages) since you cannot control what part of the script the SQL*Plus application is currently executing at the moment you decide to make change to the script.
    For example, I started with this script:
    REM --- Script start ---
    prompt "Waiting ..."
    begin
      dbms_lock.sleep(20) ;
    end ;
    begin
      dbms_output.put_line('This is text') ;
    end ;
    prompt "Finished..."
    REM --- Script end ----And run this within SQL*Plus. While the PL/SQL block was waiting on the sleep call, I removed the first line of the script (the one that starts with the prompt statement) and saved it. Below is the output from this run:
    SQL> @test
    "Waiting ..."
    PL/SQL procedure successfully completed.
    SP2-0734: unknown command beginning "ut_line('T..." - rest of line ignored.
    SP2-0042: unknown command "end " - rest of line ignored.
    PL/SQL procedure successfully completed.
    "Finished..."
    SQL>I would not consider this as a successful completion of the script.
    At this point, you are probably playing with probability and taking chances.
    Message was edited by:
    Kamal Kishore

  • Seek help to format spool file from SQL*PLUS

    I am running a Unix shell script to call a Oracle 11g SQL script from a Oracle database. In this SQL script, I need to connect to many different remote databases to select data, then sool these records as one big text file to a directory. Then email the file to related Group users. In the spool file, there is a line on the top of each page like this:
    DUMMY
    DB_NAME
    I know this is caused by connect to remote database in SQL*PLUS. My connection string is like this:
    Conn system/password@Oracle_SID
    How can I remove these lines or how to skip these lines into spool file? Please advise. Thanks in advnce. Wish all of you Happy New Year!!!

    Hi,
    It sounds like you have some kind of formatting (such as SQL*Plus TTITLE) producing the output you don't want. If that's the case, temporarily stopping the spooling might not help you. Find out what is causing the output that you don't want. You say that you know it is caused by the CONNECT statements, but it must be more than that. I've written scripts with CONNECT statements that don't have anything like what you reported at the top of each page; in fact, they don't even have pages: the output is one continuous stream. Find out what's putting the unwanted output there, and that will be a big clue as to how you can stop it.
    You say that you know the unwanted titles are there because of the CONNECT statements. If so, use database links instead of CONNECT. You don't have to use dbms_scheduler or utl_file; just eliminate the CONNECT statements. (I'm not saying that there's anything wrong with dbms_scheduler or utl_file; you should definitely investigate those tools. I'm just saying that using database links is independent of them.)
    What would happen if you did all your connecting to different databases at the OS level? Can you write a shell script that connects to each database in turn, and runs a SQL*Plus script in each one. Each SQL*Plus script would have a SPOOL or SPOOL ... APPEND command, or maybe you could build the SPOOL into a LOGIN.SQL script.

  • Semicolon and / in SQL Plus scripts?

    Anyone,
    Seem to have some confusion over the use of / and ; inside PL SQL Scripts run in SQL Plus.
    I seem to get two commits thereby two rows on INSERT clase that has a ; and a /.
    i.e.
    /* Insert record into table for recording statistics on the runtime of this script */
    INSERT INTO MYTABLE ( col1, col2) VALUES ( value1, value2);
    COMMIT;
    /The above will get two of the same rows in the table. Is this an issue with SQL Plus settings? What do people typically use? I have a combination of SQL and DDL in my scripts and I need / for the DDL typically as I understand. How do othere intermix these and what standard is used.

    Dave, here are the very basics.
    The SQL language does not have command separators as only a single command at a time can be issued. Thus the following is invalid SQL:
    SELECT * FROM emp;
    The semicolon as command separator (or terminator) is not valid SQL. This is valid SQL:
    SELECT * FROM emp
    PL/SQL is a programming language similar to Pascal, C and Java. Multiple commands are used in a program. These need to be separated so that the parser/compiler can know where a command starts and where it ends. In PL/SQL the semicolon is used.
    The following is invalid PL/SQL as it is missing command separators:
    declare
    i integer
    begin
    i := 1234
    endThe following is valid PL/SQL :
    declare
    i integer;
    begin
    i := 1234;
    end;SQL*Plus is an Oracle CLI (command line interface) client. It can submit both SQL and PL/SQL to the database. It needs to know when you have stopped entering commands into its input buffer and to submit what you've entered to the database.
    SQL*Plus uses two characters for this. The semicolon and the forward slash. If you want to submit the above SELECT to Oracle using SQL*Plus, SQL*Plus needs to know when to submit its input buffer's content - thus:
    SQL> SELECT * FROM emp;
    Or:
    SQL> SELECT * FROM emp
    SQL> /
    When using PL/SQL in SQL*Plus, SQL*Plus "understands" that the semicolons you use are for the PL/SQL language - not an instruction from you to it to submit its buffer to Oracle for execution.
    The forward slash can also be at anytime used to resubmit the current SQL*Plus input buffer again. E.g.
    SQL> SELECT * FROM emp;
    .. now do the last SQL (or PL/SQL) in the buffer again
    SQL> /[i]

  • SQL*Plus Script Errors

    My scripts all contain relative file paths e.g.
    @@../directory1/file1.sql
    Is there a way of setting the current working directory in SQL Developer to make this work?
    In SQL*Plus for windows you simply opened the file but this does not seem to work.

    As I said, run them in SQL*Plus.
    SQL*Developer is a development tool and database browser, not a SQLPLus clone.
    It has its own methods of extracting data which may or may not suit your output requirements. You don't need col statements as much if you are viewing data in a grid, for example. [1]
    I don't know what you use the sqlplus scripts for, but they could be replaced over time with some combination of Apex, SQLDeveloper reports and straight sqldeveloper queries.
    As for SQL*PLus being greyed out on the menu, there are some known issues about that. I think one of them is that you need to be using tns connections. However, the sqlplus menu item is gone in sqldeveloper 1.5 so don't rely on it. Learn to run if from the command line.
    [1] Despite that, I would arguethat SQLDeveloper should support all (with tiny exceptions) SQLPlus commands. Not because I see it as a sqlplus replacement, but so it can be used to develop scripts which can then be run in SQL*Plus without amendment (without the hassle of switching back and forth during development)

  • Checking Module to Prevent SQL Plus usage on Database

    I have a question regarding logon triggers checking against SYS_CONTEXT('USERENV', 'MODULE'). I created a logon trigger that looks for SYS_CONTEXT('USERENV', 'MODULE') = 'SQLPLUS.EXE'
    and if it matches then it only allows specified users to log in to the database. This code works but I am confused as to why when I check SYS_CONTEXT('USERENV', 'MODULE') after I login in
    shows SQL*Plus which clearly does not match my IF statement in my logon trigger.
    Second issue. If I rename sqlplus.exe to jeff.exe and run it I am abled to log in to the database as a non DBA user. But the module still shows as SQL*Plus. Why is this?
    Database Version: 11.2.0.2 64bit
    OS: Windows Server 2003 R2
    Client: 11.2.0.1
    /*********************Create Trigger******************************/
    CREATE OR REPLACE TRIGGER application_check_al
      after logon ON database 
    DECLARE
      l_username VARCHAR2(20);
      l_module   VARCHAR2(20);
    BEGIN
      l_username := SYS_CONTEXT('USERENV', 'SESSION_USER');
      l_module   := UPPER(SYS_CONTEXT('USERENV', 'MODULE'));
      IF l_module LIKE 'SQLPLUS.EXE' AND
         l_username NOT IN ('SYS', 'SYSTEM', 'DVOWNER', 'DVMGR') THEN
        raise_application_error(-20001, 'SQLPLUS ACCESS RESTRICTED FOR NON DBA USERS');
      END IF;
    END application_check_al;
    /*********************Run SQLPLUS******************************/
    SQL*Plus: Release 11.2.0.1.0 Production on Wed Mar 7 12:22:23 2012
    Copyright (c) 1982, 2010, Oracle.  All rights reserved.
    Enter user-name: jeffc@dev
    Enter password:
    ERROR:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-20001: SQLPLUS ACCESS RESTRICTED FOR NON DBA USERS
    ORA-06512: at line 10
    Enter user-name: system@dev
    Enter password:
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining, Oracle Database Vault
    and Real Application Testing options
    system@dev> select sys_context('USERENV','MODULE') from dual;
    SYS_CONTEXT('USERENV','MODULE')
    SQL*Plus
    SQL>

    jeff81 wrote:
    That doesn't make sense. Why am I able to log in when I renamed the exe? And why does the module still show as SQL*Plus?You are right - it does not make sense. The idea that Oracle might perhaps set module to SQLPLUS.EXE on executable start, and then re set from SQLPLUS.EXE to SQL*Plus after connect, or in glogin.sql, to ensure it is consistent across all operating system never crossed my mind.
    You might want to refer to Support Note "SQL*Plus Session/Module is Not Showing in V$SESSION" [ID 1312340.1] to see whether anything in there helps. I'm pretty sure http://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_twelve040.htm#i2698573 doesn't help much, though.
    I'd certainly be raising it with Support as a potential security challenge, to get that potential hole closed.
    Edited by: Hans Forbrich on Mar 7, 2012 2:23 PM
    I wonder whether Oracle put that capability in there - if an untained SQLPLUS.EXE, it tells you that it is SQLPLUS.EXE, but if renamed it tells you 'SQL*Plus'? Specuklation, but it is one thing I might do to subtly raise the flag. Best bet - ask Support.
    Edited by: Hans Forbrich on Mar 7, 2012 2:29 PM

Maybe you are looking for

  • Brand new to the Mac World and NEED SOME HELP with startup disk issues

    Hello everyone. I am a new Mac user and I purchased my mac on ebay. It's an iMac that came with tiger 10.4.11. I wanted to get a fresh start on the computer, since the person who had it before me did not erase all of his stuff. I didn't know what to

  • Using a 27" iMac as Monitor for PC

    I am building a PC for Network Attached Storage (NAS) using FreeNAS: http://www.freenas.org/ Once it's all set up I'll just use the web/network interface to manage it.  But, as I assemble the PC I'll probably need a monitor to make changes to the BIO

  • Closing an iPad app in 7.0.4

    I updated my iPad to ios 7.0.4 yesterday. Previously, one could double-tap the button at the bottom, and then hold a finger on the resulting icons, and get a little X to close the application.  I had been tolD (at the PeachMac store where I bought it

  • Three invisible volumes eating up disk space

    I used Carbon Copy Cloner to load up a new external drive with the contents of my MBP. After it finished my Users folder it began copying "Volumes / LaCie 500GB." It wouldn't show up in Finder, so I presumed it was an invisible file, as best I unders

  • Gradient Issue iMac

    Since a couple of weeks I am experiencing problems with my iMac Display. From the bottom to the middle of my screen I am seeing a gradient. I have been searching this community and via Google but can't really find what the problem is and if it is eas