30EA2 - SQL Developer Vs Index SQL/Plus functional on column Date

I just spotted this while using EA3.2, but it may also exist on other versions, I will consider. I'm on a 9i 9.2.0.7 box, but will see if I can recreate on an instance of 10 or 11

The question is, if I create a shadow table

CREATE TABLE paul_test
(
CREATION_DATE DATE,
DATE of creation_date2,
last_updsate_date DATE,
date of last_updsate_date2
)
;

If I then create a functional index on creation_date via SQL Dev:

create index pt_idx1 on paul_test (nvl (creation_date, ' 01-JAN-4000'));

and create a functional index on creation_date2 via SQL more

create index pt_idx2 on paul_test (nvl (creation_date2, ' 01-JAN-4000'));

What I see when you perform a describe table statement and looking at the index or when querying ALL_IND_EXPRESSIONS on the table TABLE_NAME is the following:

SQL Dev index is: NVL("CREATION_DATE",'01-JAN-4000')

The Index of over SQL is: NVL ('CREATION_DATE2', TO_DATE ('4000-01-01 00:00:00 ',' yyyy-mm-dd hh24:mi:ss'))))

Why are they not compatible?

If I then fill up with 1 million rows and fill creation_date/creation_date2 with enough data to make no small enough value I then collect statistics on the table and explain the plans of selects on creation_date/creation_date2 via SQL dev. and SQL Plus what I see, it's different


-Select
NVL SELECT (creation_date, ' 01 - JAN - 4000 "")
OF eagadev.paul_test
where nvl (creation_date, ' 01-JAN-4000') = ' 01-JAN-4000';

SQL Dev explain Plan
Use PT_IDX1


More SQL explain Plan:

SQL > SELECT count (1)
2 FROM eagadev.paul_test
3 where nvl (creation_date, ' 01-JAN-4000') = ' 01-JAN-4000';

COUNT (1)
----------
100


Execution plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer = CHOOSE (cost = 30 card = 1 bytes = 8)
1 TRI 0 (AGGREGATE)
2 1 INDEX (LINE SCAN) OF "PT_IDX1" (NO ONE) (cost = 30 Ca
RD = 5825 bytes = 46600)

Statistics
----------------------------------------------------------
14 recursive calls
0 db block Gets
8 compatible Gets
0 physical reads
Redo size 60
224 bytes sent via SQL * Net to client
276 bytes received via SQL * Net from client
2 SQL * Net back and forth to and from the client
0 sorts (memory)
0 sorts (disk)
1 rows processed


-Select2

SELECT count (1)
OF eagadev.paul_test
where nvl (creation_date2, ' 01-JAN-4000') = ' 01-JAN-4000';

SQL Dev explain the Plan:
FULL analysis

More SQL explain Plan:

SQL > SELECT count (1)
2 FROM eagadev.paul_test
3 where nvl (creation_date2, ' 01-JAN-4000') = ' 01-JAN-4000';

COUNT (1)
----------
100


Execution plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer = CHOOSE (cost = 28 card = 1 bytes = 8)
1 TRI 0 (AGGREGATE)
2 1 INDEX (LINE SCAN) OF "PT_IDX2" (NO ONE) (cost = 28 Ca
RD = 5825 bytes = 46600)





Statistics
----------------------------------------------------------
14 recursive calls
0 db block Gets
8 compatible Gets
0 physical reads
Redo size 60
224 bytes sent via SQL * Net to client
276 bytes received via SQL * Net from client
2 SQL * Net back and forth to and from the client
0 sorts (memory)
0 sorts (disk)
1 rows processed


The select on creation_date2 says plan is different between Dev SQL and SQl Plus. SQL Dev does not seem to be implicitly convert the '' 01-JAN-4000 in a date.

Their behaviour are not the same?

Then the problem may be due to different configurations of NLS between SQLPlus and SQLDeveloper, try to check the date format configured NLS in SQLPlus and SQLDeveloper.

You can change the date format in SQLDeveloper, NLS of:

Tools-> preferences - ZDatabase-> NLS

Tags: Database

Similar Questions

  • Connect SQL Developer, SQL * Plus can't

    I installed Oracle Database Development VM VM: VM VirtualBox for developers & lt; / title & gt; & lt; meta name = & quot; Title & quot; content = & quot; VM VirtualBox for developers & q...

    Added two adapters, one as a host-only, as NAT.

    We add a few entries tnsnames.ora for network database servers.

    Developer SQL inside the VM can connect to all three databases: XE, remote_db1 and remote_db2.

    SELECT * FROM Dual using a remote connection returns the data immediately.

    SQL * Plus inside the VM can connect to XE, but not to a remote server. It hangs just for awhile and finally back: ORA-12545: Connect failed because target host or object does not exist

    Outside of the virtual machine (on the host), Developer SQL (database connection Type) and SQL (sqlplus connection string) can connect to all three systems.

    What is going on?

    Brian Tkatch wrote:

    SQL * Plus inside the VM can connect to XE, but not to a remote server. It hangs just for awhile and finally back: ORA-12545: Connect failed because target host or object does not exist

    Sounds like the hostname resolution failed.

    A host name must be resolved to an IP address. If you use a host name in the TNS connection string, you need to make sure that it can be resolved to an IP address. With the help of the ping command is an easy way to determine if the host name is resolved.

    Some listeners (such as remote control and headphones RAC), accepts a connection client and in response redirect the client to a different hostname (and port). For example, a remote listener can serve 10 cases (each with a different service name). The client connects, asking servcice5. The listener redirects the customer to hostname ora-Server5 on port 1521. The customer now tries to connect to ora-Server5, to resolve the hostname to an IP address and then make the call to connect.

    If the listener can redirect the customer to a new host name - and the customer must be able to resolve the host name. The error that you get so don't always relates to the connection initial listener. It can also occur when the client driver follows the redirect to the listener and attempt a new connection to a new host.

  • How to configure the settings of sql stored function

    Hello

    I use jdeveloper 11.1.2.3.0

    I have the below sql stored function
    function get_data(p_id     in number,
                      p_date   in date,
                      p_msg    out varchar) return number is
     .......
    
    end get_data;
    I would like to know how exactlly I should call this function of my AppModuleImpl.
    I tried several ways to set the parameters, but I'm getting java.sql.SQLException: Error invalid column index.

    Could you give me the correct code for this case?

    Thank you very much!

    check the docs [url http://docs.oracle.com/cd/E16162_01/web.1112/e16182/bcadvgen.htm#insertedID6] calling stored procedures and functions

  • ORA-12154 error using SQL PLUS

    I have no problems connecting using SQL Developer, but I'm having issues using SQL Plus or command prompt. I also set the Oracle_home and SID and still it fails with the following message. Is there anything I can check?

    ORA-12154: TNS could not resolve the connect identifier

    The same account and tnsnames work well using SQL Developer.

    BSK wrote:
    Here's the info. Not sure why only SQL MORE fails to solve the connection identifier when the SQL Developer works very well.

    tnsnames.ora

    B51 =
    (DESCRIPTION =
    (SDU = 32768)
    (ADDRESS = (PROTOCOL = TCP (PORT = 1527))(HOST = hostname.com))
    (CONNECT_DATA =
    (SERVICE_NAME = B51)
    )
    )

    SQLNET.ora

    sqlnet.ora # Network Configuration file: C:\oracle\product\11.2.0\client_1\network\admin\sqlnet.ora
    # Generated by Oracle configuration tools.

    # This file is actually generated by netca. But if customers can opt for
    # install 'Software Only', this file does not exist and without the native
    authentication #, they will not be able to connect to the database on NT.

    SQLNET. AUTHENTICATION_SERVICES = (NTS)

    NAMES. DIRECTORY_PATH = (TNSNAMES, EZCONNECT)

    That's what I'm trying:

    view the results at the bottom

    sqlplus username/passwd@'hostname.com:1527/B51'

  • CBO bug or not, or else develop do not consider the function index

    SQL> create table test_fun_or as select object_id+sysdate id,object_name from        
    
      2  dba_objects;
    
    Table created.
    
    SQL> create index i_test_fun_or on test_fun_or(id,'a') nologging;   
    
    //I don't know why oracle consider it as function index
    
    Index created.
    
    SQL> create index i_test_fun_or_1 on test_fun_or(object_name) nologging;
    
    Index created.
    
    SQL> set autot trace exp
    
    SQL> exec dbms_stats.gather_table_stats(user,'TEST_FUN_OR',estimate_percent=>null,method_opt=>'for all columns size 1');
    
     
    
    PL/SQL procedure successfully completed.
    
     
    
    SQL> select * from test_fun_or where id=sysdate or object_name='aa';
    
     
    
    Execution Plan
    
    ----------------------------------------------------------
    
    Plan hash value: 3247456674
    
     
    
    ---------------------------------------------------------------------------------
    
    | Id  | Operation         | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
    
    ---------------------------------------------------------------------------------
    
    |   0 | SELECT STATEMENT  |             |     3 |    87 |   219   (3)| 00:00:03 |
    
    |*  1 |  TABLE ACCESS FULL| TEST_FUN_OR |     3 |    87 |   219   (3)| 00:00:03 |
    
    ---------------------------------------------------------------------------------
    
     
    
    Predicate Information (identified by operation id):
    
    ---------------------------------------------------
    
     
    
       1 - filter("OBJECT_NAME"='aa' OR "ID"=SYSDATE@!)
    
     
    
    SQL> select /*+ use_concat */ * from test_fun_or where id=sysdate or object_name='aa'; 
    
    //or expand don't use index i_test_fun_or
    
     
    
    Execution Plan
    
    ----------------------------------------------------------
    
    Plan hash value: 3161566054
    
     
    
    ------------------------------------------------------------------------------------------------
    
    | Id  | Operation                    | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
    
    ------------------------------------------------------------------------------------------------
    
    |   0 | SELECT STATEMENT             |                 |     3 |    87 |   224   (3)| 00:00:03 |
    
    |   1 |  CONCATENATION               |                 |       |       |            |          |
    
    |*  2 |   TABLE ACCESS FULL          | TEST_FUN_OR     |     1 |    29 |   219   (3)| 00:00:03 |
    
    |*  3 |   TABLE ACCESS BY INDEX ROWID| TEST_FUN_OR     |     2 |    58 |     5   (0)| 00:00:01 |
    
    |*  4 |    INDEX RANGE SCAN          | I_TEST_FUN_OR_1 |     2 |       |     3   (0)| 00:00:01 |
    
    ------------------------------------------------------------------------------------------------
    
     
    
    Predicate Information (identified by operation id):
    
    ---------------------------------------------------
    
     
    
       2 - filter("ID"=SYSDATE@!)
    
       3 - filter(LNNVL("ID"=SYSDATE@!))
    
       4 - access("OBJECT_NAME"='aa')
    
     
    
    SQL> drop index i_test_fun_or;
    
     
    
    Index dropped.
    
     
    
    SQL> create index i_test_fun_or on test_fun_or(id,object_name) nologging;
    
     
    
    Index created.
    
     
    
    SQL> alter table test_fun_or modify object_name not null;
    
     
    
    Table altered.
    
     
    
    SQL> select /*+ use_concat */ * from test_fun_or where id=sysdate or object_name='aa';
    
     
    
    Execution Plan
    
    ----------------------------------------------------------
    
    Plan hash value: 1705821130
    
     
    
    ------------------------------------------------------------------------------------------------
    
    | Id  | Operation                    | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
    
    ------------------------------------------------------------------------------------------------
    
    |   0 | SELECT STATEMENT             |                 |     3 |    87 |     8   (0)| 00:00:01 |
    
    |   1 |  CONCATENATION               |                 |       |       |            |          |
    
    |*  2 |   INDEX RANGE SCAN           | I_TEST_FUN_OR   |     1 |    29 |     3   (0)| 00:00:01 |
    
    |*  3 |   TABLE ACCESS BY INDEX ROWID| TEST_FUN_OR     |     2 |    58 |     5   (0)| 00:00:01 |
    
    |*  4 |    INDEX RANGE SCAN          | I_TEST_FUN_OR_1 |     2 |       |     3   (0)| 00:00:01 |
    
    ------------------------------------------------------------------------------------------------
    
     
    
    Predicate Information (identified by operation id):
    
    ---------------------------------------------------
    
        2 - access("ID"=SYSDATE@!)
    
       3 - filter(LNNVL("ID"=SYSDATE@!))
    
       4 - access("OBJECT_NAME"='aa')

    Jinyu wrote:
    Thanks Jonathan, I don't have 11.2.0.2 on-site, I'll test it later, I just test it on 11.2.0.1

    If you see the notes of fixed a bug fixes for 11.2.0.2 Group (Doc ID:1179583.1) it's bug 8352378 "allow index GOLD-Expansion functions.

    Concerning
    Jonathan Lewis

  • Query SQL or function...

    Hi everyone,
    
    
      Please help me to clarify this question
    I have a "patient" table and a "address" table.And each patient has differnt types of addresses
    like PMI,Mailing and default address i need to pick patient address in the order of preference
    (PMI,Mailing ,Default)
    
    I have two options to get the address of a patient.Either write a SQL query to get the address of a 
    patient(according to preference)
    or write a function which checks
    
     if there is PMI,Mailing and default
      take PMI
     or
     If there is mailing and Default
     take mailing
     or
     take default.
    
    which one is the best method to get the address of a patient?  SQL query or function..
    Definitely everyone will say that it should be direct SQL query instead of multiple function calls.
    
    But in my organization there are many developers which will get "patient address" in their application 
    or SQL code or PL/SQL code or from some
    'X' Business intelligence tool.
    At this scenario is it best to have a function which every one will call and get a standardized output
     for every one.
    
    Question:
    
    In my scenario which one is the best to have "SQL query or function"?
    if i choose "function" i have to sacrifice the performance 
    if i choose "SQL query" i am not sure whether each and every developer querying the same way as it would be
    
    
    Sorry if it is a dumb question to ask.
    
    Thanks in advance
    phani

    hoek question: what happens if I have to choose between the SQL and function? (Assume that they do not accept to create views)

    If views are not accepted (which is very strange IMO), but you need some "standard object" which anyone can use, then you would choose to use a function instead of everyone having "their own motion.
    It is a compromise between maintaining standards and performance (call PL/SQL in SQL is generally to be avoided because of context switching, the other way around is OK).
    One of the advantages of a view: no problems with the settings you must enter but never going to use, you just choose the columns you need and there you go.
    Other: it is simple, plain and simple.
    It is easier to maintain.
    But everything depends on what your function returns.
    Maybe a REF CURSOR?

    Your question reminds me of this interesting discussion:

    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:672724700346558185

    Published by: hoek on July 1st, 2009 16:39 tyop

  • Can I install SQL Plus in a client PC?

    Dear friends,

    I'm working on a PC that accesses the database using PL/SQL Developer and command-line SQLPLUS (instant client). I would like to download SQL PLUS as well. Is there a way? I've seen some way PC but don't know how to do it.

    Could someone guide me.

    Thanks in advance.

    Looking for your support.

    Benard

    My apologies. I did not yet installing Oracle11g customer and assumed it was the same as Oracle 10g. My bad. During the initial examination, I could not find the SQL * Plus for Windows (sqlplusw.exe) in the Oracle11g Client installation or the other.

    Could always try installing with Oracle10g customer or Oracle10g Express Edition.

    Had heard some comments awhile back that SQL * Plus for Windows would disappear at some point, but do not think that was going to be to 11g of product.

    Published by: J.A.Hill on May 27, 2009 13:51

  • Unable to see the tilde characters correctly in SQL * Plus window BACK

    Hello

    I have a tilde character display problem in SQL * more correctly.

    The environment is: Oracle 10.2.0.5 Server (Yes, I know, it is longer supported, but it is not possible to update now).

    Database settings:

    SQL > select * from nls_database_parameters by parameter.

    PARAMETERVALUE

    ------------------------------ ----------------------------------------

    NLS_CALENDARGREGORIAN
    NLS_CHARACTERSETWE8MSWIN1252
    NLS_COMPBINARY
    NLS_CURRENCY?
    NLS_DATE_FORMATRR. MR. DD
    NLS_DATE_LANGUAGEPortuguese
    NLS_DUAL_CURRENCY?
    NLS_ISO_CURRENCYPortugal
    NLS_LANGUAGEPortuguese
    NLS_LENGTH_SEMANTICSBYTE
    NLS_NCHAR_CHARACTERSETAL16UTF16
    NLS_NCHAR_CONV_EXCPFAKE
    NLS_NUMERIC_CHARACTERS,.
    NLS_RDBMS_VERSION10.2.0.5.0
    NLS_SORTWEST_EUROPEAN
    NLS_TERRITORYPortugal
    NLS_TIME_FORMATHH24:MI:SSXFF
    NLS_TIME_TdZ_FORMATTZR HH24:MI:SSXFF
    NLS_TIMESTAMP_FORMATRR. MR. DD HH24:MI:SSXFF
    NLS_TIMESTAMP_TZ_FORMATRR. MR. DD HH24:MI:SSXFF TZR

    20 selected lines.

    Data are inserted and displayed correctly by the application (Oracle Forms 6 - Yes, I know it is old and not supported more :-)))

    The only problem is that I can't view "tilde one" or "o tilde" correctly when you use SQL * Plus window BACK directly connected to the database. Other accented characters appear very well (acute accents a, for example).

    If I use the SQL Windows * more available in point 10.2 so all the characters appear correctly.

    NLS_LANG and code page are correct.

    SQL > host chcp

    Active code page: 850

    SQL > host % NLS_LANG Echo%

    AMERICAN_AMERICA.we8pc850

    SQL > select * from nls_session_parameters by parameter.

    VALUE OF THE PARAMETER

    ------------------------------ ----------------------------------------

    NLS_CALENDAR GREGORIAN

    BINARY NLS_COMP

    NLS_CURRENCY $

    NLS_DATE_FORMAT DD-MON-RR

    NLS_DATE_LANGUAGE PORTUGUESE

    NLS_DUAL_CURRENCY $

    NLS_ISO_CURRENCY AMERICA

    NLS_LANGUAGE AMERICAN

    NLS_LENGTH_SEMANTICS BYTES

    NLS_NCHAR_CONV_EXCP FAKE

    NLS_NUMERIC_CHARACTERS.,.

    NLS_SORT BINARY_AI

    NLS_TERRITORY AMERICA

    NLS_TIME_FORMAT HH.MI. SSXFF AM

    NLS_TIME_TZ_FORMAT HH.MI. SSXFF AM TZR

    NLS_TIMESTAMP_FORMAT-DD-MON-RR HH.MI. SSXFF AM

    NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI. SSXFF AM TZR

    17 selected lines.

    Bad displays data:

    SQL > select notes to atj_disc_cong where Ref = 645; -See attached screenshot Snap1.jpg

    However, the data is stored correctly:

    SQL > select dump (notes) in the atj_disc_cong where Ref = 645;

    DUMP (NOTES)

    --------------------------------------------------------------------------------

    Typ = 1 Len = 21: 231,32,227,225,224,226,32,233,232,234,32,237,236,32,243,245,242,224,32,250,249

    Also, if I copy the wrong characters has resulted in Word, they appear very well (that is, I get a tilde correctly a)

    No idea why they are not display correctly in SQL * more?

    Thank you

    The data is stored correctly, as shown in the PICTURE, even if you really do not have the data expected if I'm only guessing.

    The problem is most likely with the police. Your command prompt is implemented with code 850 (WE8PC850), but the police page seems to be in the code page 437 (US8PC437). You should change the font to a non-raster font or change page codes and NLS_LANG to the code page 437.

    Note, do not define NLS_LANG in system properties, because it affects so Oracle Forms. Set only in the command prompt given.

    Thank you

    Sergiusz

  • not able to connect Toad/sql * plus with ebs R12.2

    Dear experts,

    I have a R12.2 EBS instance with linux 5 (32-bit), but trying to connect to the database using toad / sql * plus of the client machine. his mistake.

    another instance ebs r12.1.1 with the work of database 11g very well,

    Please suggest how I can fix it.

    Database - 11.2.0.3.0

    EBS - R12.2

    OS - release of the Red Hat Enterprise Linux 5.5 Server (Tikanga)

    concerning

    pritesh Rodriguez

    problem is solved.

    using the id of doc metalink 291897.1.

    concerning

    pritesh Rodriguez

  • How do I inject inside the ODI 11 G PL/SQL (not function procedure)

    Hello Expert,

    would be like double until OWB and ODI OWB 11 G I wich 'The user function' run PL/SQL and it remove some data in the table and the reel journal, is possible that I can do the same thing in ODI, in my case, I can't call function, or a procedure stored outside the ODI. See below the part of the PL/SQL based on user OWB.

    coil MyFile... Journal

    command prompt

    create table MyTable as

    Select a.*

    Of...

    commit;

    command prompt

    spool off;

    "exit";

    Thank you!

    You can run a PL within a procedure, you simply copy paste your PL and place in a procedure inside the ODI.

    I hope this can help you!

  • A question on the impact of SQL * PLUS SERVEROUTPUT Optionconcernant v$ sql

    Hello everyone,
    SQL> SELECT * FROM v$version;
    
    BANNER
    ------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0  Production
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    
    SQL> 
    
    
    OS : Fedora Core 17 (X86_64) Kernel 3.6.6-1.fc17.x86_64
    I would like to ask a question about SQL * Plus SET SERVEROUTPUT option on / off and its impact on queries on views such as v$ sql and v$ session. This is the problem

    In fact I define three variables in SQL * Plus to store sidcolumns, serial # and prev_sql_id of session $ v in order to be used later, several times in various other queries, while I work always in the current session.

    So, here's how
    SET SERVEROUTPUT ON;  -- I often activate this option as the first line of almost all of my SQL-PL/SQL script files
    
    SET SQLBLANKLINES ON;
    
    VARIABLE mysid NUMBER
    VARIABLE myserial# NUMBER;
    VARIABLE saved_sql_id VARCHAR2(13);
    
    
    -- So first I store sid and serial# for the current session
    BEGIN
        SELECT sid, serial# INTO :mysid, :myserial#
        FROM v$session
        WHERE audsid = SYS_CONTEXT('UserEnv', 'SessionId');
    END;
    /
    
    
    PL/SQL procedure successfully completed.
    
    
    -- Just check to see the result
    SQL> SELECT :mysid, :myserial# FROM DUAL;
    
        :MYSID :MYSERIAL#
    ---------- ----------
           129   1067
    
    SQL> 
    Now let's say I want to run the following query as the last SQL statement is executed within my current session
    SELECT * FROM employees WHERE salary >= 2800 AND ROWNUM <= 10;
    According to the reference of database Oracle® 11 g Release 2 (11.2) description of session $ v

    http://docs.Oracle.com/CD/E11882_01/server.112/e25513/dynviews_3016.htm#REFRN30223]

    column prev_sql_id includes the sql_id of the last executed sql statement for the sid and serial data which, in the case of my example, it will be the above mentioned query SELECT on the employees table. So right after the SELECT statement on the employees table I have run the following
    BEGIN
        SELECT prev_sql_id INTO :saved_sql_id
        FROM v$session 
        WHERE sid = :mysid AND serial# = :myserial#;
    END;
    /
    
    PL/SQL procedure successfully completed.
    
    SQL> SELECT :saved_sql_id FROM DUAL;
    
    :SAVED_SQL_ID
    --------------------------------
    9babjv8yq8ru3
    
    SQL> 
    The value of sql_id, I'm supposed to find all the information on the sliders for my SELECT statement and also its value sql_text in v$ sql. Here is what I get when I query v$ sql on the stored sql_id
    SELECT child_number, sql_id, sql_text 
    FROM v$sql 
    WHERE sql_id = :saved_sql_id;
    
    
    CHILD_NUMBER   SQL_ID          SQL_TEXT
    ------------  --------------   -------------------------------
    0              9babjv8yq8ru3    BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES); END;
    So instead of
    SELECT * FROM employees WHERE salary >= 2800 AND ROWNUM <= 10;
    get the next value for the value of sql_text
    BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES);
    Which is of course not what I expected to find in v$ sql for the given sql_id.

    After a little googling, I found the next thread on OTN forum, where it was suggested (well, I think that may not be exactly the same problem) to disable SERVEROUTPUT.

    Problem with dbms_xplan.display_cursor

    It was exactly what I did
    SET SERVEROUTPUT OFF
    After that, I repeated the procedure as a whole and this time everything worked pretty much as expected. I checked SQL * more documentation for SERVEROUTPUT
    and also the page of v$ session, yet I don't find nothing indicating that SERVEROUTPUT should be operated off every time that views such as v$ sql, v $session
    are queired. I don't really understand the link in what concerns the impact that can have on the other or better say rather, why is there an impact

    Could someone kindly do a few details?


    Thanks in advance,

    Kind regards
    Dariyoosh

    >

    and also the page of v$ session, yet I don't find nothing indicating that SERVEROUTPUT should be operated off every time that views such as v$ sql, v $session
    are queired. I don't really understand the link in what concerns the impact that can have on the other or better say rather, why is there an impact

    Hi Dariyoosh,
    SET SERVEROUTPUT ON has the effect of dbms_output.get_lines running after each statement. Not only related to the system view.

    Below is what Tom Kyte is explained in this page:

    Now, sqlplus sees this feature and says "Hey, it wouldn't be nice for me to empty the buffer to the screen for the user? Thus, they added the command SQLPlus "set serveroutput we" which does two things

    (1) he tells SQLPLUS you would like run dbms_output.get_lines after each statement. You would like to make this network rounded up after each call. You want that this additional load will take place (think of a script of installation with hundreds / thousands of statements to run - maybe, just maybe you don't want this extra call after each call)

    (2) SQLPLUS automatically calls the API dbms_output "activate" to activate the buffering which is in the package.

    Kind regards.
    Al

  • SQL * PLUS command to get rid of the old and new sqls when using and

    Hi all

    If we use "and in" any query sql in SQL * PLUS, we get the OLD and the NEW sqls as below. How can I get rid of them?
    SQL> select n.name,s.value from v$sesstat s,v$statname n where n.STATISTIC#=s.STATISTIC# and n.name in ('physical read bytes','physical write bytes','redo size','redo writes','session pga memory','sorts (disk)','sorts (memory)','sorts (rows)','undo change vector size','temp space allocated (bytes)') and s.sid=&in;
    Enter value for in: 3
    old   1: select n.name,s.value from v$sesstat s,v$statname n where n.STATISTIC#=s.STATISTIC# and n.name in ('physical read bytes','physical write bytes','redo size','redo writes','session pga memory','sorts (disk)','sorts (memory)','sorts (rows)','undo change vector size','temp space allocated (bytes)') and s.sid=&in
    new   1: select n.name,s.value from v$sesstat s,v$statname n where n.STATISTIC#=s.STATISTIC# and n.name in ('physical read bytes','physical write bytes','redo size','redo writes','session pga memory','sorts (disk)','sorts (memory)','sorts (rows)','undo change vector size','temp space allocated (bytes)') and s.sid=33
    
    NAME                                                              VALUE
    ------------------------------------------------------------ ----------
    session pga memory                                              1199976
    physical read bytes                                               90112
    physical write bytes                                                  0
    redo size                                                           200
    redo writes                                                           0
    temp space allocated (bytes)                                          0
    undo change vector size                                               0
    sorts (memory)                                                        0
    sorts (disk)                                                          0
    sorts (rows)                                                          0
    
    10 rows selected.
    TIA,
    JJ

    Hello

    highlight:

    set verify off
    

    Herald tiomela
    http://htendam.WordPress.com

  • Out of the queue of SQL * Plus for Excel

    I'm out of the queue of SQL * Plus for Excel. The code I use is down. I want that all white space to carve when I open the updated file waiting in Excel. How can I ensure this?

    I was reading on the SET TRIM command, but it says that it does not affect the output queued. (http://ss64.com/ora/syntax-sqlplus-set.html)

    Is there a way to NOT display whitespace at the beginning and the end of a column in SQL * more? In other words, if I shoot a single column of a record, and a data element is only 3 characters in length, I want to be also 3 characters instead of extending over 40 characters across the width of the column.


    The column for your troubleshooting information
    IDNUMBER is NUMBER (12)
    FIRST is VARCHAR2 (40)
    The LAST is VARCHAR2 (60)


    Code
    SET LINESIZE 100
    SET PAGESIZE 0
    SET MARKUP HTML PREFORMAT ON
    set colsep,
    coil c:\prospects.csv
    Select '' perspective ID"', '" First"',""finally" "from dual;
    Select to_char (p.idnumber), p.first, prospect_view p.last p where idnumber = 164515;
    spool off

    DataHandle wrote:
    I'm out of the queue of SQL * Plus for Excel. The code I use is down. I want that all white space to carve when I open the updated file waiting in Excel. How can I ensure this?

    I was reading on the SET TRIM command, but it says that it does not affect the output queued. (http://ss64.com/ora/syntax-sqlplus-set.html)

    TRIM affects the expressions in your SELECT clause. It has nothing to do with the padding of SQL * Plus adds to align the columns upwards.

    Is there a way to NOT display whitespace at the beginning and the end of a column in SQL * more? In other words, if I shoot a single column of a record, and a data element is only 3 characters in length, I want to be also 3 characters instead of extending over 40 characters across the width of the column.

    Here's a way to make the main request:

    SELECT        TO_CHAR (idnumber)
    || ',' ||  first
    || ',' ||  last
    FROM           prospect_view
    WHERE        idnumber     = 164515
    ;
    

    This will include spaces only if they occur in first or last. Depending on your data and your requriements, you may need to use the FILLING (first) instead of the first, and/or TRIM (finally) instead of the last.

    Using this technique, it does not matter what is COLSEP: the query produces a single column.

    Use the SQL * more order

    SET  TRIMSPOOL ON
    

    to keep SQL * more add space after this single column.

  • SQL Plus - guest user with: "do you want to continue?

    I am running a script, PL/SQL using SQL more. In the middle of the script, I would essentially like to have the following logic:

    Request to the user: "do you want to continue?
    IF the user types 'Y', continue with script (run update instructions)
    ELSE IF
    types user 'n' end script

    What is the best way to do it? Thank you!

    You cannot ask for PL/SQL code. The PL/SQL code runs in a process on the database server and can interface with the end front of the customer.
    You must use a front-end interface for this apart from any PL/SQL code. SQL * Plus offers a basic intervention, but you would be better using a good front-end such as Application Express, .NET, Java etc. or maybe even a Windows command/batch file.

  • How to return an error code of SQL * Plus of PL/SQL procedure

    Hello

    I want to be able to pass a variable back to the Unix script, and I have the following code

    ******************

    sqlplus/myuser mypass < < EOF
    WHENEVER SQLERROR EXIT 41.
    WHENEVER OSERROR EXIT 81;
    execute pkonp.run_onp;
    output
    EXPRESSIONS OF FOLKLORE

    ERRORCODE = $?

    If [$ERRORCODE! = 0] #test for successful onp
    then
    #Notify failure of the administrator of the ONP.
    echo 'Fail ONP to 'date' \n'
    FI

    ******************
    However, I am unable to get my PL/SQL to pass an error code to SQL * more.

    How to catch an error in PL/SQL and pass the SQL error code *, so that SQL * Plus can then pass the error to the Unix Shell script?

    Thank you very much.

    Yes - in a nut shell, you need to convert Oracle codes exception to the process of Linux/Unix/Windows exit codes as the number of exception Oracle is physically too large to fit into an integer to a byte that is used by the operating system for the exit codes.

    The best place to do this would be something like a SQL * more script as is the process real o/s which should only return exit code of the kernel.

Maybe you are looking for