[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
Similar Messages
-
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 -- -
SELECT SYS_CONTEXT ('userenv', 'ip_address') FROM dual;
I am using the following query
SELECT SYS_CONTEXT ('userenv', 'ip_address') FROM DUAL:
and the retuned row is blank.
Any Idea why?SELECT SYS_CONTEXT ('userenv', 'ip_address') FROM dual
will return the IP address of the client of the current session. If the current session is connected to a local database (i.e. not using SQL*NET), then this query appears to return NULL.
SELECT SYS_CONTEXT ('userenv', 'host') FROM dual
will return the host name from which the client is connected, even if the client is connected locally.
If the host name is not sufficient, then I'm not sure what your other options are (perhaps writing a java stored procedure which returns the IP address of the database server? always connecting via SQL*Net?) -
hi master
sir i use this command for user ip address
SELECT sys_context('userenv', 'host'), sys_context('userenv', 'ip_address') FROM dual;
BUT
form6i give me this error
Error 201 at line 26, column 12
Identifier SYS_CONTEXT must be declared
please give me idea how i get ip_address in form
thankthank for your reply
sir my need is
i check user computer name if that computer in table then i update the user feeding ouer wise i insert that computer name as new and give the feeding form access to user
you see my code
SELECT sys_context('userenv','host'), sys_context('userenv', 'ip_address') INTO HOSTNAME,IPADD FROM dual;
SELECT COUNT(*) INTO USERCOUNT FRoM forclosingyear WHERE HOSTNAME=HOSTNAME AND IPADD=IPADD;
IF USERCOUNT>0 THEN
update forclosingyear SET YEARID=:SYID,datefrom=:ysdate,dateto=:yedate WHERE HOSTNAME=HOSTNAME AND IPADD=IPADD;
ELSIF USERCOUNT=0 THEN
INSERT INTO forclosingyear (YEARID,datefrom,dateto,HOSTNAME,IPADD) VALUES (:SYID,:ysdate,:yedate,HOSTNAME,IPADD);
END IF;
this is my need
please give me idea how i get termenal name or user computer name
thank
aamir -
F4_FILENAME - For selecting a local file from a Selection-Screen
This code in ERP will allow me to drill down to my local drive to select a file:
However, anybody know a similar Function Module in BW to do this?
F4_Filename does not exist, at least in our BW environment.
Thank-You.
PARAMETER: p_locat LIKE rlgrap-filename
DEFAULT '/interfaces_r3/inbound/archive/RGIS/RGISTOSAP.TXT.20061008'.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_locat.
PERFORM get_file USING p_locat.
form get_file using p_locat.
DATA: v_file LIKE ibipparms-path.
MOVE: p_locat TO v_file.
DATA: v_repid LIKE syst-repid,
v_dynnr LIKE syst-dynnr.
v_repid = syst-repid.
v_dynnr = syst-dynnr.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = v_repid
dynpro_number = v_dynnr
field_name = field
IMPORTING
file_name = v_file.
MOVE: v_file TO p_locat.Hopefully, the class is in BW.
report zrich_0001.
data: ifiletable type filetable.
data: xfiletable like line of ifiletable.
data: rc type i.
parameters: p_file1 type localfile default'C:test.txt'.
at selection-screen on value-request for p_file1.
call method cl_gui_frontend_services=>file_open_dialog
EXPORTING
* WINDOW_TITLE =
* DEFAULT_EXTENSION =
* DEFAULT_FILENAME =
* FILE_FILTER =
INITIAL_DIRECTORY = 'C:'
* MULTISELECTION =
changing
file_table = ifiletable
rc = rc
* USER_ACTION =
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
others = 4.
read table ifiletable into xfiletable index 1.
if sy-subrc = 0.
p_file1 = xfiletable-FILENAME.
endif.
Regards,
Rich Heilman -
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:50Hello
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 -
Getting returned XMLSERIALIZE information into an APEX variable...
((Application Express 4.1.1.00.23 11g)
So i have the following code:
with test_table as(
SELECT VM_REPORT_DATE,quantity,item from VM_CORE unpivot (
quantity fOR ITEM in (VM_HOSTS_NUM,VM_NUMBER,VM_PHYS_MEM,VM_VIRT_MEM,VM_CPU_COUNT,VM_TOTAL_DISK,VM_PROVISIONED_DISK)
) where VM_DCNAME='bc_production')
SELECT XMLSERIALIZE(CONTENT XMLELEMENT("SERIES",xmlAttributes(item as "name"),
XMLAGG(XMLElement("point",xmlAttributes(VM_REPORT_DATE as "name",quantity as "y")))
)) as THEDATA from test_table group by item;
Which successfully returns:
THEDATA
<SERIES name="VM_CPU_COUNT"><point name="2013-10-29" y="1312"></point><point name="2013-10-23" y="1308"></point></SERIES>
<SERIES name="VM_HOSTS_NUM"><point name="2013-10-29" y="20"></point><point name="2013-10-23" y="22"></point></SERIES>
<SERIES name="VM_NUMBER"><point name="2013-10-29" y="617"></point><point name="2013-10-23" y="616"></point></SERIES>
<SERIES name="VM_PHYS_MEM"><point name="2013-10-29" y="4727.59"></point><point name="2013-10-23" y="5175.54"></point></SERIES>
<SERIES name="VM_PROVISIONED_DISK"><point name="2013-10-29" y="76307.65"></point><point name="2013-10-23" y="75848.3"></point></SERIES>
<SERIES name="VM_TOTAL_DISK"><point name="2013-10-29" y="95955"></point><point name="2013-10-23" y="93793.75"></point></SERIES>
<SERIES name="VM_VIRT_MEM"><point name="2013-10-29" y="3751.98"></point><point name="2013-10-23" y="3739.98"></point></SERIES>
This is going to be the heart of needing to set an APEX variable to the above data with <DATA></DATA> tags added around it.
What I'm unsure how to do is return the above with a PLSQL variable of chart_series_data.
chart_series_data := '<data>'||chr(10);
chart_series_data := chart_series_data || "WHAT I RETURNED ABOVE";
chart_series_data := chart_series_data||chr(10)||'</data>';
Thanks
RobWhy not just doing it all in the query ?
with test_table as(
select vm_report_date, quantity,item
from vm_core
unpivot (
quantity for item in (vm_hosts_num, vm_number, vm_phys_mem, vm_virt_mem, vm_cpu_count, vm_total_disk, vm_provisioned_disk)
) where vm_dcname = 'bc_production'
select xmlserialize(document
xmlelement("DATA"
, xmlagg(
xmlelement("SERIES"
, xmlattributes(item as "name")
, xmlagg(
xmlelement("point"
, xmlattributes(
vm_report_date as "name"
, quantity as "y"
) as XMLDATA
from test_table
group by item ; -
How to create a tool pane for apps in SharePoint using SharePoint hosted app model 2013..I mean i m looking for something like webpart propeties to be given to the user for selecting desired content.Can someone provide help code for this functionality
Hi,
According to your description, when users select several items in a library and click a button, you want to get related data from these items/files and then perform
other operations.
Yes, the “Custom Action in Ribbon” solution would be a good choice for you cause what you need is only clicking a button after selected items in a list view page.
With JavaScript Client Object Model, we can get data of the selected items using JavaScript, then add the JavaScript code into the custom action to make it to be triggered
when clicking the button.
I would suggest you take a look at the two links below about how to work with custom ribbon button and JavaScript Client Object Model for a quick start:
https://patrickboom.wordpress.com/tag/client-object-model/
http://blogs.msdn.com/b/jfrost/archive/2009/11/08/how-to-display-a-sharepoint-dialog-from-ribbon-button-and-get-selected-item-context.aspx
Best regards
Patrick Liang
TechNet Community Support -
Converting single column content into rows
Hi All,
I have a table containing data in the following format
SNO Content
1 a,ab,aab,b,c
2 a,aac,aab,c,ccb,ee
3 bb,b,c
I have a requirement to convert this into following format
SNO Content
1 a
1 ab
1 aab
1 b
1 c
2 a
3 bb
3 b
3 c
How to acheive this in 10g? Is it possible in 9i?
Please share your thoughts.
Thanks in advance
Regards,
Subbu Stest@ORA92>
test@ORA92> @ver
BANNER
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
PL/SQL Release 9.2.0.1.0 - Production
CORE 9.2.0.1.0 Production
TNS for 32-bit Windows: Version 9.2.0.1.0 - Production
NLSRTL Version 9.2.0.1.0 - Production
5 rows selected.
test@ORA92>
test@ORA92> select * from t;
SNO CONTENT
1 a,ab,aab,b,c
2 a,aac,aab,c,ccb,ee
3 bb,b,c
3 rows selected.
test@ORA92>
test@ORA92> select sno,
2 rtrim(substr(lst,
3 instr(lst, ',', 1, iter.pos) + 1,
4 instr(lst, ',', 1, iter.pos + 1) - instr(lst, ',', 1, iter.pos)),
5 ',') content
6 from (select sno, ',' || content || ',' lst from t) csv,
7 (select rownum pos from all_objects) iter
8 where iter.pos <= ((length(csv.lst) - length(replace(csv.lst, ','))) / length(',')) - 1
9 order by sno;
SNO CONTENT
1 a
1 ab
1 aab
1 c
1 b
2 a
2 aab
2 ee
2 ccb
2 c
2 aac
3 bb
3 c
3 b
14 rows selected.
test@ORA92>
test@ORA92>Haven't tried this with a large number of rows, but I suspect it would be slow in that case. Regular expressions should make this simpler and more efficient in 10g.
Cheers,
pratz -
Error when we tried to increase limits for Property of type string
hi,
Actually initially we were getting error when we were trying to add content for property of type string of character length greater than 255.
After that we increase size for that property in pointbase from 250 to 1000 and that works.
But when we tried to increase limit from 1000 to 4000,it was taking only limit upto 1300.
Response needed urgentlyCases can be
1. file name should be in caps (upper case lower case conversion
2. when executing in bg variant not picked
3. collision of file path across servers in a system
In a system there will be servers like in Quality it can have varying servers ex sapqp1 sapqp2 sapqp3
In here qp1 qp2 and qp3 are the servers in quality which can hold the unix data (al11) . If qp2 is directed in your check and if qp2 dosent have the file path it throws error. recently we have faced a similar issue . Problem was solved when basis guys made the setting across all server's to access the path.
Try these options.
Br,
vijay. -
Query for select CLOB data field
Hi All,
I want to know how to write a SQL query for select CLOB tyoe data from a tablw. when I am trying to use the simple SQL it gives an messageLOB types requires OCI8 mode and currently uasing OCI7 ode.
Also I am not aware of oci mode?
If its working for OCI8 mode how I should changer it in to OCI8 mode? (I am using 10g rel 2)
Thans and regards
BuddhikeHi ,
i don't want to use loop (sy-tabix) ..
any particular reason for this ?
as u cannot automatically generate serial number, u have to go for loop....endloop.
Thanks
Karthik -
Best
practice to remove content databases from SharePoint 2007 without any Farm
impact <o:p></o:p>Hi ,
For removing a content database from a Web application, you can take steps as below:
1.On the Manage Content Databases page, click the content database that you want to remove.
2.On the Manage Content Database Settings page, in the Remove Content Database section, select the Remove content database check box.
If any sites are currently using this database, a message box appears. Click OK to indicate that you want to proceed with the removal.
3.Click OK.
Reference:
http://technet.microsoft.com/en-us/library/cc262440(v=office.12).aspx
Best Regards,
Eric
Eric Tao
TechNet Community Support -
Query Issue with select level from dual
Hi,
I have a question regarding this query. The problem seems that when selecting level from dual while including another table the rows returned seem to increase exponentially.
I can add distinct and get the correct number of rows but am worried that this will cause a possible performance issue. Am I using the level option wrong?
I have included details below.
There are 4 rows in tbl_incidents
When I run the following queries I get rows returned based on the total number of rows
select start_date + level - 1, tbl_incidents.incident_id, level
from dual, tbl_incidents
where incident_id = 6
connect by level <= 1;
returns 1 row
select start_date + level - 1, tbl_incidents.incident_id, level
from dual, tbl_incidents
where incident_id = 6
connect by level <= 2;
returns 5 rows
select start_date + level - 1, tbl_incidents.incident_id, level
from dual, tbl_incidents
connect by level <= 3 and incident_id = 6;
returns 21 rows
select start_date + level - 1, tbl_incidents.incident_id, level
from dual, tbl_incidents
connect by level <= 4 and incident_id = 6;
returns 85 rows
select start_date + level - 1, tbl_incidents.incident_id, level
from dual, tbl_incidents
connect by level <= 5 and incident_id = 6;
returns 341 rows
So with
r being the number of rows in tbl_incidents and
l being the number used in the connect by for level and
q being the number of rows returned by the query
it appears that
q(l) = r * q(l-1) + 1
level 2: 4 * 1 + 1 = 5
level 3: 4 * 5 + 1 = 21
level 4: 4 * 21 + 1 = 85
level 5: 4 * 85 + 1 = 341
Thanks much,
NoraHi,
The dual table is used when you want to do something in SQL when you are not otherwise using a table.
Generating a "counter table" of the integers 1, 2, 3,..., X is an example
SELECT LEVEL AS n
FROM dual
WHERE LEVEL <= x;There is never any point in joining dual to another table, as in
select start_date + level - 1
, tbl_incidents.incident_id
, level
from dual
, tbl_incidents
where incident_id = 6
connect by level <= x;You will always get the same more easily by just eliminating dual:
select start_date + level - 1
, incident_id
, level
from tbl_incidents
where incident_id = 6
connect by level <= x;It is quite useful and common to join a counter-table to a real table, like this cross-join:
WITH counter_table AS
SELECT LEVEL AS n
FROM dual
WHERE LEVEL <= x
select start_date + n - 1
, incident_id
, n
from tbl_incidents
, counter_table
where incident_id = 6 -
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 -
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.
Maybe you are looking for
-
Need to fix the width of a column in interactive report
Hi, I have a column named 'Comment'. Its have a huge data due to which the lenght of that column in interactive report get increased. I need to fix the length to a desired value. I used following code in Region Footer: <style> table.apexir_WORKSHEET_
-
EM - Delete Existing Tracking ID and add New Tracking ID
Hello Everyone I am working on u201CDual Tracking IDu201D issue for EM Project. Issue: Current design, when Users change Tracking ID (Inbound Delivery Bill of Lading #), In Event Management, we have both Old and New Tracking ID (YTRACK_NO). Solution:
-
More "out of memory" problems FCE2
Hi, Last week I was experiencing "dropped frame" error messages on FCE2. As suggested by Ian R., I printed my project onto video and my "dropped frame" problem immediately went away. But then it came back. Now, along with the "dropped frame" messages
-
ICloud Control Panel will not install! What do I need to do?
I have tried running the installer but it fails with the following error message: "Could not update the ini file C:\Windows\system32\mapisvc.inf." What is going wrong & what do I need to do to install iCloud Control Panel? N.B. I am using a laptop wi
-
Corrupted zip file of download pkg
I've tried downloading App server 7 (Platform edition) several times and from several download locations but each time I get corrupted zip file and can't open it. BTW, other stuff (Application framework, Studio 4, etc) is downloaded correctly. I'm us