Parallel piplelined function not parallelizing with ref cursor
RDBMS 11.2.0.3
I have a function with the following signature
function to_file (
p_source in sys_refcursor
, p_file_name in varchar2
, p_directory in varchar2 default 'DD_DUMP'
return dd_dump_ntt
pipelined
parallel_enable ( partition p_source by any )
authid current_user;The function works in parallel when I use a cursor expression like this
begin
for rec in ( select *
from table(dd_dump.to_file( cursor(select /*+ parallel(i 4) */ c1||chr(9)||c2 from mytable i), 'f.out' ))
loop
dbms_output.put_line(rec.file_name || chr(9) || rec.num_records );
end loop;
end;
f.out_162 276234
f.out_213 280399
f.out_230 286834
f.out_70 289549But when I use a refcursor, it does not run in parallel
declare
rc sys_refcursor;
begin
open rc for 'select /*+ parallel(i 4) */ c1||chr(9)||c2 from mytable i';
for rec in ( select *
from table(dd_dump.to_file( rc, 'f.out' ))
loop
dbms_output.put_line(rec.file_name || chr(9) || rec.num_records );
end loop;
end;
f.out_914 1133016Is this an expected behavior or am I doing something wrong? How can I use the function when the client returns the SQL statement as a character string
Edited by: Sanjeev Chauhan on Mar 9, 2012 11:54 AM
Sanjeev Chauhan wrote:
I am not performing any DML in the pipelined function. If you read the note carefuly it shows parallel_enable works only when you use:
table(table_function(<font color=red>CURSOR</font>(select...)))and not when you use
table(table_function(<font color=red>ref-cursor-name</font>))SY.
Similar Messages
-
Plsql use a function which returns a ref cursor
Hi
I've been using an function which returns a ref cursor. I've been returning this into a java resultset. Fine!
Now i'm in plsql and want to use the same function. I'm not sure how to get this resultset in plsql.It's not very practical to use a refcursor like you want to, but here you go
create or replace function test_ref
return sys_refcursor
is
v_rc sys_refcursor;
begin
open v_rc for select emp_name from emp ;
return v_rc;
end;
declare
v_rc sys_refcursor;
v_emp_name emp.emp_name%type;
begin
v_rc := test_ref ;
loop
fetch v_rc into v_emp_name ;
exit when v_rc%notfound ;
dbms_output.put_line('Employee Name: '||v_emp_name );
end loop;
end; -
PLS-00428 Why SELECT must be adorned with REF CURSOR to work?
hello
*"PLS-00428: an INTO clause is expected in this SELECT statement"* - This problem has been resolved. I just want to understand WHY SELECT statements need to be paired with REF CURSOR.
To reproduce this,
DECLARE
Id1 numeric(19,0);
Id2 numeric(19,0);
CreateTimestamp date;
BEGIN
-- ATTN: You'd either need to select into variable or open cursor!
select * from SystemUser left join Person on Person.Id = SystemUser.PersonId WHERE Person.PrimaryEmail in ('[email protected]','[email protected]');
END;
Solution?
* In install script:
CREATE OR REPLACE PACKAGE types
AS
TYPE cursorType IS REF CURSOR;
END;
* Then in your query:
DECLARE
Id1 numeric(19,0);
Id2 numeric(19,0);
Result_cursor types.cursorType;
BEGIN
OPEN Result_cursor FOR select * from SystemUser left join Person on Person.Id = SystemUser.PersonId WHERE Person.PrimaryEmail in ('[email protected]','[email protected]');
END;
I Googled for reasonable explaination - closest is: http://www.tek-tips.com/viewthread.cfm?qid=1338078&page=34
That in oracle block or procedures are expected to do something and a simple SELECT is not!! (Very counter intuitive). What needs to be done is therefore to put the select output into a ref-cursor to fool oracle so that it thinks the procedure/block is actually doing something. Is this explanation right? Sounds more like an assertion than actually explaining...
Any suggestion please? Thanks!Opening a cursor (ref cursor or otherwise) is not the same as executing a select statement.
A select statement returns data, so if you are using it inside PL/SQL code it has to return that data into something i.e. a local variable or structure. You can't just select without a place for the data to go.
Opening a cursor issues the query against the database and provides a pointer (the ref cursor), but at that point, no data has been retrieved. The pointer can then be used or passed to some other procedure or code etc. so that it may then fetch the data into a variable or structure as required.
It's not counter-intuitive at all. It's very intuitive. -
Send & Recieve functionality not working with WebDav after installing Acrobat XI
Send & Recieve functionality not working with WebDav after installing Acrobat XI for PDF. Acrobat XI is complete installations(Trial Version).
Hi Kiro ,
Did you try opening that file in any other browser ?If not ,please try doing that once and see if that works for you.
Try Repairing Acrobat once and see if that helps.
Launch Acrobat>Navigate to Help>Repair Acrobat Installation.
Regards
Sukrit Dhingra -
VC 7.0 Oracle stored procedures resultset with ref cursor
Can VC (we are on NW7 SP13) handle Oracle's datatype ref cursor - which is the standard solution in Oracle to return result sets - as the return value of a stored procedure?
When testing a data service in the VC story board based upon a simple Oracle function like:
create or replace package pkg_dev
is
type t_cursor is ref cursor;
end;
create or replace function vc_stub return pkg_dev.t_cursor
as
l_cursor pkg_dev.t_cursor;
begin
open l_cursor for select ename from emp;
return l_cursor;
end;
(just as example - I know that could be easily retrieved using the BI JDBC connector framework and accessing tables / views)
I am always running in the "portal request failed ( Could not execute Stored Procedure)" error - so I am not able to use the "add fields" function to bind the output.
The defaulttrace contains entries like:
Text: com.sap.portal.vc.HTMLBRunTime
[EXCEPTION]
com.sapportals.connector.execution.ExecutionException: Could not execute stored procedure
Caused by: java.sql.SQLException: Invalid column type
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
We deployed Oracle's own jdbc-driver for Oracle 10g. Using that driver and a portal jdbc connector framework entry the stored procedures of the Oracle database user mapped to the portal user are discovered and available in the "Find Data Services" section.We deployed the drivers as described in the HowTo Papers (e.g.Hwo to Configure UD Connect on the J2EE Server for JDBC Access to External Databases). When deploying the drivers you assign a freely definable name for the set of Oracle's jar-files (eg. oracle_10) as library name. Having deployed the drivers in that way only System Definitions via BI JDBC connector framework were working. With a little help from SAP Support (call lasted more than 2 months till a very capable member of the support team made things working in a very short time) we got the portal jdbc connection with Oracle's jar-files working:
Here are instructions how to add reference:
1. Connect to the j2ee using telnet, e.g in the cmd window type:
telnet <host> <port> + 8, enter uid and pwd of j2ee admin.
2. jump 0
3. add deploy
4. change_ref -m com.sapportals.connectors.database <your lib name> <your lib name = oracle_10>
Trying to manually add this reference in visual admin connector container for JDBCFactory failed - reference could be added and saved, but then disappeared (at least in NW7 with SP12). Adding the reference as described above solved the problem. -
64bit OraOLEDB failed when calling stored procedure with Ref Cursor
Hi everyone,
I used the ADO VB sample provided with the Oracle 10g provider installation.
But I compiled it in 64bit Visual Studio 2005 and ran on Windows 2003 x64 server.
The function call "cmd.Execute" when it is trying to call a stored procedure which has an Out Ref Cursor parameter. The exception is
"PLS-00306: wrong number or types arguments in call"
I already set the property "PLSQLRSet" to true. But it doesn't help.
The same code works if I compiled in 32 bit.
It also works if the stored procedure does not have Ref Cursor parameter.
I am guessing this is a bug in the 64bit Oracle provider. Anyone can confirm this please? or am I missing anything?
WilsonIt appears to work with 11.1.0.6.20 OLEDB provider but only for ExecuteNonQuery, I'm not able to work with Fill, and yes... in x86 works perfectly, but in x64 we are still having the ORA-06550 and PLS-00306 error.
Our Connection string is as follows:
"Provider=OraOLEDB.Oracle.1;OLEDB.NET=true;Password=xxxxx;Persist Security Info=True;User ID=exxxxx;Data Source=ECOR; PLSQLRSet=True"
We are not using ODP.NET.
Can you confirm that Fill method works with such update? -
ORA-01008 with ref cursor and dynamic sql
When I run the follwing procedure:
variable x refcursor
set autoprint on
begin
Crosstab.pivot(p_max_cols => 4,
p_query => 'select job, count(*) cnt, deptno, row_number() over (partition by job order by deptno) rn from scott.emp group by job, deptno',
p_anchor => Crosstab.array('JOB'),
p_pivot => Crosstab.array('DEPTNO', 'CNT'),
p_cursor => :x );
end;I get the following error:
^----------------
Statement Ignored
set autoprint on
begin
adsmgr.Crosstab.pivot(p_max_cols => 4,
p_query => 'select job, count(*) cnt, deptno, row_number() over (partition by
p_anchor => adsmgr.Crosstab.array('JOB'),
p_pivot => adsmgr.Crosstab.array('DEPTNO', 'CNT'),
p_cursor => :x );
end;
ORA-01008: not all variables bound
I am running this on a stored procedure as follows:
create or replace package Crosstab
as
type refcursor is ref cursor;
type array is table of varchar2(30);
procedure pivot( p_max_cols in number default null,
p_max_cols_query in varchar2 default null,
p_query in varchar2,
p_anchor in array,
p_pivot in array,
p_cursor in out refcursor );
end;
create or replace package body Crosstab
as
procedure pivot( p_max_cols in number default null,
p_max_cols_query in varchar2 default null,
p_query in varchar2,
p_anchor in array,
p_pivot in array,
p_cursor in out refcursor )
as
l_max_cols number;
l_query long;
l_cnames array;
begin
-- figure out the number of columns we must support
-- we either KNOW this or we have a query that can tell us
if ( p_max_cols is not null )
then
l_max_cols := p_max_cols;
elsif ( p_max_cols_query is not null )
then
execute immediate p_max_cols_query into l_max_cols;
else
RAISE_APPLICATION_ERROR(-20001, 'Cannot figure out max cols');
end if;
-- Now, construct the query that can answer the question for us...
-- start with the C1, C2, ... CX columns:
l_query := 'select ';
for i in 1 .. p_anchor.count
loop
l_query := l_query || p_anchor(i) || ',';
end loop;
-- Now add in the C{x+1}... CN columns to be pivoted:
-- the format is "max(decode(rn,1,C{X+1},null)) cx+1_1"
for i in 1 .. l_max_cols
loop
for j in 1 .. p_pivot.count
loop
l_query := l_query ||
'max(decode(rn,'||i||','||
p_pivot(j)||',null)) ' ||
p_pivot(j) || '_' || i || ',';
end loop;
end loop;
-- Now just add in the original query
l_query := rtrim(l_query,',')||' from ( '||p_query||') group by ';
-- and then the group by columns...
for i in 1 .. p_anchor.count
loop
l_query := l_query || p_anchor(i) || ',';
end loop;
l_query := rtrim(l_query,',');
-- and return it
execute immediate 'alter session set cursor_sharing=force';
open p_cursor for l_query;
execute immediate 'alter session set cursor_sharing=exact';
end;
end;
/I can see from the error message that it is ignoring the x declaration, I assume it is because it does not recognise the type refcursor from the procedure.
How do I get it to recognise this?
Thank you in advanceThank you for your help
This is the version of Oracle I am running, so this may have something to do with that.
Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production
I found this on Ask Tom (http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:3027089372477)
Hello, Tom.
I have one bind variable in a dynamic SQL expression.
When I open cursor for this sql, it gets me to ora-01008.
Please consider:
Connected to:
Oracle8i Enterprise Edition Release 8.1.7.4.1 - Production
JServer Release 8.1.7.4.1 - Production
SQL> declare
2 type cur is ref cursor;
3 res cur;
4 begin
5 open res for
6 'select * from (select * from dual where :p = 1) connect by 1 = 1'
7 using 1;
8 end;
9 /
declare
ERROR at line 1:
ORA-01008: not all variables bound
ORA-06512: at line 5
SQL> declare
2 type cur is ref cursor;
3 res cur;
4 begin
5 open res for
6 'select * from (select * from dual where :p = 1) connect by 1 = 1'
7 using 1, 2;
8 end;
9 /
PL/SQL procedure successfully completed.
And if I run the same thing on 10g -- all goes conversely. The first part runs ok, and the second
part reports "ORA-01006: bind variable does not exist" (as it should be, I think). Remember, there
is ONE bind variable in sql, not two. Is it a bug in 8i?
What should we do to avoid this error running the same plsql program code on different Oracle
versions?
P.S. Thank you for your invaluable work on this site.
Followup June 9, 2005 - 6pm US/Eastern:
what is the purpose of this query really?
but it would appear to be a bug in 8i (since it should need but one). You will have to work that
via support. I changed the type to tarray to see if the reserved word was causing a problem.
variable v_refcursor refcursor;
set autoprint on;
begin
crosstab.pivot (p_max_cols => 4,
p_query =>
'SELECT job, COUNT (*) cnt, deptno, ' ||
' ROW_NUMBER () OVER ( ' ||
' PARTITION BY job ' ||
' ORDER BY deptno) rn ' ||
'FROM emp ' ||
'GROUP BY job, deptno',
p_anchor => crosstab.tarray ('JOB'),
p_pivot => crosstab.tarray ('DEPTNO', 'CNT'),
p_cursor => :v_refcursor);
end;
/Was going to use this package as a stored procedure in forms but I not sure it's going to work now. -
Create view With Ref cursor data
Hi friends,
I want to create view as follows.
Example:
Create or replace v_name
select job,sal, <funcation>
from emp;
Note:- Function not having out parameter.
Function returning ref cursor values datatype.
Requirement:-
I want to create view even function returing ref cursor datatype.
Please advise how to create view.
Regards,
Kishoreuser7284612 wrote:
Hi friends,
I want to create view as follows.
Example:
Create or replace v_name
select job,sal, <funcation>
from emp;
Note:- Function not having out parameter.
Function returning ref cursor values datatype.
Requirement:-
I want to create view even function returing ref cursor datatype.
Please advise how to create view.You perhaps are misunderstanding what a ref cursor is. It does not contain data like a table, so cannot be treated as one.
Take a read of this:
PL/SQL 101 : Understanding Ref Cursors -
New functionally : good receipt with ref to contract
Dear Team
Is there any functionality have come up with good receipt with ref to contract. with regard to any of EHP level.
Regard
NabilDear Nabil,
We have to create a contract release order i.e a purchase order with reference to that contract in ME21N and then post a goods receipt in MIGO against the PO.
If you try to post the GR against the contract , system will give a message "Order category of purchase order ###### not possible here". Can you provide the details on your requiremnet.
Regards
Irfan Ahmed -
When I open Firefox, it goes to the first page I open, but then stops and says "Not Responding" with the mouse cursor spinning. I hit the close button and it says Windows is searching for a solution (which doesn't come).
When I open Firefox again, it says:
Well, this is embarrassing.
Firefox is having trouble recovering your windows and tabs. This is usually caused by a recently opened web page.
You can try:
Removing one or more tabs that you think may be causing the problem
Starting an entirely new browsing session
Any ideas? I gretly appreciate any help. Thanks!!What is that first page?
Can't you open any web pages in Firefox?
Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance/Themes).
*Don't click the Reset button on the Safe mode start window or otherwise make changes.
*https://support.mozilla.org/kb/Safe+Mode
A possible cause is security software (firewall,anti-virus) that blocks or restricts Firefox or the plugin-container process without informing you, possibly after detecting changes (update) to the Firefox program.
Remove all rules for Firefox and the plugin-container from the permissions list in the firewall and let your firewall ask again for permission to get full unrestricted access to internet for Firefox and the plugin-container process and the updater process.
See:
*https://support.mozilla.org/kb/Server+not+found
*https://support.mozilla.org/kb/Firewalls -
Error while working with ref cursor
Hi I tried the following but getting the err
DECLARE
TYPE ref_nm IS REF CURSOR;
vref REF_NM;
vemp emp%rowtype;
BEGIN
OPEN vref FOR SELECT ename ,sal FROM EMP;
LOOP
FETCH vref INTO vemp;
EXIT WHEN vref%NOTFOUND;
DBMS_OUTPUT.PUT_LINE ( vemp.ename ||','||vemp.sal );
END LOOP;
CLOSE vref;
END;Error is
ORA-06504: PL/SQL: Return types of Result Set variables or query do not matchSyntactically correct - but a horrible approach performance wise if you only need specific columns.
The basic problem here is using the wrong tool. A ref cursor. Why? There's no reason in this code for using a ref cursor. Using a standard cursor data type addresses the requirement a lot better.
As you can define the cursor:
cursor myCursor is select c1, c2 from tab1;
You can define an array data type for fetching that cursors data - and thus definition does not need to be touched when you change the cursor itself to include/exclude columns:
type TMyCursorBuffer is table of myCursor%RowType;
And finally you can define a bulk collection buffer for bulk processing the output of the cursor:
myBuffer TMyCursorBuffer; -
Dear All,
Version : '11.2.0.2.0'
I have a procedure which gets called from a screen ( on .Net) if use pushes a particular button.
The procedure takes 15 minutes to complete.
My requirement is to intimate the front end(.Net) as soon as the procedures gets called successfully without waiting for its completion as it is going to take 15 mins.
The reason being, the front end will popup a message saying that " The process is going to take long time, A mail will be sent to u after its completion" once it has been intimated that the procedure has been called successfully.
Could you please suggest can i return a cursor to front end without even manipulating the data.
i hope my question is understandable.9876564 wrote:
Dear All,
Version : '11.2.0.2.0'
I have a procedure which gets called from a screen ( on .Net) if use pushes a particular button.
The procedure takes 15 minutes to complete.
My requirement is to intimate the front end(.Net) as soon as the procedures gets called successfully without waiting for its completion as it is going to take 15 mins.
The reason being, the front end will popup a message saying that " The process is going to take long time, A mail will be sent to u after its completion" once it has been intimated that the procedure has been called successfully.
Could you please suggest can i return a cursor to front end without even manipulating the data.
i hope my question is understandable.
It seems to me that your problem is not an Oracle one, but a user interface one.
I'm assuming the slowness of the procedure is due to how long it's taking to query the data, and if you can't speed that up then, to have the procedure return a ref cursor, the connection between the front end and the procedure must be maintained (the process on Oracle must belong to a session, and the front end needs to be connected to that session).
So, you can't have Oracle go off and start a seperate process and then pass back the ref cursor when it's finished, because even though you can spawn off seperate processes such as using DBMS_JOB or DBMS_SCHEDULER, they will run in their own 'session' and the calling code won't keep a hold on any of those sessions... they're effectively stand-alone and seperate.
What you'll have to do is likely get your .net application to spawn off a child process to the main app, that presents the message saying it'll take some time, does the call to Oracle and waits for Oracle to return the resultant ref cursor, which it can then pass back to the main application etc. Due to .net allowing for multi-tasking, that is where the split processing should take place. -
G505s - Touchpad hot key function not working with lenovo driver
I'm using windows 8.1, Lenovo G505s laptop. Recently I got replacement from Lenovo regarding touchpad after that this Fn(F7) touchpad enable/disable not working. This is happening only when I installied touchpad driver provided by lenovo and works well with standard microsoft driver (Ofcourse, no multigesture support with that driver).
We perfomed following operations:
1. HotKey mode enable/disable in BIOS
2.Reinstallation of OS
3. Reinstallation of driver(manually)
All cases with microsoft driver this function working but with touchpad driver it is not working. It's almost 90days (88thday) daily contacting both Lenovo customer support and service center people but no use.
If anybody having this problem and have a solution please share! (My machine under warranty!)hi phani_kumar,
It's likely that you have a Synaptics driver (you can verify this by its hardware ID or use a utility software like AIDA 64 Extreme Edition).
- Link to picture (Synaptics)
- Link to picture (ELAN
If you're unable to install the driver below, can you follow this guide on how to disable driver signature enforcement then try to reinstall the driver again and observe if you can now toggle the Fn+F6.
Windows 8/7/XP/Vista 64/32-bit Edition v17.0.19
All Languages
118.1 MB zip
Regards
Did someone help you today? Press the star on the left to thank them with a Kudo!
If you find a post helpful and it answers your question, please mark it as an "Accepted Solution"! This will help the rest of the Community with similar issues identify the verified solution and benefit from it.
Follow @LenovoForums on Twitter! -
Evaluate_Analytic function not working with VPD enabled
Experts,
One of the column formula has evaluate_analytic function in the report. The report works fine with no errors when Virtual Private Database is not checked in the Physical Layer's datasource object, but the same report fails with the below error message when VPD is checked.
Please share your thoughts on how to resolve the error. Your response is greatly appreciated.
This is the error message in the answers:
Odbc driver returned an error (SQLExecDirectW).
Error Details
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 42015] Cannot function ship the following expression: Evaluate_Analytic( MIN(%1) OVER(PARTITION BY %2),([ D901.c3, D901.c4] )).Please have your System Administrator look at the log for more details on this error. (HY000)
This is in OBIEE 11.1.1.6 version. I haven't tested in old versions.
Regards,
Tom
Edited by: Tom Lype on Oct 1, 2012 2:17 PMI found the solution myself. Hopefully it should help others.
If your fact table is within a data source object which has VPD enabled in the physical layer, all other tables(dimensions) mapped to it should be from a data source object which has VPD checked. I might be wrong but at least in my case after I copied over two tables from a data source (no VPD checked) into the new data source (VPD checked), my evaluate_analytic function is working with no errors. The parameters for the evaluate_analytic function are from those two tables.
Regards,
Tom -
Function call returned in ref cursor
We have a ref cursor that calls a function in a package. When ODP.NET reads the cursor, it can't see what the function is returning. OO4O works fine, and if I take the sql that populates the ref cursor and put it into a temporary table, then select from that temporary table to return the ref cursor to ODP, it works fine. Anyone else seen this issue? Any help would be appreciated. Thanks.
Eric Schrauth
[email protected]Did you set the parameter direction to be ParameterDirection.Input when you created the parameter? Post your code.
Maybe you are looking for
-
Relation between 'only balance in local currency' check box and OBA1-KDF
Hi, in the master data of the GL account, the check box 'only balance in local currency' should be unchecked it to set that account as Valuation account, i.e in the OI exchange rate defferences? or , if the account takes only in local balance also se
-
Why do I have to use SELECT INTO clause in a Stored Proc ?
Hi, I'm new to oracle. I've bought Oracle Database 10g SQL and Oracle Database 10 A beginner's Guide, two books from Oracle press but I can't find any answer for that. Why when I'm writing a Stored Procedure with a SELECT statement do I have to use a
-
i am currently using office 2010 and filesite 8.5 sp2 or sp3 and experiencing the same issue with the icon grouping in the taskbar in all the threads i have read the responses state that the solution was to upgrade to office 2010 well that might have
-
AIR for iOS 3.5 [Retina Icon not displaying]
Am I doing something wrong here ? My XML file contains <icon> <image144x144>assets/[email protected]</image144x144> <image72x72>assets/icon72.png</image72x72> <image50x50>assets/icon50.png</image50x50> <image100x100>as
-
What I did is that I copy all codes from FBL1N to Z* for me to modify and put header on its report, And these error occur "The type syldb_sp is unknown" I already activate the include where this type was used. Is there anything I need to do more? Nee