SQL & PL/SQL :: Embedded Ref Cursor?

Jun 26, 2012

I have the following tables: First one (PART) is the master and other 2 are children.I need to create query that would link both children to the parent. So I was thinking about using embedded refcursor (since my function returns a ref cursor).

on using this ? Is this ok or any other better way of doing this ?

TABLE PART
PART_ID, PART_NAME
TABLE ABC
ABC_ID,PART_ID

[code]...

View 6 Replies


ADVERTISEMENT

Performance Tuning :: Cursor Embedded In Select

Jul 21, 2010

I've been examining som old queries in an existing db due to more and more problems regarding performance. The sql is used as backend for a java/jboss web application with the possibility for users to enter data. With more and more data, there starting to come complaints about the performance.

I stumbled upon a select query with an embedded cursor similar to this :

select id, name ...,
cursor(select id, sequence.... from table2),
cursor(select id, name.... from table3)
from table1
join table4 on (table1.id = table4.id)
where .....

The javacode is a prepared statement with the actual sql as a string and the content of the cursors saved in conjunction with each row.

when i use sqldeveloper to show the explain plan without the cursors, the cost is 2428
when i use sqldeveloper to show the explain plan with just 1 of the cursors, the cost is ~165000

Is there a better way to do this instead of cursors ?

View 2 Replies View Related

SQL & PL/SQL :: How To Get Latest Record In Embedded Select Statement

Mar 12, 2013

I am trying to run an Oracle report with a query that has an embeded sql. this sql is returning more than 1 row, and the report is failing.

I need to pick the latest record entered that this sql return.

I tried rownnum and it works but only i can get the rown num I specify, not the latest record. I try to order, but I am getting an error back.

select w.emp_no, (select t.timestamp
from tob.work_unit t
where t.work_date = to_date('20130312', 'YYYYMMDD')
and rownum = 1
order by t.timestamp desc)
,w. spare_type
from work.work_unit w
where w.work_date = to_date('20130312', 'YYYYMMDD')

I am getting missing right parenthesis at the order by keyword My report is much complex than this, but I am tring to see if I can get the row that I want.

View 10 Replies View Related

SQL & PL/SQL :: How Query Call Embedded Materialized View Automatically

Jul 13, 2010

I have to optimize the queries for user online panel. We have already created 2 materialized views:

mv_channel, mv_area

mv_channel (article_id, area, aweg_txt3, sum(value), sum(units))
mv_area (article_id, area, sum(value), sum(units))

For this query:

SELECT /*+ REWRITE*/
sum(value) as value,
sum(units) as unit,
article_id
from
...
where
...
and area in ('RB','RR','RS')
and aweg_txt3 n ('SB')
...

is the matview mv_channel very useful. The execution time was just 8s-13s instead fo 190s. But if the user also asks for this query but without AWEG_TXT3 in the where-clause, then it lasted 1:25min (longer than if the matview mv_area will be used).

The problem is that, the matview mv_area cannot be used in the case, in which the AWEG_TXT3 is in where clause (because it doesn't have aweg_txt3).

How can i do, so that :

- in case of AWEG_TXT3 in where-clause the matview mv_channel will be used and
- in another one (without AWEG_TXT3 in where-clause) the matview mv_area will be called automatically from the query

View 1 Replies View Related

Application Express :: LDAP Authentication Using Embedded Weblogic Server

Sep 28, 2012

I am trying to use embedded weblogic server for creating an LDAP authtication secheme but it is not working

I believe that embedded ldap server works on the same port as the admin server of the domain but configuring it has been a pain. I got the following code from forum to test the ldap connection

declare
l_retval pls_integer;
l_retval2 pls_integer;
l_session dbms_ldap.session;
l_ldap_host varchar2(256);
[code]........
  
Every time I run this, I get the following error

ldap session : 01000000(returned from init)
error: ORA-31202: DBMS_LDAP: LDAP client/server error: Invalid credentials
-31202

View 0 Replies View Related

Application Express :: Apex Listener Versus The Embedded PL/SQL Gateway

Jan 24, 2013

What are the pro's and con's to using the APEX Listener vs the Embedded PL/SQL gateway?

We just started using APEX and on a development server, we set it up using the EPG because this seemed like the easier thing to do. However, they now have a couple apps that are approaching production status and I now need to look at placing the APEX runtime on our production Oracle Database server. So I am trying to decide if I should continue using the EPG or if I should use the APEX Listener.

The server is Windows Server 2008 Enterprise R2 (64 Bit) with Oracle 11g R2 (11.2.0.3.0) also running at 64 bit. I am planning on using APEX 4.2.1.

I have also not found information about how to move APEX application from development to production. Do I export the schema from the dev server and import it to the production server? Do I have to recreate the same workspace name on the production server as well?

use a separate dev and production server setup for APEX?

View 3 Replies View Related

Forms :: Oracle Forms Output Embedded In HTML File?

Jun 15, 2012

i'm using db and forms 10g. i want the output of the form to be embedded within a simple html page. lets say i want the html page to be divided into three frames. the uppermost horizontal frame will hold a banner (say). the left vertical frame will hold some advertisement (say).

(1) now the rest of the page will be covered by the third frame in which the fmx's will run.

(2) i want the login.fmx (startup form) to show up first instead of the servlet. infact the servlet should not show up at all.

View 1 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

PL/SQL :: Cursor In Another Cursor

Aug 31, 2012

i have a program like this

DECLARE
V_VARIABLE1 VARCHAR2(10);

CURSOR_ABC IS select...............;
BEGIN
OPEN CURSOR_ABC;
LOOP
FETCH CURSOR_ABC INTO V_VARIABLE1;
EXIT WHEN CURSOR_ABC%NOTFOUND;

WHAT IF I WANT TO INSERT ANOTHER SAME KINDA CURSOR LOOP HERE LIKE*

CURSOR_XYZ IS select...............;
BEGIN
OPEN CURSOR_XYZ;
LOOP
FETCH CURSOR_XYZ INTO V_VARIABLE2;
EXIT WHEN CURSOR_XYZ%NOTFOUND;
END LOOP;
CLOSE CURSOR_XYZ;
END LOOP;
CLOSE CURSOR_ABC;

View 3 Replies View Related

Passing Ref Cursor

Oct 14, 2010

We receive hand punches (clock data) every day. Normally a person badges in(hand punch) which creates a row in the clock_tran_processed table. The information from that hand punch is the employee id (emp_id) the date hand punch occurred and a work_summary id (wrks_id). At the end of the day, the employee badges out (hand punch out) and another entry in the clock_tran_processed table is created. The new row will have the emp_id (employee name), date the hand punch occurred and the same work summary id from the morning.

Normally hand punches should occur in pairs. One in, one out... or one in, out for lunch, in for lunch, out for day. I am seeing intervals of three and five. Meaning the employee clocked in twice and out once, or in once and out twice. This shouldn't happen.

I am writing a report that will show number of clocks per for all employees that have three(3) or five(5) clock entries.I wrote a ref cursor that gives all the employees that have a count of 3 or 5 and the employee id (emp_id). I need to pass that employee id to another query that will then get me the dates of the clocks.Here is the ref cursor thus far (I am printing those with a count of 3 and 5).

CODEDECLARE

TYPE ClockTran_Refcur IS REF CURSOR;
ClockTran_cur ClockTran_Refcur;
NumClock_num number :=0;
NumClock_name clock_tran_processed.emp_id%TYPE;
[code]...

How do I pass that variable to the get the clktranpro_time's? I am using "Easy Oracle PL/SQL Programming" but I am not seeing this type of example(pgs 140-148).

View 5 Replies View Related

Cursor Pin S Wait On X

Apr 17, 2013

In our environment we have db link to fetch data from other database. Whenever we try to fetch data using the dblink we receive the wait event "cursor: pin S wait on X" and we do not get any result. The db link works fine. what could be the issue.

DB Version : 11.1.0.7 OS: AIX

View 1 Replies View Related

Cursor - Pin S Wait On X

Nov 14, 2006

i am using the Oracle 10 g 10.2 with the windows 2003 3 sessions from a single User shows the currenncy on the top activity graph of the enterprice manager they are not getting so much resources of system....when i go in the detail of the session i get

cursor: pin S wait on X

i am unable to kill these sessions how could i get rid of these sessions

View 2 Replies View Related

SQL & PL/SQL :: Error While Using Cursor

Apr 10, 2013

My task has more lines of code,so i tried to present here only few lines of code where i am getting the error.The following cursor needs to select data from two tables with some conditions that are included in cursor and place those in other table.I used BULK collect.

CURSOR c_arch_trk (p_run_date DATE,
p_nbr_days_arch1 NUMBER,
p_nbr_days_arch2 NUMBER )
IS
SELECT a.SIS_PGM_START_DATE,a.SIS_PGM_END_DATE,a.PGM_MSTR_NBR,a.PGM_TRK_NBR,a.CNTL_LOCN,a.CMPNY_VNDR_NBR,a.AGRMNT_MSTR_NBR,
a.SLS_CONT_NBR,b.PGM_NAME,b.PGM_BASIS,b.AGRMNT_CNTL_LOCN
[code]....

View 3 Replies View Related

SQL & PL/SQL :: Collection Over Cursor?

Jun 30, 2010

What is the advantage of collections over CURSOR? What is the use for collections and when collections is used?

View 1 Replies View Related

SQL & PL/SQL :: Reporting Using Cursor

Nov 8, 2010

I am using Oracle 11G. I have set of tables in a schema - DDXX_UTIL.

Table Names wll be with the high level qualifiers DDXX_REJ_EMP*

DDXX_REJ_EMPLOYEE
DDXX_REJ_EMPLOYEE_DEPEND
DDXX_REJ_EMPLOYEE_ADDRESS
DDXX_REJ_EMPLOYEE_SAL
DDXX_REJ_EMPLOYEE_EXP

My requirement is to get the number of rejections happened on that day after the batch cycle for the tables with the high level qualifier DDXX_REJ_EMP* and list out each table followed by the rejection cause and count.

Expected Result
-----------------------------------------------------------------
TABLE NAME : DDXX_REJ_EMPLOYEE
REJECTION_CAUSE COUNT
ID LIST MISSING 25
MANDAORY FIELDS IS NULL 56

TABLE NAME : DDXX_REJ_EMPLOYEE_DEPEND
REJECTION_CASUE COUNT
ID LIST MISSING 25
MANDAORY FIELDS IS NULL 56

Given below is the create statement for one of the table.

CREATE TABLE DDXX_UTIL.DDXX_REJ_EMPLOYEE
(
REJECTION_CAUSE VARCHAR2(510 BYTE),
INTEG_REJ_DATE VARCHAR2(10 BYTE)
);

SAMPLE_DATA
DDXX_REJ_EMPLOYEE
REJECTION_CAUSE INTEG_REJ_DATE
INVALID ID 31-OCT-10
INCORRECT FIELD 31-OCT-10
INVALID ID 31-OCT-10
INCORRECT FIELD 31-OCT-10

I need to group by the rejection cause and integ_rej_date for all the tables.

View 5 Replies View Related

SQL & PL/SQL :: Passing Value From One Cursor To Other One

May 24, 2011

I would like to know whether a value obtained from one cursor can be passed to the other cursor as a parameter and by passing it i want to retrieve a list of records and print only the records obtained from the second cursor where the value is passed.

View 3 Replies View Related

SQL & PL/SQL :: Use REF Cursor In Query

Aug 20, 2013

I have a function :

FUNCTION WP19DUMMY(vname IN VARCHAR2) RETURN SYS_REFCURSOR
IS
tmpcur SYS_REFCURSOR ;
BEGIN
OPEN tmpcur FOR SELECT IVALUE FROM GENPARAMS WHERE NAME = vname;
RETURN tmpcur;
END WP19DUMMY;

I want to use the returned REF CURSOR in a SQL query. So I ran the following @ SQL prompt :

SELECT WP19DUMMY('TD') FROM DUAL;

and I am gettng the following result :

WP19DUMMY('TD
--------------------
CURSOR STATEMENT : 1
CURSOR STATEMENT : 1

IVALUE
-------------
0

BUT I do not want such a result. I want a result that will only return the IVALUE.

View 6 Replies View Related

SQL & PL/SQL :: Use Of Cursor Variables?

Mar 11, 2012

what is use of cursor variables?

View 1 Replies View Related

SQL & PL/SQL :: Looping Through A Ref Cursor

Feb 16, 2008

I have a procedure which has an out value of a ref cursor (made up of different columns from different tables). I would like to call that procedure from another procedure and loop through each row.

I know how to call my stored procedure but I don't know how to loop through it.

View 5 Replies View Related

SQL & PL/SQL :: Varray To Cursor

Mar 31, 2011

Iam passing the varray to cursor as show below.

type t is varray(50) of number;
t1 t;
cursor c1(t3 t) is select name from temp2 where id in(t3(1),t3(2));
name1 varchar2(20);
begin
t1 :=t(501,384,3242,106);
[code]......

my question varray size is 50, while creating the cursor i have to pass the 50 values like t3(1),t3(2).....t3(50). I have tried to use t3.first..t3.last in IN condition but throwing some error, any other method/hints to pass the values dynamically to cursor IN condition.

View 5 Replies View Related

SQL & PL/SQL :: Ref Cursor As OUT Parameter

Aug 8, 2012

CREATE OR REPLACE PACKAGE test_package IS
TYPE refcur IS REF CURSOR;
END test_package;
CREATE OR REPLACE PROCEDURE get_info(o_cursor OUT test_package.refcur)
AS
BEGIN
OPEN o_cursor FOR
SELECT * FROM emp;
END get_info;

What is the advantage of using refcursor variable as OUT parameter in procedure. Instead of that why cannot we use variables or TYPE variables. use ref cursor as OUT parameter in procedure.

View 1 Replies View Related

SQL & PL/SQL :: Limitations Of Ref Cursor?

Dec 31, 2011

limitations of REf cursor? and What is the difference in declaring as SYS_REFCURSOR and REFCURSOR?

View 1 Replies View Related

SQL & PL/SQL :: Invalid Cursor?

Dec 2, 2010

procedure vieworderstatus(in_CALL_ID IN NUMBER ,
in_DAYS_OF_HISTORY in number ,
out_SUPLY_REORDR_STATUS_LST OUT supplyreordrlist ,
out_ERR_CODE OUT NUMBER,
out_ERR_MESSAGE out varchar2);

This procedure takes retrievs cust_id for given input call_id. The procedure then retrieves order information for that customer and returns using the out ref cursor. I need to test the scenario where the user passes invalid call_id.

The following query returns no data for call_id = 12345 ( invalid call_id)
select fk_cust_id into v_cust_id
from xcom_call
where call_id = in_CALL_ID;

in such cases; I just need to return null ref cursor and log the error but right now when I pass invalid call_id ; I am getting "invalid cursor" error.How do I handle this ?

View 35 Replies View Related

SQL & PL/SQL :: Cursor For Loop

Jul 30, 2012

When a cursor returns no records, how to handle this in Cursor for loop..

I had given sample code for handling this by using normal open,fetch statement, provide by applying for -Cursor For loop

DECLARE
P_BU_ID NUMBER;
P_SUMRY_DATA_TY_ID NUMBER;
P_OP_DATE VARCHAR2(32767);
P_PROC_DATE VARCHAR2(32767);
P_FIN_YEAR NUMBER;
[code]........

View 3 Replies View Related

SQL & PL/SQL :: Cursor FOR Loop?

Jun 15, 2012

I am an experienced SAS programmer jumping into PL/SQL for the first time and have already encountered a problem.Let's assume I have 7 records (shown below). (In reality, I have millions of records, but the concept's the same.) The Value field is only populated when it changes. Therefore, I am forced to "fill in the gaps" as I read the data file. It's fairly straightforward. I carry the value foward one record at a time, using it if the Value field in not populated. The ANSWER I want is also shown.

In reading through a PL/SQL book, I realized that only 2 chapters are relevant to what I do. My guess is this solution involves cursors; probably a Cursor FOR loop,

ID Year Amt ANSWER
1 2010 200 200
1 2011 ..... 200
1 2012 ..... 200
2 2009 300 300
2 2010 ..... 300
2 2011 450 450
2 2012 ..... 450

View 5 Replies View Related

PL/SQL :: Cursor On A Table

Oct 22, 2012

I have a table with more than 200 columns. I would like to declare a cursor to query all the columns for each record (if c1%found then ....). As the table has more than 200 columns is it a good practice to declare a cursor

View 7 Replies View Related







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