Rowid in cursor
hi ,
I am using rowid in cursor. the code is running fine while run at sample test table which having 40k data but while
runing it on production table which having data 190 million records of data.it shoiwng error
Thanks all in advance.& pls also suggest how to tune this proc.
Error starting at line 1 in command:
begin
UPDATE_PROC_RJ_NOV;
end;
Error report:
ORA-01410: invalid ROWID
ORA-06512: at "CDR.UPDATE_PROC_RJ_NOV", line 16
ORA-06512: at line 2
01410. 00000 - "invalid ROWID"
*Cause:
*Action:
code :
create or replace PROCEDURE UPDATE_PROC_RJ_NOV AS
CURSOR REC_CUR IS
SELECT ROWID,SUBSTR(CALLING_NO,-10),DECODE(LAST_CELL_ID,'-',FIRST_CELL_ID,LAST_CELL_ID) FROM RJ_CDMA_CDR_NOV;
TYPE R_NO_T IS TABLE OF VARCHAR2(4000);
TYPE CALLING_NO_T IS TABLE OF VARCHAR2(4000);
R_NO R_NO_T;
CALLING_NUM CALLING_NO_T;
BTS_TAB CALLING_NO_T;
L NUMBER(38);
CALLING_NO_TAB VARCHAR2(40);
BEGIN
OPEN REC_CUR;
LOOP
FETCH REC_CUR BULK COLLECT INTO R_NO,CALLING_NUM,BTS_TAB LIMIT 1000;
EXIT WHEN R_NO.COUNT() = 0;
FORALL I IN R_NO.FIRST .. R_NO.LAST
UPDATE TEST
SET BTS = BTS_TAB(I),
NEW_CALLING_NO=CALLING_NUM(I)
WHERE ROWID=R_NO(I);
COMMIT;
END LOOP;
CLOSE REC_CUR;
END;
I am not sure what you are trying to accomplish with this, but as posted, it will never work. You are selecting the rowid from rj_cdma_cdr_nov and trying to use it to update test. The rowid identifies the physical location on disk of a row. How can a row from test have the same physical location as a row from rj_cdma_cdr_nov?
If your intention really is to update rj_cdma_cdr_nov, then, as Sybrand says, do it as a single update along the lines of:
UPDATE rj_cdma_cdr_nov
SET bts = DECODE(last_cell_id, '-', first_cell_id, last_cell_id)
new_calling_no =SUBSTR(calling_no, -10)john
Similar Messages
-
Hi all,
Suppose i am updating some Rows in a cursor.
Can u plz let me know the Syntax of Using ROWID in Cursor with a simple example.plzz
i am trying to execute the follwing code but it si throwing error.Here i am trying to update salaries of employees who belong tO IT Department and whose salary is <5000
Declare
Cursor inc_salary is
Select e.employee_id,e.salary,e.department_id,d.department_id DEPART
from employees e,departments d
where e.department_id=d.department_id
and d.department_id='IT'
and e.salary<5000 FOR UPDATE OF SALARY;
Begin
For inc_record in inc_salary
Loop
DBMS_OUTPUT.PUT_LINE('Employee Id is '||inc_record.employee_id);
DBMS_OUTPUT.PUT_LINE('Original Salary is '||inc_record.salary);
DBMS_OUTPUT.PUT_LINE('Department No in Employees Table is '||inc_record.department_id);
DBMS_OUTPUT.PUT_LINE('Department No in Departments Table is '||inc_record.DEPART);
End Loop;
DBMS_OUTPUT.PUT_LINE('Lets Now increase the Salary of Employees');
DBMS_OUTPUT.PUT_LINE('********************************');
For inc_record in inc_salary
Loop
Update employees
Set Salary=5000
where Rowid=inc_salary.rowid;
End Loop;
End;
Edited by: user12920808 on Aug 19, 2012 4:39 AMYou update within
For inc_record in inc_salarywhere inc_salary is a cursor and inc_record is a record where rows inc_salary are fetched into. While in update statement you are referencing cursor.column instead or record. column. You need to change:
where Rowid=inc_salary.rowid;to
where Rowid=inc_record.rowid;However, cursor inc_salary doesn't include employees.rowid, so you need to add it. And it should be department_name = 'IT', not department_id:
Declare
Cursor inc_salary is
Select e.employee_id,e.salary,e.department_id,d.department_id DEPART,e.rowid e_rowid
from employees e,departments d
where e.department_id=d.department_id
and d.department_name='IT'
and e.salary<5000 FOR UPDATE OF SALARY;
Begin
For inc_record in inc_salary
Loop
DBMS_OUTPUT.PUT_LINE('Employee Id is '||inc_record.employee_id);
DBMS_OUTPUT.PUT_LINE('Original Salary is '||inc_record.salary);
DBMS_OUTPUT.PUT_LINE('Department No in Employees Table is '||inc_record.department_id);
DBMS_OUTPUT.PUT_LINE('Department No in Departments Table is '||inc_record.DEPART);
End Loop;
DBMS_OUTPUT.PUT_LINE('Lets Now increase the Salary of Employees');
DBMS_OUTPUT.PUT_LINE('********************************');
For inc_record in inc_salary
Loop
Update employees
Set Salary=5000
where Rowid=inc_record.e_rowid;
End Loop;
End;
Employee Id is 105
Original Salary is 4800
Department No in Employees Table is 60
Department No in Departments Table is 60
Employee Id is 106
Original Salary is 4800
Department No in Employees Table is 60
Department No in Departments Table is 60
Lets Now increase the Salary of Employees
PL/SQL procedure successfully completed.
SQL> And why do you have two loops instead of one. All you need is:
SQL> Declare
2 Cursor inc_salary is
3 Select e.employee_id,e.salary,e.department_id,d.department_id DEPART,e.rowid e_rowid
4 from employees e,departments d
5 where e.department_id=d.department_id
6 and d.department_name='IT'
7 and e.salary<5000 FOR UPDATE OF SALARY;
8 Begin
9 For inc_record in inc_salary
10 Loop
11 DBMS_OUTPUT.PUT_LINE('Employee Id is '||inc_record.employee_id);
12 DBMS_OUTPUT.PUT_LINE('Original Salary is '||inc_record.salary);
13 DBMS_OUTPUT.PUT_LINE('Department No in Employees Table is '||inc_record.department_id);
14 DBMS_OUTPUT.PUT_LINE('Department No in Departments Table is '||inc_record.DEPART);
15 Update employees
16 Set Salary=5000
17 where Rowid=inc_record.e_rowid;
18 End Loop;
19 End;
20 /
Employee Id is 105
Original Salary is 4800
Department No in Employees Table is 60
Department No in Departments Table is 60
Employee Id is 106
Original Salary is 4800
Department No in Employees Table is 60
Department No in Departments Table is 60
PL/SQL procedure successfully completed.
SQL> SY. -
Hello All,
I have table with 25 columns.
First three columns are composite keys
1. ID, . STORE_NUM, 3. STORE_NUM_WEEK
to update data i have to use all three column in WHERE clause for proper update. So in cursor also i have to select all three rows., Instead i SELECTED ROWID in cursor and used in where caluse in BULK COLLECT and FORALL update. instead of fetching all three rows. IS this the correct approch. WIth ROWID in don't have to use HINTs and the query and updation runs faster then the other( without ROWID).
I was reading on the intenet some where that using ROWID in not advisible in query.
How correct it is in my case.
Please clearify my daughts.
Thank you in AdvanceThank you sundar for your response.
Please look at my procedure. as under . I am posting the same for your consideration. It is updating selective rows only not all rows. As suggested. How can I do in SQL what about the formula to calculate the value to update.
Please ignore the syntex but look ate code and if you have any suggestion.Sorry for BIG CODE Procedure SP_930_End_Of_Week_OH_up (
pSKU In SS_SKU_Store_Week.SKU%Type,
pStore In SS_SKU_Store_Week.Store_Num%Type)
Is
Type tOnHand is table of SS_SKU_Store_Week.End_Of_Week_On_Hand%Type;
Type tPlannedReceipts is table of SS_SKU_Store_Week.Planned_Receipts%Type;
Type tShipmentQuantity is table of SS_SKU_Store_Week.Shipment_Quantity%Type;
Type tWarehouseAllocation is table of SS_SKU_Store_Week.Warehouse_Allocation%Type;
Type tPlannedSalesTW is table of SS_SKU_Store_Week.Distributed_Planned_Sales%Type;
Type tPlannedWeekFlag is table of SS_SKU_Store_Week.Planned_Week_Flag%Type;
Type tOpertunityRating is table of SS_SKU_Store_Week.OPPORTUNITY_RATING%type;
Type tLastWeekEndOfWeekOnHand is table of number index by binary_integer;
Type tEndOfWeekOnHand is table of number index by binary_integer;
Type tRowid Is Table Of ROWID Index By Binary_Integer;
-- vYearWeekKey tYearWeekKey;
vOnHand tOnHand;
vPlannedReceipts tPlannedReceipts;
vShipmentQuantity tShipmentQuantity ;
vWarehouseAllocation tWarehouseAllocation;
vPlannedSalesTW tPlannedSalesTW;
vPlannedWeekFlag tPlannedWeekFlag;
vLastWeekEndOfWeekOnHand tLastWeekEndOfWeekOnHand;
v_total_EndOfWeekOnHand tEndOfWeekOnHand;
vOpertunityRating tOpertunityRating;
vdistributedSales tPlannedSalesTW; -- distributed planned sales
vOpRat tEndOfWeekOnHand;
vRowId tRowId;
vRowId_1 tRowId;
vEndOfWeekOnHand Number;
vFirstWeek Boolean;
vForwardSales Number;
v_idx pls_integer;
CURSOR OpportunityRating_Cursor Is
SELECT Opportunity_Rating,
End_Of_Week_On_Hand,
Decode(PSW_Flag, 0, 0, Distributed_Planned_Sales)
DistributedPlannedSales,
ROWID
FROM SS_SKU_Store_Week
WHERE SKU = pSKU AND
Store_Num = pStore
ORDER BY Year_Week_Key Desc;
--FOR UPDATE;
Cursor EOWOH_Cursor is
SELECT Floor(Starting_On_Hand * On_Hand_Percent) + Contributing_On_Hand OnHand,
(Planned_Receipts * On_Order_Flag) + Contributing_On_Order PlannedReceipts,
Nvl(Shipment_Quantity, 0) ShipmentQuantity,
Decode(PSW_Flag, 0, 0, Distributed_Planned_Sales) DistributedPlannedSales,
Warehouse_Allocation, SS_SKU_Store_Week.ROWID
FROM SS_SKU,
SS_SKU_Store,
SS_SKU_Store_Week
WHERE SS_SKU.SKU = pSKU AND
SS_SKU.SKU = SS_SKU_store.SKU AND
SS_SKU_Store.Store_Num = pStore AND
SS_SKU_Store.SKU = SS_SKU_Store_Week.SKU AND
SS_SKU_Store.Store_Num = SS_SKU_Store_Week.Store_Num
ORDER BY Year_Week_Key;
Begin
vFirstWeek := True;
Open EOWOH_Cursor;
Loop
FETCH EOWOH_Cursor bulk collect
INTO vOnHand,
vPlannedReceipts,
vShipmentQuantity,
vPlannedSalesTW,
vWarehouseAllocation,
vRowID limit 100;
for i in 1..vRowId.count loop
begin
If vFirstWeek Then
vFirstWeek := False;
vLastWeekEndOfWeekOnHand(i) := vOnHand(i);
ElsIf vEndOfWeekOnHand > 0 Then
vLastWeekEndOfWeekOnHand(i) :=vEndOfWeekOnHand;
Else
vLastWeekEndOfWeekOnHand(i) := 0;
End If;
vEndOfWeekOnHand := vLastWeekEndOfWeekOnHand(i)
+ vPlannedReceipts(i)
+ vShipmentQuantity(i)
+ vWarehouseAllocation(i)
- vPlannedSalesTW(i);
v_total_EndOfWeekOnHand(i):=vEndOfWeekOnHand;
exception
when others then
null;
end;
End loop;
forall i in 1..vRowId.count
UPDATE SS_SKU_Store_Week
SET End_Of_Week_On_Hand =
v_total_EndOfWeekOnHand(i)
WHERE ROWID= vRowId(i);
Exit When EOWOH_Cursor%NotFound;
End Loop;
close EOWOH_Cursor;
Commit;
vForwardSales := 0;
v_idx :=1;
vRowId.delete;
vOnHand.delete;
OPEN OpportunityRating_Cursor;
LOOP
FETCH OpportunityRating_Cursor bulk collect into
vOpertunityRating,vOnHand, vdistributedSales,
vRowId limit 100;
FOR i in 1..vRowId.count LOOP
IF vOpertunityRating(i) Is Not Null Then
vOpRat(v_idx):=case vforwardsales
when 0 then 1
else Round(vOnHand(i)/ vForwardSales, 4)
end;
vRowId_1(v_idx) :=vRowId(i);
v_idx :=v_idx+1;
vForwardSales := 0;
END IF;
vForwardSales := vForwardSales + vdistributedSales(i);
END LOOP;
FORALL i in 1..vRowId_1.count
update SS_SKU_Store_Week
SET Opportunity_Rating = vOpRat(i)
Where ROWID= vRowId_1(i);
EXIT WHEN OpportunityRating_Cursor%NOTFOUND;
END LOOP;
CLOSE OpportunityRating_Cursor;
COMMIT;
Exception
When OTHERS Then
Null;
End SP_930_End_Of_Week_OH_up;
Do you have suggestion. -
PL/SQL cursor with FOR UPDATE STATEMENT
Welcome,
I have some troubles with cursors. When I try update values in table using cursor i receive ORA-01410 Error : "INVALID ROWID".
I use code as below:
ALTER SESSION SET CURRENT_SCHEMA=TEST_SCHEMA;
DECLARE
TYPE LogTable_typ IS TABLE OF ADMIN_FILE_LOG%ROWTYPE;
v_ModuleId KTIMS.ADMIN_FILE_LOG.MODULE_ID%TYPE;
v_CDR KTIMS.ADMIN_FILE_LOG.CDR_SUCCESS%TYPE;
CURSOR c1 IS
SELECT MODULE_ID, cdr_success FROM ADMIN_FILE_LOG
FOR UPDATE OF CDR_SUCCESS NOWAIT;
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO v_ModuleId,v_CDR;
IF v_ModuleId = 'LOAD' THEN
UPDATE ADMIN_FILE_LOG SET CDR_SUCCESS = 70 WHERE CURRENT OF c1;
END IF;
EXIT WHEN c1%NOTFOUND;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM || SQLCODE);
END;
When I use ROWID in cursor declaration all works fine.Working code is:
ALTER SESSION SET CURRENT_SCHEMA=KTIMS;
DECLARE
TYPE LogTable_typ IS TABLE OF ADMIN_FILE_LOG%ROWTYPE;
v_ModuleId KTIMS.ADMIN_FILE_LOG.MODULE_ID%TYPE;
v_CDR KTIMS.ADMIN_FILE_LOG.CDR_SUCCESS%TYPE;
v_id ROWID;
CURSOR c1 IS
SELECT MODULE_ID, cdr_success, ROWID FROM ADMIN_FILE_LOG
FOR UPDATE OF CDR_SUCCESS NOWAIT;
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO v_ModuleId,v_CDR,v_id;
IF v_ModuleId = 'LOAD' THEN
UPDATE ADMIN_FILE_LOG SET CDR_SUCCESS = 70 WHERE ROWID = v_id;
END IF;
EXIT WHEN c1%NOTFOUND;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM || SQLCODE);
END;
What is difference in this two cases ?
I try to find this in Oracle documentation "Database PL/SQL User's Guide and Reference" ( http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/sqloperations.htm#i45288 ).
Please help.Hi,
I think the USE of NOWAIT clause in cursor for update is, to remove the lock immediately after the transaction is over.
In the second example where you are fetching the rowid explicitly and use the same id in loop to make the update, so there should not be any problem in this case.
In the first example when you are using CURRENT OF to do the update, it is basically work on basis of latest fetched row from cursor and do the update (but i think implicitly it use the reference of row id also).
I am not sure about it , but still try once by removing the NOWAIT clause from your cursor for update and try once , see whether you are still facing the error or not. -
Error When try to use rowid with table alias
I tried to use table alias to test functions of rules manager and met the following problems.
1. I clone tables employees and departments from HR schema.
2. create event_struct as following:
BEGIN
dbms_rlmgr.create_event_struct(event_struct => 't_a');
dbms_rlmgr.add_elementary_attribute(event_struct => 't_a',
attr_name => 'a_employees',
tab_alias => exf$table_alias('employees'));
dbms_rlmgr.add_elementary_attribute(event_struct => 't_a',
attr_name => 'a_departments',
tab_alias => exf$table_alias('departments'));
END;
3. create rule class as following:
BEGIN
dbms_rlmgr.create_rule_class(rule_class => 't_as',
event_struct => 't_a',
action_cbk => 't_acb',
rslt_viewnm => 't_arv');
END;
4. after adding a rule to the rule class, I try to test as the following
DECLARE
r_emp ROWID;
r_dept ROWID;
CURSOR a_cur IS
SELECT emp.ROWID, dept.ROWID
FROM employees emp, departments dept
WHERE emp.department_id = dept.department_id;
i NUMBER := 1;
BEGIN
OPEN a_cur;
LOOP
FETCH a_cur
INTO r_emp, r_dept;
EXIT WHEN a_cur%NOTFOUND;
dbms_output.put_line(i);
i := i + 1;
dbms_output.put_line(r_emp);
dbms_rlmgr.add_event(rule_class => 't_alia',
event_inst => r_emp,
event_type => 'employees');
dbms_rlmgr.add_event(rule_class => 't_alia',
event_inst => r_dept,
event_type => 'departments');
END LOOP;
END;
But I got the following error
SQL> DECLARE
2 r_emp ROWID;
3 r_dept ROWID;
4 CURSOR a_cur IS
5 SELECT emp.ROWID, dept.ROWID
6 FROM employees emp, departments dept
7 WHERE emp.department_id = dept.department_id;
8 i NUMBER := 1;
9 BEGIN
10 OPEN a_cur;
11 LOOP
12 FETCH a_cur
13 INTO r_emp, r_dept;
14 EXIT WHEN a_cur%NOTFOUND;
15 dbms_output.put_line(i);
16 i := i + 1;
17 dbms_output.put_line(r_emp);
18 dbms_rlmgr.add_event(rule_class => 't_alia',
19 event_inst => r_emp,
20 event_type => 'employees');
21 dbms_rlmgr.add_event(rule_class => 't_alia',
22 event_inst => r_dept,
23 event_type => 'departments');
24 END LOOP;
25 END;
26 /
DECLARE
ERROR at line 1:
ORA-06550: line 1, column 36:
PLS-00201: identifier 'AAAVN9AAEAAAQH8AAA' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
ORA-06512: at "EXFSYS.DBMS_RLMGR", line 974
ORA-06512: at line 18Hello,
Rowids for the individual tables can be added as events only if the rule class is configured as a Composite one. For all other cases, rowids are treated just as data and they should be formatted as string of name-value pairs or instances of AnyData. Your script suggests that you intended to create a composite rule class so that you could add rowids individually. Please recreate the rule class as composite and try again. The error message you received is incorrect and has been fixed to indicate that the error is with the format of the data item passed in.
Hope this helps,
-Aravind. -
Using cursor to update column, is this inefficient or illegal?
I have declared a cursor as follows in a PL/SQL procedure:
cursor C is SELECT a FROM t
FOR UPDATE;
Later on in the procedure, I've written the following:
update t
set b = 'text'
where current of C;
My question is, am I allowed to do this when the column I am updating is not the one which I have selected in the cursor? If this is indeed legal, are there any performance issues involved?
Thanks,
PeterPeter,
As it is confirmed by our folks that it is LEGAL to update columns that are not
fetched in the CURSOR, I am just going to talk about other things.
CURSOR is a read only resultset in PL/SQL which just gives you a handle to each of the rows that you are fetching from one or more table(s), based on the columns that you select in CURSOR. It is advised that you select the ID columns of the table(s) like PK if available from those tables so that you would not run into updating rows more than what is actually required. If we are not fetching the rows based on UNIQUE value and we use these values in UPDATE statements inside, we may get into trouble. Alternative and proves very good with performance is ROWID. I have used ROWID in CURSOR fetches and it works great.DECLARE
CURSOR empCur IS
SELECT ROWID unique_col, ename, job, sal FROM EMP
WHERE sal > 1000;
BEGIN
FOR empRec IN empCUR
LOOP
UPDATE emp SET job = 'Tech Lead'
WHERE ROWID = empRec.unique_col;
END LOOP;
END;Andrew,
Just curious, could you educate me on MVP status from Brainbech?
Thx,
SriDHAR -
Hi all,
I am new to PL/SQL. I am getting the following errors during the runtime. Please help
OWNER: BANINST1 NAME: GOKINTL TYPE: PACKAGE BODY
LINE/COL ERROR
115/14 PLS-00323: subprogram or cursor 'P_GOBINTL_INSERT' is declared in
a package specification and must be defined in the package body
147/14 PLS-00323: subprogram or cursor 'P_GORDOCM_INSERT' is declared in
a package specification and must be defined in the package body
167/14 PLS-00323: subprogram or cursor 'P_GOBINTL_UPDATE_ROW' is
declared in a package specification and must be defined in the
package body
183/9 PL/SQL: SQL Statement ignored
183/9 PLS-00394: wrong number of values in the INTO list of a FETCH
statement
199/14 PLS-00323: subprogram or cursor 'P_GORDOCM_UPDATE_ROW' is
declared in a package specification and must be defined in the
package body
6 rows selected.
PL/SQL code:
/* Functions to determine whether international student */
/* or not. */
FUNCTION f_check_gobintl_exists
( pidm IN GOBINTL.GOBINTL_PIDM%TYPE)
RETURN VARCHAR2 IS
status VARCHAR2(1) := '';
chk_gobintl_tab VARCHAR2(1) := '';
CURSOR GOBINTL_C
IS
SELECT 'Y'
FROM GOBINTL
WHERE GOBINTL_PIDM = pidm;
BEGIN
OPEN GOBINTL_C;
FETCH GOBINTL_C INTO chk_gobintl_tab;
IF GOBINTL_C%NOTFOUND THEN
status := 'N';
ELSE
status := 'Y';
END IF;
CLOSE GOBINTL_C;
RETURN status;
END f_check_gobintl_exists;
/* Function to determine whether the student is a */
/* non-resident alien or not. */
FUNCTION f_check_nonresident_status(
pidm IN GORVISA.GORVISA_PIDM%TYPE,
input_date IN GORVISA.GORVISA_VISA_START_DATE%TYPE)
RETURN VARCHAR2
IS
status VARCHAR2(1) := '';
chk_non_resi_status VARCHAR2(1) := '';
CURSOR CHK_NONRESI_STATUS_C
IS
SELECT 'Y'
FROM GORVISA,
STVVTYP
WHERE STVVTYP_NON_RES_IND = 'Y'
AND GORVISA_VTYP_CODE = STVVTYP_CODE
AND GORVISA_PIDM = pidm
AND GORVISA_VISA_START_DATE <= TRUNC(input_date)
AND GORVISA_VISA_EXPIRE_DATE >= TRUNC(input_date);
BEGIN
OPEN CHK_NONRESI_STATUS_C;
FETCH CHK_NONRESI_STATUS_C INTO chk_non_resi_status;
IF CHK_NONRESI_STATUS_C%NOTFOUND THEN
status := 'N';
ELSE
status := 'Y';
END IF;
CLOSE CHK_NONRESI_STATUS_C;
RETURN status;
END f_check_nonresident_status;
/* Function to select a single row from gobintl table. */
FUNCTION f_gobintl_select
( pidm GOBINTL.GOBINTL_PIDM%TYPE)
RETURN GOBINTL%ROWTYPE
IS
gobintl_row GOBINTL%ROWTYPE;
CURSOR GOBINTL_C
IS
SELECT GOBINTL_PIDM,
GOBINTL_SPOUSE_IND,
GOBINTL_SIGNATURE_IND,
GOBINTL_USER_ID,
GOBINTL_ACTIVITY_DATE,
GOBINTL_PASSPORT_ID,
GOBINTL_NATN_CODE_ISSUE,
GOBINTL_PASSPORT_EXP_DATE,
GOBINTL_I94_STATUS ,
GOBINTL_I94_DATE,
GOBINTL_REG_NUMBER,
GOBINTL_DURATION,
GOBINTL_CELG_CODE,
GOBINTL_CERT_NUMBER ,
GOBINTL_CERT_DATE_ISSUE,
GOBINTL_CERT_DATE_RECEIPT,
GOBINTL_ADMR_CODE,
GOBINTL_NATN_CODE_BIRTH,
GOBINTL_NATN_CODE_LEGAL,
GOBINTL_LANG_CODE,
GOBINTL_SPON_CODE,
GOBINTL_EMPT_CODE,
GOBINTL_FOREIGN_SSN,
GOBINTL_CHILD_NUMBER,
GOBINTL_VPDI_CODE
FROM GOBINTL
WHERE GOBINTL_PIDM = pidm;
BEGIN
OPEN GOBINTL_C;
FETCH GOBINTL_C INTO gobintl_row;
CLOSE GOBINTL_C;
RETURN gobintl_row;
END f_gobintl_select;
/* Function to select a single row from gordocm table. */
FUNCTION f_gordocm_select
( pidm IN GORDOCM.GORDOCM_PIDM%TYPE,
seq_no IN GORDOCM.GORDOCM_SEQ_NO%TYPE,
vtyp_code IN GORDOCM.GORDOCM_VTYP_CODE%TYPE,
visa_number IN GORDOCM.GORDOCM_VISA_NUMBER%TYPE,
docm_code IN GORDOCM.GORDOCM_DOCM_CODE%TYPE)
RETURN GORDOCM%ROWTYPE
IS
gordocm_row GORDOCM%ROWTYPE;
CURSOR GORDOCM_C
IS
SELECT GORDOCM_PIDM ,
GORDOCM_SEQ_NO ,
GORDOCM_VTYP_CODE,
GORDOCM_VISA_NUMBER,
GORDOCM_DOCM_CODE,
GORDOCM_DISPOSITION ,
GORDOCM_USER_ID ,
GORDOCM_ACTIVITY_DATE ,
GORDOCM_SRCE_CODE ,
GORDOCM_REQUEST_DATE ,
GORDOCM_RECEIVED_DATE
FROM GORDOCM
WHERE GORDOCM_PIDM = pidm
AND GORDOCM_SEQ_NO = seq_no
AND GORDOCM_VTYP_CODE = vtyp_code
AND GORDOCM_VISA_NUMBER = visa_number
AND GORDOCM_DOCM_CODE = docm_code;
BEGIN
OPEN GORDOCM_C;
FETCH GORDOCM_C into gordocm_row;
CLOSE GORDOCM_C;
RETURN gordocm_row;
END f_gordocm_select;
/* Function to select the row id of the row for the */
/* given pidm from gobintl. */
FUNCTION f_get_gobintl_rowid
(pidm IN GOBINTL.GOBINTL_PIDM%TYPE )
RETURN ROWID
AS
gobintl_rowid rowid := null;
CURSOR get_gobintl is
SELECT rowid
FROM gobintl
WHERE gobintl_pidm = pidm;
BEGIN
OPEN get_gobintl;
FETCH get_gobintl INTO gobintl_rowid;
CLOSE get_gobintl;
RETURN gobintl_rowid;
END f_get_gobintl_rowid;
/* Function to select the row id of the row for the */
/* given pidm from gorvisa. */
FUNCTION f_get_gorvisa_rowid
(pidm IN GORVISA.GORVISA_PIDM%TYPE )
RETURN ROWID
AS
gorvisa_rowid rowid := null;
CURSOR get_gorvisa IS
SELECT rowid
FROM gorvisa
WHERE gorvisa_pidm = pidm
ORDER BY gorvisa_seq_no desc;
BEGIN
OPEN get_gorvisa;
FETCH get_gorvisa INTO gorvisa_rowid;
CLOSE get_gorvisa;
RETURN gorvisa_rowid;
END f_get_gorvisa_rowid;
-- new functions for OA to return visa and international data
FUNCTION f_gorvisa_value
(p_pidm IN SPRIDEN.SPRIDEN_PIDM%TYPE ,
p_return_value VARCHAR2)
RETURN VARCHAR2 IS
CURSOR get_gorvisa
IS
SELECT *
FROM gorvisa
WHERE gorvisa_pidm = p_pidm
ORDER BY gorvisa_seq_no DESC;
gorvisa_var NUMBER := 0;
BEGIN
IF gv_gorvisa_row.gorvisa_pidm is NULL or
gv_gorvisa_row.gorvisa_pidm <> p_pidm then
OPEN get_gorvisa;
FETCH get_gorvisa INTO gv_gorvisa_row;
IF get_gorvisa%NOTFOUND THEN
gorvisa_var :=1;
END IF;
CLOSE get_gorvisa;
end if;
IF gorvisa_var = 0 THEN
CASE p_return_value
WHEN 'N' THEN
RETURN gv_gorvisa_row.gorvisa_visa_number;
WHEN 'C' THEN
RETURN gv_gorvisa_row.gorvisa_vtyp_code;
ELSE
RETURN ' ';
END CASE;
END IF;
RETURN NULL;
END f_gorvisa_value;
FUNCTION f_gobintl_value
(p_pidm IN SPRIDEN.SPRIDEN_PIDM%TYPE ,
p_return_value VARCHAR2)
RETURN VARCHAR2 IS
CURSOR get_gobintl
IS
SELECT *
FROM gobintl
WHERE gobintl_pidm = p_pidm;
gobintl_var NUMBER := 0;
BEGIN
IF gv_gobintl_row.gobintl_pidm is NULL or
gv_gobintl_row.gobintl_pidm <> p_pidm then
OPEN get_gobintl;
FETCH get_gobintl INTO gv_gobintl_row;
IF get_gobintl%NOTFOUND THEN
gobintl_var := 1;
END IF;
CLOSE get_gobintl;
end if;
IF gobintl_var = 0 THEN
CASE p_return_value
WHEN 'B' THEN
RETURN gv_gobintl_row.gobintl_natn_code_birth;
WHEN 'L' THEN
RETURN gv_gobintl_row.gobintl_natn_code_legal;
ELSE
RETURN ' ';
END CASE;
END IF;
RETURN NULL;
END f_gobintl_value;
/* Procedure to insert a row into gobintl table. */
PROCEDURE p_gobintl_insert
( pidm IN GOBINTL.GOBINTL_PIDM%TYPE,
spouse_ind IN GOBINTL.GOBINTL_SPOUSE_IND%TYPE,
signature_ind IN GOBINTL.GOBINTL_SIGNATURE_IND%TYPE,
user_id IN GOBINTL.GOBINTL_USER_ID%TYPE,
activity_date IN GOBINTL.GOBINTL_ACTIVITY_DATE%TYPE,
passport_id IN GOBINTL.GOBINTL_PASSPORT_ID%TYPE,
natn_code_issue IN GOBINTL.GOBINTL_NATN_CODE_ISSUE%TYPE,
passport_exp_date IN GOBINTL.GOBINTL_PASSPORT_EXP_DATE%TYPE,
i94_status IN GOBINTL.GOBINTL_I94_STATUS%TYPE,
i94_date IN GOBINTL.GOBINTL_I94_DATE%TYPE,
reg_number IN GOBINTL.GOBINTL_REG_NUMBER%TYPE,
duration IN GOBINTL.GOBINTL_DURATION%TYPE,
celg_code IN GOBINTL.GOBINTL_CELG_CODE%TYPE,
cert_number IN GOBINTL.GOBINTL_CERT_NUMBER%TYPE,
cert_date_issue IN GOBINTL.GOBINTL_CERT_DATE_ISSUE%TYPE,
cert_date_receipt IN GOBINTL.GOBINTL_CERT_DATE_RECEIPT%TYPE,
admr_code IN GOBINTL.GOBINTL_ADMR_CODE%TYPE,
natn_code_birth IN GOBINTL.GOBINTL_NATN_CODE_BIRTH%TYPE,
natn_code_legal IN GOBINTL.GOBINTL_NATN_CODE_LEGAL%TYPE,
lang_code IN GOBINTL.GOBINTL_LANG_CODE%TYPE,
spon_code IN GOBINTL.GOBINTL_SPON_CODE%TYPE,
empt_code IN GOBINTL.GOBINTL_EMPT_CODE%TYPE,
foreign_ssn IN GOBINTL.GOBINTL_FOREIGN_SSN%TYPE,
child_number IN GOBINTL.GOBINTL_CHILD_NUMBER%TYPE,
vpdi IN GOBINTL.GOBINTL_VPDI_CODE%TYPE
IS
BEGIN
INSERT INTO GOBINTL
( GOBINTL_PIDM,
GOBINTL_SPOUSE_IND,
GOBINTL_SIGNATURE_IND,
GOBINTL_USER_ID,
GOBINTL_ACTIVITY_DATE,
GOBINTL_PASSPORT_ID,
GOBINTL_NATN_CODE_ISSUE,
GOBINTL_PASSPORT_EXP_DATE,
GOBINTL_I94_STATUS,
GOBINTL_I94_DATE,
GOBINTL_REG_NUMBER,
GOBINTL_DURATION,
GOBINTL_CELG_CODE,
GOBINTL_CERT_NUMBER,
GOBINTL_CERT_DATE_ISSUE,
GOBINTL_CERT_DATE_RECEIPT,
GOBINTL_ADMR_CODE,
GOBINTL_NATN_CODE_BIRTH,
GOBINTL_NATN_CODE_LEGAL,
GOBINTL_LANG_CODE,
GOBINTL_SPON_CODE,
GOBINTL_EMPT_CODE,
GOBINTL_FOREIGN_SSN,
GOBINTL_CHILD_NUMBER,
GOBINTL_VPDI_CODE
VALUES
( pidm,
NVL(spouse_ind,'T'),
NVL(signature_ind,'T'),
user_id,
activity_date,
passport_id,
natn_code_issue,
passport_exp_date,
i94_status,
i94_date,
reg_number,
duration,
celg_code,
cert_number,
cert_date_issue,
cert_date_receipt,
admr_code,
natn_code_birth,
natn_code_legal,
lang_code,
spon_code,
empt_code,
foreign_ssn,
child_number,
'SV'
END p_gobintl_insert;
/* Procedure to insert a row into gordocm table. */
PROCEDURE p_gordocm_insert
pidm IN GORDOCM.GORDOCM_PIDM%TYPE,
seq_no IN GORDOCM.GORDOCM_SEQ_NO%TYPE,
vtyp_code IN GORDOCM.GORDOCM_VTYP_CODE%TYPE,
visa_number IN GORDOCM.GORDOCM_VISA_NUMBER%TYPE,
docm_code IN GORDOCM.GORDOCM_DOCM_CODE%TYPE,
disposition IN GORDOCM.GORDOCM_DISPOSITION%TYPE,
user_id IN GORDOCM.GORDOCM_USER_ID%TYPE,
activity_date IN GORDOCM.GORDOCM_ACTIVITY_DATE%TYPE,
srce_code IN GORDOCM.GORDOCM_SRCE_CODE%TYPE,
request_date IN GORDOCM.GORDOCM_REQUEST_DATE%TYPE,
received_date IN GORDOCM.GORDOCM_RECEIVED_DATE%TYPE,
vpdi_gordocm IN GORDOCM.GORDOCM_VPDI_CODE%TYPE
IS
BEGIN
INSERT INTO GORDOCM
( GORDOCM_PIDM,
GORDOCM_SEQ_NO,
GORDOCM_VTYP_CODE,
GORDOCM_VISA_NUMBER,
GORDOCM_DOCM_CODE,
GORDOCM_DISPOSITION,
GORDOCM_USER_ID,
GORDOCM_ACTIVITY_DATE,
GORDOCM_SRCE_CODE,
GORDOCM_REQUEST_DATE,
GORDOCM_RECEIVED_DATE,
GORDOCM_VPDI_CODE
VALUES
( pidm,
seq_no,
vtyp_code,
visa_number,
docm_code,
disposition,
user_id,
activity_date,
srce_code,
request_date,
received_date,
'SV'
END p_gordocm_insert;
/* Procedure to update a row in gobintl table. */
PROCEDURE p_gobintl_update_row
( pidm IN GOBINTL.GOBINTL_PIDM%TYPE,
spouse_ind IN GOBINTL.GOBINTL_SPOUSE_IND%TYPE,
signature_ind IN GOBINTL.GOBINTL_SIGNATURE_IND%TYPE,
user_id IN GOBINTL.GOBINTL_USER_ID%TYPE,
activity_date IN GOBINTL.GOBINTL_ACTIVITY_DATE%TYPE,
passport_id IN GOBINTL.GOBINTL_PASSPORT_ID%TYPE,
natn_code_issue IN GOBINTL.GOBINTL_NATN_CODE_ISSUE%TYPE,
passport_exp_date IN GOBINTL.GOBINTL_PASSPORT_EXP_DATE%TYPE,
i94_status IN GOBINTL.GOBINTL_I94_STATUS%TYPE,
i94_date IN GOBINTL.GOBINTL_I94_DATE%TYPE,
reg_number IN GOBINTL.GOBINTL_REG_NUMBER%TYPE,
duration IN GOBINTL.GOBINTL_DURATION%TYPE,
celg_code IN GOBINTL.GOBINTL_CELG_CODE%TYPE,
cert_number IN GOBINTL.GOBINTL_CERT_NUMBER%TYPE,
cert_date_issue IN GOBINTL.GOBINTL_CERT_DATE_ISSUE%TYPE,
cert_date_receipt IN GOBINTL.GOBINTL_CERT_DATE_RECEIPT%TYPE,
admr_code IN GOBINTL.GOBINTL_ADMR_CODE%TYPE,
natn_code_birth IN GOBINTL.GOBINTL_NATN_CODE_BIRTH%TYPE,
natn_code_legal IN GOBINTL.GOBINTL_NATN_CODE_LEGAL%TYPE,
lang_code IN GOBINTL.GOBINTL_LANG_CODE%TYPE,
spon_code IN GOBINTL.GOBINTL_SPON_CODE%TYPE,
empt_code IN GOBINTL.GOBINTL_EMPT_CODE%TYPE,
foreign_ssn IN GOBINTL.GOBINTL_FOREIGN_SSN%TYPE,
child_number IN GOBINTL.GOBINTL_CHILD_NUMBER%TYPE,
vpdi IN GOBINTL.GOBINTL_VPDI_CODE%TYPE
IS
BEGIN
UPDATE GOBINTL
SET GOBINTL_SPOUSE_IND = spouse_ind,
GOBINTL_SIGNATURE_IND = signature_ind,
GOBINTL_USER_ID = user_id,
GOBINTL_ACTIVITY_DATE = activity_date,
GOBINTL_PASSPORT_ID = passport_id,
GOBINTL_NATN_CODE_ISSUE = natn_code_issue,
GOBINTL_PASSPORT_EXP_DATE = passport_exp_date,
GOBINTL_I94_STATUS = i94_status,
GOBINTL_I94_DATE = i94_date,
GOBINTL_REG_NUMBER = reg_number,
GOBINTL_DURATION = duration,
GOBINTL_CELG_CODE = celg_code,
GOBINTL_CERT_NUMBER = cert_number,
GOBINTL_CERT_DATE_ISSUE = cert_date_issue,
GOBINTL_CERT_DATE_RECEIPT = cert_date_receipt,
GOBINTL_ADMR_CODE = admr_code,
GOBINTL_NATN_CODE_BIRTH = natn_code_birth,
GOBINTL_NATN_CODE_LEGAL = natn_code_legal,
GOBINTL_LANG_CODE = lang_code,
GOBINTL_SPON_CODE = spon_code,
GOBINTL_EMPT_CODE = empt_code,
GOBINTL_FOREIGN_SSN = foreign_ssn,
GOBINTL_CHILD_NUMBER = child_number,
GOBINTL_VPDI_CODE = 'SV'
WHERE GOBINTL_PIDM = pidm;
END p_gobintl_update_row;
/* Procedure to update a row in gordocm table. */
PROCEDURE p_gordocm_update_row
pidm IN GORDOCM.GORDOCM_PIDM%TYPE,
seq_no IN GORDOCM.GORDOCM_SEQ_NO%TYPE,
vtyp_code IN GORDOCM.GORDOCM_VTYP_CODE%TYPE,
visa_number IN GORDOCM.GORDOCM_VISA_NUMBER%TYPE,
docm_code IN GORDOCM.GORDOCM_DOCM_CODE%TYPE,
disposition IN GORDOCM.GORDOCM_DISPOSITION%TYPE,
user_id IN GORDOCM.GORDOCM_USER_ID%TYPE,
activity_date IN GORDOCM.GORDOCM_ACTIVITY_DATE%TYPE,
srce_code IN GORDOCM.GORDOCM_SRCE_CODE%TYPE,
request_date IN GORDOCM.GORDOCM_REQUEST_DATE%TYPE,
received_date IN GORDOCM.GORDOCM_RECEIVED_DATE%TYPE,
vpdi_gordocm IN GORDOCM.GORDOCM_VPDI_CODE%TYPE
IS
BEGIN
UPDATE GORDOCM
SET GORDOCM_DISPOSITION = disposition,
GORDOCM_USER_ID = user_id,
GORDOCM_ACTIVITY_DATE = activity_date,
GORDOCM_SRCE_CODE = srce_code,
GORDOCM_REQUEST_DATE = request_date,
GORDOCM_RECEIVED_DATE = received_date,
GORDOCM_VPDI_CODE = vpdi_gordocm
WHERE GORDOCM_PIDM = pidm
AND GORDOCM_SEQ_NO = seq_no
AND GORDOCM_VTYP_CODE = vtyp_code
AND GORDOCM_VISA_NUMBER = visa_number
AND GORDOCM_DOCM_CODE = docm_code;
END p_gordocm_update_row;
/* Procedure to delete a row from gobintl table. */
PROCEDURE p_gobintl_delete_row
pidm IN GOBINTL.GOBINTL_PIDM%TYPE
IS
BEGIN
DELETE
FROM GOBINTL
WHERE GOBINTL_PIDM = pidm;
END p_gobintl_delete_row;
/* Procedure to delete a row from gordocm table. */
PROCEDURE p_gordocm_delete_row
pidm IN GORDOCM.GORDOCM_PIDM%TYPE,
seq_no IN GORDOCM.GORDOCM_SEQ_NO%TYPE,
vtyp_code IN GORDOCM.GORDOCM_VTYP_CODE%TYPE,
visa_number IN GORDOCM.GORDOCM_VISA_NUMBER%TYPE,
docm_code IN GORDOCM.GORDOCM_DOCM_CODE%TYPE
IS
BEGIN
DELETE
FROM GORDOCM
WHERE GORDOCM_PIDM = pidm
AND GORDOCM_SEQ_NO = seq_no
AND GORDOCM_VTYP_CODE = vtyp_code
AND GORDOCM_VISA_NUMBER = visa_number
AND GORDOCM_DOCM_CODE = docm_code;
END p_gordocm_delete_row;
END GOKINTL;
/Hello,
Create a package specifiction see following example and add just defintions or all the function and procedure
CREATE OR REPLACE PACKAGE gokintl
AS
PROCEDURE item_logging;
FUNCTION get_sys_parms (i_parameter IN VARCHAR2)
RETURN VARCHAR2;
END gokintl;
/Then package body, I have comment FIX THIS SOMETHING WRONG take a look and fix your logic
CREATE OR REPLACE PACKAGE BODY gokintl
AS
FUNCTION f_check_gobintl_exists (pidm IN gobintl.gobintl_pidm%TYPE)
RETURN VARCHAR2
IS
status VARCHAR2 (1) := '';
chk_gobintl_tab VARCHAR2 (1) := '';
CURSOR gobintl_c
IS
SELECT 'Y'
FROM gobintl
WHERE gobintl_pidm = pidm;
BEGIN
OPEN gobintl_c;
FETCH gobintl_c INTO chk_gobintl_tab;
IF gobintl_c%NOTFOUND
THEN
status := 'N';
ELSE
status := 'Y';
END IF;
CLOSE gobintl_c;
RETURN status;
END f_check_gobintl_exists;
/* Function to determine whether the student is a */
/* non-resident alien or not. */
FUNCTION f_check_nonresident_status (pidm IN gorvisa.gorvisa_pidm%TYPE,
input_date IN gorvisa.gorvisa_visa_start_date%TYPE
RETURN VARCHAR2
IS
status VARCHAR2 (1) := '';
chk_non_resi_status VARCHAR2 (1) := '';
CURSOR chk_nonresi_status_c
IS
SELECT 'Y'
FROM gorvisa, stvvtyp
WHERE stvvtyp_non_res_ind = 'Y'
AND gorvisa_vtyp_code = stvvtyp_code
AND gorvisa_pidm = pidm
AND gorvisa_visa_start_date <= TRUNC (input_date)
AND gorvisa_visa_expire_date >= TRUNC (input_date);
BEGIN
OPEN chk_nonresi_status_c;
FETCH chk_nonresi_status_c INTO chk_non_resi_status;
IF chk_nonresi_status_c%NOTFOUND
THEN
status := 'N';
ELSE
status := 'Y';
END IF;
CLOSE chk_nonresi_status_c;
RETURN status;
END f_check_nonresident_status;
/* Function to select a single row from gobintl table. */
FUNCTION f_gobintl_select (pidm gobintl.gobintl_pidm%TYPE)
RETURN gobintl%ROWTYPE
IS
gobintl_row gobintl%ROWTYPE;
CURSOR gobintl_c
IS
SELECT gobintl_pidm,
gobintl_spouse_ind,
gobintl_signature_ind,
gobintl_user_id,
gobintl_activity_date,
gobintl_passport_id,
gobintl_natn_code_issue,
gobintl_passport_exp_date,
gobintl_i94_status,
gobintl_i94_date,
gobintl_reg_number,
gobintl_duration,
gobintl_celg_code,
gobintl_cert_number,
gobintl_cert_date_issue,
gobintl_cert_date_receipt,
gobintl_admr_code,
gobintl_natn_code_birth,
gobintl_natn_code_legal,
gobintl_lang_code,
gobintl_spon_code,
gobintl_empt_code,
gobintl_foreign_ssn,
gobintl_child_number,
gobintl_vpdi_code
FROM gobintl
WHERE gobintl_pidm = pidm;
BEGIN
OPEN gobintl_c;
FETCH gobintl_c INTO gobintl_row;
CLOSE gobintl_c;
RETURN gobintl_row;
END f_gobintl_select;
/* Function to select a single row from gordocm table. */
FUNCTION f_gordocm_select (pidm IN gordocm.gordocm_pidm%TYPE,
seq_no IN gordocm.gordocm_seq_no%TYPE,
vtyp_code IN gordocm.gordocm_vtyp_code%TYPE,
visa_number IN gordocm.gordocm_visa_number%TYPE,
docm_code IN gordocm.gordocm_docm_code%TYPE
RETURN gordocm%ROWTYPE
IS
gordocm_row gordocm%ROWTYPE;
CURSOR gordocm_c
IS
SELECT gordocm_pidm,
gordocm_seq_no,
gordocm_vtyp_code,
gordocm_visa_number,
gordocm_docm_code,
gordocm_disposition,
gordocm_user_id,
gordocm_activity_date,
gordocm_srce_code,
gordocm_request_date,
gordocm_received_date
FROM gordocm
WHERE gordocm_pidm = pidm
AND gordocm_seq_no = seq_no
AND gordocm_vtyp_code = vtyp_code
AND gordocm_visa_number = visa_number
AND gordocm_docm_code = docm_code;
BEGIN
OPEN gordocm_c;
FETCH gordocm_c INTO gordocm_row;
CLOSE gordocm_c;
RETURN gordocm_row;
END f_gordocm_select;
/* Function to select the row id of the row for the */
/* given pidm from gobintl. */
FUNCTION f_get_gobintl_rowid (pidm IN gobintl.gobintl_pidm%TYPE)
RETURN ROWID
AS
gobintl_rowid ROWID := NULL;
CURSOR get_gobintl
IS
SELECT ROWID
FROM gobintl
WHERE gobintl_pidm = pidm;
BEGIN
OPEN get_gobintl;
FETCH get_gobintl INTO gobintl_rowid;
CLOSE get_gobintl;
RETURN gobintl_rowid;
END f_get_gobintl_rowid;
/* Function to select the row id of the row for the */
/* given pidm from gorvisa. */
FUNCTION f_get_gorvisa_rowid (pidm IN gorvisa.gorvisa_pidm%TYPE)
RETURN ROWID
AS
gorvisa_rowid ROWID := NULL;
CURSOR get_gorvisa
IS
SELECT ROWID
FROM gorvisa
WHERE gorvisa_pidm = pidm
ORDER BY gorvisa_seq_no DESC;
BEGIN
OPEN get_gorvisa;
FETCH get_gorvisa INTO gorvisa_rowid;
CLOSE get_gorvisa;
RETURN gorvisa_rowid;
END f_get_gorvisa_rowid;
-- new functions for OA to return visa and international data
FUNCTION f_gorvisa_value (p_pidm IN spriden.spriden_pidm%TYPE,
p_return_value varchar2
RETURN VARCHAR2
IS
CURSOR get_gorvisa
IS
SELECT *
FROM gorvisa
WHERE gorvisa_pidm = p_pidm
ORDER BY gorvisa_seq_no DESC;
gorvisa_var NUMBER := 0;
BEGIN
IF (gv_gorvisa_row.gorvisa_pidm IS NULL
OR gv_gorvisa_row.gorvisa_pidm = p_pidm) --- FIX THIS SOMETHIGNG WRONG HERE
THEN
OPEN get_gorvisa;
FETCH get_gorvisa INTO gv_gorvisa_row;
IF get_gorvisa%NOTFOUND
THEN
gorvisa_var := 1;
END IF;
CLOSE get_gorvisa;
END IF;
IF gorvisa_var = 0
THEN
CASE p_return_value
WHEN 'N'
THEN
RETURN gv_gorvisa_row.gorvisa_visa_number;
WHEN 'C'
THEN
RETURN gv_gorvisa_row.gorvisa_vtyp_code;
ELSE
RETURN ' ';
END CASE;
END IF;
RETURN NULL;
END f_gorvisa_value;
FUNCTION f_gobintl_value (p_pidm IN spriden.spriden_pidm%TYPE,
p_return_value varchar2
RETURN VARCHAR2
IS
CURSOR get_gobintl
IS
SELECT *
FROM gobintl
WHERE gobintl_pidm = p_pidm;
gobintl_var NUMBER := 0;
BEGIN
IF gv_gobintl_row.gobintl_pidm IS NULL
OR gv_gobintl_row.gobintl_pidm = p_pidm -- FIX THIS SOMETHIGNG WRONG HERE
THEN
OPEN get_gobintl;
FETCH get_gobintl INTO gv_gobintl_row;
IF get_gobintl%NOTFOUND
THEN
gobintl_var := 1;
END IF;
CLOSE get_gobintl;
END IF;
IF gobintl_var = 0
THEN
CASE p_return_value
WHEN 'B'
THEN
RETURN gv_gobintl_row.gobintl_natn_code_birth;
WHEN 'L'
THEN
RETURN gv_gobintl_row.gobintl_natn_code_legal;
ELSE
RETURN ' ';
END CASE;
END IF;
RETURN NULL;
END f_gobintl_value;
/* Procedure to insert a row into gobintl table. */
PROCEDURE p_gobintl_insert (pidm IN gobintl.gobintl_pidm%TYPE,
spouse_ind IN gobintl.gobintl_spouse_ind%TYPE,
signature_ind IN gobintl.gobintl_signature_ind%TYPE,
user_id IN gobintl.gobintl_user_id%TYPE,
activity_date IN gobintl.gobintl_activity_date%TYPE,
passport_id IN gobintl.gobintl_passport_id%TYPE,
natn_code_issue IN gobintl.gobintl_natn_code_issue%TYPE,
passport_exp_date IN gobintl.gobintl_passport_exp_date%TYPE,
i94_status IN gobintl.gobintl_i94_status%TYPE,
i94_date IN gobintl.gobintl_i94_date%TYPE,
reg_number IN gobintl.gobintl_reg_number%TYPE,
duration IN gobintl.gobintl_duration%TYPE,
celg_code IN gobintl.gobintl_celg_code%TYPE,
cert_number IN gobintl.gobintl_cert_number%TYPE,
cert_date_issue IN gobintl.gobintl_cert_date_issue%TYPE,
cert_date_receipt IN gobintl.gobintl_cert_date_receipt%TYPE,
admr_code IN gobintl.gobintl_admr_code%TYPE,
natn_code_birth IN gobintl.gobintl_natn_code_birth%TYPE,
natn_code_legal IN gobintl.gobintl_natn_code_legal%TYPE,
lang_code IN gobintl.gobintl_lang_code%TYPE,
spon_code IN gobintl.gobintl_spon_code%TYPE,
empt_code IN gobintl.gobintl_empt_code%TYPE,
foreign_ssn IN gobintl.gobintl_foreign_ssn%TYPE,
child_number IN gobintl.gobintl_child_number%TYPE,
vpdi IN gobintl.gobintl_vpdi_code%TYPE
IS
BEGIN
INSERT INTO gobintl
gobintl_pidm,
gobintl_spouse_ind,
gobintl_signature_ind,
gobintl_user_id,
gobintl_activity_date,
gobintl_passport_id,
gobintl_natn_code_issue,
gobintl_passport_exp_date,
gobintl_i94_status,
gobintl_i94_date,
gobintl_reg_number,
gobintl_duration,
gobintl_celg_code,
gobintl_cert_number,
gobintl_cert_date_issue,
gobintl_cert_date_receipt,
gobintl_admr_code,
gobintl_natn_code_birth,
gobintl_natn_code_legal,
gobintl_lang_code,
gobintl_spon_code,
gobintl_empt_code,
gobintl_foreign_ssn,
gobintl_child_number,
gobintl_vpdi_code
VALUES (
pidm,
NVL (spouse_ind, 'T'),
NVL (signature_ind, 'T'),
user_id,
activity_date,
passport_id,
natn_code_issue,
passport_exp_date,
i94_status,
i94_date,
reg_number,
duration,
celg_code,
cert_number,
cert_date_issue,
cert_date_receipt,
admr_code,
natn_code_birth,
natn_code_legal,
lang_code,
spon_code,
empt_code,
foreign_ssn,
child_number,
'SV'
END p_gobintl_insert;
/* Procedure to insert a row into gordocm table. */
PROCEDURE p_gordocm_insert (pidm IN gordocm.gordocm_pidm%TYPE,
seq_no IN gordocm.gordocm_seq_no%TYPE,
vtyp_code IN gordocm.gordocm_vtyp_code%TYPE,
visa_number IN gordocm.gordocm_visa_number%TYPE,
docm_code IN gordocm.gordocm_docm_code%TYPE,
disposition IN gordocm.gordocm_disposition%TYPE,
user_id IN gordocm.gordocm_user_id%TYPE,
activity_date IN gordocm.gordocm_activity_date%TYPE,
srce_code IN gordocm.gordocm_srce_code%TYPE,
request_date IN gordocm.gordocm_request_date%TYPE,
received_date IN gordocm.gordocm_received_date%TYPE,
vpdi_gordocm IN gordocm.gordocm_vpdi_code%TYPE
IS
BEGIN
INSERT INTO gordocm
gordocm_pidm,
gordocm_seq_no,
gordocm_vtyp_code,
gordocm_visa_number,
gordocm_docm_code,
gordocm_disposition,
gordocm_user_id,
gordocm_activity_date,
gordocm_srce_code,
gordocm_request_date,
gordocm_received_date,
gordocm_vpdi_code
VALUES (
pidm,
seq_no,
vtyp_code,
visa_number,
docm_code,
disposition,
user_id,
activity_date,
srce_code,
request_date,
received_date,
'SV'
END p_gordocm_insert;
/* Procedure to update a row in gobintl table. */
PROCEDURE p_gobintl_update_row (pidm IN gobintl.gobintl_pidm%TYPE,
spouse_ind IN gobintl.gobintl_spouse_ind%TYPE,
signature_ind IN gobintl.gobintl_signature_ind%TYPE,
user_id IN gobintl.gobintl_user_id%TYPE,
activity_date IN gobintl.gobintl_activity_date%TYPE,
passport_id IN gobintl.gobintl_passport_id%TYPE,
natn_code_issue IN gobintl.gobintl_natn_code_issue%TYPE,
passport_exp_date IN gobintl.gobintl_passport_exp_date%TYPE,
i94_status IN gobintl.gobintl_i94_status%TYPE,
i94_date IN gobintl.gobintl_i94_date%TYPE,
reg_number IN gobintl.gobintl_reg_number%TYPE,
duration IN gobintl.gobintl_duration%TYPE,
celg_code IN gobintl.gobintl_celg_code%TYPE,
cert_number IN gobintl.gobintl_cert_number%TYPE,
cert_date_issue IN gobintl.gobintl_cert_date_issue%TYPE,
cert_date_receipt IN gobintl.gobintl_cert_date_receipt%TYPE,
admr_code IN gobintl.gobintl_admr_code%TYPE,
natn_code_birth IN gobintl.gobintl_natn_code_birth%TYPE,
natn_code_legal IN gobintl.gobintl_natn_code_legal%TYPE,
lang_code IN gobintl.gobintl_lang_code%TYPE,
spon_code IN gobintl.gobintl_spon_code%TYPE,
empt_code IN gobintl.gobintl_empt_code%TYPE,
foreign_ssn IN gobintl.gobintl_foreign_ssn%TYPE,
child_number IN gobintl.gobintl_child_number%TYPE,
vpdi IN gobintl.gobintl_vpdi_code%TYPE
IS
BEGIN
UPDATE gobintl
SET gobintl_spouse_ind = spouse_ind,
gobintl_signature_ind = signature_ind,
gobintl_user_id = user_id,
gobintl_activity_date = activity_date,
gobintl_passport_id = passport_id,
gobintl_natn_code_issue = natn_code_issue,
gobintl_passport_exp_date = passport_exp_date,
gobintl_i94_status = i94_status,
gobintl_i94_date = i94_date,
gobintl_reg_number = reg_number,
gobintl_duration = duration,
gobintl_celg_code = celg_code,
gobintl_cert_number = cert_number,
gobintl_cert_date_issue = cert_date_issue,
gobintl_cert_date_receipt = cert_date_receipt,
gobintl_admr_code = admr_code,
gobintl_natn_code_birth = natn_code_birth,
gobintl_natn_code_legal = natn_code_legal,
gobintl_lang_code = lang_code,
gobintl_spon_code = spon_code,
gobintl_empt_code = empt_code,
gobintl_foreign_ssn = foreign_ssn,
gobintl_child_number = child_number,
gobintl_vpdi_code = 'SV'
WHERE gobintl_pidm = pidm;
END p_gobintl_update_row;
/* Procedure to update a row in gordocm table. */
PROCEDURE p_gordocm_update_row (pidm IN gordocm.gordocm_pidm%TYPE,
seq_no IN gordocm.gordocm_seq_no%TYPE,
vtyp_code IN gordocm.gordocm_vtyp_code%TYPE,
visa_number IN gordocm.gordocm_visa_number%TYPE,
docm_code IN gordocm.gordocm_docm_code%TYPE,
disposition IN gordocm.gordocm_disposition%TYPE,
user_id IN gordocm.gordocm_user_id%TYPE,
activity_date IN gordocm.gordocm_activity_date%TYPE,
srce_code IN gordocm.gordocm_srce_code%TYPE,
request_date IN gordocm.gordocm_request_date%TYPE,
received_date IN gordocm.gordocm_received_date%TYPE,
vpdi_gordocm IN gordocm.gordocm_vpdi_code%TYPE
IS
BEGIN
UPDATE gordocm
SET gordocm_disposition = disposition,
gordocm_user_id = user_id,
gordocm_activity_date = activity_date,
gordocm_srce_code = srce_code,
gordocm_request_date = request_date,
gordocm_received_date = received_date,
gordocm_vpdi_code = vpdi_gordocm
WHERE gordocm_pidm = pidm
AND gordocm_seq_no = seq_no
AND gordocm_vtyp_code = vtyp_code
AND gordocm_visa_number = visa_number
AND gordocm_docm_code = docm_code;
END p_gordocm_update_row;
/* Procedure to delete a row from gobintl table. */
PROCEDURE p_gobintl_delete_row (pidm IN gobintl.gobintl_pidm%TYPE)
IS
BEGIN
DELETE FROM gobintl
WHERE gobintl_pidm = pidm;
END p_gobintl_delete_row;
/* Procedure to delete a row from gordocm table. */
PROCEDURE p_gordocm_delete_row (pidm IN gordocm.gordocm_pidm%TYPE,
seq_no IN gordocm.gordocm_seq_no%TYPE,
vtyp_code IN gordocm.gordocm_vtyp_code%TYPE,
visa_number IN gordocm.gordocm_visa_number%TYPE,
docm_code IN gordocm.gordocm_docm_code%TYPE
IS
BEGIN
DELETE FROM gordocm
WHERE gordocm_pidm = pidm
AND gordocm_seq_no = seq_no
AND gordocm_vtyp_code = vtyp_code
AND gordocm_visa_number = visa_number
AND gordocm_docm_code = docm_code;
END p_gordocm_delete_row;
END gokintl;
/Regards -
hi ,
below query taking lot of time,can anybody help me tune the query.My db version is oracle 9.2
explain plan for select MRH_MRN,DECODE(MRH_SEX,'M','MALE','FEMALE') AS SEX, trim((mrh_sur_name||' '||mrh_first_name||' '||mrh_middle_name)) as MEMNAME, decode(nvl(mrh_fellow_status_yn,'333'),'Y','FCA','ACA')
AS ACA_FCA, DECODE(MRH_RESI_STATUS,'I',MRH_PROF_ADDR_LINE_1,'A',MRH_RES_ADDR_LINE_1) AS L_ADD1, DECODE(MRH_RESI_STATUS,'I',MRH_PROF_ADDR_LINE_2,'A',MRH_RES_ADDR_LINE_2) AS L_ADD2, DECODE(MRH_RESI_STATUS,'I',MRH_PROF_ADDR_LINE_3,'A',MRH_RES_ADDR_LINE_3) AS L_ADD3, DECODE(MRH_RESI_STATUS,'I',MRH_PROF_ADDR_LINE_4,'A',
MRH_RES_ADDR_LINE_4) AS L_ADD4, DECODE(MRH_RESI_STATUS,'I',a.city_name,'A',C.CITY_NAME) AS L_CITY, DECODE(MRH_RESI_STATUS,'I',MRH_PROF_ZIP_POSTAL_CODE,'A',MRH_RES_ZIP_POSTAL_CODE) AS L_PIN, DECODE
(MRH_RESI_STATUS,'I',b.cou_name,'A',D.COU_NAME) as L_Country, DECODE(MRH_RESI_STATUS,'I','NOT APPLICABLE',MRH_PROF_ADDR_LINE_1) AS R_ADD1, DECODE(MRH_RESI_STATUS,'I',' ',MRH_PROF_ADDR_LINE_2)
AS R_ADD2, DECODE(MRH_RESI_STATUS,'I',' ',MRH_PROF_ADDR_LINE_3) AS R_ADD3, DECODE(MRH_RESI_STATUS,'I',' ',MRH_PROF_ADDR_LINE_4) AS R_ADD4, DECODE(MRH_RESI_STATUS,'I',' ','A',A.CITY_NAME) AS R_CITY, DECODE(MRH_RESI_STATUS,'I',' ','A',
MRH_PROF_ZIP_POSTAL_CODE) AS R_PIN, DECODE(MRH_RESI_STATUS,'I',' ','A',B.COU_NAME) as R_Country, decode(nvl(mrh_mem_sub_status,'555'),'26','EXPIRED','') as sub_status, decode(nvl(mrh_mem_status,'777'),'1','ACTIVE',
'2','REMOVED') as mem_status,mrh_resi_status, DECODE(MRH_COP_STATUS,'1',DECODE(MRH_COP_TYPE ,'13','FULLTIME-COP','1','FULLTIME-COP', '12','PARTTIME-COP','2','PARTTIME-COP'),'NOT HOLDING COP')
AS COP_STATUS, TO_CHAR(MRH_ENROL_DT,'RRRR') AS ASSO_YR,TO_CHAR(MRH_FELLOW_DT,'RRRR') AS FELLOW_YR from om_mem_reg_head,om_city A,om_country B,om_city C,om_country D where mrh_doc_status=5 and mrh_prof_city_code=A.City_code(+) and mrh_prof_cou_code=
B.cou_code(+) and mrh_res_city_code=C.City_code(+) and mrh_res_cou_code=D.cou_code(+) and trim((mrh_sur_name||' '||mrh_first_name||''||mrh_middle_name)) like upper('%%') ORDER BY trim((mrh_sur_name||' '||mrh_first_name||' '||mrh_middle_name))
SQL> select * from table(dbms_xplan.display());
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost
|
| 0 | SELECT STATEMENT | | 2863 | 684K| | 201
PLAN_TABLE_OUTPUT
6 |
| 1 | SORT ORDER BY | | 2863 | 684K| 1496K| 201
6 |
| 2 | NESTED LOOPS OUTER | | 2863 | 684K| | 190
0 |
| 3 | NESTED LOOPS OUTER | | 2863 | 637K| | 190
0 |
PLAN_TABLE_OUTPUT
| 4 | HASH JOIN OUTER | | 2863 | 589K| | 190
0 |
| 5 | HASH JOIN OUTER | | 2863 | 545K| | 189
1 |
| 6 | TABLE ACCESS FULL| OM_MEM_REG_HEAD | 2863 | 500K| | 188
2 |
| 7 | TABLE ACCESS FULL| OM_COUNTRY | 677 | 10832 | |
4 |
PLAN_TABLE_OUTPUT
| 8 | TABLE ACCESS FULL | OM_COUNTRY | 677 | 10832 | |
4 |
| 9 | INDEX UNIQUE SCAN | CITY_CODE_PK | 1 | 17 | |
|
| 10 | INDEX UNIQUE SCAN | CITY_CODE_PK | 1 | 17 | |
|
PLAN_TABLE_OUTPUT
Note: cpu costing is off, PLAN_TABLE' is old version
18 rows selected.
SQL>Edited by: user00726 on Jan 23, 2009 3:53 AMContinued:
Cursor 0 Ver 0 0.000000 0.000053 SQL*Net more data from client
Cursor 0 Ver 0 0.000000 0.000045 library cache lock
Cursor 0 Ver 0 0.000000 0.000279 library cache lock
Cursor 0 Ver 0 0.000000 0.000488 library cache lock
Cursor 0 Ver 0 0.000000 0.000268 library cache lock
Cursor 0 Ver 0 0.000000 0.000304 library cache lock
Cursor 2 Ver 1 Parse at 0.000000
select condition from cdef$ where rowid=:1
Cursor 2 Ver 1 Parse at -0.000015 (Parse to Parse -0.000015),CPU Time 0.010000,Elapsed Time 0.003856,Rows Affected 0,Blks from Buff 0,Blks from Disk 0,**Shared Pool Misses** 1,Goal=0
Cursor 2 Ver 1 -0.000015 0.001111 row cache lock
Cursor 0 Ver 0 -0.000015 0.000226 library cache lock
Cursor 0 Ver 0 -0.000015 0.000248 library cache lock
Cursor 3 Ver 1 Parse at 0.004589 (0.004589)
select /*+ rule */ bucket_cnt, row_cnt, cache_cnt, null_cnt, timestamp#, sample_size, minimum, maximum, distcnt, lowval, hival, density, col#, spare1, spare2, avgcln from hist_head$ where obj#=:1 and intcol#=:2
Cursor 3 Ver 1 Parse at 0.004578 (Parse to Parse -0.000011),CPU Time 0.000000,Elapsed Time 0.002148,Rows Affected 0,Blks from Buff 0,Blks from Disk 0,**Shared Pool Misses** 1,Goal=0
Bind Variables:BINDS #3: 0.004578
Cursor 3 Ver 1 Execute at 0.017441 (Parse to Exec 0.012852),CPU Time 0.000000,Elapsed Time 0.012477,Rows Affected 0,Blks from Buff 0,Blks from Disk 0,
Cursor 3 Ver 1 Fetch at 0.017859 (Parse to Fetch 0.013270),CPU Time 0.000000,Elapsed Time 0.000349,Rows Retrievd 0,Blks from Buff 3,Blks from Disk 0
Bind Variables:BINDS #2: 0.017859
Cursor 2 Ver 1 Execute at 0.018460 (Parse to Exec 0.018460),CPU Time 0.000000,Elapsed Time 0.018154,Rows Affected 0,Blks from Buff 3,Blks from Disk 0,
Cursor 2 Ver 1 Fetch at 0.018618 (Parse to Fetch 0.018618),CPU Time 0.000000,Elapsed Time 0.000074,Rows Retrievd 1,Blks from Buff 2,Blks from Disk 0
Cursor 2 Ver 2 Parse at 0.019176 (0.014587)
select condition from cdef$ where rowid=:1
Cursor 2 Ver 2 Parse at 0.019168 (Parse to Parse -0.000008),CPU Time 0.000000,Elapsed Time 0.000084,Rows Affected 0,Blks from Buff 0,Blks from Disk 0,Goal=CHOOSE
Bind Variables:BINDS #2: 0.019168
Cursor 2 Ver 2 Execute at 0.019446 (Parse to Exec 0.000270),CPU Time 0.000000,Elapsed Time 0.000122,Rows Affected 0,Blks from Buff 0,Blks from Disk 0,
Cursor 2 Ver 2 Fetch at 0.019538 (Parse to Fetch 0.000362),CPU Time 0.000000,Elapsed Time 0.000045,Rows Retrievd 1,Blks from Buff 2,Blks from Disk 0
Cursor 2 Ver 3 Parse at 0.019871 (0.000695)
select condition from cdef$ where rowid=:1
Cursor 2 Ver 3 Parse at 0.019863 (Parse to Parse -0.000008),CPU Time 0.000000,Elapsed Time 0.000065,Rows Affected 0,Blks from Buff 0,Blks from Disk 0,Goal=CHOOSE
Bind Variables:BINDS #2: 0.019863
Cursor 2 Ver 3 Execute at 0.020110 (Parse to Exec 0.000239),CPU Time 0.000000,Elapsed Time 0.000101,Rows Affected 0,Blks from Buff 0,Blks from Disk 0,
Cursor 2 Ver 3 Fetch at 0.020190 (Parse to Fetch 0.000319),CPU Time 0.000000,Elapsed Time 0.000034,Rows Retrievd 1,Blks from Buff 2,Blks from Disk 0
Cursor 2 Ver 4 Parse at 0.020495 (0.000624)
select condition from cdef$ where rowid=:1
Cursor 2 Ver 4 Parse at 0.020487 (Parse to Parse -0.000008),CPU Time 0.000000,Elapsed Time 0.000057,Rows Affected 0,Blks from Buff 0,Blks from Disk 0,Goal=CHOOSE
Bind Variables:BINDS #2: 0.020487
Cursor 2 Ver 4 Execute at 0.020725 (Parse to Exec 0.000230),CPU Time 0.000000,Elapsed Time 0.000101,Rows Affected 0,Blks from Buff 0,Blks from Disk 0,
Cursor 2 Ver 4 Fetch at 0.020803 (Parse to Fetch 0.000308),CPU Time 0.000000,Elapsed Time 0.000033,Rows Retrievd 1,Blks from Buff 2,Blks from Disk 0
Cursor 2 Ver 5 Parse at 0.021132 (0.000637)
select condition from cdef$ where rowid=:1
Cursor 2 Ver 5 Parse at 0.021124 (Parse to Parse -0.000008),CPU Time 0.000000,Elapsed Time 0.000057,Rows Affected 0,Blks from Buff 0,Blks from Disk 0,Goal=CHOOSE
Bind Variables:BINDS #2: 0.021124
Cursor 2 Ver 5 Execute at 0.021361 (Parse to Exec 0.000229),CPU Time 0.000000,Elapsed Time 0.000102,Rows Affected 0,Blks from Buff 0,Blks from Disk 0,
Cursor 2 Ver 5 Fetch at 0.021438 (Parse to Fetch 0.000306),CPU Time 0.000000,Elapsed Time 0.000031,Rows Retrievd 1,Blks from Buff 2,Blks from Disk 0
Cursor 2 Ver 6 Parse at 0.021740 (0.000608)
select condition from cdef$ where rowid=:1
Cursor 2 Ver 6 Parse at 0.021732 (Parse to Parse -0.000008),CPU Time 0.000000,Elapsed Time 0.000057,Rows Affected 0,Blks from Buff 0,Blks from Disk 0,Goal=CHOOSE
Bind Variables:BINDS #2: 0.021732
Cursor 2 Ver 6 Execute at 0.021969 (Parse to Exec 0.000229),CPU Time 0.000000,Elapsed Time 0.000103,Rows Affected 0,Blks from Buff 0,Blks from Disk 0,
Cursor 2 Ver 6 Fetch at 0.022047 (Parse to Fetch 0.000307),CPU Time 0.000000,Elapsed Time 0.000032,Rows Retrievd 1,Blks from Buff 2,Blks from Disk 0
Cursor 2 Ver 7 Parse at 0.022357 (0.000617)
select condition from cdef$ where rowid=:1
Cursor 2 Ver 7 Parse at 0.022348 (Parse to Parse -0.000009),CPU Time 0.000000,Elapsed Time 0.000055,Rows Affected 0,Blks from Buff 0,Blks from Disk 0,Goal=CHOOSE
Bind Variables:BINDS #2: 0.022348
Cursor 2 Ver 7 Execute at 0.022588 (Parse to Exec 0.000231),CPU Time 0.000000,Elapsed Time 0.000103,Rows Affected 0,Blks from Buff 0,Blks from Disk 0,
Cursor 2 Ver 7 Fetch at 0.022669 (Parse to Fetch 0.000312),CPU Time 0.000000,Elapsed Time 0.000035,Rows Retrievd 1,Blks from Buff 2,Blks from Disk 0
Cursor 1 Ver 1 Parse at 0.042845 (0.020488)
select MRH_MRN,DECODE(MRH_***,'M','MALE','FEMALE') AS ***, trim((mrh_sur_name||' '||mrh_first_name||' '||mrh_middle_name)) as MEMNAME, decode(nvl(mrh_fellow_status_yn,'333'),'Y','FCA','ACA')
AS ACA_FCA, DECODE(MRH_RESI_STATUS,'I',MRH_PROF_ADDR_LINE_1,'A',MRH_RES_ADDR_LINE_1) AS L_ADD1, DECODE(MRH_RESI_STATUS,'I',MRH_PROF_ADDR_LINE_2,'A',MRH_RES_ADDR_LINE_2) AS L_ADD2,
DECODE(MRH_RESI_STATUS,'I',MRH_PROF_ADDR_LINE_3,'A',MRH_RES_ADDR_LINE_3) AS L_ADD3, DECODE(MRH_RESI_STATUS,'I',MRH_PROF_ADDR_LINE_4,'A',
MRH_RES_ADDR_LINE_4) AS L_ADD4, DECODE(MRH_RESI_STATUS,'I',a.city_name,'A',C.CITY_NAME) AS L_CITY, DECODE(MRH_RESI_STATUS,'I',MRH_PROF_ZIP_POSTAL_CODE,'A',MRH_RES_ZIP_POSTAL_CODE) AS L_PIN,
DECODE(MRH_RESI_STATUS,'I',b.cou_name,'A',D.COU_NAME) as L_Country, DECODE(MRH_RESI_STATUS,'I','NOT APPLICABLE',MRH_PROF_ADDR_LINE_1) AS R_ADD1,
DECODE(MRH_RESI_STATUS,'I',' ',MRH_PROF_ADDR_LINE_2)
AS R_ADD2, DECODE(MRH_RESI_STATUS,'I',' ',MRH_PROF_ADDR_LINE_3) AS R_ADD3, DECODE(MRH_RESI_STATUS,'I',' ',MRH_PROF_ADDR_LINE_4) AS R_ADD4,
DECODE(MRH_RESI_STATUS,'I',' ','A',A.CITY_NAME) AS R_CITY, DECODE(MRH_RESI_STATUS,'I',' ','A',MRH_PROF_ZIP_POSTAL_CODE) AS R_PIN,
DECODE(MRH_RESI_STATUS,'I',' ','A',B.COU_NAME) as R_Country, decode(nvl(mrh_mem_sub_status,'555'),'26','EXPIRED','') as sub_status, decode(nvl(mrh_mem_status,'777'),'1','ACTIVE','2','REMOVED') as mem_status,mrh_resi_status,
DECODE(MRH_COP_STATUS,'1',DECODE(MRH_COP_TYPE ,'13','FULLTIME-COP','1','FULLTIME-COP', '12','PARTTIME-COP','2','PARTTIME-COP'),'NOT HOLDING COP')
AS COP_STATUS, TO_CHAR(MRH_ENROL_DT,'RRRR') AS ASSO_YR,TO_CHAR(MRH_FELLOW_DT,'RRRR') AS FELLOW_YR from om_mem_reg_head,om_city A,om_country B,om_city C,om_country D
where mrh_doc_status=5 and mrh_prof_city_code=A.City_code(+) and mrh_prof_cou_code=
B.cou_code(+) and mrh_res_city_code=C.City_code(+) and mrh_res_cou_code=D.cou_code(+) and trim((mrh_sur_name||' '||mrh_first_name||''||mrh_middle_name)) like upper('%%')
ORDER BY trim((mrh_sur_name||' '||mrh_first_name||' '||mrh_middle_name))
Cursor 1 Ver 1 Parse at 0.042835 (Parse to Parse -0.000010),CPU Time 0.030000,Elapsed Time 0.051833,Rows Affected 0,Blks from Buff 17,Blks from Disk 0,**Shared Pool Misses** 1,Goal=CHOOSE
Bind Variables:BINDS #1: 0.042835
Cursor 1 Ver 1 Execute at 0.043419 (Parse to Exec 0.000574),CPU Time 0.000000,Elapsed Time 0.000208,Rows Affected 0,Blks from Buff 0,Blks from Disk 0,
Cursor 1 Ver 1 0.043419 0.000004 SQL*Net message to client
Cursor 1 Ver 1 0.043419 0.003686 db file sequential read
Cursor 1 Ver 1 0.043419 0.002923 db file sequential read
Cursor 1 Ver 1 0.043419 0.002460 db file sequential read
Cursor 1 Ver 1 0.043419 0.002328 db file sequential read
Cursor 1 Ver 1 0.043419 0.002560 db file sequential read
Cursor 1 Ver 1 0.043419 0.002310 db file sequential read
Cursor 1 Ver 1 0.043419 0.001007 global cache cr request
Cursor 1 Ver 1 0.043419 0.018467 global cache cr request
Cursor 1 Ver 1 0.043419 0.000662 global cache cr request
Cursor 1 Ver 1 0.043419 0.000633 global cache cr request
Cursor 1 Ver 1 0.043419 0.000732 global cache cr request
Cursor 1 Ver 1 0.043419 0.000661 global cache cr request
Cursor 1 Ver 1 0.043419 0.000573 global cache cr request
Cursor 1 Ver 1 0.043419 0.000336 global cache cr request
Cursor 1 Ver 1 0.043419 0.000519 global cache cr request
Cursor 1 Ver 1 0.043419 0.000580 global cache cr request
Cursor 1 Ver 1 0.043419 0.000609 global cache cr request
Cursor 1 Ver 1 0.043419 0.000594 global cache cr request
Cursor 1 Ver 1 0.043419 0.000632 global cache cr request
Cursor 1 Ver 1 0.043419 0.000560 global cache cr request
Cursor 1 Ver 1 0.043419 0.000541 global cache cr request
Cursor 1 Ver 1 0.043419 0.000678 global cache cr request
Cursor 1 Ver 1 0.043419 0.004071 db file sequential read
Cursor 1 Ver 1 0.043419 0.003703 db file sequential read
Cursor 1 Ver 1 0.043419 0.002589 db file sequential read
Cursor 1 Ver 1 0.043419 0.002501 db file sequential read
Cursor 1 Ver 1 0.043419 0.002323 db file sequential read
Cursor 1 Ver 1 0.043419 0.002255 db file sequential read
Cursor 1 Ver 1 0.043419 0.000044 direct path write
Cursor 1 Ver 1 0.043419 0.002430 db file sequential read
Cursor 1 Ver 1 0.043419 0.002414 db file sequential read
Cursor 1 Ver 1 0.043419 0.002258 db file sequential read
Cursor 1 Ver 1 0.043419 0.002489 db file scattered read
Cursor 1 Ver 1 0.043419 0.002684 db file sequential read
Cursor 1 Ver 1 0.043419 0.001459 db file scattered read
Cursor 1 Ver 1 0.043419 0.001390 db file scattered read
Cursor 1 Ver 1 0.043419 0.003237 db file sequential read
Cursor 1 Ver 1 0.043419 0.002058 db file scattered read
Cursor 1 Ver 1 0.043419 0.002354 db file sequential read
Cursor 1 Ver 1 0.043419 0.001442 db file scattered read
Cursor 1 Ver 1 0.043419 0.002131 db file sequential read
Cursor 1 Ver 1 0.043419 0.001750 db file scattered read
Cursor 1 Ver 1 0.043419 0.002576 db file sequential read
Cursor 1 Ver 1 0.043419 0.002148 db file scattered read
Cursor 1 Ver 1 0.043419 0.001690 db file scattered read
Cursor 1 Ver 1 0.043419 0.004970 direct path write
Cursor 1 Ver 1 0.043419 0.000004 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000002 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000002 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.000001 direct path write
Cursor 1 Ver 1 0.043419 0.006478 direct path read
Cursor 1 Ver 1 0.043419 0.008549 direct path read
Cursor 1 Ver 1 0.043419 0.004526 direct path read
Cursor 1 Ver 1 0.043419 0.006710 direct path read
Cursor 1 Ver 1 0.043419 0.004265 direct path read
Cursor 1 Ver 1 0.043419 0.005163 direct path read
Cursor 1 Ver 1 0.043419 0.004436 direct path read
Cursor 1 Ver 1 0.043419 0.005263 direct path read
Cursor 1 Ver 1 0.043419 0.004336 direct path read
Cursor 1 Ver 1 0.043419 0.004833 direct path read
Cursor 1 Ver 1 0.043419 0.005417 direct path read
Cursor 1 Ver 1 0.043419 0.004910 direct path read
Cursor 1 Ver 1 0.043419 0.005258 direct path read
Cursor 1 Ver 1 0.043419 0.005949 direct path read
Cursor 1 Ver 1 0.043419 0.004894 direct path read
Cursor 1 Ver 1 0.043419 0.005025 direct path read
Cursor 1 Ver 1 0.043419 0.003486 direct path read
Cursor 1 Ver 1 0.043419 0.004630 direct path read
Cursor 1 Ver 1 0.043419 0.005373 direct path read
Cursor 1 Ver 1 0.043419 0.004671 direct path read
Cursor 1 Ver 1 0.043419 0.004182 direct path read
Cursor 1 Ver 1 0.043419 0.004140 direct path read
Cursor 1 Ver 1 0.043419 0.004455 direct path read
Cursor 1 Ver 1 0.043419 0.004885 direct path read
Cursor 1 Ver 1 0.043419 0.004205 direct path read
Cursor 1 Ver 1 0.043419 0.007226 direct path read
Cursor 1 Ver 1 0.043419 0.004015 direct path read
Cursor 1 Ver 1 0.043419 0.004626 direct path read
Cursor 1 Ver 1 0.043419 0.004261 direct path read
Cursor 1 Ver 1 0.043419 0.005263 direct path read
Cursor 1 Ver 1 0.043419 0.005032 direct path read
Cursor 1 Ver 1 0.043419 0.005932 direct path read
Cursor 1 Ver 1 0.043419 0.004317 direct path read
Cursor 1 Ver 1 0.043419 0.004461 direct path read
Cursor 1 Ver 1 0.043419 0.004831 direct path read
Cursor 1 Ver 1 0.043419 0.007193 direct path read
Cursor 1 Ver 1 0.043419 0.004200 direct path read
Cursor 1 Ver 1 0.043419 0.004428 direct path read
Cursor 1 Ver 1 0.043419 0.006657 direct path read
Cursor 1 Ver 1 0.043419 0.004356 direct path read
Cursor 1 Ver 1 0.043419 0.004633 direct path read
Cursor 1 Ver 1 0.043419 0.004510 direct path read
Cursor 1 Ver 1 0.043419 0.004066 direct path read
Cursor 1 Ver 1 0.043419 0.004499 direct path read
Cursor 1 Ver 1 0.043419 0.005222 direct path read
Cursor 1 Ver 1 0.043419 0.005093 direct path read
Cursor 1 Ver 1 0.043419 0.007578 direct path read
Cursor 1 Ver 1 0.043419 0.004474 direct path read
Cursor 1 Ver 1 0.043419 0.004210 direct path read
Cursor 1 Ver 1 0.043419 0.004198 direct path read
Cursor 1 Ver 1 0.043419 0.004891 direct path read
Cursor 1 Ver 1 0.043419 0.004463 direct path read
Cursor 1 Ver 1 0.043419 0.004405 direct path read
Cursor 1 Ver 1 0.043419 0.004505 direct path read
Cursor 1 Ver 1 0.043419 0.004605 direct path read
Cursor 1 Ver 1 0.043419 0.004597 direct path read
Cursor 1 Ver 1 0.043419 0.004167 direct path read
Cursor 1 Ver 1 0.043419 0.004253 direct path read
Cursor 1 Ver 1 0.043419 0.004265 direct path read
Cursor 1 Ver 1 Fetch at 2482.387262 (Parse to Fetch 2482.344417),CPU Time 0.000000,Elapsed Time 0.000320,Rows Retrievd 15,Blks from Buff 0,Blks from Disk 0
Cursor 1 Ver 1 2482.387262 0.501546 SQL*Net message from client
Cursor 1 Ver 1 2482.387262 0.000006 SQL*Net message to client
Cursor 1 Ver 1 Fetch at 2482.889619 (Parse to Fetch 2482.846774),CPU Time 0.000000,Elapsed Time 0.000323,Rows Retrievd 15,Blks from Buff 0,Blks from Disk 0
Cursor 1 Ver 1 2482.889619 0.506369 SQL*Net message from client
Cursor 1 Ver 1 2482.889619 0.000006 SQL*Net message to client
Cursor 1 Ver 1 Fetch at 2483.396665 (Parse to Fetch 2483.353820),CPU Time 0.000000,Elapsed Time 0.000367,Rows Retrievd 15,Blks from Buff 0,Blks from Disk 0
Cursor 1 Ver 1 2483.396665 0.535534 SQL*Net message from client
Cursor 1 Ver 1 2483.396665 0.000004 SQL*Net message to client
Cursor 1 Ver 1 Fetch at 2483.932842 (Parse to Fetch 2483.889997),CPU Time 0.000000,Elapsed Time 0.000332,Rows Retrievd 15,Blks from Buff 0,Blks from Disk 0
Cursor 1 Ver 1 2483.932842 0.553812 SQL*Net message from client
Cursor 1 Ver 1 2483.932842 0.000003 SQL*Net message to client
Cursor 1 Ver 1 Fetch at 2484.487473 (Parse to Fetch 2484.444628),CPU Time 0.000000,Elapsed Time 0.000341,Rows Retrievd 15,Blks from Buff 0,Blks from Disk 0
Cursor 1 Ver 1 2484.487473 1.013580 SQL*Net message from client
Cursor 1 Ver 1 Fetch at 2494.463444 (Parse to Fetch 2494.420599),CPU Time 0.000000,Elapsed Time 0.000328,Rows Retrievd 15,Blks from Buff 0,Blks from Disk 0
Cursor 1 Ver 1 2494.463444 0.500517 SQL*Net message from client
Cursor 1 Ver 1 2494.463444 0.000005 SQL*Net message to client
Cursor 1 Ver 1 Fetch at 2494.964582 (Parse to Fetch 2494.921737),CPU Time 0.000000,Elapsed Time 0.000312,Rows Retrievd 15,Blks from Buff 0,Blks from Disk 0
Cursor 1 Ver 1 2494.964582 0.494577 SQL*Net message from client
Cursor 1 Ver 1 2494.964582 0.000005 SQL*Net message to client
Cursor 1 Ver 1 Fetch at 2495.459844 (Parse to Fetch 2495.416999),CPU Time 0.000000,Elapsed Time 0.000379,Rows Retrievd 15,Blks from Buff 0,Blks from Disk 0
Cursor 1 Ver 1 2495.459844 0.504069 SQL*Net message from client
Cursor 1 Ver 1 2495.459844 0.000004 SQL*Net message to client
Cursor 1 Ver 1 Fetch at 2495.964545 (Parse to Fetch 2495.921700),CPU Time 0.000000,Elapsed Time 0.000325,Rows Retrievd 15,Blks from Buff 0,Blks from Disk 0
Cursor 1 Ver 1 2495.964545 0.945648 SQL*Net message from client
Cursor 1 Ver 1 2495.964545 0.000005 SQL*Net message to client
Cursor 1 Ver 1 Fetch at 2496.910911 (Parse to Fetch 2496.868066),CPU Time 0.010000,Elapsed Time 0.000443,Rows Retrievd 15,Blks from Buff 0,Blks from Disk 0
Cursor 1 Ver 1 2496.910911 0.529252 SQL*Net message from client
Cursor 1 Ver 1 2496.910911 0.000006 SQL*Net message to client
Cursor 1 Ver 1 Fetch at 2497.441067 (Parse to Fetch 2497.398222),CPU Time 0.000000,Elapsed Time 0.000553,Rows Retrievd 15,Blks from Buff 0,Blks from Disk 0
Cursor 1 Ver 1 2497.441067 1.027699 SQL*Net message from client
Cursor 1 Ver 1 2497.441067 0.000005 SQL*Net message to client
Cursor 1 Ver 1 Fetch at 2498.469611 (Parse to Fetch 2498.426766),CPU Time 0.000000,Elapsed Time 0.000540,Rows Retrievd 15,Blks from Buff 0,Blks from Disk 0
Cursor 1 Ver 1 2498.469611 0.568125 SQL*Net message from client
Cursor 1 Ver 1 2498.469611 0.000004 SQL*Net message to client
Cursor 1 Ver 1 Fetch at 2499.038475 (Parse to Fetch 2498.995630),CPU Time 0.000000,Elapsed Time 0.000331,Rows Retrievd 15,Blks from Buff 0,Blks from Disk 0
Cursor 1 Ver 1 2499.038475 0.483811 SQL*Net message from client
Cursor 1 Ver 1 2499.038475 0.000005 SQL*Net message to client
Cursor 1 Ver 1 Fetch at 2499.522916 (Parse to Fetch 2499.480071),CPU Time 0.000000,Elapsed Time 0.000325,Rows Retrievd 15,Blks from Buff 0,Blks from Disk 0
Cursor 1 Ver 1 2499.522916 0.502698 SQL*Net message from client
Cursor 1 Ver 1 2499.522916 0.000004 SQL*Net message to client
Cursor 1 Ver 1 Fetch at 2500.026324 (Parse to Fetch 2499.983479),CPU Time 0.000000,Elapsed Time 0.000326,Rows Retrievd 15,Blks from Buff 0,Blks from Disk 0
Cursor 1 Ver 1 2500.026324 0.471111 SQL*Net message from client
Cursor 1 Ver 1 2500.026324 0.000005 SQL*Net message to client
Cursor 1 Ver 1 Fetch at 2500.503998 (Parse to Fetch 2500.461153),CPU Time 0.000000,Elapsed Time 0.006252,Rows Retrievd 15,Blks from Buff 0,Blks from Disk 0
Cursor 1 Ver 1 2500.503998 0.555502 SQL*Net message from client
Cursor 1 Ver 1 2500.503998 0.000006 SQL*Net message to client
Cursor 1 Ver 1 Fetch at 2501.061609 (Parse to Fetch 2501.018764),CPU Time 0.000000,Elapsed Time 0.001460,Rows Retrievd 15,Blks from Buff 0,Blks from Disk 0
Cursor 1 Ver 1 2501.061609 0.475445 SQL*Net message from client
Cursor 1 Ver 1 2501.061609 0.000006 SQL*Net message to client
Cursor 1 Ver 1 Fetch at 2501.537910 (Parse to Fetch 2501.495065),CPU Time 0.000000,Elapsed Time 0.000327,Rows Retrievd 15,Blks from Buff 0,Blks from Disk 0
Cursor 1 Ver 1 2501.537910 0.485953 SQL*Net message from client
Cursor 1 Ver 1 2501.537910 0.000004 SQL*Net message to client
Cursor 1 Ver 1 Fetch at 2502.024468 (Parse to Fetch 2501.981623),CPU Time 0.000000,Elapsed Time 0.000319,Rows Retrievd 15,Blks from Buff 0,Blks from Disk 0
Cursor 1 Ver 1 2502.024468 0.551960 SQL*Net message from client
Cursor 1 Ver 1 2502.024468 0.000005 SQL*Net message to client
Cursor 1 Ver 1 Fetch at 2502.577104 (Parse to Fetch 2502.534259),CPU Time 0.000000,Elapsed Time 0.000372,Rows Retrievd 15,Blks from Buff 0,Blks from Disk 0
Cursor 1 Ver 1 2502.577104 1.102767 SQL*Net message from client
Cursor 1 Ver 1 2502.577104 0.000005 SQL*Net message to client
Cursor 1 Ver 1 Fetch at 2503.680503 (Parse to Fetch 2503.637658),CPU Time 0.000000,Elapsed Time 0.000326,Rows Retrievd 15,Blks from Buff 0,Blks from Disk 0
Cursor 1 Ver 1 2503.680503 1.867908 SQL*Net message from client
Cursor 1 Ver 1 2503.680503 0.000005 SQL*Net message to client
Cursor 1 Ver 1 Fetch at 2505.549082 (Parse to Fetch 2505.506237),CPU Time 0.000000,Elapsed Time 0.000337,Rows Retrievd 15,Blks from Buff 0,Blks from Disk 0
Cursor 1 Ver 1 2505.549082 340.381485 SQL*Net message from client
Cursor 1 Ver 1 2845.941542 0.000013 direct path read
Cursor 1 Ver 1 2845.941542 0.000002 direct path read
Cursor 1 Ver 1 2845.941542 0.000003 direct path read
Cursor 1 Ver 1 2845.941542 0.000585 library cache lock
Cursor 1 Ver 1 2845.941542 0.000142 library cache lock
Cursor 3 Ver 1 2845.941542 0.001207 library cache lock
Cursor 3 Ver 1 2845.941542 0.000240 library cache lock
Cursor 3 Ver 1 2845.941542 0.000342 library cache lock
Cursor 3 Ver 1 2845.941542 0.000619 library cache lock
Cursor 3 Ver 1 2845.941542 0.000324 library cache lock
Cursor 3 Ver 1 2845.941542 0.000390 library cache lock
----------------------------------------------------------------------------------(Continued)
Charles Hooper
IT Manager/Oracle DBA
K&M Machine-Fabricating, Inc. -
Hi,
I want to use rowid for updating the rows in the ref cursor. My code looks like below:
DECLARE
emp_refcursor SYS_REFCURSOR;
emp_rec employee%ROWTYPE;
l_run_id NUMBER;
lv_sql_stmt VARCHAR2(4000) := 'SELECT a.* FROM employee a where a.run_id = :l_run_id ';
OPEN emp_refcursor FOR lv_sql_stmt
USING l_run_id;
LOOP
FETCH emp_refcursor
INTO emp_rec;
EXIT WHEN emp_refcursor%NOTFOUND;
Here in lv_sql_stmt I want to include the rowid also so that I can use the update statement with the rowid. I cant directly add the rowid in the query as I am fetching the records in emp_rec which is of the rowtype of table EMPLOYEE.
I want to use rowid for making the fetching of records faster.
Please suggest e some ways to implement it.
Thanks.
Edited by: user12841217 on Mar 23, 2010 12:12 AMuser12841217 wrote:
Hi,
I want to use rowid for updating the rows in the ref cursor.There are no rows in a ref cursor. Read the following:
PL/SQL 101 : Understanding Ref Cursors :-
PL/SQL 101 : Understanding Ref Cursors
My code looks like below:
DECLARE
emp_refcursor SYS_REFCURSOR;
emp_rec employee%ROWTYPE;
l_run_id NUMBER;
lv_sql_stmt VARCHAR2(4000) := 'SELECT a.* FROM employee a where a.run_id = :l_run_id ';
OPEN emp_refcursor FOR lv_sql_stmt
USING l_run_id;
LOOP
FETCH emp_refcursor
INTO emp_rec;
EXIT WHEN emp_refcursor%NOTFOUND;
Here in lv_sql_stmt I want to include the rowid also so that I can use the update statement with the rowid. I cant directly add the rowid in the query as I am fetching the records in emp_rec which is of the rowtype of table EMPLOYEE.
I want to use rowid for making the fetching of records faster.
Please suggest e some ways to implement it. This sounds like half of the requirement. If you're already fetching the rows using your ref cursor, then why would you need the rowid to fetch them again?
If you really need to include rowid in your query then you're going to have to fetch into a known defined structure rather than employee%ROWTYPE. This is what we call in the business... "design", which is usually based on "requirements". Know your requirements and implement a suitable design accordingly. A good design would seldom be selecting "*" within any query, as a good design would actually know what data is expected to be fetched. -
What's instance, ROWID and why we use cursor?
Dear memebers,
yesterday i have an interview there i faced the following questions.
1. what is instance?
2. what is ROWID?
3. why we use cursor?
i can give only the last one.
i am waiting for your answer.
thanks
Regards:
Muhammad Nadeem
[email protected]HY
Row Identifiers
Each row in an Oracle database has a unique row identifier, or rowid, which is used internally by the Oracle database to access the row. A rowid is an 18-digit number that is represented as a base-64 number, and it contains the physical address of a row in an Oracle database. You can view the rowid value for rows in a table by specifying the ROWID column in the select list of a query. The query in the following example retrieves the ROWID and customer_id columns from the customers table:
SELECT ROWID, customer_id
FROM customers;
Oracle instance:
An Oracle instance is the combination of the background processes and
memory structures. The instance must be started to access the data in the database. Every
time an instance is started, a System Global Area (SGA) is allocated and Oracle
background processes are started. Background processes perform functions on behalf of
the invoking process. They consolidate functions that would otherwise be handled by
multiple Oracle programs running for each user. The background processes perform
input/output (I/O) and monitor other Oracle processes to provide increased parallelism
for better performance and reliability.
REGARDS -
Opening and fetching cursor.. what accually happens?
So, if we have an explicit cursor... we open it with open c_cursor_name... and fetches it into some variable...
my question is - what really happens when we open cursor?
does oracle make only instance of cursor object in memory? or... does it reads some basic data about rows that are going to be fetched (rowid's?)..? or what?
also, if we make some insert into a table that is going to be rolled over by cursor (while cursor is fetching..), should cursor read this new data? for example, what is difference if cursor roll over an indexed ID and we make an insert with an ID=10, and cursor is currently on ID=100? or opposite? (commit included in insert)...
oh, so many questions :)
tnx :)Not really. The same SQL cursor in the shared pool applies.
The difference is on the client side. Each of the methods you've listed is essentially using a different method on the client side to interact with the cursor on the server.
Some methods are more desirable in some cases than another - there's not a single superior method. Each has pros and cons and addresses a specific set of client coding requirements.
There are some preferred methods though on the client. The three primary ones are:
a) use bind variables (enables one to re-use the same SQL cursor)
b) re-use the same client cursor handle for tight loop operations
c) use bulk binding
The first one is kind of obvious - as bind variables creates a cursor "program" that can be called/executed with different values. Like an INSERT cursor for example. The same SQL cursor can be used to insert a million rows, with each execution using different variable values to insert.
The second one is not that applicable to the PL language in PL/SQL - thanks to the integration between the PL and SQL languages. In other client languages though, you want to re-use not only the same server cursor, but the same client cursor handle. As this saves you a soft parse. So instead of this approach:
// pseudo code
for i in 1..count
CreateCursor( c, <sql statement> );
BindValue( c, 1, myVariable[i] );
ExecCursor( c );
CloseCursor( c );
end loop;..the following is far more efficient:
// pseudo code
CreateCursor( c, <sql statement> );
for i in 1..count
BindValue( c, 1, myVariable[i] );
ExecCursor( c );
end loop;
CloseCursor( c );This approach re-uses the client handle - which means a single db parse was needed. The prior approach required a brand new parse for each loop iteration. (even soft parsing is an overhead that should be avoided where possible)
The last primary factor is bulk processing. This is fairly well documented for the PL language - the important bit to remember that bulk processing is only intended to pass more data with a single call between the PL and SQL engines. Nothing more. The price of which is a bigger PGA memory footprint. Thus there is a balance between how much data (rows/variables) one should pass between the two versus the amount of memory that consumes. -
Using one Cursor data in anothe rcursor
Hi all,
I have a requirement of processing the following.
I have to select the rows for which few selected attributes are null. Then I need to take one more attribute for these rows and check that if the value of that row exists for any other row except this one. If that id exists for another row ,then I have to update two fields concatenate with the value.
Ex:- suppose I have 3 rows for which all the three attributes are null. I have a value say CCN_ID which I have to check if that exists for any other row other than this. That means the CCN_IFD of these 3 rows should be checked for existence in any other rows in the same table. If any of the CCN_ID of these 3 rows exists, then I need to update that row with attribute (Sayx)CCN_ID concatenated by the CCN_ID.
I wrote the following query to accomplish this.
select CCN_ID from TEMP_ARTICLE_TABLE where ARTICLE_NO is null and COLOR_BOTTOM is NULL and COLOR_TOP is NULL and CCN_ID IN
(SELECT DISTINCT CCN_ID from TEMP_ARTICLE_TABLE where CCN_ID in(select CCN_ID from TEMP_ARTICLE_TABLE where ARTICLE_NO is null and COLOR_BOTTOM is NULL and COLOR_TOP is NULL)
and rowId not in(select rowId from TEMP_ARTICLE_TABLE where ARTICLE_NO is null and COLOR_BOTTOM is NULL and COLOR_TOP is NULL));
But I was requested to write a Stored Procedure to do this. So, I am thinking of creating two cursors in which the first cursor's data is used in second one as follows.I am receiving compiling errors as follows while compiling t he code.Am I doing in the best possible approach? Is there any other better approach to accomplish my requirement?
SP Code:-
CREATE OR REPLACE PROCEDURE SP_ARTICLEDATA_CLEANING IS
CURSOR Cur_CCNID is
SELECT rowId,CCN_ID FROM TEMP_ARTICLE_TABLE WHERE ARTICLE_NO is null AND COLOR_TOP IS NULL AND COLOR_BOTTOM IS NULL;
CURSOR Cur_ModCCNID IS
SELECT DISTINCT CCN_ID FROM TEMP_ARTICLE_TABLE WHERE CCNID IN(Cur_CCNID.CCN_ID) AND rowId NOT IN(Cur_CCNID.rowId);
BEGIN
FOR rec in Cur_CCNID
LOOP
BEGIN
UPDATE TEMP_ARTICLE_TABLE SET COLOR_TOP='FIX_'||rec.CCN_ID WHERE CCN_ID=rec.CCN_ID and rowId in(cur_CCNID.rowId);
END;
END LOOP;
END;
Errors:-
[Error] PLS-00225 (5: 102): PLS-00225: subprogram or cursor 'CUR_CCNID' reference is out of scope
[Error] ORA-00904 (5: 102): PL/SQL: ORA-00904: "CUR_CCNID"."ROWID": invalid identifier,
[Error] PLS-00225 (11: 102): PLS-00225: subprogram or cursor 'CUR_CCNID' reference is out of scope,
[Error] ORA-00904 (11: 102): PL/SQL: ORA-00904: "CUR_CCNID"."ROWID": invalid identifier
Please guide me if there is abetter way or how to correct these errors.
Thanks,
Pavan.The basic answer to your problem is use SQL. A single SQL statement can very likely do the entire operation. There is no need for using row by row (called slow by slow) processing in PL/SQL.
PL/SQL is inferior when it comes to crunching database data. That is the territory of the very powerful and very flexible SQL language. Or simply put: Maximise SQL. Minimise PL/SQL.*
As for cursors - a cursor is the compiled and executable for a source code program (e.g. SQL statement). It is not a result set. This cursor/program outputs data. It even takes parameters in the form of bind variables. Which means the same cursor (executable) can be used repeatedly, even by different sessions, and executed with different parameters (called bind variables).
Want to insert 10 million rows? Single SQL cursor (executable program). Called 10 million times. Each time with different parameters (bind variables). Via 10,000 different application sessions. At the same time.
So a cursor calling a cursor - not really a sensible approach. Cannot be done the way you want in your code. Is used for unique processing requirements like running PL/SQL in parallel using pipe line table functions.
Bottom line - whoever told you to write a stored proc to do this, is wrong. The correct solution is writing SQL to perform the processing and update you need. That SQL can then be placed inside PL/SQL in order to manage the execution of that SQL cursor and deal with validation of input parameters, handling errors, code instrumentation and so on. -
How to add results of Loop into a Cursor
Hi,
I am opening a cursor and looping through each row (it has a select query that queries based on the value of a column obtained from another cursor).
How can I add all the rows to a new cursor (along with the column value I am getting from the first cursor), as I want to return that to a java program.
Can I create a new cursor and add the final data to it (that contains all rows), if yes How do I do that?
Thanks,
Rommel.
Message was edited by:
rommelsharmaTrying to add data from one cursor to another cursor shows a basic misconception on your part of what a cursor is.
First, what a cursor is not - it is not a result set. An in-memory set of rowids or results for a SQL. With 1000's of cursors on a database, how would this scale when every cursor needs space for storing its results?
A cursor is a SQL program - a set of instructions (as per the SQL's execution plan) of how to get the results for that SQL. When a cursor fetch is performed, this program returns the next set of rows from the actual database tables.
So you cannot take data from one or more cursors and then wrap that into a 3rd cursor.. or more accurately, you should not. The fact that it can be hacked in PL/SQL simply says a lot of the flexibility of PL/SQL.. and not about good sensible use.
So how then do you "add cursors" together? You do it at SQL level. A cursor is a program. So instead of creating multiple programs, each returning its own results, you make it a single program.
You combine the SQLs. This means using UNION, JOIN, INTERSECT, etc.
Solve the problem in SQL first and foremost. That is the most powerful language to use to crunch database data. Do not make the major and fatal performance mistake of treating SQL as a simplistic I/O library for merely reading and writing records. -
Max no.of rows capacity in a cursor ?
Gurus,
Do we have any limitations in cursors to hold max no.of rows returned by a SQL ?
My select returning 50 Million rows. Can I hold all of them in a single cursor ?
Thnaks.
SWrong question. A cursor does not have "capacity".
A cursor is an executable program. Not a set of results. It is not a copy of resulting rowids/rows for the SQL. Just imagine if it was.. how many cursors could we then open? Each cursor will consume loads of memory as each cursor will need to make a copy of the data. This is not scalable at all. A RDBMS will struggle to support more than just a couple of user sessions.
Source SQL is in fact a source program. A set of instructions in the SQL language of what the server needs to do. This program is parsed by the SQL Engine and then a binary executable program created for it. This is stored as a shared program (to be used by any session needing it) in the Shared Pool. This is why using bind variables are important (it allows the program to be generic without hardcoded values). The instructions of this binary program can be seen via its execution plan. This binary executable program is commonly called a cursor in database speak.
A program typically consists of a code segment and a data segment. The code segment is the cursor in the Shared Pool. And this code segment of the program can be used by any other session too.
When you open the cursor, you access the code segment of the program in the Shared Pool. A data segment is created just for your use of that program. This contains the state variables, bind variable values, and other data required for executing and managing the program. (A DLL in Windows and SO in Unix/Linux, work in the exact same fashion)
When you fetch from the cursor, the program is executed (as per the execution plan determined by the CBO). Your cursor's state data is updated. And you get, as output from this program, data in the form of rows.
Each subsequent fetch repeats this process, until the program (cursor) fails to find any more rows to return.
All SQL statements, every single one, is treated in this fashion. It is parsed and compiled, execution plan determined and then stuffed into the Shared Pool as a cursor. Does not matter if it is a SQL statement from Java, SQL*Plus, Delphi, inside PL/SQL, or a nested SQL generated by Oracle itself.
How many rows can be returned by a binary executable program (cursor)? You could just as well have asked, how many rows can a source code program (SQL statement) return?
The answer to that is, how many rows are in the table?
There is no limit in that regard. What is a limit in this respect, is the size of the redo when running a SQL on a table "slowly", while the table is subject to a lot of changes. The consistent read/view you have on that table (also called a snapshot) needs to be maintained for the duration of that cursor's execution. At some stage that cursor may fail to find the rows matching the version of data required to provide you with a consistent read. In such a case, the cursor will throw an exception saying that the snapshot is now too old and cannot be reconstructed anymore. -
Need help in cursor.....!
hi,
I am working in oracle 8i. I am creating cursor in my pl/sql block for the following requirement.
I need to update the ex_duty_cb amt and simultaneously i need to assign the ex_duty_cb amt
for the opening_amt column.
For ex..
Below is the actual record
ENTRY_NO OPENING_AMT EXCISE_DUTY EXCISE_DUTY_CB
1626 2000 50 2200
1627 3000 250 3300
1628 4000 200 4400
1629 5000 100 5500
This is my requirement
ENTRY_NO OPENING_AMT EXCISE_DUTY EXCISE_DUTY_CB
1626 2000 50 2050
1627 2050 250 2300
1628 2300 200 2500
1629 2500 100 2600
Please help me.........!
Below is the query....Please guide me....?
declare
cursor cur
is select entry_no,excise_duty_ob + cess_on_ed_ob + hecess_on_ed_ob as
opening_amt, excise_duty_cb
from cenvat_trans
where transaction_type = 'I'
and to_date(to_char(bill_date,'MON'),'MON') = '01-jul-2007';
begin
open cur;
for fr in cur loop
update cenvat_trans
set excise_duty_cb = fr.opening_amt;
exit when cur%notfound;
end loop;
close cur;
end;
regards,
jameSQL> select * from cenvat_trans;
ENTRY_NO OPENING_AMT EXCISE_DUTY EXCISE_DUTY_CB
1626 2000 50 2200
1627 3000 250 3300
1628 4000 200 4400
1629 5000 100 5500
SQL> merge into cenvat_trans c
2 using (select entry_no,
3 first_value(opening_amt) over(order by entry_no)+
4 sum(prev_ex) over(order by entry_no) sm1,
5 first_value(opening_amt) over(order by entry_no)+
6 sum(excise_duty) over(order by entry_no) sm2
7 from(
8 select rowid,entry_no,opening_amt,
9 excise_duty,excise_duty_cb,
10 lag(excise_duty,1,0) over(order by entry_no) prev_ex
11 from cenvat_trans)) v
12 on (c.entry_no=v.entry_no)
13 when matched then
14 update set c.opening_amt = v.sm1,
15 c.excise_duty_cb = v.sm2;
4 rows merged.
SQL> select * from cenvat_trans;
ENTRY_NO OPENING_AMT EXCISE_DUTY EXCISE_DUTY_CB
1626 2000 50 2050
1627 2050 250 2300
1628 2300 200 2500
1629 2500 100 2600
Message was edited by:
jeneesh
Oh..!
Its too late..
Maybe you are looking for
-
Family Sharing is setup but spouse can't make purchases
I've setup Family Sharing under my account and added my wife and daughter. My daughter's account works perfectly - if she tries to purchase anything it prompts her to ask for it, I get the notification, etc. When my wife tries to purchase anything i
-
How to delete repeated text in Numbers
I have a long list of names, many of which are repeats. Is there a command that deletes any repeated phrases in Numbers? Thanks.
-
CRM 7.0 WEB IC - context node values are not seen in webIC
Hi can anyone help me in resolving my problem in CRM WEB IC. Actually i have added a new context node Using wizard , by right clicking the context nodes. i have four custom fields in that node, these i have to show on the View Account overview and th
-
Hi All, We are facing error FI/CO interface: Balance in transaction currency from BAPI BAPI_ACC_DOCUMENT_POST. This error we are getting only in case of passing tax data. Can anyone help me on this. Below is the code : *fill header gd_documenthead
-
Best Way To speed up stereo mix 2bpm
i tried universal and didn't do very well. i'm assuming the rest won't do much better. so is there another program that could do a better job at time and pitch? also could i make the whole mix into a apple loop and speed it up that way? can never fig