Error executing pl sql block
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 AM
Hii 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
Similar Messages
-
06528. 00000 - "Error executing PL/SQL profiler"
HI.
i am getting an error -
ORA-06528: Error executing PL/SQL profiler
ORA-06512: at "SYS.DBMS_PROFILER", line 258
ORA-06512: at line 3
06528. 00000 - "Error executing PL/SQL profiler"
*Cause: An error occurred in during execution of a PL/SQL profiler
procedure.
when i try to run the following block
BEGIN
DBMS_PROFILER.START_PROFILER( sysdate,'');
DBMS_PROFILER.FLUSH_DATA;
END;
plz helpRun proftab.sql first. look st the test case. Hopefully you have installed dbms_profiler package. The first anonymous block is to test that, second block is your block which is failing.
SQL> ed
Wrote file afiedt.buf
1 declare
2 var1 binary_integer;
3 var2 binary_integer;
4 begin
5 DBMS_PROFILER.GET_VERSION(Var1,var2);
6 dbms_output.put_line('Var1 '||Var1);
7* end;
8 /
Var1 2
PL/SQL procedure successfully completed.
SQL> BEGIN
2 DBMS_PROFILER.START_PROFILER( sysdate,'');
3 DBMS_PROFILER.FLUSH_DATA;
4 END;
5 /
BEGIN
ERROR at line 1:
ORA-06528: Error executing PL/SQL profiler
ORA-06512: at "SYS.DBMS_PROFILER", line 123
ORA-06512: at "SYS.DBMS_PROFILER", line 132
ORA-06512: at line 2
SQL> @C:\oraclexe\app\oracle\product\10.2.0\server\RDBMS\ADMIN\proftab.sql
SQL> BEGIN
2 DBMS_PROFILER.START_PROFILER( sysdate,'');
3 DBMS_PROFILER.FLUSH_DATA;
4 END;
5 /
PL/SQL procedure successfully completed. -
ORA-06528: Error executing PL/SQL profiler
Hai
I would like to see the outcome of package (to view the report on the package).In order to get that
I installed the below package connect as internal
sql>d:\oracle\orq81\rdbms\admin\profload.sql
In order to use dbms_profiler,after that i need to have installed profilling tables ,in order to get i ran proftab.sql ,and its created three tables are
plsql_profiler_data,plsql_profiler_units,plsql+profiler_runs
after that i ran the below procedure
create or replace procedure do_mod as
cnt number := 0;
begin
dbms_profiler.start_profiler( 'mod' );
for i in 1 .. 500000
loop
cnt := cnt + 1;
if ( mod(cnt,1000) = 0 )
then
commit;
end if;
end loop;
dbms_profiler.stop_profiler;
end;/
PL/SQL procedure successfully completed.
exec no_mod
PL/SQL procedure successfully completed.
In order to see the report on packge ,i had query the table , RUN_TOTAL_TIME IS 3.5190E+11(this is seconds)
my qusetion is
1)
Please explain me that is total amount time in seconds or minutes,i donnot understand what is 3.5190e+11
SQL> select RUNID,RUN_COMMENT,RUN_TOTAL_TIME FROM PLSQL_PROFILER_RUNS;
RUNID
RUN_COMMENT
RUN_TOTAL_TIME
1
mod
7.0975E+11
2
mod
6.9767E+11
RUNID
RUN_COMMENT
RUN_TOTAL_TIME
3
no mod
3.5190E+11
2)
I had ran the above script one of the schema ,and successfully created above procedure.When i execte,it retuns below error message
SQL> exec do_mod;
BEGIN do_mod; END;
ERROR at line 1:
ORA-06528: Error executing PL/SQL profiler
ORA-06512: at "SYS.DBMS_PROFILER", line 123
ORA-06512: at "SYS.DBMS_PROFILER", line 132
ORA-06512: at "MOHAN1.DO_MOD", line 4
ORA-06512: at line 1
Any one any idea about that
Regards
mohan1) Run_total_time is the elapsed total time in nanoseconds.
A nanosecond is one billionth of a second.
It is displayed in scientific notation
where E stands for "times ten to the power of".
So, 3.5190E+11 nanoseconds
= 3.5190 * 100000000000 nanoseconds
= 351900000000 nanoseconds
= 351900000000 billionths of a second
= 351900000000 / 1000000000 seconds
= 351.9 seconds
If you want to display it in seconds, use:
SELECT runid,
run_comment,
run_total_time / 1000000000 AS seconds
FROM plsql_profiler_runs;
2) The only thing that looks wrong about your do_mod procedure
is the last line:
end;/
The / should be on the next line.
Other than that, I don't see any possible cause for
the error. -
XL Reporter Installation - Error executing IXMetaProcs.sql
Hi All,
During installation getting error-
Error Preparing Metadata Repository:
Executing SQL script 'IXMetaProcs.sql' (Start:....)
ExitCode -1073741819
!!! ERROR Error executing IXMetaProcs.sql ExitCode -1073741819
I have done the following checks.
1. XL Reporter has bee removed from Administrator->Add-On Administrator.
2. Add-Remove List Does not show XL Reporter.
3. Removed manually Database IXMetaSBOOEM from SQL Server.
4. %temp% - > SM_OBS_DLL folder not found.
5. ILytix folder not found in HKEY_CURRENT_USER -> Software
ILytix folder not found in HKEY_LOCAL_MACHINE-> Software
6. There is no other add-on installed
7. AddOnsInstall.sbo deleted.
AddOnsLocalRegistration.sbo not found.
8. C:\Prog Files\SAP\SAP Business One\Add-Ons folder not found.
But still I can't install XL Reporter.hi,
first you have to check that you have install "dot. Net Framework 2.0" which is compulsory needed for installing XL reporter, also you have to install MS Office in your system.
uninstall the XL reporter and install using the following steps
installation steps of XL-reporter add-on,
1. goto add-on administration => Register Add-on(click).
give the XL reporter address. select default group as Manual.
update.
2. goto addon manager => pending Add-on tab => select the addon row and install.
in installation give the user id and pwd of SQL server.
3.goto addon manager =>installed addons tab, start the XL reporter, once it get connected as status.
4. go to tools menu in SAP B1, in that you will find XL reporter, click that XL reporter will open.(to view XL reporter)
follow the above steps you will get the XL repoter add-on running in SAP B1.
regards
sandip -
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] -
Error executing MS sql server procedure
I am getting an error below while executing a SQL server procedure from SOA composite. My jdeveloper and Soa Suite version is 11.1.1.4.
I am using “Oracle’s MS SQL Server Driver (Type 4) Version: 7.0 and later” driver. The SQL Server version is 2005.
To configure the connection I used the steps mentioned in URL below.
http://beatechnologies.wordpress.com/2011/01/31/creating-a-dbadapter-for-mssql-server-in-osb-11g/
The MS SQL procedure signature is as below.
@p_EventId nvarchar IN
@p_EventName_IN nvarchar IN
@p_Agreement_No_IN decimal IN
@p_Acc_Base_Number_IN decimal IN
@p_Acc_Comp_No_IN decimal IN
@p_Account_Company_Name_IN nvarchar IN
@p_Agree_Stat_Code_IN nvarchar IN
@p_Agree_Type_Code_IN nvarchar IN
@p_HeadQtr_Code_IN nvarchar IN
@p_Sales_Off_Name_IN nvarchar IN
@p_Reseller_Name_IN nvarchar IN
@p_Oracle_Order_number_IN decimal IN
@p_License_Effective_Date_IN datetime IN
@p_PO_Number_IN decimal IN
@p_Invoice_Number_IN decimal IN
@p_Invoice_Date_IN datetime IN
@p_Support_Contract_ID_IN decimal IN
@p_Stmt_Of_Capacity_Due_Date_IN datetime IN
@p_Contract_Start_Date_IN datetime IN
@p_Contract_End_Date_IN datetime IN
@p_Contract_Type_IN nvarchar IN
Error message .
<fault>
<bpelFault>
<faultType>0</faultType>
<bindingFault>
<part name="summary">
<summary>Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'CompanySPProdcall' failed due to: Unimplemented object conversion. Conversion of type 1 whose JDBC type is OTHER to a Java object is not supported. An attempt was made to convert type 1 to a Java object using an unsupported JDBC type: OTHER. Use a data type with a supported JDBC type. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution. </summary>
</part>
<part name="detail">
<detail>Unimplemented object conversion. Conversion of type 1 whose JDBC type is OTHER to a Java object is not supported. An attempt was made to convert type 1 to a Java object using an unsupported JDBC type: OTHER. Use a data type with a supported JDBC type. </detail>
</part>
<part name="code">
<code>null</code>
</part>
</bindingFault>
</bpelFault>
</fault>
Please let me know the solution for this issue?
Thanks...I had the similar problem and I am using 11.1.1.5.
When I changed the platformClassName to org.eclipse.persistence.platform.database.SQLServerPlatform it worked.
You can find platformClassName in Outbound Connection Properties
Hope this might work :) -
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> -
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 -
Execute PL/SQL block with named binds from within java code?
Hi guys,
Is there any good way to execute my PL/SQL code, for example
BEGIN :x := :x+1; END;
from my Java code? I need nothing complicated, just static code block with named binds.
I have tried the Oracle exetnded JDBC (setXXXbyName methods):
public static void main(String[] args){ try { Class.forName("oracle.jdbc.driver.OracleConnection"); Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","user","password"); String SQL="begin :x:=:x+1; end;"; OracleCallableStatement stmt; stmt=(OracleCallableStatement)conn.prepareCall(SQL); stmt.setIntAtName("x", 5); stmt.registerOutParameter("x", Types.INTEGER); stmt.execute(); System.out.println(stmt.getInt("x")); } catch (Exception x) { x.printStackTrace(); } }
And get the java.sql.SQLException: operation not allowed: Ordinal binding and Named binding cannot be combined!
Then i've tried SQLJ appoach:
public static void main(String[] args){ try { Class.forName("oracle.jdbc.driver.OracleConnection"); Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","user","password"); Oracle.connect(conn); System.out.println("Connected!"); int x=3; #sql { BEGIN :x := :x+1; END; }; System.out.println("x=" + x); } catch (Exception x) { x.printStackTrace(); } }
And x=3 had retuned... Although 4 expected.
Then, I've set parameter sqlj.bind-by-identifier=true
And result is another exception! java.sql.SQLException: Missing IN or OUT parameter at index:: 2
Can you please mark my mistakes/point to correct solution?
Thanks in advance,
AlexeyFound another solution, this time working at least...
public void testPLSQL() {
String dynamicSQL=
"declare\n" +
" v_CursorID INTEGER;\n" +
" v_BlockStr VARCHAR2(500);\n" +
" v_Dummy INTEGER;\n" +
" v_x String(18);\n" +
"BEGIN\n" +
" v_CursorID := DBMS_SQL.OPEN_CURSOR;\n" +
" v_BlockStr :=?;" +
" DBMS_SQL.PARSE(v_CursorID, v_BlockStr, DBMS_SQL.V7);\n" +
" v_x:=?;"+
" DBMS_SQL.BIND_VARIABLE(v_CursorID, ':x', v_x,18);\n" +
" v_Dummy := DBMS_SQL.EXECUTE(v_CursorID);\n" +
" DBMS_SQL.VARIABLE_VALUE(v_CursorID, ':x', v_x);\n" +
" DBMS_SQL.CLOSE_CURSOR(v_CursorID);\n" +
" ?:=v_x;"+
" COMMIT;\n" +
"EXCEPTION\n" +
" WHEN OTHERS THEN\n" +
" DBMS_SQL.CLOSE_CURSOR(v_CursorID);\n" +
" RAISE;\n" +
"END DynamicPLSQL;";
try {
Class.forName("oracle.jdbc.driver.OracleConnection");
Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","user", "password");
System.out.println("Profit");
String SQL="begin :x:=:x+1; end;";
OracleCallableStatement stmt;
stmt=(OracleCallableStatement)conn.prepareCall(dynamicSQL);
stmt.setString(1, SQL);
int x=3;
stmt.setInt(2, x);
stmt.registerOutParameter(3, Types.INTEGER);
stmt.execute();
x=stmt.getInt(3);
System.out.println(x);
assertEquals(4, x);
} catch (Exception ex) {
ex.printStackTrace();
assertTrue(false);
}Now the only thing I need is to code some kind of preprocessor of SQL block, to prepare the dynamicSQL lair for SQL critter...
Please please please show me something less complicated! :8} -
hi,
i created a pl/sql block using ed <filename.sql> and tried to execut it useing @<filena.sql> or run <filename.sql>.for the 2nd command the message i got is "nothing
in buffer to run" and for the 1st comm i got nothing. i dint event get prompt.
i am totally new to oracle. please solve my probs.
thanqTo execute the PL/SQL block make sure that you have a "/" at the end of your PL/SQL block and then an <Return character>. Once you have that then you can type C:\..\..\@filename.sql. If you don't put the "/" and "return character" it in your script then after typing C:\..\..\@filename.sql press enter and then type in "/" and then press enter again.
Soji. -
How to execute pl/sql block from a file
hi all,
can anybody tell me how to execute a pl/sql block from a file.it wont contain any procedures.it is of the form
--begin
--declare
--end;
ThanxHere is the file
File is stored in C Drive (Windows Environment)
declare
x number;
begin
select 1 into x from dual;
dbms_output.put_line(x);
end;
SQL> @c:\t.sql;
1
PL/SQL procedure successfully completed.Are you facing any issues?
Regards,
Bhushan -
Error executing Catproc.sql (URGENT!)
I am trying to create a database on Oracle805 on Linux v6 and when I try executing the Catproc.sql, the script just stops halfway.
I went in to execute each script in the Catproc.sql script systematically and found that the processing stops in the midst of the execution of prvtutil.plb.
What could have gone wrong? I desperately need help. Will appreciate it if someone can help to advise me on this.
Thank you.It would be interesting if you tell wheter there are any error messages?
Make sure to run catproc as user SYS.
Try re-running catalog.sql first. -
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 ignoredHi,
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 -
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?
Maybe you are looking for
-
Can no longer get listened to podcasts off of my iPod
Since I updated iTunes with the current version 11.1.0.126, lots of things are no longer working with my iPod or iTunes. I have to manually drag items from iTunes to my iPod. Once I've listened to a podcast, I can't delete it from my iPod. Is this
-
Libocijdbc10.so: Can't load IA 32-bit on a IA-32 platform
Hi,i had a RHEL4U7 (32 bits) running Oracle 10g, and a java application and was working great. yesterday i installed Oracle 9i on the machine and the java app stopped working. i started having "java.lang.UnsatisfiedLinkError: /home/oracle/ora10g/prod
-
Problem with localizing resources with flex 4
Hi All, I'm trying to localize files with flex sdk 4 (10485) and all the swf are getting generated however when I try to run the app none of the captions are displayed. Everything was working fine with older release of sdk. I'm not sure if it is rela
-
HT1338 My mac mini keeps freezing
My Mac Mini keeps freezing
-
I have a table coming in from ECC. Based on this table details, I need to build a custom hierarchy in BW. Can you please guide me the steps to achieve this. I am trying to get details as to how i would link the parent, child and especially the next I