Error in PL/SQL block..
Hi Im facing an error in the following code.. Cant trace it out.
/* Formatted on 2009/10/21 22:09 (Formatter Plus v4.8.8) */
DECLARE
latest_task_id NUMBER;
task_name_em7 VARCHAR2 (50);
select_flag_em7 NUMBER := 1;
ds_count_em7 NUMBER;
stateid NUMBER;
ds_id_em7 NUMBER;
server_id_em7 NUMBER;
BEGIN
SELECT server_id
INTO server_id_em7
FROM ems_servers
WHERE server_name = :P82_EM7_COLLECTOR;
FOR i IN 1 .. apex_application.g_f01.COUNT
LOOP
SELECT COUNT (*)
INTO ds_count_em7
FROM delivered_service_mapping
WHERE equipment_id = apex_application.g_f01(i)
AND termination_id IS NULL;
IF ds_count_em7 = 0
THEN
MERGE INTO provision_em7 pem7
USING (SELECT apex_application.g_f01(i) apex_equip_id_em7
FROM DUAL) a
ON ( a.apex_equip_id_em7 = pem7.equipment_id
AND pem7.termination_id IS NULL)
WHEN MATCHED THEN
UPDATE
SET "PROVISION_STATE_ID" = 2, "SERVER_ID" = server_id_em7,
"LAST_PROVISION_BY" = :app_user
WHERE provision_state_id IN (1, 4, 10, 5)
WHEN NOT MATCHED THEN
INSERT (EQUIPMENT_ID, PROVISION_STATE_ID, ERROR_CODE,
SERVER_ID, LASTMODIFIED_BY, LAST_MODIFIED_ON,
REMARKS, COLLECTOR_IP, COLLECTION_STATE,CURRENT_STATE)
VALUES (a.apex_equip_id_em7,2,NULL,server_id_em7,:APP_USER,SYSDATE,NULL,NULL,NULL,NULL NULL, , , 'remarks_by_navarose for iv',
SELECT delivered_service_id
INTO ds_id_em7
FROM delivered_service
WHERE delivered_service_name = apex_application.g_f02(i);
INSERT INTO delivered_service_mapping
(ID, customer_id,
equipment_id, termination_id, delivered_service_id,
last_modified_by, last_modified_on
VALUES (delivered_service_seq.NEXTVAL, NULL,
apex_application.g_f01(i), NULL, ds_id_em7,
:APP_USER, SYSDATE
select_flag_em7 := 0;
ELSE
UPDATE delivered_service_mapping SET delivered_service_id = apex_application.g_f01(i),
last_modified_by = :APP_USER, last_modified_on = SYSDATE;
select_flag_em7 := 0;
END IF;
END LOOP;
IF select_flag_em7 = 0
THEN
IF P82_CHECK_TASK_NAME_EM7 = 1
THEN
IF :P82_CHECK_TASK_NAME_EM7 IS NULL
THEN
task_name_em7 :=
:app_user
|| '_PROVISIONING PERIODIC EM7_'
|| TO_CHAR (SYSDATE, 'YYYYMMDD_HHMISS');
INSERT INTO tasks
(task_id, task_name, created_by,
created_on, task_action, task_state_id, server_id
VALUES (task_id_seq.NEXTVAL, task_name_em7, :app_user,
SYSDATE, 14, 1, server_id_em7
ELSE
INSERT INTO tasks
(task_id, task_name, created_by,
created_on, task_action, task_state_id, server_id
VALUES (task_id_seq.NEXTVAL, :P82_TASK_NAME_EM7, :app_user,
SYSDATE, 14, 1, server_id_em7
END IF;
SELECT MAX (task_id)
INTO latest_task_id
FROM tasks
WHERE created_by = :APP_USER;
FOR i IN 1 .. apex_application.g_f01.COUNT
LOOP
INSERT INTO task_details
(task_details_id,
equipment_id, task_id
VALUES (task_detail_seq.NEXTVAL,
apex_application.g_f01 (i), latest_task_id
END LOOP;
END IF;
END IF;
END;The errror is
1 error has occurred
ORA-06550: line 42, column 123: PL/SQL: ORA-00917: missing comma ORA-06550: line 28, column 10: PL/SQL: SQL Statement ignored
Hi,
This line:
VALUES (a.apex_equip_id_em7,2,NULL,server_id_em7,:APP_USER,SYSDATE,NULL,NULL,NULL,NULL NULL, , , 'remarks_by_navarose for iv',needs a comma between the two nulls - there's just a huge gap instead!
Andy
Similar Messages
-
Exception error in PL/SQL block
Hi,
do the following conditions in a PL/SQL block cause an exception error to occur ?
A- Select statement does not return a row.
B- Select statement returns more than one row.
Thank you.If you're talking about SELECT INTO then yes:
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
Connected as cmza
SQL> set serveroutput on
SQL>
SQL> declare
2 v_text varchar2(4000);
3 begin
4 -- question 1
5 select banner
6 into v_text
7 from v$version;
8 end;
9 /
declare
v_text varchar2(4000);
begin
-- question 1
select banner
into v_text
from v$version;
end;
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at line 6
SQL> declare
2 v_text varchar2(4000);
3 begin
4 -- question 2
5 select banner
6 into v_text
7 from v$version
8 where 1 = 2;
9 end;
10 /
declare
v_text varchar2(4000);
begin
-- question 2
select banner
into v_text
from v$version
where 1 = 2;
end;
ORA-01403: no data found
ORA-06512: at line 6
SQL> -
Error in PL/SQL Block of Trigger
Hi all,
I have written a trigger whose PL/SQL block contains a simple select statment among many other statements.
Now I find that, if the select statement returns no rows the trigger does not continue its operation further and aborts there itself. And if the select statement returns some rows, then it works fine.
I tried to execute a simplified PL/SQL block of the trigger in SQL*Plus and following were the results:
declare
tempdate date;
begin
select trdt into tempdate from inv_trans;
if sql%notfound then
null;
end if;
end;
When no data is present in inv_trans table, the result was:
declare
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at line 4
And when the table inv_trans had data, the result was:
PL/SQL procedure successfully completed.
Why is the piece of code flashing an error when I have already given a treatment if no data is found.
Why is it taking "No Data in table" as an abnormal condition and not normal?
THanks in advance
Warm Regards
ManuIn your case you have to use a cursor:
declare
cursor c_cur is
select trdt from inv_trans;
r_cur c_cur%rowtype;
begin
open c_cur;
fetch c_cur into r_cur;
if c_cur%notfound then
[pre] -
Hii All,
I'm facing the following error
ERROR at line 66:
ORA-06550: line 66, column 20:
PLS-00306: wrong number or types of arguments in call to '||'
ORA-06550: line 66, column 11:
PL/SQL: Statement ignoredVersion Details
SQL> select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
CORE 11.1.0.7.0 Production
TNS for Solaris: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - ProductionMy pl sql block
Declare
p_table_name clob := 'CP_CA_DTLS' ;
Type t_column_name_tab is table of varchar2(4000)
index by binary_integer;
l_table_tab t_column_name_tab;
l_file_name constant varchar2(5000) := 'column_counts';
l_count number;
l_tab_count number;
l_str varchar2(32000);
l_tbl_str varchar2(32000);
Cursor c_table_columns(c_table_name user_tables.table_name%type)
Is
Select column_name
from user_tab_cols
where table_name = upper(c_table_name);
Type t_table_columns is table of c_table_columns%rowtype;
l_column_name_tab t_table_columns;
Begin
--Splitting comma seperated data
Select regexp_substr(p_table_name,'[^,]+{1}',1,level)
bulk collect into l_table_tab
from dual
connect by level <= length(regexp_replace(p_table_name,'[^,]*'))+1;
for k in 1..l_table_tab.count
loop
-- dbg_print(l_file_name,'***'||l_table_tab(k)||'***');
Begin
l_tbl_str := 'Select count(*) from '||l_table_tab(k);
execute immediate l_tbl_str into l_tab_count;
-- dbg_print(l_file_name,'Overall Count of table '||l_table_tab(k)||' is '||l_tab_count);
End;
-- dbg_print(l_file_name,'Column Name '||','||'Count');
Open c_table_columns(l_table_tab(k));
loop
Fetch c_table_columns bulk collect into l_column_name_tab limit 50;
exit when l_column_name_tab.count = 0;
dbms_output.put_line('l_column_name_tab.count count is : '||l_column_name_tab.count);
for i in 1..l_column_name_tab.count
loop
Begin
l_str := 'Select count(*) ' ;
l_str := l_str||' from '||l_table_tab(k) ;
l_str := l_str||' where '||l_column_name_tab(i);
l_str := l_str||' is null' ;
Execute Immediate l_str into l_count;
End;
--dbg_print(l_file_name,l_column_name_tab(i)||','||l_count);
end loop;
end loop;
Close c_table_columns;
end loop;
dbms_output.put_line('l_column_name_tab.count count is : '||l_column_name_tab.count);
End;Even I'm not able to print l_column_name_tab(i) using dbms_output.
(Later I came to know that this information can be achieved using user_tab_col_statistics table)
But would like to know whats wrong with my code.???
Plz help me .
Edited by: 792353 on Dec 3, 2010 1:26 AMHii RDB,
when I comment this part of code
-- l_str := l_str||' where '||l_column_name_tab(i);
-- l_str := l_str||' is null' ;
SQL> Declare
2
3
4 p_table_name clob := 'CP_CA_DTLS' ;
5
6 Type t_column_name_tab is table of varchar2(4000)
7 index by binary_integer;
8
9 l_table_tab t_column_name_tab;
10
11
12
13
14 l_file_name constant varchar2(5000) := 'column_counts';
15 l_count number;
16 l_tab_count number;
17 l_str varchar2(32000);
18 l_tbl_str varchar2(32000);
19
20 Cursor c_table_columns(c_table_name user_tables.table_name%type)
21 Is
22 Select column_name
23 from user_tab_cols
24 where table_name = upper(c_table_name);
25
26
27 Type t_table_columns is table of c_table_columns%rowtype;
28
29
30 l_column_name_tab t_table_columns;
31
32 Begin
33 --Splitting comma seperated data
34
35 Select regexp_substr(p_table_name,'[^,]+{1}',1,level)
36 bulk collect into l_table_tab
37 from dual
38 connect by level <= length(regexp_replace(p_table_name,'[^,]*'))+1;
39
40 for k in 1..l_table_tab.count
41 loop
42 -- dbg_print(l_file_name,'***'||l_table_tab(k)||'***');
43
44 Begin
45 l_tbl_str := 'Select count(*) from '||l_table_tab(k);
46
47 execute immediate l_tbl_str into l_tab_count;
48
49 -- dbg_print(l_file_name,'Overall Count of table '||l_table_tab(k)||' is '||l_tab_coun
t);
50
51 End;
52
53 -- dbg_print(l_file_name,'Column Name '||','||'Count');
54
55 Open c_table_columns(l_table_tab(k));
56 loop
57 Fetch c_table_columns bulk collect into l_column_name_tab limit 50;
58 exit when l_column_name_tab.count = 0;
59 dbms_output.put_line('l_column_name_tab.count count is : '||l_column_name_tab.count);
60 for i in 1..l_column_name_tab.count
61 loop
62
63 Begin
64 l_str := 'Select count(*) ' ;
65 l_str := l_str||' from '||l_table_tab(k) ;
66 -- l_str := l_str||' where '||l_column_name_tab(i);
67 -- l_str := l_str||' is null' ;
68
69 Execute Immediate l_str into l_count;
70
71 End;
72
73 --dbg_print(l_file_name,l_column_name_tab(i)||','||l_count);
74
75 end loop;
76 end loop;
77 Close c_table_columns;
78 end loop;
79
80 dbms_output.put_line('l_column_name_tab.count count is : '||l_column_name_tab.count);
81 End;
82 /
PL/SQL procedure successfully completed.its running fine so the problem is l_column_name_tab(i) !!!!!!
and there is nothing wrong with l_table_tab(k) and its declaration.
Edited by: 792353 on Dec 3, 2010 2:17 AM -
Hi
If I run PL/SQL block
DECLARE
CURSOR C1 is SELECT CLM_CASE_NO FROM CLAIM_OBJECT.CLM_INVLVD_PRTY_T where CLM_CASE_NO=XXXX;
BEGIN
FOR X in C1 loop
INSERT INTO POSTL_ADDRS_ARCHIVE P (SELECT A.* FROM CLAIM_OBJECT.POSTL_ADDRS A, CLAIM_OBJECT.CLM_INVLVD_PRTY_T C WHERE
C.CLNT_NO = A.CLNT_NO AND C.CURR_ROW_IND='A' AND C.CLM_CASE_NO =X.CLM_CASE_NO );
end loop;
end;
there is no error with the above block
If I remove where clause in cursor and run block
DECLARE
CURSOR C1 is SELECT CLM_CASE_NO FROM CLAIM_OBJECT.CLM_INVLVD_PRTY_T;
BEGIN
FOR X in C1 loop
INSERT INTO POSTL_ADDRS_ARCHIVE P (SELECT A.* FROM CLAIM_OBJECT.POSTL_ADDRS A, CLAIM_OBJECT.CLM_INVLVD_PRTY_T C WHERE
C.CLNT_NO = A.CLNT_NO AND C.CURR_ROW_IND='A' AND C.CLM_CASE_NO =X.CLM_CASE_NO );
end loop;
end;
ERROR at line 1:
ORA-01013: user requested cancel of current operation
ORA-06512: at line 12
I searched for ORA-06512
Cause:
This error message indicates the line number in the PLSQL code that the error resulted.
SELECT CLM_CASE_NO FROM CLAIM_OBJECT.CLM_INVLVD_PRTY_T has over 800,672 records.
SELECT CLM_CASE_NO FROM CLAIM_OBJECT.CLM_INVLVD_PRTY_T where CLM_CASE_NO=XXXX; has 2 records.
I am not not understanding why block 2 is throwing error (with no where clause in cursor)
Any help will be greatly appreciated
Thanks in advanceAs the error message indicates clearly the process was cancelled as you pressed CTRL+C. And yes you can’t see any data you insert in one session from other session until it gets committed. And as others have mentioned row by row operation is very expensive think about revising your approach.
Instead of having a cursor why don’t you join it directly in you select in the insert statement and try?
Thanks,
Karthick.
Message was edited by:
karthick_arp -
Error in pl/sql block with parameters
Hi,
I have the following code which works in normal cursor forloops,
Can some one please check how to achive the same functionality using bulk insert.( i want to use parameterised cursor)
step 1 ---working
declare
CURSOR DEPT_inst
is
select d.deptno
from dept d where d.dname='RESEARCH';
CURSOR emp_inst (p_dept in number)
IS
SELECT e.empno ,
e.ename ,
e.deptno
from emp1 e
where e.deptno = p_dept;
begin
for i in dept_inst loop
delete from emp2 where deptno=i.deptno;
for j in emp_inst(i.deptno) loop
INSERT INTO emp2(empno,
ename,
deptno )
VALUES (j.empno,
j.ename,
j.deptno
end loop;
end loop;
commit;
exception
when others then
dbms_output.put_line( 'exception in err insert'||SQLERRM);
ROLLBACK;
end;
step - 2 compilation error
declare
CURSOR DEPT_inst
is
select d.deptno
from dept d where dname='RESEARCH';
CURSOR emp_inst (p_dept in number)
IS
SELECT e.empno ,
e.ename ,
e.deptno
from emp1 e
where e.dept = p_dept;
TYPE id_tab_dep_1 IS TABLE OF dept_inst%ROWTYPE
INDEX BY PLS_INTEGER;
t_id_dep_1 id_tab_dep_1;
TYPE id_tab_det_1 IS TABLE OF emp_inst(t_id_det_1(indxi).deptno)%ROWTYPE
INDEX BY PLS_INTEGER;
t_id_det_1 id_tab_det_1;
BEGIN
OPEN dept_inst;
FETCH dept_inst
LOOP
BULK COLLECT into t_id_dep_1 LIMIT 100;
EXIT WHEN t_id_dep_1.count <= 0;
FOR indxi IN t_id_det_1.FIRST .. t_id_det_1.LAST LOOP
delete from emp2 where deptno=t_id_det_1(indxi).deptno;
OPEN emp_inst;
LOOP
FETCH emp_inst(t_id_det_1(indxi).deptno)
BULK COLLECT INTO t_id_det_1 limit 100;
EXIT WHEN t_id_det_1.count <= 0;
FOR indxj IN t_id_det_1.FIRST .. t_id_det_1.LAST LOOP
INSERT INTO emp2(empno,
ename,
deptno )
VALUES (t_id_det_1(indxj).empno,
t_id_det_1(indxj).ename,
t_id_det_1(indxj).deptno
END LOOP;
END LOOP;
CLOSE emp_inst;
END LOOP;
END LOOP;
CLOSE dept_inst;
EXCEPTION
WHEN OTHERS
THEN
dbms_output.put_line( 'exception in err insert' || SQLCODE ||' ' ||SQLERRM);
ROLLBACK;
RETURN;
END;
I am getting below error
TYPE id_tab_det_1 IS TABLE OF emp_inst(t_id_det_1(indxi).deptno)%ROWTYPE
ERROR at line 16:
ORA-06550: line 16, column 69:
PLS-00103: Encountered the symbol "%" when expecting one of the following:
; not null alter index characterEdited by: user11289444 on Dec 26, 2010 3:58 AMhoek wrote:
I was referring to OP's second Bulk DML, the insert part.
You cannot reference individual columns there.Then you have to be even more specific. You cannot reference individual columns there unless you are on 11g:
SQL> select * from v$version
2 /
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
SQL> declare
2 cursor dept_inst
3 is
4 select d.deptno
5 from dept d
6 where d.dname = 'RESEARCH';
7 --
8 cursor emp_inst(b_deptno in number)
9 is
10 select e.empno
11 , e.ename
12 , e.deptno
13 from emp1 e
14 where e.deptno = b_deptno;
15 --
16 type depttype is table of number index by binary_integer;
17 depttab depttype;
18 type emptype is table of emp_inst%rowtype /*this will not work*/ index by binary_integer;
19 emptab emptype;
20 --
21 begin
22 --
23 open dept_inst;
24 loop
25
26 fetch dept_inst bulk collect into depttab limit 100;
27 forall i in depttab.first..depttab.last
28 delete from emp2 where deptno = depttab(i);
29 --
30 dbms_output.put_line(sql%rowcount||' records were deleted from table emp2');
31 --
32 -- open emp_inst(depttab(i));
33 open emp_inst(depttab(1));
34 loop
35 fetch emp_inst bulk collect into emptab limit 100;
36 forall j in emptab.first..emptab.last
37 insert into emp2 values(emptab(j).empno,emptab(j).ename,emptab(j).deptno);
38 --
39 exit when emp_inst%notfound;
40 --
41 end loop;
42 exit when dept_inst%notfound;
43 close dept_inst;
44 --
45 end loop;
46 close dept_inst;
47 end;
48 /
insert into emp2 values(emptab(j).empno,emptab(j).ename,emptab(j).deptno);
ERROR at line 37:
ORA-06550: line 37, column 35:
PLS-00436: implementation restriction: cannot reference fields of BULK In-BIND
table of records
ORA-06550: line 37, column 35:
PLS-00382: expression is of wrong type
ORA-06550: line 37, column 51:
PLS-00436: implementation restriction: cannot reference fields of BULK In-BIND
table of records
ORA-06550: line 37, column 51:
PLS-00382: expression is of wrong type
ORA-06550: line 37, column 67:
PLS-00436: implementation restriction: cannot reference fields of BULK In-BIND
table of records
ORA-06550: line 37, column 67:
PLS-00382: expression is of wrong type
ORA-06550: line 37, column 35:
PL/SQL: ORA-22806: not an object or REF
ORA-06550: line 37, column 11:
PL/SQL: SQL Statement ignored
SQL> select * from v$version
2 /
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL> declare
2 cursor dept_inst
3 is
4 select d.deptno
5 from dept d
6 where d.dname = 'RESEARCH';
7 --
8 cursor emp_inst(b_deptno in number)
9 is
10 select e.empno
11 , e.ename
12 , e.deptno
13 from emp1 e
14 where e.deptno = b_deptno;
15 --
16 type depttype is table of number index by binary_integer;
17 depttab depttype;
18 type emptype is table of emp_inst%rowtype /*this will not work*/ index by binary_integer;
19 emptab emptype;
20 --
21 begin
22 --
23 open dept_inst;
24 loop
25
26 fetch dept_inst bulk collect into depttab limit 100;
27 forall i in depttab.first..depttab.last
28 delete from emp2 where deptno = depttab(i);
29 --
30 dbms_output.put_line(sql%rowcount||' records were deleted from table emp2');
31 --
32 -- open emp_inst(depttab(i));
33 open emp_inst(depttab(1));
34 loop
35 fetch emp_inst bulk collect into emptab limit 100;
36 forall j in emptab.first..emptab.last
37 insert into emp2 values(emptab(j).empno,emptab(j).ename,emptab(j).deptno);
38 --
39 exit when emp_inst%notfound;
40 --
41 end loop;
42 exit when dept_inst%notfound;
43 close dept_inst;
44 --
45 end loop;
46 close dept_inst;
47 end;
48 /
PL/SQL procedure successfully completed.
SQL> SY. -
Why sys_extract_utc(sysdate) never causes error in pl/sql block?
Oracle 11.2
I cannot use
SELECT sys_extract_utc(sysdate) FROM DUAL But I can use
v := sys_extract_utc(sysdate)in a procedure or a trigger without causing any compile or run-time error.
In my opinion, the return value of function sysdate doesn't contain any timezone info, so it should not be able to be used as the parameter of function sys_extract_utc, because it needs timezone info to do the conversion.
Any clues?
Thanks in advance.Kiran wrote:
use systimestamp it will contain timezone.I know, what I don't know is why sys_extract_utc(sysdate) can be used in procedure without causing any error. It should cause error, right? -
Error while invoking webservice using UTL_HTTP from PL/SQL Block
Hi All,
I am invoking a webservice (SOAP Request) from a PL/SQL block using UTL_HTTP package.
I am able to send the complete request and am getting the required instance on the BPEL Console, but the process is erroring out while getting response back.
and the PL/SQL Block is ending in error mentioned below:
ERROR at line 1:
ORA-29266: end-of-body reached
ORA-06512: at "SYS.UTL_HTTP", line 1321
ORA-06512: at "APPS.CSM_BPEL_TEST_PKG", line 34
ORA-06512: at line 1
Package is completing successfully if i test in local DB and local BPEL.
But giving above error in client's.
Can anyone let me know what is the cause of this.
Thanks in advanceI got it working by making process Synchronous.
But with asynchronous process it is still same error.
Thanks... -
PL/SQL block query error when going to a remote system with 1 parameter.
Hi,
I am getting the error:
Invalid function body condition: ORA-01460: unimplemented or unreasonable conversion requested ORA-02063: preceding line from HANSEN_REMOTE
The issue appears to result from opening a cursor that is a select statement is in some way accessing records via a dblink and the 'where' clause is has more then one session parameter in it. Here is the smallest pl/sql block that results with an error:
DECLARE
CURSOR c_GetPay IS
SELECT PERSON_ID
FROM CASH_PERSON@HANSEN_REMOTE
WHERE LAST_NAME = :P320_HANSEN_LAST_NAME
AND FIRST_NAME = :P320_HANSEN_FIRST_NAME;
BEGIN
OPEN c_GetPay ;
CLOSE c_GetPay ;
RETURN TRUE;
END ;
If I remove 'AND FIRST_NAME = :P320_HANSEN_FIRST_NAME' from the curser, there is no problem. This block of pl/sql is in a On Load: Before Header
on a page branch. This issue remains consistent in our 1.6.1.00.02 instance of HTMLDB with an Oracle database version 10.1.0.3.0. This instance is
a fresh install of the 10g and HTMLDB.
Does any one have any ideas of why I am getting this error message. I really need to get it resolve soon as we are trying to get an application up by the end of August and there is still alot of coding needing to be done.
Thanks for the help.
LanieScott, I have tried everything that this point except copy the whole table from the remote system.
Here is a short version of what I have tried...
-- hard coded condition...timing was not an issue here...it was quick.
declare
v_in_PersonId number(9);
cursor c_GetPay
IS select PERSON_ID --, first_name, LAST_NAME
from HANSEN_CONTACT
where first_name like 'LANIE'
AND last_name LIKE 'MOORE'
BEGIN
OPEN c_GetPay;
FETCH c_GetPay INTO v_in_PersonId;
CLOSE c_GetPay;
RETURN TRUE;
END
-- this is an internal variable set to the string literal...does not as the v function was not called.
declare
V_TEST VARCHAR2(150);
V_TEST2 VARCHAR2(150);
v_in_PersonId number(9);
cursor c_GetPay
IS select PERSON_ID --, first_name, LAST_NAME
from HANSEN_CONTACT
where first_name like :V_TEST
AND last_name LIKE :V_TEST2
BEGIN
V_TEST := 'LANIE';
V_TEST2 := 'MOORE';
OPEN c_GetPay;
FETCH c_GetPay INTO v_in_PersonId;
CLOSE c_GetPay;
RETURN TRUE;
END
-- this has the v function called in the cursor since no matter what I do, I have to call it so I don't get my original error. This takes over a minute to return, and it is using hard coded values...if I use session variables where I place the information from the user, it takes even longer.
declare
V_TEST VARCHAR2(150);
V_TEST2 VARCHAR2(150);
v_in_PersonId number(9);
cursor c_GetPay
IS select PERSON_ID --, first_name, LAST_NAME
from HANSEN_CONTACT
where first_name like V(:V_TEST)
AND last_name LIKE V(:V_TEST2)
BEGIN
V_TEST := 'LANIE';
V_TEST2 := 'MOORE';
OPEN c_GetPay;
FETCH c_GetPay INTO v_in_PersonId;
CLOSE c_GetPay;
RETURN TRUE;
END
It does not appear to be an issue if I am looking at a view going to the remote system or the table it's self. The slowness issue takes place. (In short I have tried replacing HANSEN_CONTACT which is a view with the direct table link of imsv7.contact@HANSEN_REMOTE and that did not solve the timing issue).
Any ideas? -
PL/SQL block error message
Hi,
I'm still learning PL/SQL. In my application, I created a PL/SQL block which contains an update and an insert statement. When I click Apply Changes, I receive the following error message:
1 error has occurred
ORA-06550: line 24, column 5: PL/SQL: ORA-00933: SQL command not properly ended ORA-06550: line 19, column 2: PL/SQL: SQL Statement ignored
This is my code. I'm not seeing the problem very clearly. Can someone help me out? Thanks.
BEGIN
update
HISA_AGREEMENTS
set
CREATED_BY=V('APP_USER'),
LAST_UPDATED_BY=V('APP_USER'),
APPROVER_SALUTATION=:P7_APPROVER_SALUTATION,
APPROVER_FIRST_NAME=:P7_APPROVER_FIRST_NAME,
APPROVER_MIDDLE_INITIAL=:P7_APPROVER_MIDDLE_INITIAL,
APPROVER_LAST_NAME=:P7_APPROVER_LAST_NAME,
APPROVER_NAME_SUFFIX=:P7_APPROVER_NAME_SUFFIX,
APPROVER_EMAIL_ADDR=:P7_APPROVER_EMAIL_ADDR,
SPONSOR_EMAIL_ADDR=:P7_SPONSOR_EMAIL_ADDR,
APPROVER_TITLE=:P7_APPROVER_TITLE
where
ORG_KEY_LE=:P7_ORG_KEY_LE;
insert into
HISA_AGREEMENT_DOCS
(ORG_DOC_CURR_KEY)
values
(:P7_DOCUMENT)
where
ORG_KEY_LE=:P7_ORG_KEY_LE;
END;Hello,
insert into
HISA_AGREEMENT_DOCS
(ORG_DOC_CURR_KEY)
values
(:P7_DOCUMENT)
where
ORG_KEY_LE=:P7_ORG_KEY_LE;
is wrong. The WHERE clause needs to be omitted...or you need an update.
Greetings,
Roel
http://roelhartman.blogspot.com/
You can reward this reply by marking it as either Helpful or Correct ;-) -
While executing the following pl/sql block Iam getting following error
While executing the following pl/sql block
Iam getting following error
ORA-06550: line 5, column 11:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 5, column 11:
PL/SQL: Item ignored
declare
TYPE t_customer_details IS REF CURSOR;
o_customer_details t_customer_details;
v_rec o_customer_details%ROWTYPE;
begin
o_customer_details:=pkg_search.fngetcustdetails( 2727,1000841, NULL,NULL,119105329);
LOOP
FETCH o_customer_details INTO rec ;
EXIT WHEN o_customer_details%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(' print' );
END LOOP;
CLOSE o_customer_details;
end;sorry
declare
TYPE t_customer_details IS REF CURSOR;
o_customer_details t_customer_details;
begin
o_customer_details:= pkg_search.fngetcustdetails( 2727,1000841, NULL,NULL,119105329);
FOR v_rec IN o_customer_details
LOOP
DBMS_OUTPUT.PUT_LINE(' print' );
END LOOP;
END;I changed code,
Can you say , o_customer_details:= pkg_search.fngetcustdetails( 2727,1000841, NULL,NULL,119105329); is it right?
pkg_search.fngetcustdetails return ref cursor?? -
PL/SQL Block working fine but same code procedure is giving error.
Hi Experts,
I am executing procedure getting error ORA-27486: insufficient privileges
If It's PL/SQL block it's creating job classes.
Both the cases same user.
CREATE OR REPLACE PROCEDURE JOB_CLASS_PROC
AS
V_SQL VARCHAR2 (4000);
V_JOB_STEP VARCHAR2 (50);
BEGIN
-- Create Job Class if not exist
BEGIN
FOR i
IN (SELECT SNS.OWNER_NAME OWNER_NAME,
VDB.NAME
SNAME
FROM SCHEMA_NAMES SNS,
V$DATABASE VDB
WHERE OWNER_NAME NOT IN ('')
AND (OWNER_NAME || '_JOB_CLASS')
NOT IN
(SELECT JOB_CLASS_NAME FROM DBA_SCHEDULER_JOB_CLASSES))
LOOP
V_SQL :=
'BEGIN
DBMS_SCHEDULER.CREATE_JOB_CLASS
job_class_name => ''' || i.owner_name || '_JOB_CLASS'',
service => ''' || i.SNAME || ''',
comments => ''Job class for ' || i.owner_name || '''
EXCEPTION
WHEN OTHERS THEN
RAISE;
END;';
EXECUTE IMMEDIATE V_SQL;
END LOOP;
END;
EXCEPTION
WHEN OTHERS
THEN
RAISE_APPLICATION_ERROR(-20001, V_JOB_STEP||' SQLERRM: ' || SQLERRM || ' SQLCODE: '|| SQLCODE);
END JOB_CLASS_PROC;
DECLARE
V_SQL VARCHAR2 (4000);
V_JOB_STEP VARCHAR2 (50);
BEGIN
-- Create Job Class if not exist
BEGIN
FOR i
IN (SELECT SNS.OWNER_NAME OWNER_NAME,
VDB.NAME
SNAME
FROM SCHEMA_NAMES SNS,
V$DATABASE VDB
WHERE OWNER_NAME NOT IN ('')
AND (OWNER_NAME || '_JOB_CLASS')
NOT IN
(SELECT JOB_CLASS_NAME FROM DBA_SCHEDULER_JOB_CLASSES))
LOOP
V_SQL :=
'BEGIN
DBMS_SCHEDULER.CREATE_JOB_CLASS
job_class_name => ''' || i.owner_name || '_JOB_CLASS'',
service => ''' || i.SNAME || ''',
comments => ''Job class for ' || i.owner_name || '''
EXCEPTION
WHEN OTHERS THEN
RAISE;
END;';
EXECUTE IMMEDIATE V_SQL;
END LOOP;
END;
EXCEPTION
WHEN OTHERS
THEN
RAISE_APPLICATION_ERROR(-20001, V_JOB_STEP||' SQLERRM: ' || SQLERRM || ' SQLCODE: '|| SQLCODE);
END;
Why for same code procedure is giving error.
Please help me.
Thanks.Hi,
Then with the same grants how the below script is working.
If I put the below same script in Procedure it's not working.
DECLARE
V_SQL VARCHAR2 (4000);
V_JOB_STEP VARCHAR2 (50);
BEGIN
-- Create Job Class if not exist
BEGIN
FOR i
IN (SELECT SNS.OWNER_NAME OWNER_NAME,
VDB.NAME
SNAME
FROM SCHEMA_NAMES SNS,
V$DATABASE VDB
WHERE OWNER_NAME NOT IN ('')
AND (OWNER_NAME || '_JOB_CLASS')
NOT IN
(SELECT JOB_CLASS_NAME FROM DBA_SCHEDULER_JOB_CLASSES))
LOOP
V_SQL :=
'BEGIN
DBMS_SCHEDULER.CREATE_JOB_CLASS
job_class_name => ''' || i.owner_name || '_JOB_CLASS'',
service => ''' || i.SNAME || ''',
comments => ''Job class for ' || i.owner_name || '''
EXCEPTION
WHEN OTHERS THEN
RAISE;
END;';
EXECUTE IMMEDIATE V_SQL;
END LOOP;
END;
EXCEPTION
WHEN OTHERS
THEN
RAISE_APPLICATION_ERROR(-20001, V_JOB_STEP||' SQLERRM: ' || SQLERRM || ' SQLCODE: '|| SQLCODE);
END;
Please help me.
Thanks. -
How to report an error from anonymous PL/SQL blocks
Hello,
The following SQL*Plus script
WHENEVER OSERROR EXIT FAILURE
WHENEVER SQLERROR EXIT FAILURE
DECLARE
EXIST_INDEXES BOOLEAN := FALSE;
BEGIN
FOR INDEX IN (SELECT * FROM INDEXES)
LOOP
EXIST_INDEXES := TRUE;
DBMS_OUTPUT.PUT_LINE(INDEX.SCHEMA || '.' || INDEX.NAME);
END LOOP;
IF EXIST_INDEXES THEN
RAISE_APPLICATION_ERROR(-20000,'Before proceeding, it is recommended to drop the indexes listed above');
END IF;
END;
-- Here go SQL statements that should be executed if no indexes were found
produces this output when there is an entry in table/view INDEXES:
SCHEMA_1.INDEX_1
DECLARE
ERROR at line 1:
ORA-20000: Before proceeding, it is recommended to drop the indexes listed above
ORA-06512: at line 13
When there are entries in table/view INDEXES, how to:
- suppress the 'DECLARE' and '*' lines from appearing in the script output;
- skip executing the SQL statements after the PL/SQL block;
- have the script return a non-zero code?
Regards,
Angel Tsankov1 You want the rest of the code not to execute, SO all code should be in one anonymous block.
The scope of exceptions is one block.
2 If you want to suppress
- suppress the 'DECLARE' and '*' lines from appearing in the script output;you should not use raise_application_error, because this is how raise_application_error works.
- whenever you raise an exception, the return code will be non-zero.
The code you posted is really very poor, and inefficient, but as it is unclear what you are up to (you seem to want to skip executing everything when there are any indexes, if so you can just count them), it is not possible to provide working code.
If you want to skip the rest of the code, you can declare your own exceptions, and you should just raise your own exception and the block will abort.
Hth
Sybrand Bakker
Senior Oracle DBA -
PL/SQL block returning error
Hi All,
I have used PL/SQL block in my custom report to search table heading. Basically I have two select list (LOV), user select the parameter from the list and click on go, it displays the report fine when record exists.
I am using following PL/SQL block -
>
DECLARE
v_sql VARCHAR2(4000);
BEGIN
IF :P126_PARK_NAME IS NOT NULL THEN
v_sql := 'select P.OLIC_KEY1, PA.NAME, C.TRADING_NAME, L.LIC_TYPE, P.'|| :P126_PARK_NAME ||', C.COP_ID, L.OLIC_ID Olic_id '
||' from RTT_OP_PARKS_TEMP P, RTT_COMMERCIAL_OPERATORS C , RTT_PARTIES PA, RTT_OP_LICENCES L'
||' where '|| :P126_PARK_NAME || ' IS NOT NULL '
||' AND PA.PAR_ID =C.PAR_ID '
||' AND P.COP_ID =C.COP_ID '
||' AND L.OLIC_KEY1=P.OLIC_KEY1 '
||' AND :P126_QUERY = ''Y'''
||' ORDER BY PA.NAME ';
END IF;
/* debugging */
IF :DEBUG = 'YES' THEN
htp.preopen;
htp.p(v_sql);
htp.preclose;
END IF;
RETURN (v_sql);
END;
>
Now, I want to use like condition to display all the records by checking the parameters in text field. I have created a new text field and modified the query as follows but it does not work -
>
DECLARE
v_sql VARCHAR2(4000);
BEGIN
IF :P126_PARK_NAME IS NOT NULL THEN
v_sql := 'select P.OLIC_KEY1, PA.NAME, C.TRADING_NAME, L.LIC_TYPE, P.'|| :P126_PARK_NAME ||', C.COP_ID, L.OLIC_ID Olic_id '
||' from RTT_OP_PARKS_TEMP P, RTT_COMMERCIAL_OPERATORS C , RTT_PARTIES PA, RTT_OP_LICENCES L'
||' where '|| :P126_PARK_NAME || ' IS NOT NULL '
||' AND PA.PAR_ID =C.PAR_ID '
||' AND P.COP_ID =C.COP_ID '
||' AND L.OLIC_KEY1=P.OLIC_KEY1 '
||' AND :P126_QUERY = ''Y'''
||' ORDER BY PA.NAME ';
END IF;
IF :P126_MARINE_PARK != -1 THEN
v_sql := 'select distinct L.OLIC_KEY1, PA.NAME, C.TRADING_NAME, L.LIC_TYPE, M.'|| :P126_MARINE_PARK ||', C.COP_ID '
||' from RTT_OP_MARINE_PARKS M, RTT_COMMERCIAL_OPERATORS C , RTT_PARTIES PA, RTT_OP_LICENCES L'
||' where '|| :P126_MARINE_PARK || ' IS NOT NULL '
||' M.'||:P126_MARINE_PARK||' IS LIKE :P126_MARINE_PARK||'%' '
||' AND PA.PAR_ID =C.PAR_ID '
||' AND M.COP_ID =C.COP_ID '
||' AND L.OLIC_KEY1=M.OLIC_KEY1 '
||' AND :P126_QUERY = ''Y'''
||' ORDER BY PA.NAME ';
END IF;
/* debugging */
IF :DEBUG = 'YES' THEN
htp.preopen;
htp.p(v_sql);
htp.preclose;
END IF;
RETURN (v_sql);
END;
>
Can anybody tell me what I am doing wrong here?
Thanks in advance
Regards,
M TajuddinHi Andy,
Thanks for pointing the quotation however it does not work either. Now I am getting -
>
failed to parse SQL query:
ORA-00933: SQL command not properly ended
>
Now my query is like below -
>
DECLARE
v_sql VARCHAR2(4000);
BEGIN
IF :P126_ZONE_NAME IS NOT NULL THEN
v_sql := 'select distinct L.OLIC_KEY1, PA.NAME, C.TRADING_NAME, L.LIC_TYPE, M.'|| :P126_ZONE_NAME ||', C.COP_ID '
||' from RTT_OP_MARINE_PARKS M, RTT_COMMERCIAL_OPERATORS C , RTT_PARTIES PA, RTT_OP_LICENCES L'
||' where '|| :P126_ZONE_NAME || ' IS NOT NULL '
||' AND PA.PAR_ID =C.PAR_ID '
||' AND M.COP_ID =C.COP_ID '
||' AND L.OLIC_KEY1=M.OLIC_KEY1 '
||' AND :P126_QUERY = ''Y'''
||' ORDER BY PA.NAME ';
END IF;
IF :P126_MARINE_PARK IS NOT NULL THEN
v_sql := 'select distinct L.OLIC_KEY1, PA.NAME, C.TRADING_NAME, L.LIC_TYPE, M.'|| :P126_MARINE_PARK ||', C.COP_ID '
||' from RTT_OP_MARINE_PARKS M, RTT_COMMERCIAL_OPERATORS C , RTT_PARTIES PA, RTT_OP_LICENCES L'
||' where ' || :P126_MARINE_PARK || ' IS NOT NULL '
*||' M.' || :P126_MARINE_PARK || ' IS LIKE ''' || :P126_MARINE_PARK || '%'' '*
||' AND PA.PAR_ID =C.PAR_ID '
||' AND M.COP_ID =C.COP_ID '
||' AND L.OLIC_KEY1=M.OLIC_KEY1 '
||' AND :P126_QUERY = ''Y'''
||' ORDER BY PA.NAME ';
END IF;
/* debugging */
IF :DEBUG = 'YES' THEN
htp.preopen;
htp.p(v_sql);
htp.preclose;
END IF;
RETURN (v_sql);
END;
>
Can you tell me how can I display dynamic multiple column in my query? Say in the LIKE condition if user type M in the parameter field and click on go, it must return more than one column starting column name M but in my current query it will only display one column, am I right?
Thanks again for your suggestion.
Kind regards,
M Tajuddin
http://tajuddin.whitepagesbd.com -
Display an Alert message from PL/SQL block in APEX
Hi,
we are getting an oracle exception while inserting a new row. As it is having the unique constaint on a coulumn.
Now the problem iis we need to Display an "Alert message" based on the input field validation. That java script code for alert has to be embeded nside a PL/SQL block in Oracle APEX Application.
we tried doing this with below code:
Begin
INSERT INTO <<table name>>(ID,NAME) VALUES (s1,:TXT_s2);
exception when others then
htp.p('<script language="javascript">');
htp.p('alert("Exception");');
htp.p('</script>');
end;
If anybody knows .... please reply.
Thanks,
SubarnaIf your end goal is showing a pretty error message instead of the message that the tables unique constraint raises try the following. This logic will show a nice message and not try to insert non-unique data.
(1) Create a validation of type "Function Returning Error Text".
(2) Place similar code like the following in your validation. Notice that if the unique name does not exist the no_data_found returns null allowing the validation to pass.
DECLARE
v_error varchar2(100);
BEGIN
SELECT 'A person by this name already exists.'
INTO v_error
FROM your_table
WHERE your_name = :P1_YOUR_NAME;
RETURN v_error;
EXCEPTION
WHEN no_data_found THEN
RETURN NULL;
END;
Maybe you are looking for
-
REMOTE App on Pad and Phone can't access Shard iTunes
I have done what you have to do to start Home Sharing, but as soon as i clck 'done' the HomeShare logo vanishes from the side of iTunes, and is invisible to the Pad and Phone, also adding my Library using these apps doesn't work iTunes just doesn't g
-
Delete SC when req. number ia assigned
Hi Experts, I am facing a problem. I have created a SC without the vendor is assigned. SRM try to create a Req. but no numberrange has been set up in back-end. In table BBP_PDBEI a Req. number is assigned to the SC, comming from SRM. No Reg. is creat
-
I tried to put a link to a downloadable column on a table ( a blob ) on a report. If you insert an element and then you try to list it in the report, the link works, and you download the file you entered. Buty if you close your session, and reopen it
-
Variable that carries tcode in exit
Hello, i would like to know if there is a variable in user exit that carries information about the tcode from which that exit has been triggered. If you want to use the same exit for different tcodes, how to make that difference in code? Thanks in a
-
Need help in getting refund for unwanted app not able to access content after purchase