SQL & PL/SQL :: Cursor Declaration Inside Block?

Jun 30, 2011

I can't understand the following cursor declaration (inside the DECLARE of a PL/SQL block)

CURSOR c_emps IS
SELECT emp_large_ot(empno, ename, job, mgr,hiredate, sal, comm, deptno) FROM emp_large;
emp_large_ot is an object type created as
CREATE TYPE emp_large_ot AS OBJECT
( empno NUMBER
, ename VARCHAR2(10)
, job VARCHAR2(9)

[code]...

and emp_large is similar to the standard emp table

View 3 Replies


ADVERTISEMENT

SQL & PL/SQL :: Hide Declaration Or Declare It Inside The Body Of Package

Mar 11, 2010

I have a package which has couple of Procedures and functions. I use some constants between the functions and procedure and also functions r called from the other procedure and stuff...

So I declared all these in the header

Like this

CREATE OR REPLACE PACKAGE "PROCESS_HISTORY" IS
type table_name_i is varray(100) of VARCHAR2(30);
c_add constant number := 1;
c_del constant number := 2;
c_select_frm_tmp constant number := 1;
[code]......

Now is there anyway I could hide the stuff that I don't want outside people to see? or can I declare them (constants and some functions) some where inside the body and use them?

View 9 Replies View Related

SQL & PL/SQL :: Parameterized Cursor Declaration

Apr 20, 2012

I have two different tables with the same structure.

Depending on the parameter value to the procedure I need to process any one of the table .

declare
Query_string varchar2(500);
input_string varchar2(10) := 'E';
begin
Query_string := 'select * from ';

[Code]...

My intensition is like above snippet .But it's not working fine . If the input string 'E' then we need to process emp table , other wise archieve

View 3 Replies View Related

Loop Inside Cursor

Sep 11, 2012

I have a cursor returning some value.

for each value returned by the cursor i need to traverse through 31 rows(1 row per day * no of days in the month).

E.g. if cursor returns service_name as xyz then for xyz there can be 31 rows(service may not be used on some days)

I need to go to all of them and take some values and move them to a flat file. how should that be done?

Attached File(s)
Query.png ( 20.99K )
Number of downloads: 9

View 1 Replies View Related

SQL & PL/SQL :: How To Use Desc Inside Block

Aug 1, 2011

how to use desc inside pl sql block?

View 16 Replies View Related

SQL & PL/SQL :: Calling APIs Inside Cursor

Jun 17, 2011

im calling an api inside a cursor.. for the first loop in a cursor , the api works well. however, for the rest of the loops the api doesn't give any error, but it doesn't insert any row to the table.

if i called the same api for every single value in a cursor seperately the api would insert all rows.

View 1 Replies View Related

SQL & PL/SQL :: Cursor With Parameter Inside Function

Mar 7, 2010

I have code inside function
.....
cursor cur1 is
select *
from sarchkler
where sarchkler_appl_no = in_appl_no
begin
select max(saradap_appl_no) into in_appl_no from saradap;
for rec1 in cur1 loop
......
my question I get variable for cursor after cursor declaration

View 7 Replies View Related

SQL & PL/SQL :: Error Handling Inside Cursor

Dec 31, 2012

I am writing a cursor and inside that cursor I am checking record exists or not and based on that I am doing my operation.But I am getting error that i can not use exception inside cursor see the below sample code (syntax may not be correct)

sample code------------------
cur c1
is select * from T1;
open c1
loop
fetch c1 into cur_id;

select name into var_name from t2 where id = cur_id;

exception
when no_data_found then
continue with next cursor value
end

update t3 set name = var_name where t3.id = cur_id;
commit;
end loop;
end;

View 6 Replies View Related

SQL & PL/SQL :: Cursor In DML Statement Inside A Procedure

Sep 12, 2011

I have a DML Statement inside a procedure and i use a cursor variable to get the values checked as below . I have attached my procedure not completely but the declaration part and the DML statement part.

The issue is my procedure is not inserting the records at all. It selects the values and then inserts accoringly but its not selecting because of the cursor reference R_LOC.LOCATION_GID.

when i hard code the value in the DML statemnt for the R_LOC.LOCATION_GID, the rows are inserted as expected. So i guess the way the procedure executes the value is not correct.

Modifying my select part which uses cursor variable R_LOC.LOCATION_GID under Insert statement.

select d.servprov_gid, d.depot_gid, replace(d.appointment_time,'':'') appmt_time, d.'||v_day_to_use||' DayUsed
from tesco_fresh_templates t, tesco_fresh_templates_d d, location_refnum r
where t.set_id= d.set_id
and d.depot_gid=r.location_gid
AND D.SERVPROV_GID=''R_LOC.LOCATION_GID''
and r.location_refnum_qual_gid=''TESCO.IVS SCHEDULING''
and (r.location_refnum_value=''YES'' or r.location_refnum_value=''Y'')
and t.default_set=''Y''

View 21 Replies View Related

SQL & PL/SQL :: Using Function Inside Query And Without Cursor?

Mar 17, 2013

To display highest marks,least marks,average marks,total marks of the student name entered.

desc stud;
Name Null? Type
----------------------------------------- -------- ----------------------------
SID NUMBER
NAME VARCHAR2(20)
M1 NUMBER
M2 NUMBER

How do I do that using PL/SQL and without Cursor.

View 4 Replies View Related

SQL & PL/SQL :: Select On Dba_pending_transactions Inside Block?

May 14, 2011

While writing a procedure I went into this problem. Whenever I write Query : Select * from dba_pending_transactions It works fine.

But whenever I use same Select Query inside PL-SQL block it gives error Table or view not exist. Dba_pending_transactions is view.

SQL> declare
2 v_count number(2);
3 begin
4 execute immediate 'select count(*) from dba_ending_transactions' into v_count;
5 dbms_output.put_line(v_count);
6 end;
7 /
declare
*
ERROR at line 1:
ORA-00942: table or view does not exist
ORA-06512: at line 4

Same error I get when i use it inside a procedure.

View 2 Replies View Related

PL/SQL :: Dynamic Execution Of Block Inside Trigger?

Jan 3, 2013

Im using the following oracle database.

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production

I have one problem in trigger execution. I have a small plsql block in trigger and, I want to execute it as a dynamic way. but it is giving the error. Please find the trigger code. Here my intension is that, the column name used in trigger should be dynamic. In future, if I want to switch the column name, I have to do without modification in trigger.
The error im getting is "ORA-01008: not all variables bound".

CREATE OR REPLACE TRIGGER ETM_AR_IU
AFTER UPDATE ON
EXTERNAL_MAPPING
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW

[code]...

View 17 Replies View Related

Performance Tuning :: Tablespace With Different Block Size Inside Same Database?

Nov 25, 2011

All the analysis till now on our system proves that our system is clearly I/O bound and db sequential read is the biggest culprit.

We have even identified the index which is being affected by sequential read. I am thinking of creating a new tablespace with 32K blocksize (currently all table spaces are 8k) and migrate this index to the new space. That way, Oracle will have to do less number of reads to get the required data.

But is there anything wrong in having just one tablespace with a differnt block size? Or is there anything that I have to be watchful about while doing it?

View 14 Replies View Related

SQL & PL/SQL :: Place Insert Statement In Loop Inside Anonymous Block?

Nov 25, 2012

can we place insert statement in loop inside anonymous block?

CREATE TABLE DEP(DEPTID NUMBER(5) NOT NULL PRIMARY KEY,DNAME VARCHAR2(10),LOCID VARCHAR2(10));
DECLARE
I NUMBER(5);
BEGIN
I := 0;
LOOP
INSERT INTO DEP VALUES(&DEPTID,'&DNAME',&LOCID);
I := I+1;
EXIT WHEN I = 5;
END LOOP;
END;

View 6 Replies View Related

SQL & PL/SQL :: No Data Found Stops The Loop Action Inside Block?

Jul 1, 2013

I am trying to create an anonymous PL/SQL block to output privilege information for each of the users listed in DBA_USERS In a loop. This is my block so far (not finished):

declare
v_usr varchar2(30);
v_out_header varchar2(100);

[Code]....

The output is as follows:

***User-Role Privilege report***
-----------------------------------
username: ANDREY , profile: DEFAULT
SYSTEM privileges granted directly to the user(not through ROLE) :
no_data_found

A problem I am encountering is that for some users I have no direct privileges that are not granted through roles, And when I have the expression v_qry (which is basically "'select grantee ||'',''|| privilege from DBA_SYS_PRIVS where grantee not in (select role from dba_roles) and grantee ='||'''' ||v_usr||''''") not initialized with values because the select statement retrieved 0 results, I have the process interfered by the no_data_found error/exception.

Questions: how I can preferrably simply, avoid/overcome my problem? Some way to make the loop go on in spite of no data found? maybe something similar to NVL?

View 14 Replies View Related

Server Administration :: ORA-04030 - Split From Tablespace With Different Block Size Inside Same Database

Nov 26, 2011

i written this code i m facing ORA-04030: out of process memory when trying to allocate 16408 bytes error

/* Formatted on 2011/11/26 11:52 (Formatter Plus v4.8. */
DECLARE
row_id varchar2(50);
v_batch_id temp.batch_id%TYPE;
v_slab_id temp.slab_id%TYPE;
flag NUMBER (2);
num varchar2(50) := &row_id;

[code].....

View 1 Replies View Related

SQL & PL/SQL :: How To Call Cursor Within Anonymous Block

Apr 17, 2013

I'm having an issue with an Oracle ref_cursor, how to call the cursor within an anomimous Pl/Sql Block. I did it once but I can't get it working now.

DECLARE
v_cursor sys_refcursor;
t_cursor v_cursor%rowtype;
BEGIN
OPEN v_cursor FOR

[code].....

View 5 Replies View Related

Forms :: Use Cursor To Get Data From DB To Control Block

Feb 7, 2010

i want to use cursor to get data from db to "control block "(db item =no ) this data had where clause depend on item on other block

this my code :

declare
cursor get_sol is
select SOL_STEP,PROB_ID
from MI_SOLUTION
where PROB_ID=:MI_FORM_PROB.PROB_ID;
begin
go_block('control');
[code]......

when am using when_validate_item trigger error raise :

FRM-40737:Illegal restricted procedure next_record in when_validate_item

that's the trigger ? or how to solve ? in case of execute query in what trigger i will write the same code to get data in case of execute query by user .

View 9 Replies View Related

Forms :: Get Block Name From Cursor Focus Location?

Jul 27, 2010

I have a delete button at the bottom of the form and have two blocks on top of it. I need to know which block i have the focus on or selected the record on pressing the delete button so that I go to that block and do a delete_record from that block. I came across :system.trigger_block which says it gives the name of the block where the cursor was located when the current trigger initially fired. But whenever i use it only returns the name of the block the delete button is located in. Instead i wanted to know where the focus of the cursor was or which record was selected in the above 2 blocks to go to that block and delete the record.

View 1 Replies View Related

Forms :: Two Cursor Record Block - Decode Function

Sep 16, 2010

I have Two cursor record block..which is attached in form..

My TASK IS

In my first Block, When DBCR Column = 'D' Then in backend this column value should be save as a '1'
WHEN DBCR Column = 'C' Then Then in backend this column value should be save as a '2'

My Both Field is on Data Block...

In Property palette of this field can we write any decode condition..so it reflects directly on database.

View 2 Replies View Related

Get Variable Declaration?

Apr 24, 2013

it is possible to undeclared a variable if so how dont worry am with you to solve any problem lets we can do it

View 1 Replies View Related

SQL & PL/SQL :: Variable Declaration In RAC Oracle 10g

Sep 29, 2010

We are facing a new type of issue , the issue is the variable declaration and assigning a value for it is not properly used in the procedure of a package.

for ex:

create or replace procedure test
is
v_type VARCAHR2(5) := 'XX';
v_awb varchar2(5) := 'AL';
BEGIN
Insert into tt(col1,col2,col3,col4)
select v_type,v_awb,col3,col4 from xxx;
commit;
END;

Above is the sample procedure used ,here i am declaring a variable v_type and v_awb and assigning a value for it and inserting them into a table,but the concern is the values declared is always inserting a NULL value instead of the assigned value ,but in our local we could not reproduce it. The issue is occurring in RAC oracle machine,and the version is below

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production

View 1 Replies View Related

PLS-00320 / Declaration Of Type Of Expression Is Incomplete Or Malformed

Jul 16, 2013

I have this Error in PL /SQL procedure  ORA-06550: line 6, column 12:PLS-00320: the declaration of the type of this expression is incomplete or malformedORA-06550: line 6, column 12:PL/SQL: Item ignoredwhere this is my procedure

CREATE OR REPLACE PROCEDURE MOAMALAT."IO_EMP_REP" (P_FROMDATE IN NUMBER,P_TODATE IN NUMBER,P_EMPID IN NUMBER,RCT1 OUT GLOBALPKG.RCT1)ASBEGINOPEN RCT1 FOR SELECT COUNT (I.CORRESPONDENCENUMBER) cont,EMP.FULLNAME empname,D.DEPARTMENTNAME deptnameFROM MOAMALAT.IO_INCOMING i,MOAMALAT.IO_EMPLOYEES emp,MOAMALAT.IO_DEPARTMENTS dWHERE I.RECEIVEDBY = (SELECT EM.USERIDFROM MOAMALAT.IO_EMPLOYEES emWHERE EM.EMPLOYEEID = P_EMPID)AND I.RECEIVEDBY LIKE EMP.USERID--and EMP.DEPARTMENTID=1900AND I.RECEIVEDBYDEPARTMENTID = D.DEPARTMENTIDAND I.CORRESPONDENCEDATE BETWEEN

[code]....

View 4 Replies View Related

Application Express :: 4.2 Translate (Function And Global Variable Declaration) Data?

May 1, 2013

i 'm using APEX 4.2.1.00.08 and i 'm wondering if there is a way to translate "Function and Global Variable Declaration" textarea. Every other script textarea is available for translation, but not this.

I know that this is code is loaded on header but may contains important alert messages of global functions.

View 1 Replies View Related

Variable Usage In Type Of Table Declaration Statement And Execute Immediate Statement

Aug 10, 2011

HOW to use variable P_TMPLID in following statement

TYPE typ_unrecon IS TABLE OF REC_' || P_TMPLID ||'_UNRECON%ROWTYPE index by binary_integer;

because its throwing error while compiling

and also in statement
FORALL i IN unrecondata.FIRST .. unrecondata.LAST SAVE
EXCEPTIONS
--STRSQL := '';
--STRSQL := ' INSERT INTO REC_' || P_TMPLID ||'_UNRECON VALUES ' || unrecondata(i);
-- EXECUTE IMMEDIATE STRSQL;
INSERT INTO REC_' || P_TMPLID ||'_UNRECON VALUES unrecondata(i);---throwing error on this statement
commit;
--dbms_output.put_line(unrecondata(2).TRANSID);
EXCEPTION

View 2 Replies View Related

Forms :: Multi Data Block And Checkbox Field Based On Control Block

Nov 19, 2010

i have multi data block filed. and checkbox field which based on control block...My task is when i check checkbox only one field should enabled and my mouse goes to that field

e.g

item11 item21 item31 chkbox1
item12 item22 item32 chkbox2

Scenario like this :

My item field based on data block and checkbox based on control block,while i checked chkbox1 , only item31 on that current record should be enabled and i changed value only on that field

when i checked chkbox1 , my cursor goes to item31...not item32

View 12 Replies View Related

Forms :: Distribute Master Block Total Amount In Detail Block Line Wise

May 5, 2012

i have a master detail form, In Master block we have one field cheque amount and in Detail block we have field receiveable amount invoice wise. if company paid us a cheque amount we will enter this amount in Master block field Cheque amount and in detail block there will be invoice wise receivable amounts. i want to distribute the cheque amount in detail block invoice wise for example

Cheque amount in master block = 291

Invoice wise receiveable amount is as follows

Invoice No , receivable amount , Received amount

10, 196 , 0
20 , 95 , 0
30 , 54 , 0

Result should be as follows:

Invoice No , receivable amount , Received amount

10, 196, 196
20 , 95 , 95
30 , 54, 0

Received amount field should be distributed according to the receivable amount when recevied amount = cheque amount then remaining will be 0.

View 2 Replies View Related

Backup & Recovery :: Error / Corrupt Block Relative Dba / 0x01c12a58 (file 7 / Block 76376)

Jan 25, 2011

i have an error with block corruption

Error: Corrupt block relative dba: 0x01c12a58 (file 7, block 76376)

What all the ,methods I can go for if we are working on a production environment with out any down time.

I can go for dbms repair package and restore and recover

View 3 Replies View Related

Forms :: How To Read Values In A Multi Record Control Block Using Pre-insert Trigger (block Level)

Jul 24, 2010

I have a multi record control block (basically a text item displaying 6 records) where user enters values and I want to process the values using pre-insert trigger.

I want to read value in each record and then do some tasks using a pre-insert trigger before I commit the values. To navigate between the records I was using first_record, next_record, clear_record built-ins but it gives errors like "40737-illegalrestricted procedure next_record in pre-insert trigger".

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







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