PL/SQL :: Difference Between Ref Cursor And Sys_refcursor?

Dec 6, 2012

i found this difference between ref cursor and sys_refcursor.

If you specify return_type, then the REF CURSOR type and cursor variables of that type are strong; if not, they are weak. SYS_REFCURSOR and cursor variables of that type are weak.

my situation is i have to write many stored procedure for reports and also for entery pages. few enter pages use typed datasets and few does not.

which one is better in terms of performance and maintainability in above three conditions?

View 2 Replies


ADVERTISEMENT

Forms :: Invalid Cursor Using SYS_REFCURSOR

Apr 25, 2012

i have created a procedure to open a query using a reference sys_refcursor as output parameter. i referenced the cursor in a pl/sql and is working correctly. however it throws error "ORA-01001: invalid cursor ORA-01403: no data found" when use on the oracle forms builder.

create or replace procedure mrch.prc_proj_list (p_add_clause in varchar2, p_rec_set out sys_refcursor) as
begin
Open p_rec_set for
'Select mp2.REGION region, '||
' mp2.ID proj_id, '||
' mppm2.PHASE phase, '||
' mm2.muni muni_id, '||
' mm2.MUNINAME muni_name, '||
' nvl((select Sum(ma.AMOUNT) From MRCH.MRC_AGREEMENT ma '||
' Where ma.PROJECT_ID = mp2.ID '||
' And ma.PHASE = mppm2.phase '||
' And ma.MUNI = mm2.MUNI),0) agreement, '||
' nvl((Select Sum(NVL(ma.GREEN_BOOK_AMOUNT,0) + NVL(ma.GB_ADJUST,0)) From MRCH.MRC_ALLOCATION ma '||
[code]....

View 3 Replies View Related

SQL & PL/SQL :: Difference Between Cursor And Normal For / While Loop?

Mar 7, 2011

what is the difference between using a cursor and using a normal for/while loop to retrieve and process the result set.

View 3 Replies View Related

SQL & PL/SQL :: Difference Between Implicit And Explicit Cursor?

Feb 21, 2013

What is the difference between implicit cursor and explicit cursor in PL/SqL?

And what is ref cursor ?

View 2 Replies View Related

PL/SQL :: Difference Between Explicit And Implicit Cursor?

Nov 5, 2013

difference between between these two constructs. Finally  when i read the asktom.oracle.com , I was totally confused. The reason is thatTom says...we can retrieve more than one row in implicit cursor. If that would be case, what's the difference between these two cursors?? when to use?? My understanding was implicit cursors" ---> single-row queryExplicit cursors ---> multi-row query Experts

View 10 Replies View Related

PL/SQL :: Difference Between Strong Ref Cursor And Weak?

Jul 13, 2012

differnce between strong ref cursor and weak ref cursor

View 4 Replies View Related

SQL & PL/SQL :: Difference Between With Parameter And Without Cursor In Pasted Code?

Apr 7, 2012

create table eml(num numner(10),email varchar2(100));

begin
for i in 1..20 loop
insert into eml values(i,'email.'||i||'@mmm.com');
end loop;
end;

I just want to know what is the difference between below two pl/sql block, in one block i am passing the p_email_id as paramter to cursor.Both block are working fine and giving the same result.first thing , i want to know how the p_email_id is passing to cursor get_emil_info without paramter.and which is good to use, i mean without paramter or with paramter.

--without paramterised cursor

declare
v_cnt number;
p_email_id number;
TYPE email_tab is TABLE of NUMBER index by binary_integer ;
eml_id email_tab ;
CURSOR get_eml_id is select num from eml;

[code]...

--with paramterised cursor

declare
p_email_id number;
TYPE email_tab is TABLE of NUMBER index by binary_integer ;
eml_id email_tab ;
CURSOR get_eml_id is select num from eml;

[[code]...

View 3 Replies View Related

PL/SQL :: Difference Using Cursor In Specifications And Body In Packages

Jun 24, 2013

what is the difference using cursor in specifications & body in packages?

View 1 Replies View Related

SQL & PL/SQL :: How To Use Dbms_profiler For A Procedure Returning Sys_refcursor

May 23, 2011

using dbms_profiler for a package having procedure returning sys_refcursor.

I have 2 procedure in a package. let say, proc1 and proc2 ( also proc1 is called inside from proc2)

proc1 has no parameter

proc2 has 2 paramter proc2(p_num in integer, p_data out sys_refcursor) [ in which we pass the p_num (ex: 1) and it run to get the data from the tab le and return that data through sys_refcursor.

for proc1, I am able to use dbms_profiler as below and it is working fine

-------------
DECLARE
l_res BINARY_INTEGER;
BEGIN
l_res := DBMS_PROFILER.start_profiler(run_comment => 'package.proc1: ' || SYSDATE);
package.proc1;
l_res := DBMS_PROFILER.stop_profiler;
END;
/
-------------

but for proc2, i am unable to use dbms_profiler, how to use dbms_profiler for procedure returning sys_refcursor.

i tried using as below:
-------------------------------
DECLARE
l_res BINARY_INTEGER;
P_NUM NUMBER;
P_DATA SYS_REFCURSOR;

[code]....

getting error: PLS-00312: a positional parameter association may not follow a named association

View 1 Replies View Related

PL/SQL :: Sys_refcursor Spawning Maximum Threads

Jun 23, 2013

i have a procedure which outputs 10 refcursors. It is called called by a .NET utility which then writes the data to 18 different flat files. The proc is of below format

CREATE OR REPLACE PROCEDURE FILE_EXTRACT
(OUTREC1 OUT SYS_REFCURSOR,
OUTREC2 OUT SYS_REFCURSOR,)
AS
BEGIN
OPEN OUTREC1 FOR
SELECT /*+PARALLEL(A,8)*/
COL1,COL2
FROM TABLE A;
 [code]....

 I have used parallel hint because all the tables used in the queries a huge tables and this is a nightly batch job. The issue here is that i have expected oracle to use 8 processes for this execution so all my select statements have parallel hint with degree 8 , but unusaully the procedure is erroring out on production databases because of maximum number of connections are being spawned and the database is not able to create any new session.  When i debuged and did a quick test proc where i used only one out refcursor it ran only 9 threads . then i ran by adding one more out ref cursor it spawn 17 threads. I think its the way .NET is fetching data from each of these cursors.When i print the first refcursor i do see queries which are running for the second along with the first causing the parallel queries run more than expected. The cause of the problem here is all the refcursors are executed and waiting to return data. SO when .net starts reading first cursor the other queries also run. 

View 0 Replies View Related

SQL & PL/SQL :: Error While Using Sys_refcursor In Anonymous Block

Sep 13, 2013

For my task I tried to write a package that has sys_refcursor in it.It compiled well.Now I want to see the results of it and wrote a anonymous block which gave errors.

CREATE OR REPLACE
PACKAGE xyz
IS

[Code]....

Error:Invalid reference to variable 'OBJ_CUR'.

View 4 Replies View Related

SQL & PL/SQL :: Oracle Dynamic Query Returning To Out Sys_refcursor

Nov 8, 2011

I'm trying to build a dynamic sql inside an Oracle procedure, and return it as a SYS_REFCURSOR to ADO.NET using ODP.NET in Oracle 11R2. Below is my table:

CREATE TABLE "TFWDB_ENTIDADE"
(
"CD_ENTIDADE" NUMBER(10,0) NOT NULL,
"DC_ENTIDADE" VARCHAR2(100 BYTE) NOT NULL,
"NM_ENTIDADE" VARCHAR2(255 BYTE) NOT NULL,
"CD_TIPO" NUMBER(5,0) NOT NULL,
"ID_STATUS" CHAR(1 BYTE) DEFAULT ('1') NOT NULL,
CONSTRAINT "PKFWDB_ENTIDADE" PRIMARY KEY ("CD_ENTIDADE"),
CONSTRAINT "CHFWDB_ENTIDADE" CHECK (ID_STATUS IN ('0', '1'))
);

Below is the procedure I build to SELECT it:

create or replace procedure spfwdb_sl_entidade_1(
p_cd_entidade in number,
p_dc_entidade in varchar2,
p_nm_entidade in varchar2,
p_cd_tipo in number,
p_id_status in char,
[code]........

I'm calling this code from C#, and I get an empty Result Set. What am I doing wrong? Can I output the dynamic sys_refcursor that I created? Below is my C# code using ODP.NET:

string pConnectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ORASERVER)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=ORASID)));User Id=user;Password=password;";
OracleConnection oConn = new OracleConnection(pConnectionString);
oConn.Open();
string pNomeProc = "spfwdb_sl_entidade_1";
[code]........

View 7 Replies View Related

PL/SQL :: Calculate Difference By Which Day Count Of Difference Is Going?

Oct 17, 2012

Detail table will look like below:

Product_id issue_date action_date Force_date
1 10/10/2012 10/10/2012 10/10/2012
2 10/10/2012 10/10/2012 10/10/2012
3 10/10/2012 13/10/2012 15/10/2012
[code]....

Need the data like

Issue_date count_action_date count_Force_date (diff(action_date,force_date) 1 2 3 4 5 6(days since over)

10/10/2012 3 4 1 4 2 1 0 0

How to get the data like this? automatically how to get 123.... and how to calculate the difference by which day the count of difference is going?

View 3 Replies View Related

Precompilers, OCI & OCCI :: Pro*C - Cursor Leak With Cursor Array

Sep 7, 2007

I'm dealing with an ORA-1000 error in a Pro*C application where all the cursors are correctly closed (or so it seems to me).

Here is the code for a simple program which reproduces the problem:

Each cursor is opened in a PL/SQL package:

CREATE OR REPLACE PACKAGE emp_demo_pkg AS
TYPE emp_cur_type IS REF CURSOR;
PROCEDURE open_cur(curs IN OUT emp_cur_type, dept_num IN NUMBER);
END emp_demo_pkg;

[Code]....

While testing the initialization parameter open_cursors is set to 50.

It's my understanding that Oracle doesn't close the cursors until it needs the space for another cursor, which in my test case seems to happen when I enter a value of 50 or bigger for "number of loops". To see how oracle is reusing the cursors, while the test program is running I run SQL*Plus and query v$sesstat for the session that's running the test with the following sentence:

select name, value
from v$sesstat s, v$statname n
where s.statistic# = n.statistic#
and sid = 7
and name like '%cursor%';

Even before I enter a value for number of loops I can see that the session opened 4 cursors and closed 2 of them:

NAME VALUE
---------------------------------------------------------------- ----------
opened cursors cumulative 4
opened cursors current 2

Entering a value of 5 for number of loops yields

NAME VALUE
---------------------------------------------------------------- ----------
opened cursors cumulative 11 <----- 7+
opened cursors current 8 <----- 6+

With a value of 30

NAME VALUE
---------------------------------------------------------------- ----------
opened cursors cumulative 36 <----- 25+ (apparently, Oracle reused at least 5 cursors)
opened cursors current 33 <----- 25+

With a value of 47

NAME VALUE
---------------------------------------------------------------- ----------
opened cursors cumulative 53 <----- 17+
opened cursors current 50 <----- 17+

Now I reached the upper limit set by the initialization parameter open_cursors.

Entering a value of 48, I get the ORA-1000 error.

ORA-01000: maximum open cursors exceeded
ORA-06512: at "SCOTT.EMP_DEMO

Since I open and close the cursor in the same loop iteration, I expect to find in every iterarion 1 explicit cursor and a number of implicit cursors (the PL/SQL call along with the so-called recursive cursors), but I don't expect the sum of all of them to be greater than 50. If my understanding is correct Oracle should be reusing the 50 cursors previously marked as "closeable", not raising the ORA-1000 error.

View 1 Replies View Related

SQL & PL/SQL :: Cursor With Bind Variable And Cursor Record

Feb 25, 2011

Is it possible to:

-define a cursor with bind variables
-get a cursor record from these cursor
-and pass the bind variable in the OPEN clause

Did'nt succeed as shown in the example.

SET SERVEROUTPUT ON SIZE 900000;
DECLARE
--works fine
CURSOR c1 IS SELECT * FROM USER_TABLES WHERE rownum<3;
--doesn't work
--CURSOR c1 IS SELECT * FROM USER_TABLES WHERE rownum<:1;
crec c1%rowtype;
BEGIN
--works fine
OPEN c1;
--isn't possible ?
--OPEN c1 USING 3;

[Code]....

View 3 Replies View Related

SQL & PL/SQL :: Converting Numeric Cursor To Ref Cursor?

Sep 11, 2011

just looking around to use the new feature available in oracle 11g to convert the dbms_sql numeric cursor to reference cursor, how to do it?

parse and execute the sql string first with dbms_sql and then convert it to ref cursor?

View 1 Replies View Related

SQL & PL/SQL :: Open Ref Cursor From Explicit Cursor

Nov 23, 2011

I want to return ref cursor based on explicit cursors

create table jumbo(id number, name varchar2(20));
insert into jumbo values(1,'jumbo');
create table mumbo(id number, name varchar2(20));
insert into mumbo values(1,'mumbo');
commit;

[Code].....

The above procedure has compilation errors when I am trying to open ref cursor

LINE/COL ERROR
-------- --------------------------------------------------------
20/24 PL/SQL: SQL Statement ignored
20/38 PL/SQL: ORA-00942: table or view does not exist
32/24 PL/SQL: SQL Statement ignored
32/38 PL/SQL: ORA-00942: table or view does not exist
SQL>

View 5 Replies View Related

PL/SQL :: Can User Exist When Cursor Will Using For Cursor

Aug 7, 2013

Can i user exist when cursor will using For Cursor .

View 15 Replies View Related

SQL & PL/SQL :: Get Max Difference Where Each Value Can Look At Only Next?

May 28, 2013

How do I get the max difference where each value can look at only the next value(ordered by date asc) on any particular day
example first row on 20090902 is 501.25 (earliest date)

756.2 - 501.25
4735.83 - 501.25
35.83 - 501.25

[code]....

View 19 Replies View Related

How To Get Date Difference

Jul 20, 2007

How one can get date difference in days between two dates in Oracle reports ?

View 2 Replies View Related

SQL & PL/SQL :: Difference Between Dates

Jan 23, 2013

I am looking to subtract two columns and get the difference.

select to_char('06-NOV-2012 20:00','DD-MON-YYYY HH24:MI') - to_char(systimestamp,'DD-MON-YY HH24:MI') from dual;
select to_char('06-NOV-2012 20:00','DD-MON-YYYY HH24:MI') - to_char(systimestamp,'DD-MON-YY HH24:MI') from dual
*
ERROR at line 1:

ORA-01722: invalid number

View 9 Replies View Related

SQL & PL/SQL :: ORA-00923 - Difference Between 9i And 10g

Aug 25, 2010

I encountered this problem when we recently migrated to 10g. The table nametab has two columns roll(number datatype) and name(varchar2(10) datatype).Following are the queries used and I have deliberately not given space between the "select" clause and the "from" clause.

In 9i
SELECT name,1FROM nametab where rownum < 2
NAME 1
---------- ----------
Bharath 1

Same query in 10g
SELECT name,1FROM nametab where rownum < 2
ORA-00923: FROM keyword not found where expected

Here, I have interchanged the select columns.

In 9i
SELECT 1,nameFROM nametab where rownum < 2
ORA-00923: FROM keyword not found where expected

In 10g
SELECT 1,nameFROM nametab where rownum < 2
ORA-00923: FROM keyword not found where expected

View 7 Replies View Related

SQL & PL/SQL :: Difference Between Oracle 9i And 10g?

Apr 25, 2013

what are difference in between oracle 9i and 10g regarding with Sql queries?

View 1 Replies View Related

SQL & PL/SQL :: Difference Between Using MINUS And NOT IN

Sep 28, 2011

I am looking for an explanation for having the following query:

SELECT PK_SERIAL_NUMBER FROM TABLE1 MINUS (SELECT FK_SERIAL_NUMBER FROM TABLE2);

Which normally returns the values of SERIAL_NUMBER that are not passed to the child table TABLE2

and the query:

SELECT PK_SERIAL_NUMBER FROM TABLE1 WHERE PK_SERIAL_NUMBER
NOT IN
(
SELECT FK_SERIAL_NUMBER FROM TABLE2
);

which returns 0 rows!

View 6 Replies View Related

Difference Between V$sql And Dba_hist_sqlstat?

May 30, 2011

1. difference between v$sql and dba_hist_sqlstat?

2. as of i have understood, dba_hist_sqlstat gets refreshed from v$sql.

if i run this below query i get different outputs.. how?

by using v$sql table

WITH t AS
(SELECT force_matching_signature ,
SUM(executions_delta) executions,
COUNT(*) cnt ,
parsing_schema_name ,
MIN(MODILE1) MODULE1

[code].......

View 2 Replies View Related

SQL & PL/SQL :: Difference Between Oracle 8i And 11g

Sep 22, 2011

I listen that there is a big diff B/W indexing in oracle 8i and oracle 11g.

what way the indexing is different B/W 8i and 11g.

View 3 Replies View Related

PL/SQL :: Difference Between 2 Dates

Sep 24, 2012

for the below table

create table RM_TR_INVESTMENT
(
  AS_ON_DT                DATE not null,
  EXP_ID                  NUMBER(10) not null,
  BO_REF_ID               VARCHAR2(30),
  FO_REF_ID               VARCHAR2(30),
  BK_PRODUCT_ID           VARCHAR2(20),
  BK_INV_TYPE_ID          VARCHAR2(20),
 [code]....

I want to find the sum of NP_AMT_CCY where difference between Start_Dt and Maturity_Dt >= 14 days and <=28 days.How can I build the query for the above statement ?

View 6 Replies View Related

PL/SQL :: Difference Between Oracle DB 11.2.0.1.0 And 11.2.0.3.0?

Dec 18, 2012

When I use this sql: CREATE USER testuser IDENTIFIED BY "welcome1 " to create user in Oracle DB 11.2.0.1.0. I can login with testuser/welcome1, please notice the welcome1 is not end of black space in login.

But when I do the same thing in Oracle DB 11.2.0.3.0. I can't use this user login with any password. I tried welcome1, "welcome1 " but all failed.

Why there are this difference between 11.2.0.1.0 and 11.2.0.3.0, and since in 11.2.0.3.0 the create sql are success, what password is correct when login?

View 7 Replies View Related

SQL & PL/SQL :: How To Get Difference From Hh24:mi

Aug 17, 2013

I have two columns StartTime and EndTIme.

I have data like this

EndTime StartTime Diff(endtime-StartTime)
23:00 20:00 03:00
22:00 21:30 00:30

How can i get Diff(endtime-StartTime) from hh24:mi format

View 2 Replies View Related

Difference Between Database Or SID Upgrade

Oct 19, 2012

i want to know is there any difference between upgradation of SID and database. while upgrading my database from oracle 11.2.0.2 to 11.2.0.3 in DBUA it shows my SID is upgrading (ORCL) but i have few other databases ex (test and prod).

is it enough if we upgrade the SID or we must perform any other actions..

and
2nd QUERY :

i have 2 oracle homes in my server with different versions like (11.2.0.2 and 11.2.0.3)and i have few databases and there tablespaces. how to determine which database is created on which version and which database is upgraded from 11.2.0.2 to 11.2.0.3.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved