Selecting from dual

Does anyone have a list of all of the environment selections available from dual.
e.g. select user from dual;
Thanks in advance
Bob

Hi Bob,
there are a lot of usful selections possible using DUAL. For more
information I'd like to suggest you to look into SQL Reference Guide
chapter 4, which describes for example the powerful SYS_CONTEXT
function.
Regards,
Roland
Find attached some usful examples on using dual:
================================================
Current session:
================
SQL> select sid,serial#
from v$session
where audsid in (SELECT USERENV('SESSIONID') FROM DUAL);
SID SERIAL#
13 830
Which protocol is currently used for connection?
================================================
SQL> SELECT SYS_CONTEXT('USERENV','NETWORK_PROTOCOL') from dual;
SYS_CONTEXT('USERENV','NETWORK_PROTOCOL')
tcp
When nothing will be returned then you're using the BEQUEATH protocol.
(Session on loacal server that has connected without using a listener)
Which IP address will be used by session?
=========================================
SQL> SELECT SYS_CONTEXT('USERENV','IP_ADDRESS') "My IP Address" from dual;
My IP Address
140.84.134.14
Which NLS Environment will be used?
===================================
SQL> SELECT SYS_CONTEXT('USERENV','LANGUAGE') "nls_lang" from dual;
nls_lang
AMERICAN_AMERICA.WE8ISO8859P1

Similar Messages

  • Select from dual  into a variable through db links

    HI,I need to select value of current_timestamp in to a variable d1 of a remote database inside function.
    function (db_lnk varchar2)return number
    as
    dbl varchar2(10);
    begin
    dbl:=db_lnk;
    select current_timestamp into d1 from dual@dbl;
    end;
    but getting error table or v iew does not exist.
    if i do
    select current_timestamp into d1 from dual@'||dbl||';
    then it says database link name expected.
    How to achieve this?
    Thanks

    Peter Gjelstrup wrote:
    Foreign languages, foreign languages :-){noformat}*grins*{noformat} I know - and your English is miles better than my Danish (I'm assuming - hopefully correctly?! - that that's your 1st language based on your location!) which I don't even know any words of! *{:-)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Why a function within a SELECT FROM DUAL is faster?

    1)I have a SELECT with a function. Ex:
    "SELECT DISTINCT function(...) FROM table"
    2)I changed the SELECT and put the function inside a SUB-SELECT with FROM DUAL. Ex:
    "SELECT DISTINCT (SELECT function(...) FROM DUAL) FROM table"
    3)The second SELECT is faster than the first.
    I discovered this problem on my tables and my functions. So I did a generic example for this forum with a common function and large table. My results:
    Table has 2.196.058 records and the field is a VARCHAR2:
    SELECT DISTINCT SUBSTR(field, 2) FROM Table -> Executed in 110 seconds
    SELECT DISTINCT (SELECT SUBSTR(field, 2) FROM DUAL) FROM Table -> Executed in 39 seconds
    Why "SELECT DISTINCT (SELECT function(...) FROM DUAL) FROM table" is faster than "SELECT DISTINCT function(...) FROM table"
    thanks,
    Fernando

    Hi hoek,
    I followed your informations and, sorry, I am more confused! I did an interesting example below.
    1)I created a table:
    CREATE TABLE T
         name VARCHAR2(50)
    );     2)I inserted 10 lines:
    NAME                                              
    A                                                 
    B                                                 
    C                                                 
    D                                                 
    E                                                 
    F                                                 
    G                                                 
    H                                                 
    I                                                 
    J                                                  3)I created a function that returns the parameter concatenated with the current millisecond:
    CREATE OR REPLACE FUNCTION f (param1 IN VARCHAR2) RETURN VARCHAR IS
    BEGIN
         return param1 || '-' || to_char(CURRENT_TIMESTAMP, 'FF');
    END;     4)The query(A): SELECT f(name) AS col1, f(name) AS col2, f(name) AS col3 FROM t; gave me:
    COL1        COL2        COL3
    A-693786000 A-693887000 A-693941000
    B-693989000 B-694017000 B-694043000
    C-694071000 C-694097000 C-694124000
    D-694153000 D-694180000 D-694206000
    E-694235000 E-694261000 E-694287000
    F-694316000 F-694341000 F-694367000
    G-694396000 G-694422000 G-694448000
    H-694477000 H-694503000 H-694529000
    I-694557000 I-694583000 I-694609000
    J-694638000 J-694664000 J-694690000If I repeat the SELECT, new values are generated.
    4)The query(B): SELECT (SELECT f(name) FROM Dual) AS col1, (SELECT f(name) FROM Dual) AS col2, (SELECT f(name) FROM Dual) AS col3 FROM t; gave me:
    COL1        COL2        COL3
    A-253546000 A-253643000 A-253746000
    B-253791000 B-253821000 B-253850000
    C-253881000 C-253909000 C-253937000
    D-253969000 D-253997000 D-254026000
    E-254057000 E-254085000 E-254113000
    F-254145000 F-254173000 F-254202000
    G-254232000 G-254261000 G-254289000
    H-254320000 H-254348000 H-254376000
    I-254407000 I-254436000 I-254464000
    J-254495000 J-254523000 J-254551000The result generated new values too.
    5)I changed the function and I put the DETERMINISTIC clause:
    CREATE OR REPLACE FUNCTION f (param1 IN VARCHAR2) RETURN VARCHAR DETERMINISTIC IS
    BEGIN
         return param1 || '-' || to_char(CURRENT_TIMESTAMP, 'FF');
    END;     6)I repeated the queries(A) and (B) and the result has generated different values. Then, with the DETERMINISTIC clause, the result has not changed
    7)I changed the function and I put the RESULT_CACHE clause:
    CREATE OR REPLACE FUNCTION f (param1 IN VARCHAR2) RETURN VARCHAR RESULT_CACHE IS
    BEGIN
         return param1 || '-' || to_char(CURRENT_TIMESTAMP, 'FF');
    END;8)I repeated the query(A) and now, the result was different:
    COL1        COL2        COL3
    A-381048000 A-381048000 A-381048000
    B-381242000 B-381242000 B-381242000
    C-381322000 C-381322000 C-381322000
    D-381400000 D-381400000 D-381400000
    E-381481000 E-381481000 E-381481000
    F-381556000 F-381556000 F-381556000
    G-381634000 G-381634000 G-381634000
    H-381815000 H-381815000 H-381815000
    I-381895000 I-381895000 I-381895000
    J-381971000 J-381971000 J-381971000The line columns are equals and if I repeat the SELECT, all the result is the same too. The query(B) returned the same result like the query(A)! Now I see the cache in action!
    After the tests, I concluded that the function in the subquery doesn't use cache and it is faster than the normal function. The mistery continues...

  • JDBC Lookup in PI 7.1 - SELECT ? FROM DUAL and Connection timed out

    Hi,
    We have a scenarios (Idoc to JMS) with JDBC lookup. We have used graphical JDBC lookup functionality.
    We are reading country names for a given country code from SAP in an external database table. The query is so simple. That  should not take much time
    Now the actual issues is,
    When we are executing the scenario, its taking quite a long time. Almost 6 minutes to excute a mapping. Which causing high performance issue in the Porduction.
    We started the inviestigation about found some interesting stuff. Here we have used Willy Introscope for the investigation.
    1. First few messages are taking quite a long time. LIke 6 minutes per messages. As i can see in the log i am getting below error in Willy,
    I dont know why PI is executing below queury apart from real secelt query to fetch the country name. I am getting below error: Error Message: Backends|ABCD2 mydatabase01-1526 (Oracle DB)|SQL|Dynamic|Query|SELECT ? FROM DUAL: java.sql.SQLException: Io exception: Connection timed out
    2. After couple of messages, interface works very normal. I mean rest of the messages works pretty fine.
    Please let me know if you have any idea about this error. What could be the problem for the issue.
    Thank you in advnace.
    Best Regards,
    Prasad.

    Did you check how many SQL requests were executed per one message ? Do you have a log of these SQL requests ?
    I assume that the country table is quite small, so that lookup should not be an issue.
    About this:
    >Message: Backends|ABCD2 mydatabase01-1526 (Oracle DB)|SQL|Dynamic|Query|SELECT ? FROM DUAL: >java.sql.SQLException: Io exception: Connection timed out
    1. I only know SELECT * FROM DUAL, not SELECT ? FROM DUAL. Better use the former
    2. the exception means that the database server can not be reached => check your network configuration
    So I assume that there is a network (performance) problem between PI and this Oracle server. Or the Oracle Server is so overloaded that it has (sometimes) problems in processing new requests.
    CSY
    Edited by: Christian Sy on Mar 9, 2010 10:17 AM

  • Why sql select 'Hello'||'world012345678' from dual; cause error?

    I have problem and your help to solve it would be very much appreciated.
    Can anybody tell why the result is so different for the following two sql-sentence in SQL/PLus?
    sql>select 'Hello'||'world012345678' from dual;
    sql>select 'Hello'||'world0123456789' from dual;
    sql>select 'Hello'||'world012345678' from dual;
    Result:
    select 'Hello'||'world012345678' from dual
    ERROR at line 1:
    ORA-00600: internal error code, arguments: [17182], [158346180], [], [], [],
    sql>select 'Hello'||'world0123456789' from dual;
    Helloworld0123456789
    I found that if the length of one string equals 14, then the sql will failed as the first sentence.

    If you need to check the validity of DUAL then you have:
    Select count(1) from DUAL ;
    NOT
    Select * from DUAL;
    If you find more than 1, then
    delete from dual;
    insert into dual values ('x') ;
    commit;
    Then, try you offending query.

  • Please Help me with long time oracle  select sequence.nextval from dual

    Hi
    I'm in a real problem.In fact i have a J2EE5(JPA,Hibernate 3,EJB 3.0) project deployed at websphere 6 application server and i'm using Oracle 10 g R2.
    Well i have a batch job that inserts into some table called AVERAGEBALANCE.
    the problem is that when i have activated hibernate log i discoverd that the select from dual is the longest sql (it takes some times over second !!)
    here is the log
    11/07/2011 08:49:40,406 DEBUG SQL:DefaultQuartzScheduler-SimpleThreadPoolWorker-2 - insert into AVERAGEBALANCE (CDATE_, CUSER_, AVERAGEBALANCE_, AVERAGECREDITORBALANCE_, AVERAGEDEBITORBALANCE_, BEGINDATE_, CALCULATIONDATE_, CASHSUBACCOUNTCODE_, CASHSUBACCOUNTPK_, CODE_, ENDDATE_, NBCREDITORDAYS_, NBDEBITORDAYS_, TEDABCALCULATIONPERIODICITYPK_, VERSIONNUM_, PK_) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    11/07/2011 08:49:40,468 DEBUG SQL:DefaultQuartzScheduler-SimpleThreadPoolWorker-2 - select this_.PK_ as PK1_465_0_, this_.CDATE_ as CDATE2_465_0_, this_.CUSER_ as CUSER3_465_0_, this_.UUSER_ as UUSER4_465_0_, this_.BALANCE_ as BALANCE5_465_0_, this_.BALANCETYPE_ as BALANCET6_465_0_, this_.CASHSUBACCOUNTPK_ as CASHSUBA8_465_0_, this_.CASHSUBACCOUNTCODE_ as CASHSUBA7_465_0_, this_.CODE_ as CODE9_465_0_, this_.CURRENCYPK_ as CURRENCYPK11_465_0_, this_.CURRENCYCODE_ as CURRENC10_465_0_, this_.ENDDATE_ as ENDDATE12_465_0_, this_.EXCHANGERATE_ as EXCHANG13_465_0_, this_.ORIGINBALANCEPK_ as ORIGINB15_465_0_, this_.ORIGINBALANCECODE_ as ORIGINB14_465_0_, this_.POSITIONDATE_ as POSITIO16_465_0_, this_.REVALUATIONDATE_ as REVALUA17_465_0_, this_.SUMOFCREDITS_ as SUMOFCR18_465_0_, this_.SUMOFDEBITS_ as SUMOFDE19_465_0_, this_.UDATE_ as UDATE20_465_0_, this_.VERSIONNUM_ as VERSIONNUM21_465_0_ from CASHAB this_ where this_.CASHSUBACCOUNTCODE_=? and this_.BALANCETYPE_=? and this_.POSITIONDATE_<? and this_.ENDDATE_>=? and this_.BALANCE_<>?
    11/07/2011 08:49:40,468 DEBUG SQL:DefaultQuartzScheduler-SimpleThreadPoolWorker-2 - select AVERAGEBALANCE_.nextval from dual
    11/07/2011 08:49:41,484 DEBUG SQL:DefaultQuartzScheduler-SimpleThreadPoolWorker-2 - insert into AVERAGEBALANCE (CDATE_, CUSER_, AVERAGEBALANCE_, AVERAGECREDITORBALANCE_, AVERAGEDEBITORBALANCE_, BEGINDATE_, CALCULATIONDATE_, CASHSUBACCOUNTCODE_, CASHSUBACCOUNTPK_, CODE_, ENDDATE_, NBCREDITORDAYS_, NBDEBITORDAYS_, TEDABCALCULATIONPERIODICITYPK_, VERSIONNUM_, PK_) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)well i have increased the sequence cache in fact here is the creation code of the sequence.
    CREATE SEQUENCE  "COMPTAPERF5"."AVERAGEBALANCE_"  MINVALUE 1 MAXVALUE 999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 400 NOORDER  NOCYCLE   ;i think that there is some oracle parameter to tune
    Thanks in advance
    Edited by: B.Mansour Nizar on 11 juil. 2011 01:04
    Edited by: B.Mansour Nizar on 11 juil. 2011 06:33
    Edited by: B.Mansour Nizar on 11 juil. 2011 06:34
    Edited by: B.Mansour Nizar on 11 juil. 2011 06:34
    Edited by: B.Mansour Nizar on 11 juil. 2011 06:35
    Edited by: B.Mansour Nizar on 11 juil. 2011 06:35
    Edited by: B.Mansour Nizar on 11 juil. 2011 06:36
    Edited by: B.Mansour Nizar on 15 juil. 2011 07:42

    I found it.
    It's not due to oracle but it's a hibernate issue.In fact if setting FlushMode to Manual.It wil flush the in memory entities after that it will fire the insert statement.
    Here's the log.
    15/07/2011 15:32:47,984 DEBUG SQL:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - select CASHAB_.nextval from dual
    15/07/2011 15:32:47,984 TRACE AbstractBatcher:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - preparing statement
    15/07/2011 15:32:47,984 DEBUG SequenceGenerator:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Sequence identifier generated: 20441
    15/07/2011 15:32:47,984 DEBUG AbstractBatcher:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
    15/07/2011 15:32:47,984 TRACE AbstractBatcher:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - closing statement
    15/07/2011 15:32:47,984 DEBUG ConnectionManager:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - aggressively releasing JDBC connection
    15/07/2011 15:32:47,984 DEBUG ConnectionManager:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
    15/07/2011 15:32:47,984 DEBUG AbstractSaveEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - generated identifier: 20441, using strategy: org.hibernate.id.SequenceHiLoGenerator
    15/07/2011 15:32:47,984 TRACE AbstractSaveEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - saving [com.bfi.cpt.bal.cas.CashAccountingBalance#20441]
    15/07/2011 15:32:47,984 TRACE Versioning:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - using initial version: 0
    15/07/2011 15:32:47,984 TRACE AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - flushing session
    15/07/2011 15:32:47,984 DEBUG AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - processing flush-time cascades
    15/07/2011 15:32:47,984 TRACE Cascade:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - processing cascade ACTION_PERSIST_ON_FLUSH for: com.bfi.cpt.cht.cas.CashSubAccount
    15/07/2011 15:32:47,984 TRACE Cascade:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - done processing cascade ACTION_PERSIST_ON_FLUSH for: com.bfi.cpt.cht.cas.CashSubAccount
    15/07/2011 15:32:47,984 TRACE Cascade:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - processing cascade ACTION_PERSIST_ON_FLUSH for: com.bfi.ref.cur.Currency
    15/07/2011 15:32:47,984 TRACE Cascade:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - done processing cascade ACTION_PERSIST_ON_FLUSH for: com.bfi.ref.cur.Currency
    15/07/2011 15:32:47,984 TRACE Cascade:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - processing cascade ACTION_PERSIST_ON_FLUSH for: com.bfi.cpt.bal.cas.CashAccountingBalance
    15/07/2011 15:32:47,984 TRACE Cascade:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - done processing cascade ACTION_PERSIST_ON_FLUSH for: com.bfi.cpt.bal.cas.CashAccountingBalance
    15/07/2011 15:32:47,984 DEBUG AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - dirty checking collections
    15/07/2011 15:32:47,984 TRACE AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Flushing entities and processing referenced collections
    15/07/2011 15:32:47,984 TRACE AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Processing unreferenced collections
    15/07/2011 15:32:47,984 TRACE AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Scheduling collection removes/(re)creates/updates
    15/07/2011 15:32:47,984 DEBUG AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Flushed: 1 insertions, 0 updates, 0 deletions to 3 objects
    15/07/2011 15:32:47,984 DEBUG AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
    15/07/2011 15:32:47,984 DEBUG Printer:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - listing entities:
    15/07/2011 15:32:47,984 DEBUG Printer:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - com.bfi.ref.cur.Currency{translatedName=null, certain=false, iso3166=788, quotity=1, identifier=TND, creationUser=admin, internalCode=null, name=Dinars Tunisien, creationDate=2011-07-11 14:43:06, code=TND, versionNum=0, decimal=3, updateUser=null, updateDate=null, pk=136, decimalName=millimes}
    15/07/2011 15:32:47,984 DEBUG Printer:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - com.bfi.cpt.bal.cas.CashAccountingBalance{cashSubAccount=com.bfi.cpt.cht.cas.CashSubAccount#400201, originBalanceCode=null, exchangeRate=null, sumOfDebits=0.0, endDate=31 décembre 9999, creationUser=bna, currencyPk=136, creationDate=2011-07-15 15:32:47, cashSubAccountCode=BNA/PCI_BNA/82-TND, code=2010-07-30/BNA/PCI_BNA/82-TND/AccountingDateBalance/TND, versionNum=0, originBalancePk=null, currency=com.bfi.ref.cur.Currency#136, updateUser=null, originBalance=null, balanceType=AccountingDateBalance, updateDate=null, positionDate=30 juillet 2010, sumOfCredits=10.0, pk=20441, cashSubAccountPk=400201, revaluationDate=null, balance=-10.0, currencyCode=TND}
    15/07/2011 15:32:47,984 DEBUG Printer:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - com.bfi.cpt.cht.cas.CashSubAccount{name2=null, accountPk=81, name=null, versionNum=0, currency=com.bfi.ref.cur.Currency#136, updateDate=null, chartByEntity=com.bfi.cpt.cht.std.ChartByEntity#2, refAccount=null, currencyCode=TND, chartByEntityCode=BNA/PCI_BNA, refAccountCode=null, creationDate=2011-07-15 15:25:45, account=com.bfi.cpt.cht.cas.StandardAccount#81, freeKey10=null, freeKey11=null, chartByEntityPk=2, freeKey12=null, updateUser=null, refAccountPk=null, freeKey13=null, freeKey14=null, freeKey15=null, freeKey16=null, freeKey17=null, accountCode=PCI_BNA/81, freeKey18=null, freeKey19=null, freeKey0=null, freeKey1=null, freeKey2=null, freeKey3=null, freeKey4=null, freeKey5=null, freeKey6=null, freeKey7=null, freeKey8=null, freeKey9=null, number=82-TND, creationUser=bna, freeKey20=null, freeKey21=null, freeKey22=null, freeKey23=null, freeKey24=null, freeKey25=null, freeKey26=null, freeKey27=null, freeKey28=null, freeKey29=null, currencyPk=136, code=BNA/PCI_BNA/82-TND, freeKey30=null, freeKey31=null, freeKey32=null, pk=400201}
    15/07/2011 15:32:47,984 TRACE AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - executing flush
    15/07/2011 15:32:47,984 TRACE ConnectionManager:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - registering flush begin
    15/07/2011 15:32:47,984 DEBUG UpdateTimestampsCache:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Pre-invalidating space [CASHAB]
    15/07/2011 15:32:47,984 TRACE AbstractEntityPersister:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Inserting entity: [com.bfi.cpt.bal.cas.CashAccountingBalance#20441]
    15/07/2011 15:32:47,984 TRACE AbstractEntityPersister:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Version: 0
    15/07/2011 15:32:47,984 DEBUG AbstractBatcher:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
    15/07/2011 15:32:47,984 DEBUG ConnectionManager:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - opening JDBC connection
    15/07/2011 15:32:47,984 DEBUG SQL:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - insert into CASHAB (CDATE_, CUSER_, BALANCE_, BALANCETYPE_, CASHSUBACCOUNTCODE_, CASHSUBACCOUNTPK_, CODE_, CURRENCYCODE_, CURRENCYPK_, ENDDATE_, POSITIONDATE_, SUMOFCREDITS_, SUMOFDEBITS_, VERSIONNUM_, PK_) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)Edited by: B.Mansour Nizar on 15 juil. 2011 07:38
    Edited by: B.Mansour Nizar on 15 juil. 2011 07:39
    Edited by: B.Mansour Nizar on 15 juil. 2011 07:43

  • Query from DUAL

    I am calling a Pl/sql function in a select query which has a statement as below
    SELECT SUBSTR(5/2,2,1) INTO m_delim FROM DUAL;
    The number of records returned from the calling select query is more 1 million.
    How much adversly the query from DUAL table affects the performance of the select query?

    user557052 wrote:
    I am calling a Pl/sql function in a select query which has a statement as below
    SELECT SUBSTR(5/2,2,1) INTO m_delim FROM DUAL;
    The number of records returned from the calling select query is more 1 million.
    How much adversly the query from DUAL table affects the performance of the select query?Even if you are selecting from dual, querying once would be enough based on your select statement.
    It does not seem like it is varying, you are trying to find the delimiter, which can be done once.
    Ss

  • Is select from view faster then select from table..???

    Hello Gurus,
    I want to query some data from two tables, both of table have many columns (attributes) and many rows...
    I use several where clauses to retrieve data from those tables..
    witch one is faster, I create a view or I just "select" from those tables???
    Regards.
    Nia...

    riedelme wrote:
    3360 wrote:
    riedelme wrote:
    Selecting through a view almost never helps performance and frequently hurts.Views do not affect performance.
    Views are simply queries and like queries there are fast and slow ones.I disagree.
    First of all, to use a view you are executing a query to get a result set, then accessing the data from that result set - a built-in extra step to perform to get data.First of all that entire explanation of how views work is not correct. The optimizer will rewrite the query to make the view go away if possible.
    SQL> create or replace view v as select * from dual;
    View created.
    SQL> explain plan for select * from dual where dummy = 'X';
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 272002086
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |     1 |     2 |     2   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| DUAL |     1 |     2 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("DUMMY"='X')
    13 rows selected.
    SQL> explain plan for select * from v where dummy = 'X';
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 272002086
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |     1 |     2 |     2   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| DUAL |     1 |     2 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("DUMMY"='X')
    13 rows selected.Exactly the same.
    >
    Second, when accessing the data from the view the result sets don't have indexes for fast lookups and efficient joins on later steps.This is also known as just making stuff up and is not how the database works. care to share any references at all for any of this?
    >
    Third, the systems I've seen that use views extensively - I am looking at one now - tend to perform joins on views using the same tables with the same data over and over. This is a design issue and not specifically a problem with views but they lend themselves to this misuse much too easilyCorrect as I said a view is just a query, and just like queries there are good fast views and bad slow views
    >
    I'll concede that the problem is not specifically with views themselves but as I just said they lend themselves to misuse. Tuning views of views and views joined to views is difficultYes, queries can be misused as can almost all SQL functions and functionality.
    As I said - Views are simply queries and like queries there are fast and slow ones.
    Nothing that you have posted that is accurate changes that.

  • Trying selelct A,B,C,D from dual

    I want to create a sql statement where I select from dual letters
    A THRU E. I want them to come back in one field.
    I have done the following
    select 'A' ,'B','C','D' FROM DUAL
    but this brings them back in there own field.

    This???
    SQL> with t as (
       select 'A' col1 ,'B' col2,'C' col3,'D' col4,'E' col5 from dual)
    select col1 || col2 || col3 || col4 || col5 new_col from t
    NEW_C
    ABCDE

  • Update table with select from another table

    Hallo,
    I'd like to update table b with codes from a mapping table a.
    a has:
    town_id, town_code, town_name
    b has town_code, town_id, town_population, town_zip_code,...
    Table a has all the details - town_id, town_code and town_name and acts as the mapping between town_id and town_code
    In table b, town_code is null. I want to update the column b.town_code with town_code from table a where a.town_id = b.town_id.
    How will the update query look like?
    I tried
    UPDATE B SET town_code = (SELECT A.town_code FROM A,B WHERE A.town_id=B.town_id)
    and I get the error 'single-row subquery returns more than one row'
    Will appreciate your assistance

    This is what I did.
    First, I created and populated the TOWN_INFO table:
    CREATE TABLE "TOWN_INFO"
    (     "TOWN_ID" NUMBER,
         "TOWN_CODE" NUMBER,
         "E_MAIL" CHAR(15 BYTE)
    Table Created.
    insert all
    into TOWN_INFO (TOWN_ID, E_MAIL) values (3024,'[email protected]')
    into TOWN_INFO (TOWN_ID, E_MAIL) values (3040,'[email protected]')
    into TOWN_INFO (TOWN_ID, E_MAIL) values (3052,'[email protected]')
    into TOWN_INFO (TOWN_ID, E_MAIL) values (3065,'[email protected]')
    into TOWN_INFO (TOWN_ID, E_MAIL) values (3066,'[email protected]')
    select * from dual
    5 rows created.
    The following creates and populates the mapping table:
    CREATE TABLE "TOWN_MAPP"
    (     "TOWN_CODE" NUMBER,
         "TOWN_ID" VARCHAR2(255 BYTE),
         "TOWN_NAME" CHAR(6 BYTE)
    insert all
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3024,'1001','TOWN_1')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3040,'1003','TOWN_3')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3052,'1002','TOWN_2')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3065,'1004','TOWN_4')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3066,'1006','TOWN_6')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3088,'1007','TOWN_7')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3020,'1009','TOWN_9')
    select * from dual
    7 rows created.
    And now the update query:
    UPDATE TOWN_INFO
    SET TOWN_CODE=(SELECT B.TOWN_CODE FROM TOWN_MAPP B, TOWN_INFO C
    WHERE B.TOWN_ID=B.TOWN_ID)
    SET TOWN_CODE=(SELECT B.TOWN_CODE FROM TOWN_MAPP B, TOWN_INFO C
    ERROR at line 2:
    ORA-01427: single-row subquery returns more than one row
    Thanx in advance
    Edited by: user9954260 on Apr 13, 2010 7:40 AM
    Edited by: user9954260 on Apr 13, 2010 7:44 AM

  • [11g] increasing efforts for select xmlserialize(content(...))) into ... from dual

    I wonder, that i don't get any feedback here (please see below).
    Can somebody first just confirm this observation?
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    "CORE 11.2.0.3.0 Production"
    TNS for Linux: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    NLSRTL 11.2.0.3.0 Production
    Oracle Database 11g Enterprise Edition 11.2.0.3.0 64bit Production
    PL/SQL 11.2.0.3.0 Production
    TNS for Linux: 11.2.0.3.0 Production
    I recognized for my application, that there is an increasing efforts (in terms of time) for executing
    (in a pl/sql package procedure invoked by a BIU trigger)
    SELECT XMLSERIALIZE(CONTENT(p_xml_data)) INTO v_xml_clob FROM DUAL;
    Here is a little demo sqlplus script:
    create or replace package test_pkg
    as
           procedure check_xml(
             p_xml_data in out nocopy xmltype);
    end;
    create or replace package body test_pkg
    as
           procedure log(
             p_txt in varchar2)
           is
             ts     TIMESTAMP WITH TIME ZONE := systimestamp;
           begin
             dbms_output.put_line(to_char(ts, 'hhmiss.FF3') || ':' || p_txt);
           end;
           procedure check_xml(
             p_xml_data in out nocopy xmltype)
           is
             v_xml_clob CLOB;
             v_len NUMBER;
           begin
             log('check_xml(): enter');
             SELECT XMLSERIALIZE(CONTENT(p_xml_data)) INTO v_xml_clob FROM DUAL;
             log('  serialized');
             v_len := dbms_lob.getlength(v_xml_clob);
             log('check_xml(): done - length = #'  || v_len);
           exception
           when others then
               oerror_pkg.set_ora_error;
               raise;
           end;
    end;
    drop table test_table;
    create table test_table(
           tid number(19,0),
           data xmltype
    create or replace trigger BIU_TEST_TABLE
    before insert or update on test_Table
    for each row
    declare
    begin
       test_pkg.check_xml(:new.data);
    end;
    insert into test_table(tid, data)
    select ctr_tab.ctr, '<root><node>' || ctr_tab.ctr || '</node></root>'
    from (  SELECT LEVEL ctr
           FROM dual
           CONNECT BY LEVEL <= 200) ctr_tab;
    The output is going like this
    021543.204:check_xml(): enter
    021543.204:  serialized
    021543.204:check_xml(): done - length = #32
    021543.206:check_xml(): enter
    021543.206:  serialized
    021543.206:check_xml(): done - length = #32
    021543.207:check_xml(): enter
    021543.208:  serialized
    021543.208:check_xml(): done - length = #32
    021543.209:check_xml(): enter
    021543.210:  serialized
    021543.210:check_xml(): done - length = #32
    021543.211:check_xml(): enter
    021543.212:  serialized
    021543.212:check_xml(): done - length = #32
    021543.214:check_xml(): enter
    021543.214:  serialized
    021543.214:check_xml(): done - length = #32
    021549.625:check_xml(): enter
    021549.664:  serialized
    021549.665:check_xml(): done - length = #34
    021549.708:check_xml(): enter
    021549.746:  serialized
    021549.747:check_xml(): done - length = #34
    021549.791:check_xml(): enter
    021549.829:  serialized
    021549.830:check_xml(): done - length = #34
    021549.874:check_xml(): enter
    021549.912:  serialized
    021549.913:check_xml(): done - length = #34
    When i filter it with a little perl script to extract the efforts (xmlserialize / dbms_lob.getlength):
    0 / 0
    0 / 0
    1 / 0
    1 / 0
    1 / 0
    0 / 0
    0 / 0
    0 / 1
    1 / 0
    0 / 0
    0 / 1
    1 / 0
    0 / 0
    0 / 1
    1 / 0
    0 / 1
    0 / 1
    0 / 0
    0 / 1
    0 / 0
    0 / 1
    0 / 0
    1 / 0
    0 / 1
    0 / 0
    31 / 1
    31 / 1
    32 / 1
    32 / 1
    32 / 1
    33 / 0
    33 / 0
    34 / 1
    34 / 0
    34 / 1
    34 / 0
    34 / 1
    34 / 1
    35 / 1
    35 / 1
    36 / 0
    36 / 1
    36 / 1
    37 / 1
    37 / 0
    37 / 1
    38 / 0
    38 / 0
    39 / 1
    38 / 1
    38 / 1
    38 / 1
    Unfortunately i can't easily change the way the insert from select is done (legacy code not under my control)
    Can someone tell me, if there is a way starting with the trigger to avoid those increasing efforts?
    - many thanks!
    best regards,
    Frank

    [ Addendum - 24.01.2014:
      This only worked for the test/demo program. It didn't work for my application.
       For my application i really had to move the logic to the INSERT before the trigger
       - similar to the 3rd posting for my monologue(!) here.
    A little step further:
    I also don't have the problem if i expand the code of the PROCEDURE test_pkg.check_xml(...) directly into the trigger
    - instead of invoking the PROCEDURE in the trigger:
    create or replace package test_pkg
    as
           procedure log(
             p_txt in varchar2);
    end;
    create or replace package body test_pkg
    as
           procedure log(
             p_txt in varchar2)
           is
             ts     TIMESTAMP WITH TIME ZONE := systimestamp;
           begin
             dbms_output.put_line(to_char(ts, 'hhmiss.FF3') || ':' || p_txt);
           end;
    end;
    drop table test_table;
    create table test_table( 
           tid number(19,0),
           data xmltype
    create or replace trigger BIU_TEST_TABLE
    before insert or update on test_Table
    for each row
    declare
    begin 
      -- test_pkg.check_xml(:new.data);
           declare
             v_xml_clob CLOB;
             v_len NUMBER;
           begin
             test_pkg.log('check_xml(): enter');
             SELECT XMLSERIALIZE(CONTENT(:new.data)) INTO v_xml_clob FROM DUAL;
             test_pkg.log('  serialized');
             v_len := dbms_lob.getlength(v_xml_clob);
            test_pkg.log('check_xml(): done - length = #'  || v_len);
           exception
           when others then
               oerror_pkg.set_ora_error;
               raise;
           end;
       end; 
    insert into test_table(tid, data)
    select ctr_tab.ctr, '<root><node>' || ctr_tab.ctr || '</node></root>'
    from (  SELECT LEVEL ctr
           FROM dual
           CONNECT BY LEVEL <= 200) ctr_tab;
    -- rollback;
    That gives some hint.
    Does oracle have some problem / limit for invoking procedures (functions) from triggers?
    Or only if those use certain features?
    An issue about deterministic and re-entrance?
    Well, that boxes me into a corner.
    Because the single package procedure implements a functionality at a central place - i.e. a single central place to extend it or to fix it.
    If i now have to expand its content (like a macro) into the triggers of the respective table i am in trouble.
    Because those tables (and their triggers) are dynamically generated by a compiler tool of a c++ client.
    This means for extension and fixes i need to change, test, deliver and deploy a list of c++ client processes :-(
    Is there any way around?
    How can i inform oracle that the invocation of a PL/SQL procedure is functionally identically with expanding the PL/SQL functions code into the trigger?
    rgds,
    Frank

  • Problem with:  select 'c' as X from dual

    Problem with 'select 'c' as X from dual'
    I get 2 different results when I execute the above with SQLPlus (or java) depending on the instance I am connected to. For one instance the result is a single character and for the other the character is padded with blanks to 32 chars in the SQLPlus window (and java). Does anyone know what database setting causes this to happen? Is it a version issue ?
    Test #1: Oracle 9.2.0.6 - SQLPlus result is padded with blanks
    SQL*Plus: Release 9.2.0.1.0 - Production on Mon Dec 10 09:27:58 2007
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
    With the Partitioning option
    JServer Release 9.2.0.6.0 - Production
    SQL> select 'c' as X from dual;
    X
    c
    SQL>
    Test #2 Oracle 9.2.0.1 SQLPlus result is a single character.
    SQL*Plus: Release 9.2.0.1.0 - Production on Mon Dec 10 09:29:27 2007
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.1.0 - Production
    SQL> select 'c' as X from dual;
    X
    c
    SQL>

    Using 9.2.0.6 On AIX 5.2 I get the single byte result:
    UT1 > select 'c' as X from dual;
    X
    c
    If the databases are on different Oracle Homes you may want to check the sqlplus global logon files for any set commands.
    If you executed the two sql statements from different OS directories you may also want to check your sqlpath for sqlplus .logon files.
    Try issueing clear columns and repeating the statement. Are the results the same?
    HTH -- Mark D Powell --

  • Delay due to selecting sysdate from  dual

    Our application accessing dummy table dual frequently for getting current date and time. But some times this could reduce our database performance.
    How could we overcome this problem.
    ASH report_
    Top Events_
    latch: library cache      29.87      "5015593920","214","0"      26.57      address      number      tries
    Top SQL Statements_
    0vnruqfxmtu6q     Select to_number(to_char(Sysdate, 'YYYYMMDD')) from dual

    orianmoon wrote:
    Thanks for your replies,
    Please check this below link which shows my database performance at the time of running a particular sql , which is selecting sysdate using table dual. It created Lbrary cache latch contention.
    http://arun-itadmin.blogspot.com/2010/12/oracle-performance-screen.html
    My question is
    Is this the problem of frequent usage of table dual or usage of 'sysdate' ?
    It there any way to get date and time other than using sysdate function?
    Edited by: orianmoon on Dec 8, 2010 9:42 PMI don't see anything there that points the finger at SELECT SYSDATE FROM DUAL;

  • Bug: in ManagedDataAccess while fetch from "Select .., NULL, ... From dual"

    Hi,
    I have the problem with the new managed ODP.Net driver.
    If I fetch data from a select which has column with a fixed value "NULL" the driver decides after a certain amount of data that the value is not null any more. Which causes a lot of problems especially if you try to hide not needed blob data.
    The Problem somehow depends on the FetchSize of the command. It seems like the error occurs if more than one db round trip to fetch the result is necessary.
    System: Windows 7 64 Bit
    Platform: .net 4.0 x86
    database: 11g Release 11.2.0.3.0 - 64bit Production
    Oracle.ManagedDataAccess Version: 4.112.350
    I created a small example to reproduce the problem.
    Thanks for your help
    Dominik
    Stored Proc:
    create or replace PROCEDURE TestNullField
      v_IntPara IN NUMBER DEFAULT NULL ,
      v_StrPara IN VARCHAR2 DEFAULT NULL,
      cv_1 OUT SYS_REFCURSOR
    AS
    BEGIN
          OPEN cv_1 FOR
            select rownum, v_StrPara, NULL from dual connect by level <= v_IntPara;
            --select IDX, NULL, DESCRIPTION FROM TEST_BLOBTABLE;
    END;C# Code:
    using System;
    using System.Text;
    using Oracle.ManagedDataAccess.Client;
    using System.Data;
    namespace OracleBlobTest
        class Program
            private static string _connectionString = @"User ID=YourUser;Password=YourPwd;Data Source=YourServer:YourPort/YourSchema;";
            private static string _spName = @"TestNullField";
            private static string _strPara = @" Long test string";
            private static int _intPara = 200;
            static void Main(string[] args)
                using (OracleConnection connection = new OracleConnection(_connectionString))
                    using (OracleCommand cmd = connection.CreateCommand())
                        cmd.CommandText = _spName;
                        cmd.CommandType = CommandType.StoredProcedure;
                        connection.Open();
                        string alongString = _strPara;
                        while (alongString.Length < 2000)
                            alongString += alongString;
                        alongString = alongString.Substring(0, 2000);
                        OracleCommandBuilder.DeriveParameters(cmd);
                        if (cmd.Parameters.Count > 0 && (cmd.Parameters[0]).Direction != ParameterDirection.ReturnValue)
                            cmd.Parameters[0].Value = _intPara;
                            cmd.Parameters[1].Value = alongString;
                        // change this to change the moment when it starts to go wrong
                        ///cmd.FetchSize = 5000;
                        using (OracleDataReader reader = cmd.ExecuteReader())
                            int count = 0;
                            while (reader.Read())
                                count++;
                                for (int idx = 0; idx < reader.FieldCount; idx++)
                                    if (reader.GetName(idx) == "NULL")
                                        if (!reader.IsDBNull(idx))
                                            //something is very wrong here - why is not not null any more???
                                            Console.WriteLine("Fix NULL Field[{0}] {1} is not null >{2}< in row {3} ", idx, reader.GetName(idx), reader[idx], count);
                            Console.WriteLine("Rows found: " + count);
                    connection.Close();
                Console.WriteLine("done press enter");
                Console.ReadLine();
    }Edited by: user540519 on 10.12.2012 15:11
    Edited by: user540519 on 19.12.2012 13:50

    Hello
    I ran the testcase here and reproduced the issue on 32 bit unmanaged beta v4.0.30319
    note: same testcase works with Oracle.DataAccess (but not with managed).
    This appears to match unpublished defect Bug 14666093 and is meant to be fixed in a later beta release.
    Some things I noticed when testing
    with the default fetchsize the breaking point is 67 iterations.
    e.g.
    private static int _intPara = 66;    // Works
    private static int _intPara = 67;  // Fails
    If I increase the fetchsize then it breaks at different values as you noticed..
    Hope this helps.
    Kind Regards
    John

  • For j in (select a, (select 1 from dual),c ) loop ..end loop;...... error

    declare
    begin
    for cur in (select (select 1 from dual) col from dual)
    loop
      null;
    end loop;
    end;in TOAD, OK, BUT IN FORM ERROR!
    Edited by: indoracle on Feb 23, 2012 2:38 AM
    Edited by: indoracle on Feb 23, 2012 2:40 AM

    A couple of things.
    First, please take a few minutes to review the following:
    <ul>
    <li>Oracle Forums FAQ
    <li>Before posting on this forum please read
    <li>10 Commandments for the OTN Forums Member
    <li>How to ask questions the smart way
    </ul>
    Following these simple guidelines will ensure you have a positive experience in any forum; not just this one! ;-)
    Using the formating information in the Oracle Forms FAQ, it is always recommended that you put your code samples in the ... tags (use lower case "code") so your code is more readable.
    Second, the use of all capital letters is concidered YELLING. I'm sure you did not intend to YELL at anyone, so please only use capital letters when they are needed, not for everything. :)
    Third, what is your Forms Version? If you look at the *10 Commandments for the OTN Forums Member* you'll see that it is always best to give program version information. Depending on your Forms version, the subquery in your SQL statement may not be supported or it could simply be the Cursor For Loop construct [ FOR j IN ( SQL Statement)...] that is not supported. You may have to declare an explicit cursor and reference the explicit cursor in place of your SQL Statement.
    Forth, your FOR LOOP doesn't do anything!
    LOOPEND LOOP; There is nothing between LOOP and END LOOP. I am going to assume that this is intented and just a point of sanatizing your code because what happens in the loop is not relevant to the error.
    ERROR 103.. This is a Forms internal PL/SQL error; meaning the Forms PL/SQL engine can not parse your code. Again, this is probably because the subquery or cursor FOR loop with (SQL Statement versus explicit cursor) is not supported by your Forms version.
    Please, what is your Forms version and any other information that might be helpful.
    Craig...

Maybe you are looking for

  • Problem connecting to Weblogic Server

    I have a JMS application for which I am trying to create a connection factory for Oracle ESB (Weblogic). I added the wlfullclient.jar to my classpath and start the application. I receive the following error in my application's log? Caused by: org.spr

  • How can I change the settings in my time capsule to support UPnP?

    Trying to change the settings on my time capsule to support UPnP so I might remotely access 3rd party software.  Any suggestions?

  • Pop-up menu as "menu" button?

    I've noticed a lot of Blu-rays show the pop-up menu when you press "menu" (rather than "pop up menu"). Is there a way to do this in Encore? I'd prefer it to go to the pop-up one I've made with the movie playing rather than go to the main menu any ide

  • Navigating from APEX to Original App

    Hi, We have integrated APEX with Oracle E-Business Suite. When we click on APEX URL we are able to navigate from Oracle E-Business Suite to APEX. But I need following solution. What steps I need to follow if I want to come back from APEX to Oracle E-

  • Photos in Blog Excerpts

    I've been working with I web a while. I'm trying to create a blog that not only displays the entire entry in the except, but displays a few of the images within the text of the blog. It seems that all the setting only allow for the "placeholder" imag