Function in Select...from dual

Hi
One generate question.
We can do the following task in the Select Statements:-
1. Select Function_Name('Parameter) from dual;
2. Select Package_Name.Function_Name('Parameter') from dual;
Why dont we can call the procedure from the Select Statements:-
Select Procedure_Name('Parameter') from dual;
Can we we call the Procedure in side the procedure statements ???
Thanks
Sandeep

Procedure or function, it's not an Oracle question. In all prog language, it's same.
Where a function return one value into a variable (or query here) :
declare
var_in1 varchar2(10);
var_in2 varchar2(10);
var_out varchar2(10);
var_out:=myfunction(var_in1,var_in2);
print var_out;
--or
print myfunction(var_in1,var_in2);a procedure have some output variable (may be more than one) :
declare
var_in1 varchar2(10);
var_in2 varchar2(10);
var_out1 varchar2(10);
var_out2 varchar2(10);
Myprocedure(var_in1,var_in2,var_out1,var_out2);
print var_out1;
print var_out2;Nicolas.

Similar Messages

  • 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...

  • 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! *{:-)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • 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

  • 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

  • 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;

  • Select sysdate from dual (to custom format).

    Dear all,
    i like to SELECT SYSDATE FROM DUAL, and run this result in a query something like:
    SELECT X, Y, Z FROM TABLENAME WHERE ACCESSDATE = (SELECT SYSDATE FROM DUAL);
    The problem is that the value of ACCESSDATE is in an format like DD-MM-YYYY and that sysdate form dual is
    DD-MON-YYYY.
    How do i get sysdate into the format DD-MM-YYYY?
    Thanks already,
    Johan.

    Perhaps usefull for performance:
    first of all: no subselect is not needed. sysdate can be used as an argument directly (all functions are).
    secondly, if accessdate is of type 'date' and the table has a lot of rows, converting it to a char will bypass the index usage. Instead, if you are worrying about the time try this (the display format is of no concern here if the datatype is date):
    SELECT X, Y, Z FROM TABLENAME WHERE ACCESSDATE >trunc(sysdate) and ACCESSDATE < trunc(sysdate+1);
    if accessdate is of type 'varchar2' then this should be enough (and should remain using the indexes on accessdate):
    SELECT X, Y, Z FROM TABLENAME WHERE ACCESSDATE = to_date(sysdate,DD-MM-YYYY);
    Hope this helps,
    L.

  • Output of value returned from function in SELECT statement ??

    Hi
    I have created the below function
    create or replace
    FUNCTION jc_test
    RETURN VARCHAR2
    IS myrec VARCHAR2(270);
    BEGIN
    SELECT RPAD('*',270,'*')
    INTO myrec
    FROM DUAL ;
    RETURN myrec;
    END ;
    and I executed the SELECT statement in Oracle SQL developer as a script
    select
    LENGTH(jc_test()) len
    *,jc_test() rec*
    from dual ;
    I get exact output as below
    LEN REC
    270 ******************************************************************************************************************************************************************************************************************************************************************************
    So here LEN is correctly shown as 270 characters but when I see the astrisk's (also appended with spaces ) its total length is 4000 characters
    Can anyone give their thoughts on this.
    Its fine if I run as normal, i mean not as a script.
    Regards
    jc
    Edited by: JC on Jun 16, 2011 11:25 AM

    Hi,
    So here LEN is correctly shown as 270 charactersYes, correct
    but when I see the astrisk's (also appended with spaces ) its total length is 4000 charactersNo buts. It is not padded. That is just how it is displayed by your tool. In SQL*Plus this is controlled by LINESIZE and COLUMN
    SQL> create or replace function dummy return varchar2 as begin return null; end;
      2  /
    Function created.
    SQL> select dummy from dual;
    D
    X
    SQL> select dummy() from dual;
    DUMMY()
    SQL> col "dummy()" for a10
    SQL> select dummy() from dual;
    DUMMY()
    SQL>P.S: It is a really bad idea to create your own wrapper functions, built-in functions. Hopefully you are not really doing that?
    Regards
    Peter

Maybe you are looking for

  • My Macbook Pro won't let me use my external hard drive anymore, Help!

    Every time I go to time machine it has my internal hard drive as the back up drive, when it should be my external hard drive. When I tried to select my external hard drive it doesn't do anything, it goes right back to the internal hard drive. Time ma

  • Renewing

    have all my music on a external hard drive..i want to completely start over and clean out my Library and reload the songs and videos from my hard drive

  • Apache service behaving strangely

    Hello, I have apache 2 installed on my Solaris 10 machine. When I check for the servce with the following commands I get nothing except a legacy run, however, if I put in the IP of my machine the apache2 webserver shows up and is serving. I confirmed

  • Embedding music player?

    So... I've searched the forum and seen a few suggestions on embedding a music player into your iWeb, but none seem to work. I am some what familiar with HTML and am certain the code I am inserting into my website is correct, but I cannot seem to get

  • Minor bug in portal's tutorial

    Hi all, in portal tutorial (portalApp/tutorial/portlets/login/header.jsp), the "new Java style code string test": if ( username == "" ) { Have fun!