Procedure with recursive query working in 11g compiles with error in 10g
Hi, All,
I have a procedure that recursively selects tree-like table (with ID-ParentID relationship). Query itself works perfectly and exactly like I need in 11g and procedure containing it compiles well. But when I try to create the same procedure in 10g then I get a message that procedure compiled with error. I have no other suspicions but on the WITH part of the procedure.
The exact query is here (destination_tariff_zones is the tree-like table which refers to itself by parent_destination_tariff_zone_id):
+ open dtzl_cur FOR
with dtree (nm, iid, alevel, wldcard, dtzindex)
as (select dtz.iname, dtz.iid, 0, dtz.wildcard, rcdi.iindex
from destination_tariff_zones dtz, rating_cube_dimension_indices rcdi, rating_cube_dimensions rcd
where dtz.parent_tariff_zone_id is null and
dtz."rc_dimension_index_id" = rcdi.iid and
rcdi."rc_dimension_id" = rcd.iid and
rcd.rating_cube_id = rc_id and
rcd.dimension_type_id = dim_type
union all
select dtz.iname, dtz.iid, dtree.alevel + 1,
cast ((dtree.wldcard || dtz.wildcard) as varchar2(20)), rcdi.iindex
from dtree, destination_tariff_zones dtz, rating_cube_dimension_indices rcdi, rating_cube_dimensions rcd
where dtree.iid = dtz.parent_tariff_zone_id and
dtz."rc_dimension_index_id" = rcdi.iid and
rcdi."rc_dimension_id" = rcd.iid and
rcd.rating_cube_id = rc_id and
rcd.dimension_type_id = dim_type)
select iid, nm, wldcard, dtzindex
from dtree
order by wldcard;+
Is there any difference between how 11g and 10g handle WITH statements?
Please advise.
Thank you very much in advance,
Max
Max Afanasiev wrote:
then is there any alternative to implement what I need?You can look at using CONNECT BY to emulate a recursive query. If you can post the following we may be able to help:
1. Sample data in the form of CREATE / INSERT statements.
2. Expected output
3. Explanation of expected output (A.K.A. "business logic")
4. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.
Similar Messages
-
Define a trigger in procedure with error
I have oracle database 11gR2 and i want to create some triggers automatically with a block . when i want to run query in below , i have an error .
My block is :
declare
tablesid number ;
tablenames varchar2(4000);
cursor c1 is
select id , title from hr.tables;
begin
open c1;
loop
fetch c1 into tablesid , tablenames;
CREATE OR REPLACE TRIGGER tablenames||'_before_insert'
before insert
on hr.tablenames
DECLARE
columnid number ;
columnval number ;
columntitle varchar(4000);
cursor c2 is
select id from hr.columns where tableid = tablesid ;
BEGIN
-- open c2 ;
for rec in c2 loop
select title into columntitle from hr.columns where id = rec.id
insert into hr.rowaction(columnid,newvalue,oldvalue,actiondate)
select id ,:new.columntitle,:old.columntitle,sysdate
from hr.tabletiltes
where id = rec.id
select title into columntitle from hr.columns where id = rec.id;
dbms_output.put_line(columntitle);
end loop;
end;
end loop ;close c1; end;
>ORA-06550: line 11, column 6:
PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:
( begin case declare end exit for goto if loop mod null
pragma raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
continue close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe purge
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action :
Bind Variable "new" is NOT DECLARED
anonymous block completed
Bind Variable "new" is NOT DECLARED
anonymous block completed
ThanksThis is a duplicate post of your other question: create trigger automatic
DO NOT start duplicate threads for the same question.
Locking this thread -
Problem with libraries forms 10G
Hi,
I work in a company that bought a system done in Oracle. Actually we're using forms and reports 6i, but we are going to migrate to the Forns/reports 10g .
We already have the archives of the new version, the problem is that we must turn our own products to the new version but putting new libraries, and when treatment to compile them, these do not work. The compiler sends errors like
Error PL/SQL 201 identifier
'GORDMSK.GORDMSK_DISPLAY_IND' must be declared
I do not understand why, because this libraries was provided by the company that developed the system.
Our forms already have been turned through the Oracle migration assistant, the problem are the libraries.
somebody can help me?I'm confused. Is what your saying is that you took the libraries (10g) from the bought system and attached them to your application (6i)?
-
DG4ODBC MSSQL query works in sql, but won't compile in PL/SQL.
I'm using DG4ODBC from 11g to query a SQL Server database. The query I'm using works in a SQL DEveloper SQL worksheet and sqlplus, but won't compile in a PL/SQL procedure.
The query is
INSERT
INTO crm_labels
accountid,
label_name,
cir_labelcode,
cir_knownasname,
cir_countryidname,
parentaccountidname,
cir_customertypecode1,
cir_customertypecode2,
cir_dealstatus
SELECT "AccountId",
REPLACE("Name",chr(0)) label_name,
REPLACE("Cir_labelcode",chr(0)) ,
REPLACE("Cir_knownasname",chr(0)),
REPLACE("cir_countryidName",chr(0)),
REPLACE("ParentAccountIdName",chr(0)),
"Cir_customertypecode1",
"Cir_customertypecode2",
"Cir_dealstatus"
FROM "dbo"."Account"@crmsvc
WHERE "Cir_labelcode" IS NOT NULL;The error message is
Error(1): ORA-04052: error occurred when looking up remote object dbo.Account@CRMSVC ORA-01948: identifier's name length (34) exceeds maximum (30)I'm guessing that it is attempting to describe additional columns in the Account table.
If I remove the dbo,
FROM "Account"@crmsvcI get
Error(1): ORA-04052: error occurred when looking up remote object PUBLIC.Account@CRMSVC ORA-00604: error occurred at recursive SQL level 1 ORA-28500: connection from ORACLE to a non-Oracle system returned this message: [Microsoft][ODBC SQL Server Driver][SQL Serve which is less than helpful. However, if I try to use the same query to create a materialized view, I get.
SQL Error: ORA-04052: error occurred when looking up remote object PUBLIC.Account@CRMSVC
ORA-00604: error occurred at recursive SQL level 1
ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'Address1_TimeZoneRuleVersionNu'. {42S22,NativeErr = 207}[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'Address1_UTCConversionTimeZone'. {42S22,NativeErr = 207}[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'Address2_TimeZoneRuleVersionNu'. {42S22,NativeErr = 207}[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'Address2_UTCConversionTimeZone'. {42S22,NativeErr = 207}[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'Pias_NewLabelInDealNotificatio'. {42S22,NativeErr = 207}
ORA-02063: preceding 2 lines from CRMSVCwhich seems to confim that in some circumstance, oracle will attempt to parse more than was asked for.
Any work arounds?
BANNER
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 64-bit Windows: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
DG4ODBC is also 11.2.0.3The gateway claims about this column "Address1_TimeZoneRuleVersionNu" which is not listed in your select list.
When a gateway connection is established it first checks out all columns of the table you want to select to determine the data types and then it fetches the data for the columns you want to select. But there's also an exception - when you use functions the gateway is not able to translate into the syntax of the foreign database. in this case ALL columns will be fetched into the Oracle database and the result is processed locally (post processing).
You're using replace function which won't be mapped to the foreign database equivalent using DG4ODBC so it will post process the result and fetch from all columns all the data into the Oracle database. Your table contains a column which exceeds the 30 character limitation of Oracle, hence the select will fail.
The only work around is to create a view on the foreign database side which reduces the column name length to 30 characters or less. -
Running a SQL Stored Procedure from Power Query with Dynamic Parameters
Hi,
I want to execute a stored procedure from Power Query with dynamic parameters.
In normal process, query will look like below in Power Query. Here the value 'Dileep' is passed as a parameter value to SP.
Source = Sql.Database("ABC-PC", "SAMPLEDB", [Query="EXEC DBO.spGetData 'Dileep'"]
Now I want to pass the value dynamically taking from excel sheet. I can get the required excel cell value in a variable but unable to pass it to query.
Name_Parameter = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
Name_Value = Name_Parameter{0}[Value],
I have tried like below but it is not working.
Source = Sql.Database("ABC-PC", "SAMPLEDB", [Query="EXEC DBO.spGetData Name_Value"]
Can anyone please help me with this issue.
Thanks
DileepHi,
I got it. Below is the correct syntax.
Source = Sql.Database("ABC-PC", "SAMPLEDB", [Query="EXEC DBO.spGetData '" & Name_Value & "'"]
Thanks
Dileep -
Calling a Stored Procedure with output parameters from Query Templates
This is same problem which Shalaka Khandekar logged earlier. This new thread gives the complete description about our problem. Please go through this problem and suggest us a feasible solution.
We encountered a problem while calling a stored procedure from MII Query Template as follows-
1. Stored Procedure is defined in a package. Procedure takes the below inputs and outputs.
a) Input1 - CLOB
b) Input2 - CLOB
c) Input3 - CLOB
d) Output1 - CLOB
e) Output2 - CLOB
f) Output3 - Varchar2
2. There are two ways to get the output back.
a) Using a Stored Procedure by declaring necessary OUT parameters.
b) Using a Function which returns a single value.
3. Consider we are using method 2-a. To call a Stored Procedure with OUT parameters from the Query Template we need to declare variables of
corresponding types and pass them to the Stored Procedure along with the necessary input parameters.
4. This method is not a solution to get output because we cannot declare variables of some type(CLOB, Varchar2) in Query Template.
5. Even though we are successful (step 4) in declaring the OUT variables in Query Template and passed it successfully to the procedure, but our procedure contains outputs which are of type CLOB. It means we are going to get data which is more than VARCHAR2 length which query template cannot return(Limit is 32767
characters)
6. So the method 2-a is ruled out.
7. Now consider method 2-b. Function returns only one value, but we have 3 different OUT values. Assume that we have appended them using a separator. This value is going to be more than 32767 characters which is again a problem with the query template(refer to point 5). So option 2-b is also ruled out.
Apart from above mentioned methods there is a work around. It is to create a temporary table in the database with above 3 OUT parameters along with a session specific column. We insert the output which we got from the procedure to the temporary table and use it further. As soon the usage of the data is completed we delete the current session specific data. So indirectly we call the table as a Session Table. This solution increases unnecessary load on the database.
Thanks in Advance.
RajeshRajesh,
please check if this following proposal could serve you.
Define the Query with mode FixedQueryWithOutput. In the package define a ref cursor as IN OUT parameter. To get your 3 values back, open the cursor in your procedure like "Select val1, val2, val3 from dual". Then the values should get into your query.
Here is an example how this could be defined.
Package:
type return_cur IS ref CURSOR;
Procedure:
PROCEDURE myProc(myReturnCur IN OUT return_cur) ...
OPEN myReturnCur FOR SELECT val1, val2, val3 FROM dual;
Query:
DECLARE
MYRETURNCUR myPackage.return_cur;
BEGIN
myPackage.myProc(
MYRETURNCUR => ?
END;
Good luck.
Michael -
Problem Calling MaxDB stored procedure with output from MII Query template
Hi,
I am using Max DB Database studio to write stored procedure, I am calling stored procedure from MII Query using CALL statement.
Can anyone guide me how to pass output values of stored procedure.
Examlpe::
call ProcName('[Param.1]','[Param.2]','[Param.3]','[Param.4]','[Param.5]', :isSuccess, :Trace)
In the above line of code I am not able to get the output values of stored procedure that is isSuccess and Trace values in Query template when executed. But same thing I get when executed in Database studio.
How do I call with outputs for any stored procedure in MII.
Any help would be appriciated.
Thanks,
PadmaMy call statement is like this
call RESULTDATA_INSERT('[Param.1]','[Param.2]','[Param.3]', :isSuccess, :Trace)
I am able to insert record in DB, But I am not getting output values in Query template.I have done this in Fixed Query, when I execute it throws me "Fatal error as Loaded content empty".
I tried giving select below call but it dont work.
Regards,
Rao -
Need some help with a bottom up recursive query
I need to query some hierarchical data. I've written a recursive query that allows me to examine a parent and all it's related children using an adjacency data model. The scenario is to allow users to track how columns are populated in an ETL process. I've
set up the sample data so that there are two paths:
1. col1 -> col2 -> col3 -> col6
2. col4 - > col5
You can input a column name and get everything from that point downstream. The problem is, you need to be able to start at the bottom and work your way up. Basically, you should be able to put in col6 and see how the data got from col1 to col6. I'm not sure
if it's a matter of rewriting the query or changing the schema to invert the relationships. Any input is welcome. Sample code below.
DECLARE @table_loads TABLE (column_id INT, parent_id INT, table_name VARCHAR(25), column_name VARCHAR(25))
DECLARE @column_name VARCHAR(10)
INSERT INTO @table_loads(column_id, parent_id, table_name, column_name)
SELECT 1,NULL,'table1','col1'
UNION ALL
SELECT 2,1,'table2','col2'
UNION ALL
SELECT 3,2,'table3','col3'
UNION ALL
SELECT 4,NULL,'table4','col4'
UNION ALL
SELECT 5,4,'table5','col5'
UNION ALL
SELECT 6,3,'table6','col6'
SELECT * FROM @table_loads
SET @column_name = 'col1'
WITH load_order(column_id, parent_id,table_name, column_name)
AS(
SELECT column_id, parent_id,table_name, column_name
FROM @table_loads
WHERE column_name = @column_name
UNION ALL
SELECT tl.column_id, tl.parent_id, tl.table_name, tl.column_name
FROM load_order lo
JOIN @table_loads tl
ON lo.column_id = tl.parent_id
SELECT * FROM load_orderGot it. It required a VERY subtle change in the join code:
WITH load_order(column_id, parent_id,table_name, column_name)
AS(
SELECT column_id, parent_id,table_name, column_name
FROM @table_loads
WHERE column_name = @column_name
UNION ALL
SELECT tl.column_id, tl.parent_id, tl.table_name, tl.column_name
FROM @table_loads tl
JOIN load_order lo
ON lo.parent_id = tl.column_id
SELECT * FROM load_order -
Compiles a procedure with syntax error
In the script tab, try to compile a procedure with syntax errors.
The message displays procedure compiled !!!
It should display that procedure compiled with errors.Hi Kris,
I searched through the threads, but did not come across a similar question and that is why i raised the query. It'll be helpful if you could answer the query.
regards, -
Using "with as select" to do a recursive query
Hello dear all
I have a question about "with as select" structure.
Is it possible to do a recursive query with this structure?
for example for this table ( river: name,river,lake,sea) i wrote this query to get all of the rivers flowing directly or indirectly in a specific river:
select name from RIVER r
start with r.river='Zaire'
connect by prior r.name=r.river
order by level
now how i can write the same function with "with as select"?
im using oracle 11g.
if you need ,i'll provide create/insert for the table.
best,davidset linesize 132
column Name format a20
column River format a20
column Lake format a20
column Sea format a20
WITH StartWith(
Name,
River,
Lake,
Sea,
Length,
LevelNum
) AS (
SELECT Name,
River,
Lake,
Sea,
Length,
1 LevelNum
FROM RIVER
WHERE River IS NULL
UNION ALL
SELECT r.Name,
r.River,
r.Lake,
r.Sea,
r.Length,
s.LevelNum + 1 LevelNum
FROM RIVER r
INNER JOIN
StartWith s
ON s.Name = r.River
SEARCH DEPTH FIRST BY Name SET NameOrder
SELECT lpad(' ',LevelNum - 1) || Name Name,
River,
Lake,
Sea,
Length
FROM StartWith
ORDER BY NameOrder
NAME RIVER LAKE SEA LENGTH
Amazonas Atlantic Ocean 6518
Amudarja Ozero Aral 1415
Pjandsh Amudarja 1125
Amur Arctic Ocean 2918
Argun Amur 1620
Schilka Amur 560
Ingoda Schilka 708
Onon Schilka 1032
Chatanga Arctic Ocean 1636
Colorado Pacific Ocean 2700
Columbia River Pacific Ocean 1952
NAME RIVER LAKE SEA LENGTH
Connecticut River Atlantic Ocean 660
Cuanza Atlantic Ocean
Cunene Atlantic Ocean
Dalaelv Baltic Sea 520
Oesterdalaelv Dalaelv
Vaesterdalaelv Dalaelv
Djuba Indian Ocean
Dnepr Black Sea 2201
Don Sea of Azov 1870
Donau Black Sea 2850
Drin Mediterranean Sea
NAME RIVER LAKE SEA LENGTH
Black Drin Drin 133
White Drin Drin
Elbe North Sea 1144
Moldau Elbe 435
Gambia Atlantic Ocean
Garonne Atlantic Ocean 650
Gloma North Sea 598
Goetaaelv North Sea 93
Han Yellow Sea
Hudson River Atlantic Ocean 493
Hwangho Yellow Sea
NAME RIVER LAKE SEA LENGTH
Jangtse-Kiang East China Sea 6100
Jenissej Arctic Ocean 4130
Grosser Jenissej Jenissej 605
Kleiner Jenissej Jenissej 680
Joekulsa a Fjoellum Norwegian Sea 206
Karun Persian Gulf 890
Kemijoki Baltic Sea 520
Ounasjoki Kemijoki
Kitakami Pacific Ocean
Klaraelv Vaenern 347
Kokemaeenjoki Baltic Sea 169
NAME RIVER LAKE SEA LENGTH
Kolyma Arctic Ocean 2513
Kura Caspian Sea 1364
Lena Arctic Ocean 4400
Limpopo Indian Ocean
Loire Atlantic Ocean 1010
Mekong South China Sea 4500
Mississippi Gulf of Mexico 3750
Arkansas Mississippi 2334
Missouri Mississippi 3726
Neva Baltic Sea 74
Niger Atlantic Ocean
NAME RIVER LAKE SEA LENGTH
Bani Niger
Benue Niger
Nile Mediterranean Sea
Atbara Nile
Blue Nile Nile
White Nile Nile
Bahr el-Djebel White Nile
Bahr el-Gasal White Nile
Sobat White Nile
Baro Sobat
Pibor Sobat
NAME RIVER LAKE SEA LENGTH
Northern Dwina Arctic Ocean 740
Jug Northern Dwina 574
Suchona Northern Dwina 562
Ob Arctic Ocean 3680
Bija Ob 688
Irtysch Ob 4248
Black Irtysch Irtysch 672
Ischim Irtysch 2450
Katun Ob 306
Tobol Ob 1591
Oranje Atlantic Ocean
NAME RIVER LAKE SEA LENGTH
Vaal Oranje
Orinoco Atlantic Ocean 2736
Oulujoki Baltic Sea
Petschora Arctic Ocean 1809
Rhein Bodensee North Sea 1320
Rhone Mediterranean Sea 812
Rio Balsas Atlantic Ocean 770
Rio Grande Gulf of Mexico 3030
Rio de la Plata Atlantic Ocean 300
Parana Rio de la Plata 4700
Paraguay Parana 2200
NAME RIVER LAKE SEA LENGTH
Uruguay Rio de la Plata 1650
Rufiji Indian Ocean
Ruvuma Indian Ocean
Sanaga Atlantic Ocean
Save Indian Ocean
Schari Tschadsee
Seine North Sea 776
Senegal Atlantic Ocean
St. Lorenzstrom Atlantic Ocean 1170
Syrdarja Ozero Aral 2212
Tana Indian Ocean
NAME RIVER LAKE SEA LENGTH
Thames North Sea 346
Thjorsa Atlantic Ocean 230
Torneaelv Baltic Sea 375
Umeaelv Baltic Sea
Ural Caspian Sea 2428
Volga Caspian Sea 3531
Oka Volga 1480
Volta Atlantic Ocean
Webi Schebeli Indian Ocean
Weichsel Baltic Sea 1068
Weser North Sea 477
NAME RIVER LAKE SEA LENGTH
Fulda Weser 218
Werra Weser 292
Western Dwina Baltic Sea 1020
Zaire Atlantic Ocean 4320
Kwa Zaire 100
Casai Kwa 1570
Cuango Kwa 1230
Cuilo Kwa 970
Lomami Zaire 1600
Lukuga Zaire 230
Luvua Zaire 210
NAME RIVER LAKE SEA LENGTH
Ruki Zaire 730
Busira Ruki 830
Tshuapa Busira 1300
Sanga Zaire 530
Ubangi Zaire 2300
Bomu Ubangi 280
Uelle Ubangi 560
Zambezi Indian Ocean
Chire Zambezi
Kafue Zambezi
Luangwa Zambezi
132 rows selected.
SQL>SY. -
Cursor query works in anonymous block but not in procedure
Hello,
My cursor query works fine in anonymous blcok but fails in pl/sql block.
Anonymous block:
declare
cursor c1 is
select object_name
from all_objects
where owner='IRIS_DATA'
and object_type='SEQUENCE';
v_string varchar2(2000);
begin
for c2 in c1 loop
v_string := 'DROP SEQUENCE IRIS_DATA.'||c2.object_name;
execute immediate v_string;
end loop;
commit;
exception
when others then
dbms_output.put_line('Exception :'||sqlerrm);
end;
works fine.
but inside the procedure the it doesn't go inside the cursor loop
procedure get_sequence is
l_dp_handle NUMBER;
v_job_state varchar2(4000);
l_last_job_state VARCHAR2(30) := 'UNDEFINED';
l_job_state VARCHAR2(30) := 'UNDEFINED';
l_sts KU$_STATUS;
v_logs ku$_LogEntry;
v_row PLS_INTEGER;
v_string1 varchar2(2000);
cursor seq_obj is
select object_name
from all_objects
where owner='IRIS_DATA'
and object_type='SEQUENCE';
begin
log_status('get_sequence started.');
--Cursor records to drop the sequences before importing.
for seq_obj_rec in seq_obj loop
log_status('get_sequence: Dropping sequence started.');
v_string1 := 'DROP SEQUENCE IRIS_DATA.'||seq_obj_rec.object_name;
execute immediate v_string1;
end loop;
log_status('get_sequence: Dropping sequence completed.');
exception
WHEN OTHERS THEN
log_status('get_sequence: exception.');
end get_sequence;
it's not going into the seq_obj_rec cursor.
I granted select on all_objects to the user.this user is also having the DBA role as well.
Please advice.PROCEDURE Get_sequence
IS
l_dp_handle NUMBER;
v_job_state VARCHAR2(4000);
l_last_job_state VARCHAR2(30) := 'UNDEFINED';
l_job_state VARCHAR2(30) := 'UNDEFINED';
l_sts KU$_STATUS;
v_logs KU$_LOGENTRY;
v_row PLS_INTEGER;
v_string1 VARCHAR2(2000);
CURSOR seq_obj IS
SELECT object_name
FROM all_objects
WHERE owner = 'IRIS_DATA'
AND object_type = 'SEQUENCE';
BEGIN
Log_status('get_sequence started.');
--Cursor records to drop the sequences before importing.
FOR seq_obj_rec IN seq_obj LOOP
Log_status('get_sequence: Dropping sequence started.');
v_string1 := 'DROP SEQUENCE IRIS_DATA.'
||seq_obj_rec.object_name;
EXECUTE IMMEDIATE v_string1;
END LOOP;
Log_status('get_sequence: Dropping sequence completed.');
EXCEPTION
WHEN OTHERS THEN
Log_status('get_sequence: exception.');
END get_sequence; How do I ask a question on the forums?
SQL and PL/SQL FAQ
scroll down to #9 & use tags in the future. -
A In-line view query works with 8.1.6 but returns ORA-1008 with 8.1.7
Hello Gurus,
The following query works fine with 8.1.6 but returns
ORA-1008: not all variables bound
with 8.1.7.
Here is the query:
SELECT y.node_id , y.parent_node_id
FROM ( SELECT x.node_id
,x.parent_node_id
FROM ( SELECT a.node_id
,a.parent_node_id
FROM xor_hs_base_details a
WHERE a.node_id <>
a.parent_node_id
AND a.base_id=1
) x
CONNECT BY PRIOR x.node_id =
x.parent_node_id
START WITH x.parent_node_id = 1
) y
WHERE y.node_id IN ( SELECT node_id
FROM xor_hs_transactions
WHERE hierarchy_id = 1
AND created_by
= 'system'
AND committed_on IS NULL
Any ideas??
TIA.
...AtulAfter having a closer look at metalink it seems to be obvious, that Forms 6i (8.0.6.) only supports user exits generated with the 8.0.6. precompiler.
If this is the case new questions follow:
Is there a way to get a 8.0.6. precompiler?
Is it possible to connect to a 8.1.5. database with such a user exit? Does anybody have corresponding experiences?
Our customer uses a 8.1.7. database. What about connecting to that database with the user exit?
/Ralph -
Is it possible to working in Java Stored Procedures with OCI driver?
Hello ALL.
Could you help me...
Is it possible to working in Java Stored Procedures with OCI driver?
I want to try to do some workaround...
I need to work with following parametrs from Java Stored Procedures:
DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
String url = null;
url = "jdbc:oracle:oci:@TEST";
conn = DriverManager.getConnection (url,"scott","tiger");
Is it possible?
I tried but I have errors...
Please, help me!
ThanksYou cannot call OCI functions directly from PL/SQL. You could, of course, write an external procedure that made OCI calls, though you could also write an external procedure in Java. I'm guessing the documentation is trying to convey this same information-- you would need an external procedure that used OCI if you wanted to use the old-school interfaces for LONG and LOB data types. If you converted to using LOBs rather than LONGs, you could do everything in PL/SQL.
Justin -
Procedure with variable number of columns
Hi, I have a procedure that looks like this:
PROCEDURE PROC(p_cursor OUT sys_refcursor)
And in the procedure, I build up QUERY dynamically and the number of columns varies at runtime.
At the end I do
OPEN p_cursor for QUERY
Then to call this, I'm doing
call PROC(?)
My question is, how would I go about running the query from this procedure, then adding rows or modifying the existing results, then returning the modified data?
What I want to do is add a new row based on some condition, so I still need to return a variable number of columns, but I need to modify the results before I return them.
Is there any way of doing this? I need to do some calculations on the columns (the variable columns), create a new row, insert into result set, and return this new result set.A sys_refcursor is ideally suited to pass back to a front end gui like .NET or Java which can then use that cursor to retrieve the data.
In PL/SQL there is no point in using a sys_refcursor unless you know, at design/compile time what the returned columns are going to be.
If the resultant columns are dynamic, then you have no choice but to use the DBMS_SQL package, where you can parse and execute any SQL statement you like and then use the DBMS_SQL package to describe what the resultant columns are and how many there are. From that you can reference the columns by position rather than by name.
e.g.
CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2) IS
v_v_val VARCHAR2(4000);
v_n_val NUMBER;
v_d_val DATE;
v_ret NUMBER;
c NUMBER;
d NUMBER;
col_cnt INTEGER;
f BOOLEAN;
rec_tab DBMS_SQL.DESC_TAB;
col_num NUMBER;
v_rowcount NUMBER := 0;
BEGIN
-- create a cursor
c := DBMS_SQL.OPEN_CURSOR;
-- parse the SQL statement into the cursor
DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
-- execute the cursor
d := DBMS_SQL.EXECUTE(c);
-- Describe the columns returned by the SQL statement
DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
-- Bind local return variables to the various columns based on their types
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000); -- Varchar2
WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val); -- Number
WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val); -- Date
ELSE
DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000); -- Any other type return as varchar2
END CASE;
END LOOP;
-- Display what columns are being returned...
DBMS_OUTPUT.PUT_LINE('-- Columns --');
FOR j in 1..col_cnt
LOOP
DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' - '||case rec_tab(j).col_type when 1 then 'VARCHAR2'
when 2 then 'NUMBER'
when 12 then 'DATE'
else 'Other' end);
END LOOP;
DBMS_OUTPUT.PUT_LINE('-------------');
-- This part outputs the DATA
LOOP
-- Fetch a row of data through the cursor
v_ret := DBMS_SQL.FETCH_ROWS(c);
-- Exit when no more rows
EXIT WHEN v_ret = 0;
v_rowcount := v_rowcount + 1;
DBMS_OUTPUT.PUT_LINE('Row: '||v_rowcount);
DBMS_OUTPUT.PUT_LINE('--------------');
-- Fetch the value of each column from the row
FOR j in 1..col_cnt
LOOP
-- Fetch each column into the correct data type based on the description of the column
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_v_val);
WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_n_val);
WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'));
ELSE
DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_v_val);
END CASE;
END LOOP;
DBMS_OUTPUT.PUT_LINE('--------------');
END LOOP;
-- Close the cursor now we have finished with it
DBMS_SQL.CLOSE_CURSOR(c);
END;
SQL> exec run_query('select empno, ename, deptno, sal from emp where deptno = 10');
-- Columns --
EMPNO - NUMBER
ENAME - VARCHAR2
DEPTNO - NUMBER
SAL - NUMBER
Row: 1
EMPNO : 7782
ENAME : CLARK
DEPTNO : 10
SAL : 2450
Row: 2
EMPNO : 7839
ENAME : KING
DEPTNO : 10
SAL : 5000
Row: 3
EMPNO : 7934
ENAME : MILLER
DEPTNO : 10
SAL : 1300
PL/SQL procedure successfully completed.
SQL> exec run_query('select * from emp where deptno = 10');
-- Columns --
EMPNO - NUMBER
ENAME - VARCHAR2
JOB - VARCHAR2
MGR - NUMBER
HIREDATE - DATE
SAL - NUMBER
COMM - NUMBER
DEPTNO - NUMBER
Row: 1
EMPNO : 7782
ENAME : CLARK
JOB : MANAGER
MGR : 7839
HIREDATE : 09/06/1981 00:00:00
SAL : 2450
COMM :
DEPTNO : 10
Row: 2
EMPNO : 7839
ENAME : KING
JOB : PRESIDENT
MGR :
HIREDATE : 17/11/1981 00:00:00
SAL : 5000
COMM :
DEPTNO : 10
Row: 3
EMPNO : 7934
ENAME : MILLER
JOB : CLERK
MGR : 7782
HIREDATE : 23/01/1982 00:00:00
SAL : 1300
COMM :
DEPTNO : 10
PL/SQL procedure successfully completed.
SQL> exec run_query('select * from dept where deptno = 10');
-- Columns --
DEPTNO - NUMBER
DNAME - VARCHAR2
LOC - VARCHAR2
Row: 1
DEPTNO : 10
DNAME : ACCOUNTING
LOC : NEW YORK
PL/SQL procedure successfully completed.
SQL>In 11g, you can create a sys_refcursor and then the DBMS_SQL package allows you to convert that refcursor into a DBMS_SQL cursor so that you can get the description of the results and do the same. This isn't available prior to 11g though.
However_ before any of that, you should really ask yourself if there is a real need to dynamically be creating queries. There is rarely any real need to do that and if you're finding it's common in your application then this is often a sign of poor design or poorly defined business requirements (leaving the technical side to try and be "flexible" and hence leading to unmaintainable code etc.). -
Package compile faile with error ORA-03113: end-of-file on communication..
Hi There,
We're trying to compile a package and we're getting this error that we're not sure how to debug and/or tackle. Your assistance is highly appreciated.
create or replace
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 4252
Session ID: 1149 Serial number: 5910
The package use to compile without any issues; also we have it working in other environments. We can't see any differences at this stage.
Oracle Version:11.2.0.1 x64
OS: Windows 2008 Server R2
Thanks in advance for your help.
ThanksI have tried dropping the package and re-compiling it but to no avail. I can compile other packages/procedures/functions without any issues.
Also, trying to run either EXEC UTL_RECOMP.recomp_parallel(4, 'SCHEMA_NAME'); or @?/rdbms/admin/UTLRP.SQL gives the following erros:
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 7040
Session ID: 388 Serial number: 9039
ERROR:
ORA-03114: not connected to ORACLE
DOC> The following query reports the number of objects that have compiled
DOC> with errors (objects that compile with errors have status set to 3 in
DOC> obj$). If the number is higher than expected, please examine the error
DOC> messages reported with each object (using SHOW ERRORS) to see if they
DOC> point to system misconfiguration or resource constraints that must be
DOC> fixed before attempting to recompile these objects.
DOC>#
ERROR:
ORA-03114: not connected to ORACLE
DOC> The following query reports the number of errors caught during
DOC> recompilation. If this number is non-zero, please query the error
DOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errors
DOC> are due to misconfiguration or resource constraints that must be
DOC> fixed before objects can compile successfully.
DOC>#
ERROR:
ORA-03114: not connected to ORACLE
ERROR:
ORA-03114: not connected to ORACLE
ERROR:
ORA-03114: not connected to ORACLE
ERROR:
ORA-03114: not connected to ORACLE
ERROR:
ORA-03114: not connected to ORACLE
Maybe you are looking for
-
Please Help:(,Unable to capture from camcorder using Audigy 2 ZS Video Edi
Hi there! Well I have been trying to use the Sound Blaster Audigy 2 zs video editor to transfer Hi8 tapes from my camcorder (Samsung SLC860) to my laptop (Compaq presario, AMD Athlon 64 3200+, .25 GB RAM, xp). I have successfully done this before *so
-
NoClassDefFoundError error when deploying a resource adapter rar file
Hi, Iam trying to deploy a resource adapter(RA) rar file which uses orabpel.jar. 1. When i dont package the orabpel.jar along with the adapter, i get the following error during deployment [Apr 19, 2007 8:05:00 PM] Connector Module Deployer for BRMAda
-
How to go to SAP R/3 Easy access from BW???
-
My internet speed is around 100kbps these are my speed test results and hub stats could somebody please advise on what it could be. ADSL Line Status Connection information Line state: Connected Connection time: 0 day, 00:45:18 Downstream: 7,104 Kbps
-
How do I change the name of my "User" name?
I bought a used Macbook Pro. I hate my Home User name and can't figure out how to change it. Let me explain. When looking at the finder window at the botom it gives a path "Macintosh HD > Users > Abc123". How can I change "Abc123" to a name I like? U