Help me in debugging this procedure
PROCEDURE p_main_dpn (
m_post IN OUT VARCHAR2,
m_company VARCHAR2,
m_user_group VARCHAR2,
m_user_id VARCHAR2,
m_choice VARCHAR2,
m_year VARCHAR2,
m_period VARCHAR2,
m_tot_count NUMBER,
g_asset_code VARCHAR2
IS
CURSOR c1 (m_last_day_of_period DATE)
IS
SELECT company, asset_code, asset_dept, capital_cost, current_wdv,
dpn_type, status, residual_val, dpn_prd, dpn_year, nl_intf,
asset_life, updated_wdv, dpn_date, comm_date
FROM fa_asset_reg
WHERE status = 'C'
AND company = m_company
AND asset_code =
NVL (g_asset_code, asset_code)
-- dpn before sale
AND updated_wdv > residual_val
AND TO_NUMBER (TO_CHAR (NVL (dpn_date, comm_date), 'yyyymmdd')) <
TO_NUMBER (TO_CHAR (m_last_day_of_period, 'yyyymmdd'))
ORDER BY asset_dept;
rc1 c1%ROWTYPE;
sl_value NUMBER (15, 2);
-- Used in Sraight Line Method Calculation
sl_dpn NUMBER (15, 2); -- Straight Line depreciation amount
rb_value NUMBER (15, 2);
-- Used in Reducing Balance Method Calculation
rb_dpn NUMBER (15, 2);
-- Reducing Balance depreciation amount
m_doc_ref VARCHAR2 (16); -- For generating new Doc-Ref
m_updated_wdv NUMBER (15, 2); -- Latest book value of the Asset
m_tot_dpn NUMBER (15, 2); -- Department-wise total depreciation
m_loop_count NUMBER; -- To check for First Loop
m_prev_dept VARCHAR2 (12);
m_next_dept VARCHAR2 (12);
period_last_day DATE; --*
m_period_days NUMBER; --*
m_dpn_days NUMBER; --* used for datewise DPN calculation
dpn_for_a_day NUMBER; --*
m_last_day DATE; --*
m_start_day DATE; --*
m_from_day DATE; --*
Chk Number;
BEGIN
/* First Delete any Trial Depreciations Calculated */
DELETE FROM fa_temp_dpn
WHERE company = m_company;
Chk :=1;
BEGIN
/* This check is done to calculate dpn before sale for a particular asset*/
IF g_asset_code IS NULL
THEN
SELECT LAST_DAY (fdp), LAST_DAY (fdp) - fdp + 1, fdp
INTO m_last_day, m_period_days, m_start_day
FROM sm_calendar
WHERE company = m_company AND YEAR = m_year AND prd = m_period;
DBMS_OUTPUT.PUT_LINE('m_last_day, m_period_days, m_start_day'||m_last_day||','|| m_period_days||','|| m_start_day);
ELSE
SELECT SYSDATE, LAST_DAY (fdp) - fdp + 1,
TRUNC (SYSDATE - fdp) + 1, fdp
INTO m_last_day, m_period_days,
m_dpn_days, m_start_day
FROM sm_calendar
WHERE company = m_company AND YEAR = m_year AND prd = m_period;
END IF;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
m_post := 'System calendar not defined properly';
END;
--OPEN c1 (m_last_day);
FOR RC1 IN C1(m_last_day)
LOOP
cHK := 0;
/*FETCH c1
INTO rc1;*/
cHK := 0.1;
dbms_OUTPUT.PUT_LINE('ENtered the loop'||c1%rowcount||m_last_day);
EXIT WHEN c1%NOTFOUND or c1%rOWCOUNT = 0;ADDED BY ALOK
cHK := 0.2;
m_loop_count := NVL (m_loop_count, 0) + 1;
cHK := 0.3;
DBMS_OUTPUT.PUT_LINE('m_loop_count '||m_loop_count );
-- No more depreciation for the Asset which has depreciated
-- upto the Residual Value!!
rb_dpn := NULL;
sl_dpn := NULL;
-- SLL or SL% METHOD
IF rc1.dpn_type = 'S' OR rc1.dpn_type = 'P'
THEN
-- Provision is given for adding already depreciated assets into the register.****
sl_value := NVL (rc1.current_wdv, NVL (rc1.capital_cost, 0));
DBMS_OUTPUT.put_line ('SL Value ' || sl_value);
IF rc1.dpn_type = 'S'
THEN -- SLL METHOD
sl_dpn := (sl_value - rc1.residual_val) / rc1.asset_life;
DBMS_OUTPUT.put_line
( 'sl_dpn := (SL_VALUE - rc1.residual_val)/rc1.asset_life'
|| sl_dpn
ELSIF rc1.dpn_type = 'P'
THEN -- SL% METHOD
sl_dpn :=
((sl_value - rc1.residual_val) * rc1.asset_life) / 100;
DBMS_OUTPUT.put_line
( 'sl_dpn := ((SL_VALUE - rc1.residual_val)*rc1.asset_life)/100'
|| sl_dpn
END IF;
-- Dpn Calculation for no. of days in the period.
dpn_for_a_day := sl_dpn / m_period_days;
DBMS_OUTPUT.put_line('dpn_for_a_day '||dpn_for_a_day );
IF g_asset_code IS NULL
THEN
-- Get the no. of days from rc1.dpn_date to last_day of current period.
IF rc1.dpn_date = rc1.comm_date
THEN
-- Dpn calculation for the first time.
m_start_day := rc1.dpn_date;
DBMS_OUTPUT.put_line('m_start_day '||m_start_day);
END IF;
ELSE
IF TO_CHAR (m_start_day, 'MMYYYY') =
TO_CHAR (rc1.comm_date, 'MMYYYY')
THEN
m_start_day := rc1.comm_date;
DBMS_OUTPUT.put_line('TO_CHAR (m_start_day, ''MMYYYY'')'||TO_CHAR (m_start_day, 'MMYYYY'));
ELSE
m_start_day := rc1.dpn_date + 1;
END IF;
END IF;
m_dpn_days := TRUNC (m_last_day - m_start_day) + 1;
DBMS_OUTPUT.put_line('m_dpn_days '||m_dpn_days);
-- Compare the days for which depreciation has to be calculated with the
-- no. of days in the period.
IF m_dpn_days > m_period_days
THEN
m_post :=
'Depreciation has not been done for a previous period.';
EXIT;
ELSE
-- Restore the DPN into same variable
sl_dpn := dpn_for_a_day * m_dpn_days;
DBMS_OUTPUT.put_line('sl_dpn '||sl_dpn);
END IF;
Chk := 2;
-- Update the Current Value of this Asset(SL)
m_updated_wdv := rc1.updated_wdv - sl_dpn;
-- RBL OR RB% METHOD
ELSIF rc1.dpn_type = 'R' OR rc1.dpn_type = 'Q'
THEN
rb_value :=
NVL (rc1.updated_wdv,
NVL (rc1.current_wdv, NVL (rc1.capital_cost, 0))
Chk :=3;
IF rc1.dpn_type = 'R'
THEN
rb_dpn := (rb_value - rc1.residual_val) / rc1.asset_life;
ELSIF rc1.dpn_type = 'Q'
THEN
rb_dpn :=
((rb_value - rc1.residual_val) * rc1.asset_life) / 100;
END IF;
-- Dpn Calculation for no. of days in the period.
dpn_for_a_day := rb_dpn / m_period_days;
IF g_asset_code IS NULL
THEN
-- Get the no. of days from rc1.dpn_date to last_day of current period.
IF rc1.dpn_date = rc1.comm_date
THEN
-- Dpn calculation for the first time.
m_start_day := rc1.dpn_date;
END IF;
ELSE
IF TO_CHAR (m_start_day, 'MMYYYY') =
TO_CHAR (rc1.comm_date, 'MMYYYY')
THEN
m_start_day := rc1.comm_date;
ELSE
m_start_day := rc1.dpn_date + 1;
END IF;
END IF;
m_dpn_days := TRUNC (m_last_day - m_start_day) + 1;
-- Compare the days for which depreciation has to be calculated with the
-- no. of days in the period.
IF m_dpn_days > m_period_days
THEN
m_post :=
'Depreciation has not been done for previous a period.';
EXIT;
ELSE
-- Restore the DPN into same variable
rb_dpn := dpn_for_a_day * m_dpn_days;
END IF;
Chk := 4;
-- Update the Current Value of this Asset(RB)
m_updated_wdv :=
NVL (rc1.updated_wdv,
NVL (rc1.current_wdv, NVL (rc1.capital_cost, 0))
- rb_dpn;
END IF;
-- Check if the depreciation reduces the current book value
-- to make it lesser than Residual Value
IF m_updated_wdv < rc1.residual_val
THEN
IF rc1.dpn_type = 'S' OR rc1.dpn_type = 'P'
THEN
sl_dpn := sl_dpn - (rc1.residual_val - m_updated_wdv);
ELSIF rc1.dpn_type = 'R' OR rc1.dpn_type = 'Q'
THEN
rb_dpn := rb_dpn - (rc1.residual_val - m_updated_wdv);
END IF;
m_updated_wdv := rc1.residual_val;
END IF;
m_from_day := m_start_day;
Chk := 5;
-- Check whether Department-wise AJ consolidation required.
IF m_choice = 'Y'
THEN /* Department-wise AJ required */
INSERT INTO fa_stats
(company, asset_code, closing_wdv, YEAR,
prd, dpn_per_day, no_of_days, from_date,
TO_DATE, asset_dpn, usr_id, TIMESTAMP
VALUES (rc1.company, rc1.asset_code, m_updated_wdv, m_year,
m_period, dpn_for_a_day, m_dpn_days, m_from_day,
m_last_day, NVL (rb_dpn, sl_dpn), m_user_id, SYSDATE
DBMS_OUTPUT.PUT_LINE('Inserted the value into Fa_Stats');
UPDATE fa_asset_reg
SET dpn_year = m_year,
dpn_prd = m_period,
dpn_date = m_last_day,
updated_wdv = m_updated_wdv
WHERE company = m_company AND asset_code = rc1.asset_code;
DBMS_OUTPUT.PUT_LINE(SQL%ROWCOUNT||'Rows Updated the value into Fa_Asset_Reg');
m_next_dept := rc1.asset_dept;
IF m_next_dept = NVL (m_prev_dept, m_next_dept)
THEN /* same department */
m_tot_dpn := NVL (m_tot_dpn, 0)
+ NVL (NVL (sl_dpn, rb_dpn), 0);
m_prev_dept := m_next_dept;
IF m_loop_count = m_tot_count
THEN /* last record */
p_create_dpn_jv (m_company,
m_user_group,
m_user_id,
m_post,
m_period,
m_year,
m_last_day,
'XXXXXX',
m_next_dept,
m_choice,
m_tot_dpn,
m_updated_wdv,
rc1.nl_intf,
NULL,
NULL,
NULL,
NULL
--m_updated_wdv & m_last_day not applicable if CHOICE = 'Y'
EXIT;
END IF;
END IF;
IF m_next_dept <> m_prev_dept
THEN
p_create_dpn_jv (m_company,
m_user_group,
m_user_id,
m_post,
m_period,
m_year,
m_last_day,
'XXXXXX',
m_prev_dept,
m_choice,
m_tot_dpn,
m_updated_wdv,
rc1.nl_intf,
NULL,
NULL,
NULL,
NULL
--m_updated_wdv & m_last_day not applicable if CHOICE = 'Y'
m_tot_dpn := NVL (NVL (sl_dpn, rb_dpn), 0);
m_prev_dept := m_next_dept;
IF m_loop_count = m_tot_count
THEN /* last record */
p_create_dpn_jv (m_company,
m_user_group,
m_user_id,
m_post,
m_period,
m_year,
m_last_day,
'XXXXXX',
m_next_dept,
m_choice,
m_tot_dpn,
m_updated_wdv,
rc1.nl_intf,
NULL,
NULL,
NULL,
NULL
--m_updated_wdv & m_last_day not applicable if CHOICE = 'Y'
EXIT;
END IF;
END IF;
ELSE
Chk := 5.1; /* choice is N */
p_create_dpn_jv (rc1.company,
m_user_group,
m_user_id,
m_post,
m_period,
m_year,
m_last_day,
rc1.asset_code,
rc1.asset_dept,
m_choice,
NVL (sl_dpn, rb_dpn),
m_updated_wdv,
rc1.nl_intf,
dpn_for_a_day,
m_dpn_days,
m_from_day,
m_last_day
Chk := 5.2;
END IF;
END LOOP;
-- CLOSE c1;
cHK := 7;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
m_post := 'Processing failed !! No data found ';
WHEN DUP_VAL_ON_INDEX
THEN
m_post :=
'Posting failed . Duplicate value exists for ' || rc1.asset_code;
ROLLBACK;
wHEN otHERS THEN
m_post := 'ERROR oCCURED'||SQLERRM||chk||' '||m_loop_count;
rOLLBACK;
END;
Here when i'm executing this procedure, I'm getting a error ORA-01002- Fetch Out of Sequence.
Plz help me.
Thanks in advance.
Regards,ALok
Earlier it was having the simple loop.But i changed
it to the FOr loop cursor,
Cos, For loop is more efficient in fetching the
data.Only from 10g on and when you don't use BULK fetch
in your cursor loop.
As for your other question: I meant of course the ROLLBACK
in the procedure p_create_dpn_jv.
Again, if you can't remove that ROLLBACK there, you could
bulk fetch all the records of your main cursor and process them
afterwards in a FOR/FORALL loop, if the result fits into the available
memory of course.
C.
Similar Messages
-
Help me to debug this function.
public Frame getParentFrame()
Container container = null;
for(container = getParent();!(container instanceof Frame); ){
container = container.getParent();/*/
return (Frame)container;
When I use this function , it will wrong at the line marked "*"(I put this program at the applet),please help me to debug this program.Let me translate that into something that the average programmer could understand, instead of that awful for-statement...public Frame getParentFrame() {
Container container = getParent();
while (!(container instanceof Frame)) {
container = container.getParent(); // Error here?
return (Frame)container;
}Now, you say it has an error at that line? Okay, to debug it you look at the error message. And then you figure out what's wrong with that line of code that causes that message. Sorry, that's all I can say because you didn't mention what the actual error was. -
Help with running a stored procedure
Hi, could anybody help me with debugging this stored procedure:
extraction_date in varchar2
as
begin
execute immediate '
declare
/* Output file handler */
fileHandler UTL_FILE.FILE_TYPE;
asset_id VARCHAR2(60) := '''';
cursor c_table is
SELECT "ASSET ID"
FROM REUT_MAIN_BOND
WHERE MATURITY > TO_DATE(' || extraction_date || ', "MM-DD-YYYY");
row c_table%ROWTYPE;
begin
fileHandler := UTL_FILE.FOPEN(''TEMP'', ''northfielddescupdate.in'', ''w'',32000);
for row in c_table
loop
asset_id := row.ASSET;
UTL_FILE.PUTF(fileHandler, ''asset_id'', ''\n'');
end loop;
UTL_FILE.FCLOSE(fileHandler);
end;';
commit;
end;
when I run it - SQL> exec create_in_file('08102004')
it gives me the following errors:
ERROR at line 1:
ORA-06550: line 8, column 11:
PL/SQL: ORA-06553: PLS-103: Encountered the symbol "CALL" when expecting one of
the following:
<an identifier> <a double-quoted delimited-identifier>
ORA-06553: PLS-112: end-of-line in quoted identifier
ORA-06550: line 7, column 2:
PL/SQL: SQL Statement ignored
ORA-06550: line 6, column 8:
PLS-00341: declaration of cursor 'C_TABLE' is incomplete or malformed
ORA-06550: line 10, column 5:
PL/SQL: Item ignored
ORA-06550: line 15, column 14:
PLS-00364: loop index variable 'ROW' use is invalid
ORA-06550: line 15, column 2:
PL/SQL: Statement ignored
ORA-06512: at "PETAR_NORTHFIELD.CREATE_IN_FILE", line 6
ORA-06512: at line 1
Thank you for your helpQ #1 (and possibly the only question) - why are you using NDS for this?
-
Hi,
I have some 1000 lines of code in a procedure
now i want to debug this procedure to find out where the error getting
could any one help me how to debug the huge lines of procedureHi,
I usually opt for PL/SQL developer tool for debugging millions of line of code. Try to grant the privilege to user 'debug connect session'.
Try to execute the procedure in step by step execution. Pass the run time variable input value to procedure and go on with debug procedure then you can watch how code is carrying out the changes.
HTH
- Pavan Kumar N -
Help needed in debugging dynamic SQL.
When I pass the p_deptno =30 and run the below code the refcursor returns the rows.But when I pass the dpetno =null then it goes to the condition if p_job is not null and throws an error.Can any one please help me in debugging this code.
declare
p_deptno number:=null;
p_job varchar2(30):='SALESMAN';
v_sql varchar2(4000);
l_ename varchar2(30);
TYPE my_cursor IS REF CURSOR;
RC my_cursor;
begin
v_sql := 'select ename
from emp
where 1=1';
if p_deptno is not null then
v_sql := v_sql||' AND deptno='||p_deptno;
else
if p_job is not null then
v_sql := v_sql||' AND job='||p_job;
end if;
end if;
OPEN RC FOR v_sql;
LOOP
FETCH RC INTO l_ename;
EXIT WHEN RC%NOTFOUND;
dbms_output.put_line(l_ename);
END LOOP;
CLOSE RC;
END;Thanks.
Edited by: user3565577 on Mar 6, 2010 8:44 PMHi
I've mocked up a simple test and it seems to use the indexes when I try with one or the other values being supplied, I've made an assumption on the indexes you have (i.e. single column indexes on job and deptno),
--indexes on emp table:
p2056@dbapw01> @indexes
Enter value for table_name: emp
Enter value for owner: p2056
INDEX_OWNER INDEX_NAME INDEX_TYPE PAR COLUMN_NAME STATUS
P2056 EMPI1 NORMAL NO DEPTNO VALID
P2056 EMPI2 NORMAL NO JOB VALID
2 rows selected.
--when accessing with a job value
p2056@dbapw01> explain plan for select *
2 from emp
3 where (
4 (null is null and job = 'SALESMAN')
5 OR
6 ('SALESMAN' is null and deptno = null)
7 OR
8 ('SALESMAN' is null and null is null)
9 );
Explained.
p2056@dbapw01> @xplan
PLAN_TABLE_OUTPUT
Plan hash value: 1888885832
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 2 | 154 | 1 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| EMP | 2 | 154 | 1 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | EMPI2 | 2 | | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("JOB"='SALESMAN')
--when accessing with a deptno value
p2056@dbapw01> explain plan for select *
2 from emp
3 where (
4 (2 is null and job = null)
5 OR
6 (null is null and deptno = 2)
7 OR
8 (null is null and 2 is null)
9 );
Explained.
p2056@dbapw01> @xplan
PLAN_TABLE_OUTPUT
Plan hash value: 1336173234
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 77 | 1 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 77 | 1 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | EMPI1 | 1 | | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("DEPTNO"=2) -
Hi friends,
I am using [SBO_SP_PostTransactionNotice] for update. is there any possibility to debug this procedure?. If it is possible pls guide me.
Regards,
SilambuHi,
But Update also happening.
thanks,
silambu -
Please help me debug this program unit!!!!!
dear sir,
i tried diligently to find and to debug this tiny program unit,although my observation to the coding rules of the packages ,compilation error still occur.
therefore,kindly i'm asking you sir to learn me how to correct it.
thank you.
create or replace package test_pack is
type emp_table_type is table of emp.sal%type
index by binary_integer;
emp_list emp_table_type;
function test_sal
(v_sal in emp.sal%type)
return emp_table_type;
end test_pack;
create or replace package body test_pack is
temp emp.sal%type;
cursor emp_cursor is
select sal from emp;
i number :=1;
j number :=1;
function test_sal
(v_sal in emp.sal%type)
return emp_table_type
is
open emp_cursor;
loop
fetch emp_cursor into temp;
if temp < v_sal then
emp_list(i):=temp;
bms_output.put_line('rowcount i='||emp_cursor%rowcount);
dbms_output.put_line('iterator i='||i);
i:=i+1;
else
dbms_output.put_line('rowcount j='||emp_cursor%rowcount);
dbms_output.put_line('iterator j='||j);
j:=j+1;
end if;
if emp_cursor%notfound then
dbms_output.put_line('cursor closed...');
close emp_cursor;
return emp_list;
exit;
end if;
end loop;
end test_pack;You can use "show err" to show the errors after compilation errors occur:
SQL> create or replace package test_pack is
2 type emp_table_type is table of emp.sal%type index by binary_integer;
3 emp_list emp_table_type;
4 function test_sal(v_sal in emp.sal%type) return emp_table_type;
5 end test_pack;
6 /
Package is aangemaakt.
SQL> create or replace package body test_pack is
2 temp emp.sal%type;
3 cursor emp_cursor is
4 select sal from emp;
5 i number :=1;
6 j number :=1;
7
8 function test_sal
9 (v_sal in emp.sal%type)
10 return emp_table_type
11 is
12 open emp_cursor;
13 loop
14 fetch emp_cursor into temp;
15 if temp < v_sal then
16 emp_list(i):=temp;
17 bms_output.put_line('rowcount i='||emp_cursor%rowcount);
18 dbms_output.put_line('iterator i='||i);
19 i:=i+1;
20 else
21 dbms_output.put_line('rowcount j='||emp_cursor%rowcount);
22 dbms_output.put_line('iterator j='||j);
23 j:=j+1;
24 end if;
25 if emp_cursor%notfound then
26 dbms_output.put_line('cursor closed...');
27 close emp_cursor;
28 return emp_list;
29 exit;
30 end if;
31 end loop;
32 end test_pack;
33 /
Waarschuwing: package-body is aangemaakt met compilatiefouten.
SQL> show err
Fouten voor PACKAGE BODY TEST_PACK:
LINE/COL ERROR
14/7 PLS-00103: Symbool "FETCH" aangetroffen terwijl een van de
volgende werd verwacht:
constant exception <een ID>
<een scheidingsteken-ID tussen dubbele aanhalingstekens>
table LONG_ double ref char time timestamp interval date
binary national character nchar
32/5 PLS-00103: Symbool "TEST_PACK" aangetroffen terwijl een van de
volgende werd verwacht:
;To make your program compile, add a begin and end and fix the typo (in bold):
SQL> create or replace package body test_pack is
2 temp emp.sal%type;
3 cursor emp_cursor is
4 select sal from emp;
5 i number :=1;
6 j number :=1;
7
8 function test_sal
9 (v_sal in emp.sal%type)
10 return emp_table_type
11 is
12 begin
13 open emp_cursor;
14 loop
15 fetch emp_cursor into temp;
16 if temp < v_sal then
17 emp_list(i):=temp;
18 dbms_output.put_line('rowcount i='||emp_cursor%rowcount);
19 dbms_output.put_line('iterator i='||i);
20 i:=i+1;
21 else
22 dbms_output.put_line('rowcount j='||emp_cursor%rowcount);
23 dbms_output.put_line('iterator j='||j);
24 j:=j+1;
25 end if;
26 if emp_cursor%notfound then
27 dbms_output.put_line('cursor closed...');
28 close emp_cursor;
29 return emp_list;
30 exit;
31 end if;
32 end loop;
33 end;
34 end test_pack;
35 /
Package-body is aangemaakt.
SQL> declare
2 t test_pack.emp_table_type;
3 begin
4 t := test_pack.test_sal(2000);
5 for i in 1..t.count
6 loop
7 dbms_output.put_line(t(i));
8 end loop;
9 end;
10 /
rowcount i=1
iterator i=1
rowcount i=2
iterator i=2
rowcount i=3
iterator i=3
rowcount j=4
iterator j=1
rowcount i=5
iterator i=4
rowcount j=6
iterator j=2
rowcount j=7
iterator j=3
rowcount j=8
iterator j=4
rowcount j=9
iterator j=5
rowcount i=10
iterator i=5
rowcount i=11
iterator i=6
rowcount i=12
iterator i=7
rowcount j=13
iterator j=6
rowcount i=14
iterator i=8
rowcount i=14
iterator i=9
cursor closed...
800
1600
1250
1250
1500
1100
950
1300
1300
PL/SQL-procedure is geslaagd.To fix the bug of the last iteration and put the variables in the sections they belong:
SQL> create or replace package test_pack is
2 type emp_table_type is table of emp.sal%type index by binary_integer;
3 function test_sal(v_sal in emp.sal%type) return emp_table_type;
4 end test_pack;
5 /
Package is aangemaakt.
SQL> create or replace package body test_pack
2 is
3 function test_sal(v_sal in emp.sal%type) return emp_table_type
4 is
5 emp_list emp_table_type;
6 temp emp.sal%type;
7 cursor emp_cursor is select sal from emp;
8 i number :=1;
9 j number :=1;
10 begin
11 open emp_cursor;
12 loop
13 fetch emp_cursor into temp;
14 if emp_cursor%notfound then
15 dbms_output.put_line('cursor closed...');
16 exit;
17 end if;
18 if temp < v_sal then
19 emp_list(i):=temp;
20 dbms_output.put_line('rowcount i='||emp_cursor%rowcount);
21 dbms_output.put_line('iterator i='||i);
22 i:=i+1;
23 else
24 dbms_output.put_line('rowcount j='||emp_cursor%rowcount);
25 dbms_output.put_line('iterator j='||j);
26 j:=j+1;
27 end if;
28 end loop;
29 close emp_cursor;
30 return emp_list;
31 end;
32 end test_pack;
33 /
Package-body is aangemaakt.
SQL> declare
2 t test_pack.emp_table_type;
3 begin
4 t := test_pack.test_sal(2000);
5 for i in 1..t.count
6 loop
7 dbms_output.put_line(t(i));
8 end loop;
9 end;
10 /
rowcount i=1
iterator i=1
rowcount i=2
iterator i=2
rowcount i=3
iterator i=3
rowcount j=4
iterator j=1
rowcount i=5
iterator i=4
rowcount j=6
iterator j=2
rowcount j=7
iterator j=3
rowcount j=8
iterator j=4
rowcount j=9
iterator j=5
rowcount i=10
iterator i=5
rowcount i=11
iterator i=6
rowcount i=12
iterator i=7
rowcount j=13
iterator j=6
rowcount i=14
iterator i=8
cursor closed...
800
1600
1250
1250
1500
1100
950
1300
PL/SQL-procedure is geslaagd.To be really efficient and not care about looping, using counters and dbms_output, and assuming the emp table won't ever be a big table (else use the LIMIT clause):
SQL> create or replace package body test_pack
2 is
3 function test_sal(v_sal in emp.sal%type) return emp_table_type
4 is
5 emp_list emp_table_type;
6 begin
7 select sal bulk collect into emp_list
8 from emp
9 where sal < v_sal
10 ;
11 return emp_list;
12 end;
13 end;
14 /
Package-body is aangemaakt.
SQL> declare
2 t test_pack.emp_table_type;
3 begin
4 t := test_pack.test_sal(2000);
5 for i in 1..t.count
6 loop
7 dbms_output.put_line(t(i));
8 end loop;
9 end;
10 /
800
1600
1250
1250
1500
1100
950
1300
PL/SQL-procedure is geslaagd.Hope it helps.
Regards,
Rob. -
While opening the iTune Store i receive the following error, "The procedure entry point ADAdPolicyEngine_DidEnterSation could not be located in the dynamic link library iAdCore.dll" Please help me to clear this error.
I faced the same issue. This solved it for me: Troubleshooting issues with iTunes for Windows updates
Hope this helps. -
Need some help in debugging this exported script
Below is DDL generated by visio forward engineering tool . The example below consists of 2 test tables with one foreign key.
Forward engineering generated DDL script
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Table1]') AND type in (N'U'))
DROP TABLE [dbo].[Table1]
GO
CREATE TABLE [dbo].[Table1] (
[test] CHAR(10) NOT NULL
, [test2] CHAR(10) NULL
GO
ALTER TABLE [dbo].[Table1] ADD CONSTRAINT [Table1_PK] PRIMARY KEY CLUSTERED (
[test]
GO
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Table2]') AND type in (N'U'))
DROP TABLE [dbo].[Table2]
GO
CREATE TABLE [dbo].[Table2] (
[test2] CHAR(10) NOT NULL
GO
ALTER TABLE [dbo].[Table2] ADD CONSTRAINT [Table2_PK] PRIMARY KEY CLUSTERED (
[test2]
GO
GO
ALTER TABLE [dbo].[Table1] WITH CHECK ADD CONSTRAINT [Table2_Table1_FK1] FOREIGN KEY (
[test2]
REFERENCES [dbo].[Table2] (
[test2]
GO
GO
When i converted this DDL script using scratch editor the migration tool gave some errors can anyone help me to resolve below
DECLARE
v_temp NUMBER(1, 0) := 0;
BEGIN
BEGIN
SELECT 1 INTO v_temp
FROM DUAL
WHERE EXISTS ( SELECT *
FROM objects
WHERE OBJECT_ID_ = NULL/*TODO:OBJECT_ID(N'[OPS].[Table1]')*/
AND TYPE IN ( N'U' )
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
IF v_temp = 1 THEN
TRUNCATE TABLE Table1;
END IF;
END;
CREATE TABLE Table1
test CHAR(10) NOT NULL,
test2 CHAR(10)
ALTER TABLE Table1
ADD
CONSTRAINT Table1_PK PRIMARY KEY( test );
--SQLDEV:Following Line Not Recognized
DECLARE
v_temp NUMBER(1, 0) := 0;
BEGIN
BEGIN
SELECT 1 INTO v_temp
FROM DUAL
WHERE EXISTS ( SELECT *
FROM objects
WHERE OBJECT_ID_ = NULL/*TODO:OBJECT_ID(N'[OPS].[Table2]')*/
AND TYPE IN ( N'U' )
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
IF v_temp = 1 THEN
TRUNCATE TABLE Table2;
END IF;
END;
CREATE TABLE Table2
test2 CHAR(10) NOT NULL
ALTER TABLE Table2
ADD
CONSTRAINT Table2_PK PRIMARY KEY( test2 );
--SQLDEV:Following Line Not Recognized
ALTER TABLE Table1
ADD
CONSTRAINT Table2_Table1_FK1 FOREIGN KEY( test2 ) REFERENCES Table2 (test2)
--SQLDEV:Following Line Not Recognized
;Pl do not post duplicates - Need some help in debugging this script
-
Pls help me in debugging the emial procedure
Hi;
I am trying to compike this procedure for sending a mail but am unable to rectify the errors..can u ppl pls help me?
DECLARE
m_body CLOB;
mas_id number;
mcust_id number;
mcustomer_name varchar2(100);
mproduct varchar2(15);
minstance varchar2(10);
mtoa varchar2(10);
mton number;
mpriority number;
massesor1 varchar2(15);
massesor2 varchar2(15);
mreviewer1 varchar2(15);
mreviewer2 varchar2(15);
mDoa date;
mstartdate date;
mreviewdate date;
mfinaldate date;
mactualdate date;
mssc varchar2(10);
mpanno number;
mtime varchar2(10);
mcustinterview varchar2(10);
minterviewdate date;
mdev_by varchar2(100);
mcust-feedback varchar2(4000);
mSr_no number;
mgar_id number;
mpoc varchar2(30);
BEGIN
select ASSESMENT_ID, CUSTOMER_ID, CUSTOMER, PRODUCT, INSTANCE, TOA, TON, REL_PRIORITY, ASSESOR1, ASSESOR2, REVIEWER1, REVIEWER2, DOA, START_DATE, REVIEW_DUE_DATE, FINAL_DUE_DATE, ACTUAL_DEL_DATE, SSC , PA_NO, TIME_ENTRY, CUST_INTVW , INTVW_DATE , DEV_BY_ENG , CUST_FB , SR_NO , GAR_ID , POC from assesment into
mas_id,mcust_id, mcustomer_name, mproduct,minstance, mtoa,mton, mpriority, massesor1,massesor2, mreviewer1, mreviewer2, mDoa,mstartdate, mreviewdate, mfinaldate, mactualdate, mssc, mpanno, mtime,mcustinterview, minterviewdate, mdev_by, mcust-feedback,mSr_no, mgar_id, mpoc, from ASSESMENT where
CUSTOMER= :P17_CUSTOMER_ID;
m_body := m_body || ' ' || mas_id || ' ' || mcust_id || ' ' || mcustomer_name || ' ' || mproduct || ' ' || minstance || ' ' || mtoa || ' ' || mton || ' ' || mpriority ||' ' || massesor1 || ' ' || massesor2 ||' ' || mreviewer1 || ' ' || mreviewer2 ||' ' || mDoa || ' ' || mstartdate || ' ' || mreviewdate || ' ' || mfinaldate ||' ' || mactualdate || ' ' || mssc ||' ' || mpanno || ' ' || mtime ||' ' || mcustinterview || ' ' || minterviewdate || ' ' || mdev_by || ' ' || mcust-feedback ||' ' || mSr_no || ' ' || mgar_id ||' ' || mpoc || utl_tcp.crlf ||utl_tcp.crlf;
apex_mail.send( p_to => :P17_TO_ID,
p_from => :P17_FROM_ID ,
p_body => m_body, p_subj => 'Test mail');
APEX_MAIL.PUSH_QUEUE;
END;
Thanks in advance
Samiya
Edited by: user10763992 on Jun 19, 2009 12:15 AMRephrase the select statment;
From:
select ASSESMENT_ID, CUSTOMER_ID, CUSTOMER, PRODUCT, INSTANCE, TOA, TON, REL_PRIORITY, ASSESOR1, ASSESOR2, REVIEWER1, REVIEWER2, DOA, START_DATE, REVIEW_DUE_DATE, FINAL_DUE_DATE, ACTUAL_DEL_DATE, SSC , PA_NO, TIME_ENTRY, CUST_INTVW , INTVW_DATE , DEV_BY_ENG , CUST_FB , SR_NO , GAR_ID , POC from assesment into
mas_id,mcust_id, mcustomer_name, mproduct,minstance, mtoa,mton, mpriority, massesor1,massesor2, mreviewer1, mreviewer2, mDoa,mstartdate, mreviewdate, mfinaldate, mactualdate, mssc, mpanno, mtime,mcustinterview, minterviewdate, mdev_by, mcust-feedback,mSr_no, mgar_id, mpoc, from ASSESMENT where
CUSTOMER= :P17_CUSTOMER_ID;
To:
select ASSESMENT_ID, CUSTOMER_ID, CUSTOMER, PRODUCT, INSTANCE, TOA, TON, REL_PRIORITY, ASSESOR1, ASSESOR2, REVIEWER1, REVIEWER2, DOA, START_DATE, REVIEW_DUE_DATE, FINAL_DUE_DATE, ACTUAL_DEL_DATE, SSC , PA_NO, TIME_ENTRY, CUST_INTVW , INTVW_DATE , DEV_BY_ENG , CUST_FB , SR_NO , GAR_ID , POC into mas_id,mcust_id, mcustomer_name, mproduct,minstance, mtoa,mton, mpriority, massesor1,massesor2, mreviewer1, mreviewer2, mDoa,mstartdate, mreviewdate, mfinaldate, mactualdate, mssc, mpanno, mtime,mcustinterview, minterviewdate, mdev_by, mcust-feedback,mSr_no, mgar_id, mpoc from ASSESMENT where CUSTOMER= :P17_CUSTOMER_ID;
Regards,
Anasuya -
Please help debug 'this.events[...] is null or not an object
Hi.
I'm getting this error : line 3267 this.events[...] is null or not an object.
How can I debug this? when I click yes to debug, I am not brought to my line of code, so I can't figure it out. has anyone encountered this before?Hi. thank you for your response. I actually think i pinpointed the code, but don't know how to resolve it.
it seemed to be coming from a script. when i attempted to delete the javascript, i got a message that it was in use. i deleted all instances of calling it from my afc, when i click 'afc' tab from the scripts page, it still shows that the script is called. the peculiar thing is that it has the correct form, but when it comes to having the name of the dictionary field, it does NOT have it (usual format is 'dictionaryfieldname: when the item is changed', but instead just has 'when the item is changed'. assuming that there was some hanging pointer, i subsequently added this script to all my fields in the afc, and hoped that when i would delete them , it would pick up the orphan reference. if anyone has any ideas how to get around this sticky issue, i'd be greatful. i do not want to delete the afc, or dictionary. -
How to debug a procedure in SQL Developer
i am a plsql writer .... i use SQL Developer to connect to oracle on windows platform ... iam using oracle
version 10g some time i need to debug a procedure or i want to run a procedure in debug mode
please tell me how to do this SQL DeveloperThere's great help inside sqldev, just follow the Help Contents - Concepts and usage - Running and debugging...
Have fun,
K. -
Debug Stored procedure or database trigger by 10g Forms
Hi,
I want to debug my table level trigger (On update for each row), I am updating this table by forms. When I debug this form I am unable to watch the database debug.
Please help me regarding database trigger/function/procedures by debugging forms.not possible via forms
you can debug it on SQL Developer by using manual INSERT Updates commands -
Help needed in TEXT determination procedure - Urgent
Hi Experts,
I have defined my own text determination procedure for complaints. This procedure is for the item category for the transaction(complaint).
The following are the Text ID's that I have include in my procedure :
1. C001
2. C002
3. C003
My requirment is to have logs(history) for each of the text id's(C001, C002, C003).
i.e. what ever i do in C001, it has to be loogged only in text id let;s say ZC001, same way C002 shld be logged only in ZC002 and C003 in ZC003.
I have also defined ZC001, ZC002, ZC003 in the text detrmination procedure.
Please help me in slving this problem. Can i do it in the config itself or shld i go for development?.
Regards,
Arul Jothi A.hi,
This is what exactly i am lloking for, but i tried with your proposal. It didint work.
Please find the detailos below.
Text Object CRM_ORDERI
Text Det.Proc: ZCOMP001
Text Type Description Seq. changes Transfer Access Seq.
C001 Complaints Text 0001 P - -
Z001 complaints1 0002 R A ZC01
C002 Internal note 0003 P - -
Z002 original text test 0004 R A ZC02
C003 Recomm. Solution 0005 P - -
Z003 original text 3 0006 R A ZC03
Access Seq :
ZC01 :
Ref. Object CRM_ORDERI
Ref. Text Type C001
continue chcked.
ZC02.
Ref. Object CRM_ORDERI
Ref. Text Type C002
continue chked
ZC03.
Ref. Object CRM_ORDERI
Ref. Text Type C003
continue chked
I want to log all C001 text into Z001 only, C002 in Z002 only and C003 in Z003 only.
hope you got it....
Please help.
Regrads,
Arul Jothi A -
Help me to apply this sapnote please!
I've never done it before.
So we would apply this note e 1025910 - HR-IT:
Our system is SAP R/3 Enterprise with SAP_HR 470 0058
I undesterdtand the i have to download 470_132315_SYST.CAR and ALL_222454_CUST.CAR.
But then, what i have to do?
The note explain also that some table must be customized
Pls can you help me in this procedure?Hello Sleep,
The OSS notes indeed are tricky.
Prerequisite notes for 1025910:
***989847 - HR-IT: Finanziaria 2007
Prerequisite notes for 989847
***964635
***1015793
So ideal note sequence must be:
#1 Apply note 964635
#2 Apply note 1015793
#3 Apply note 989847
#4 Apply note 1025910
*Notes are usually linked to support packages, check if the linked support package is applied. (Check if the correction instructions mentioned in the note have already been applied by the suport package)
*Please plan your steps before you execute.
*Make detail notes of all manual changes made to the system.
*Check if you have a recent successfull backup (incase of emergency)
*Export the data from tables before you make any changes (incase you need to revert back).
Regards,
Ammey Kesarkar
<i>'All the best'</i>
Maybe you are looking for
-
Adobe Acrobat 9.0 Pro crashes at start up: Runtime Error-please help
I have Adobe CS4 installed on my Windows 7 PC. In addition, I have Adobe Reader XI and InDesign 6 installed. If I remember correctly, after I installed Adobe Reader XI, I uninstalled the version of the Reader which came with CS4. So here's my problem
-
hai. i need help. and just for heads up, i;m not computer/tech savvy. i dont remember when this problem was started (maybe around 2 or 3 months ago) but everytime i opened some sites, the page displayed for a while then it reload itself and shown a b
-
Apple TV all of a sudden cannot connect to Wifi
My apple tv just stopped being able to connect to my wifi. It locates it and all of my other devices, both apple and PC are connected to the Wifi and streaming without a problem. I've restarted and tried to restore, troubleshoot, disconnect, try an
-
Download Link in Interactive Report isn't Showing
I'm not sure if this is a bug or not, but I have an interactive report which allows users to download the report (under the Actions menu). The download formats that were used previously were HTML, Email and PDF, and it worked perfectly fine. However,
-
Help! HTML Data set not working in IE (but in all other browsers)
Hi there, I am totally desperate - I built a master/detail region page using a HTML data set. http://www.atcongress.com/programme/continuousLearningByName.html It works fine in Firefox/Safari/Chrome/Opera. Only IE7 and IE8 give me grief - displaying