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...
Similar Messages
-
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:42I 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 -
Select multiple rows from dual table
Is it possible to select multiple rows from dual table using a single select statement.
i.e., i want the out put to be
column_name
1
2
3
4
Edited by: vidya.ramachandra on Dec 14, 2009 8:24 AMAside from the fact you're responding to an old thread...
1002424 wrote:
While using CONNECT BY, I see it always leave behind one row.
Suppose I have a condition based on which I have to generate constant rows like
SELECT 1 FROM DUAL WHERE ROWNUM < N;
Here if N = 0, still it gives out single row.... you are obviously doing something wrong in your code elsewhere, because that SQL statement does not always return a single row...
SQL> SELECT 1 FROM DUAL WHERE ROWNUM < 0;
no rows selected
SQL> -
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
SandeepProcedure 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. -
Interesting though esoteric problem of the form 'select a * b from dual'
Hi,
Warning: The question is of very little practical significance.
(There, I warned you!!)
Database version: 10.2.0.4.0
If I try to execute the following
select 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 * 999999999999999999999999999999999999999999
from dualI get a 'ORA-01426: numeric overflow' error, which is fine.
But if I try to execute the following(note the decimal point)
select 3.14285712285715111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 * 7
from dualI get a 'ORA-00923: FROM keyword not found where expected' error.
Interestingly, if I remove any one digit from the first number(hence reducing its length by 1), the query works fine. Removing the spaces on either side of '*' still results in a 'ORA-00923: FROM keyword not found where expected' error though.
Can anyone explain why?
Regards,
SujoyHi, Sujoy,
There seems to be a limit of 255 characters (including decimal point) in a number literal. It doesn't seem to matter how m,any digits are before the decimal point and how many are after it. If you don't raise siome other error (such as "'ORA-01426: numeric overflow' error") first, then using a liteal with more than 255 characters will raise "'ORA-00923: FROM keyword not found where expected".
Multiplying by 7 in your example doesn't matter; the compiler never gets that far, because the error occurs in the compilation.
A sign doesn't matter, either, because signs are not part of the literal; they are operators applied to the value after the literal is evaluated. This is also evident because you can put withespace between the sign and the literal. -
How to calculate a string (select '1 + 1' from dual;)
I have this system that gives me data (roughly a gig per hour) in the format:
Time_idle
13h 56m
56m 23s
24h 23m
4h 3m
4m 3s
I have to translate it into date, or desimal hour so I can use it in calculations and SQL.
How can I do this?
I have tried the following:
select RTRIM(REPLACE(REPLACE(REPLACE(REPLACE(time_idle,'h',''),'m','/60'),'s','/3600'),' ','+'),'+') from thedate where prosess = 1;
and I then get:
result:
10+54/60
14+12/60
54/60+1/3600
which is correct, if I could get Oracle to calculate the number sum instead of just providing me with the string value. How do I make Oracle calculate the value of the string?
Or how can I use to_date function to translate the text into a date?
Anyone know?
BBUnfortunately this soultion breaks down when the time involved exceeds 24 hours. Try it for the given data sample 24h 23m ...
SQL> select (to_number(to_char(to_date('24m 23m', 'HH24"h" MI"m" SS"s"'), 'HH24'))) +
2 (to_number(to_char(to_date('24m 23m', 'HH24"h" MI"m" SS"s"'), 'MI'))/60) +
3 (to_number(to_char(to_date('24m 23m', 'HH24"h" MI"m" SS"s"'), 'SS'))/3600) total
4 from dual
5 /
select (to_number(to_char(to_date('24m 23m', 'HH24"h" MI"m" SS"s"'), 'HH24'))) +
ERROR at line 1:
ORA-01850: hour must be between 0 and 23
SQL> Cheers, APC -
Problem in moving to next record in For Loop end loop construct
Hi friends i have the followind code in my stored proc. I am reading each row in the temprec and then based on the variable "i_copy_notes" processing the record. If the value of the I_copy_notes" varialble is 1 then i need to move to next record. when I am using "Next" then the compiler is telling me that the "NEXT" must be declared. Please advise.
FOR TEMPREC IN
SELECT
DP_SER,
GRD_POS,
TS_POS,
ASG_ID,
DESCS,
GRD_ID
FROM DCGRD_POS
WHERE CLLI = i_FROM_CLLI AND SUBSYS = i_SUBSYS AND BAY_ID = v_OLD_BAY_ID ORDER BY GRD_ID
LOOP
IF v_OLD_GRDID = TEMPREC.GRD_ID THEN
v_NEW_GRDID := v_NEW_GRDID;
IF i_COPY_NOTES = 1 THEN
Next;
END IF;
ELSE
v_OLD_GRDID := TEMPREC.GRD_ID;
SELECT DCGRD_POS_GRD_ID.NextVal INTO v_NEW_GRDID FROM DUAL;
END IF;
INSERT INTO DCGRD_POS VALUES
i_TO_CLLI,
DCGRD_POS_ROW_SER.NextVal,
TEMPREC.DP_SER,
v_NEW_GRDID,
v_NEW_BAY_ID,
TEMPREC.GRD_POS,
DECODE(i_COPY_NOTES,1, TEMPREC.TS_POS,''),
TEMPREC.ASG_ID,
DECODE(i_COPY_NOTES,1,TEMPREC.DESCS,'UASGN'),
i_CURRENT_ISSUE,
-1,
i_SUBSYS,
SYSDATE,
i_USERID
END LOOP;
Line # = 315 Column # = 10 Error Text = PLS-00201: identifier 'NEXT' must be declared
Line # = 315 Column # = 10 Error Text = PL/SQL: Statement ignored
----------------------------------------------Personally, I'm not a big fan of this technique but you can use a goto ...
begin
for i in 1.. 10 loop
if i < 5 then
goto end_of_loop;
end if;
dbms_output.put_line(i);
<<end_of_loop>>
null;
end loop;
end; -
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 -
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,
FernandoHi 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... -
Strange "select level from dual connect by level :N" behavior
Oracle SQL Deveoper version:1.1.0.23
Oracle database server version:
select * from v$version;
Oracle9i Enterprise Edition Release 9.2.0.7.0 - Production
PL/SQL Release 9.2.0.7.0 - Production
"CORE 9.2.0.7.0 Production"
TNS for 32-bit Windows: Version 9.2.0.7.0 - Production
NLSRTL Version 9.2.0.7.0 - Production
Run the following queries in sequence as a script and look at number of rows returned:
select 1, level l from dual connect by level < 1;
select 2, level l from dual connect by level < 2;
select 3, level l from dual connect by level < 3;
select 4, level l from dual connect by level < 4;
select 5, level l from dual connect by level < 5;
select 6, level l from dual connect by level < 6;
select 7, level l from dual connect by level < 7;
select 8, level l from dual connect by level < 8;
select 9, level l from dual connect by level < 9;
select 10, level l from dual connect by level < 10;
select 11, level l from dual connect by level < 11;
select 12, level l from dual connect by level < 12;
1 L
1 1
1 rows selected
2 L
2 1
1 rows selected
3 L
3 1
3 2
2 rows selected
4 L
4 1
4 2
4 3
3 rows selected
5 L
5 1
5 2
5 3
5 4
4 rows selected
6 L
6 1
6 2
6 3
6 4
6 5
5 rows selected
7 L
7 1
7 2
7 3
7 4
7 5
7 6
6 rows selected
8 L
8 1
8 2
8 3
8 4
8 5
8 6
8 7
7 rows selected
9 L
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
8 rows selected
10 L
10 1
10 2
10 3
10 4
10 5
10 6
10 7
10 8
10 9
9 rows selected
11 L
11 1
11 2
11 3
11 4
11 5
11 6
11 7
11 8
11 9
11 10
10 rows selected
12 L
12 1
12 2
12 3
12 4
12 5
12 6
12 7
12 8
12 9
12 10
10 rows selected
1000 L
1000 1
1000 2
1000 3
1000 4
1000 5
1000 6
1000 7
1000 8
1000 9
1000 10
10 rows selected
-- wrong result. return 1 row, should return 0 row
-- May have some automagical code saw dual and return 1 row.
select 1, level l from dual connect by level < 1;
-- wrong result. Should return 11 rows, but it stopped at 10 rows.
select 12, level l from dual connect by level < 12;
select 1000, level from dual connect by level < 1000;""By default, when Oracle JDBC executes a query, it receives the result set 10 rows at a time from the database cursor.""
Sql dev overrides the default and fetches 50 (1.0) or 100 (1.1) rows at a time. In 1.1 this is configurable.
"I don't HATE any SQL, as long as it's valid."
That statement is absurd. So, if someone tells you a way to write your query that it allows it to run faster, you wouldn't care? You should hate some SQL, some of it is pure crap and needs to be rewritten. This is what we call 'junk code'. As a developer, your goal should be to write maintainable code. In short, if you have the choice between something that looks fancy and something that is legible and maintainable, choose the maintainability. Sorry, but if I ever saw that statement in a code review I would have made you rewrite it. Also, anything that runs differently on different databases should be avoided, its that simple. -
Does anyone have a list of all of the environment selections available from dual.
e.g. select user from dual;
Thanks in advance
BobHi 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 -
SELECT SESSIONTIMEZONE FROM DUAL;
Hi,
On 10g , I have :
SELECT SESSIONTIMEZONE FROM DUAL;
SESSIONTIMEZONE
+01:00
1 rows selectedWhich parameter should I change im my session to have :
SESSIONTIMEZONE
Europe/Paris
1 rows selectedIn documentation it is said :
SESSIONTIMEZONE returns the time zone of the current session. The return type is a time zone offset (a character type in the format '[+|]TZH:TZM') or a time zone region name, depending on how the user specified the session time zone value in the most recent ALTER SESSION statement.
Thank you.I want to know in which time zone my session is ? Just to know its name but not the offset which is a number. Just to have something like :
select sessiontimezone, current_date from dual;
SESSIONTIMEZONE CURRENT_DATE
Europe/Paris 10-JANV.-2012 14:12:14 Without any alter session before, because that will change the settings.
Regards. -
Select multiple values from the parameters in BI Publisher report Error
In the database, I wrote a function to retrieve data to report:
FUNCTION FN_TL002(cBDSID nvarchar2)
RETURN SYS_REFCURSOR as
TYPE t_cursor is REF CURSOR;
v_cursor t_cursor;
begin
OPEN v_cursor FOR
select Brach, txmonth, txdate, total from tl001
where brach in (cBDSID)
order by brach;
RETURN v_cursor;
end fn_tl002;
In Bi Publisher:
- I have a type parameter Option select multiple ( pBranch), LOV get data from database.
* In Data model : TL001 name
+ SQL query : select FN_TL002(:pBranch) from dual
if select a value not error, and then select two values of an error: ORA-06553: PLS-306: wrong number or types of arguments in call to 'FN_TL002'
please help me!
Thanks all!See my response in the thread Re: Multi selecting drop down in BI publisher 11g report
The LOV is a Java array and your function needs to accept that array. To do this the data data type has to be a VARRAY Type. -
ORA-00907 in a simple query from dual
Hi,
Anybody knows the reason for obtain ora-00907 when we enclose between parenthesis a SQL sentence whith an orderby clause?. Look at the last example:
--> SQL fine
select 'A' zz from dual order by 1;
(select 'A' zz from dual) order by 1;
select * from (select 'A' zz from dual order by 1);
--> ORA-00907 Why?
(select 'A' zz from dual order by 1);
Regards
Carlosyou don't need order by in inlinew view
if you want order by use
select * from (select 'A' zz from dual ) order by 1; -
What means ".... FROM DUAL" in SQL statements?
Occasionally I find in different SQL statement the appedix "....from dual" e.g.
SELECT blahblah FROM DUAL;
It seems to me that this is a special built-in table.
What does that mean exactely?
PeterI guess 'FROM' clause is mandatory in Oracle. Hence,
there must always be a table from which we are
selecting values. So, for selecting some arbitary
values which are not coming from any DB Table, we use
this dummy table 'Dual'.
Like
select substr('sometext',5) from dual;
select sysdate from dual ;
etc.
Hope this clarifies.This explanation might be misleading.
The FROM clause is of cause mandatory for a SELECT statement (I think any SQL DB system, not only Oracle). So whenever you need to write a SELECT you might need a dual table.
If you are in PL/SQL you can use most functions without doing a SELECT. Like
a:= substr('sometext',5);
myDate := sysdate;For some things we need to do a select. If we don't have a matching table, then the dual table is handy to return only one row.
example
SELECT mySequence.nextval FROM DUAL;When we are using some tools, like SQL*Plus or T.O.A.D. our typical path to get information returned to the gui is a select. This would be a case were your examples could be used. But you could also do it like this: execute dbms_output.put_line(to_char(sysdate)); After switching the serveroutput on.
Maybe you are looking for
-
Replication sales order from CRM to R/3?
Hi Gurus I need some advice. We are implementing CRM for a over client Over sale Cycle is LeadOpportunity- sales order- delivery billing Once sales order created in CRM we have to send that sales order to SAP R/3 Then delivery and Billing will d
-
Filter in the Dialog box for selection
I have report that contains a file selection dialog using the following code at selection-screen on value-request for p_file. perform f_get_file using cl_gui_frontend_services=>filetype_excel. form f_get_file using p_filetype type string. data: l
-
Retrieving content via CM tags
This is a newbie question, but I could not find the answer in any documentation, and I've been stuck on this for a while! In retrieving content using content management tags (WL8.1 SP5), do my JSPs have to be in the same WL application as the Portal
-
Framework Class CL_RSRD_PRODUCER_PRECALC type PROD delivers no document
Hi Im working in Query Designer and go to option Publish - BEx Broadcaster I create a new timing of an e-mail transmission with PDF, If I will carry out, then I get the message "framework Class CL_RSRD_PRODUCER_PRECALC type PROD delivers no document
-
Unable to license Office 365 ProPlus when customized at the application level
It has long been claimed that Office 365 ProPlus can only be installed as one single package, and that Click-to-Run is not customizable at the application level. Microsoft lists the following at http://technet.microsoft.com/en-us/library/jj839718.as