how to update a blob column containing XML data in oracle - sql

i have tried below two approaches:
update table set blobcolname='<?xml>...';
got this error: "string literal tool long" - since the xml value that i am inserting is tool long
2.
DECLARE
str varchar2(32767);
BEGIN
str:='<?xml>...';
update table set blobcolname = str;
END;
/
got this error: ORA-01461:can bind a LONG value only for insert into a LONG column

If you have an option to install two functions in your database, I would use this:
First: I create a function to convert a clob to a blob object
create or replace function clob_to_blob (p1_clob CLOB) return BLOB is
Result BLOB;
o1 integer;
o2 integer;
c integer;
w integer;
begin
o1 := 1;
o2 := 1;
c := 0;
w := 0;
DBMS_LOB.CreateTemporary(Result, true);
DBMS_LOB.ConvertToBlob(Result, p1_clob, length(p1_clob), o1, o2, 0, c, w);
return(Result);
end clob2blob;
/
Second: I create a function to the opposite, convert a blob to a clob
create or replace function blob_to_char (p1_blob BLOB)
return clob is
out_clob clob;
n number;
begin
if (p1_blob is null) then
return null;
end if;
if (length(p1_blob)=0) then
return empty_clob();
end if;
dbms_lob.createtemporary(out_clob,true);
n:=1;
while (n+32767<=length(p1_blob)) loop
dbms_lob.writeappend(out_clob,32767,utl_raw.cast_to_varchar2(dbms_lob.substr(p1_blob,32767,n)));
n:=n+32767;
end loop;
dbms_lob.writeappend(out_clob,length(p1_blob)-n+1,utl_raw.cast_to_varchar2(dbms_lob.substr(p1_blob,length(p1_blob)-n+1,n)));
return out_clob;
end;
/
Third: To verify that I can insert
declare
str clob;
BEGIN
str :='<?xml>...';
update table set blobcolname = clob_to_blob ( str );
END;
/
Lastly: To make a regression test and check that I got the xml as it was originally
select blob_to_char( blobcolname ) from your table;

Related

PL-SQL: returning error - inserting elements into (user input) index with shifting all the elements to element[i+1]

TYPE arr is VARRAY(10) of VARCHAR(32);
ar arr := arr('1', '1', '1');
idx INTEGER(100);
tmp INTEGER(100);
val VARCHAR(32);
PROCEDURE APPENDARR (arr IN OUT arr, idx IN, val IN) IS
BEGIN
if(idx > arr.LIMIT) then
tmp := (idx - arr.LIMIT);
arr.extend(tmp);
FOR i in REVERSE idx..arr.LAST LOOP
arr(i) := arr(i - 1);
if(arr(i) = arr(idx)) THEN
arr(i) := val;
END IF;
END LOOP;
ELSE
arr.extend();
arr(idx) := val;
END IF;
END;
error code:
ORA-06550: line 10, column 48:
PLS-00103: Encountered the symbol "," when expecting one of the following:
out
long double ref char time timestamp interval date binary
national character nchar
anyone who can help me with my error? sorry english is not my native language but i try my best :)!
I'm guessing this is part of a package, as otherwise you would need the create or replace syntax. For demo purposes, I put it in an anonymous block just to test compilation.
Two issues:
integer doesn't take a precision, it's just integer.
The idx and val parameters are missing datatypes.
The following compiles (I haven't checked what it does or whether there is any better implementation):
declare
type arr is varray(10) of varchar(32);
ar arr := arr('1', '1', '1');
idx integer;
tmp integer;
val varchar(32);
procedure appendarr
( arr in out arr
, idx in integer
, val in varchar2 )
is
begin
if idx > arr.limit then
tmp := idx - arr.limit;
arr.extend(tmp);
for i in reverse idx .. arr.last loop
arr(i) := arr(i - 1);
if arr(i) = arr(idx) then
arr(i) := val;
end if;
end loop;
else
arr.extend();
arr(idx) := val;
end if;
end;
begin
null;
end;
PL/SQL if conditions are terminated by the then keyword so they don't need brackets as in other languages, so I removed them.
Also, you have variables idx, tmp and val declared at the top which are not used anywhere, and which also have the same names as local variables within the procedure, which could be confusing. If there isn't some more code you haven't shown that uses them, maybe you can get rid of them.
Edit: As requested, here is what it would look like as a standalone procedure:
create or replace type arr as varray(10) of varchar(32)
/
create or replace procedure appendarr
( arr in out arr
, idx in integer
, val in varchar2 )
as
tmp integer;
begin
if idx > arr.limit then
tmp := idx - arr.limit;
arr.extend(tmp);
for i in reverse idx .. arr.last loop
arr(i) := arr(i - 1);
if arr(i) = arr(idx) then
arr(i) := val;
end if;
end loop;
else
arr.extend();
arr(idx) := val;
end if;
end appendarr;
/
(The / character is required by some development tools to separate blocks, but is not part of the PL/SQL language itself.)
It seems the aim is to insert value val into element idx of array arr, shifting existing values up one place. However, it doesn't quite work:
declare
ar arr := arr('First', 'Second');
begin
appendarr
( arr => ar
, idx => 2
, val => 'New value' );
for i in ar.first..ar.last loop
dbms_output.put_line(i||' '||ar(i));
end loop;
end;
1 First
2 New value
3
Fixed version:
create or replace type varchar2_tt as table of varchar2(50)
/
create or replace procedure varchar2_tt_append
( arr in out varchar2_tt
, pos in pls_integer default null
, val in varchar2 )
as
idx pls_integer := nvl(pos,arr.last +1);
begin
if idx > arr.last then
arr.extend(idx - arr.last);
else
arr.extend();
for i in reverse greatest(idx,2)..arr.last loop
arr(i) := arr(i - 1);
end loop;
end if;
arr(idx) := val;
end varchar2_tt_append;
/
Test:
declare
ar varchar2_tt := varchar2_tt('First', 'Second', 'Third', 'Fourth');
begin
varchar2_tt_append
( arr => ar
, pos => 1
, val => 'New value' );
for i in ar.first..ar.last loop
dbms_output.put_line(i||' '||ar(i));
end loop;
end;
1 New value
2 First
3 Second
4 Third
5 Fourth

Oracle PL/SQL: Function Error when passing parameters

When I pass a parameter to a function call, I get the following error:
Error: PLS-00306: wrong number or types of arguments in call to
'GET_NUM'.
The code is as follows:
CREATE OR REPLACE PACKAGE BODY TESTJNSABC IS
-- FUNCTION IMPLEMENTATIONS
FUNCTION get_num(num IN NUMBER)
RETURN VARCHAR2 IS
my_cursor VARCHAR2(20);
BEGIN
IF get_num = 1 THEN
my_cursor:= 'hello world';
ELSE
my_cursor:= 'Hi!';
END IF;
RETURN my_cursor;
END;
-- PROCEDURE IMPLEMENTATIONS
PROCEDURE testingabc AS
x NUMBER(3);
BEGIN
x:= 2;
dbms_output.put_line(get_num(x));
END testingabc;
END TESTJNSABC;
You have an issue in IF get_num = 1 THEN, because you are calling the function get_num without parameters, while it has one input parameter
If you want to check the parameter value, you probably mean:
IF num = 1 THEN
The problem is at IF get_num = 1. The code will work after you change it to IF num = 1.
Entire sample code below:
CREATE OR REPLACE PACKAGE BODY TESTJNSABC IS
-- FUNCTION IMPLEMENTATIONS
FUNCTION get_num(num IN NUMBER)
RETURN VARCHAR2 IS
my_cursor VARCHAR2(20);
BEGIN
IF num = 1 THEN
my_cursor:= 'hello world';
ELSE
my_cursor:= 'Hi!';
END IF;
RETURN my_cursor;
END;
-- PROCEDURE IMPLEMENTATIONS
PROCEDURE testingabc AS
x NUMBER(3);
BEGIN
x:= 2;
dbms_output.put_line(get_num(x));
END testingabc;
END TESTJNSABC;

Reference to Unintialized collection exception using array PLSQL

I am getting reference to uninitialized collection exception when trying to add element to an array. Please help.Is that correct way to initialize the array as mentioned in my calling code?
CREATE OR REPLACE TYPE SCHEMA.STRARRAY AS TABLE OF VARCHAR2 (255);
CREATE OR REPLACE PROCEDURE SCHEMA.PR_VALIDATE
(
FILEARRAY IN STRARRAY,
DUPARRAY OUT STRARRAY)
IS
dupCount NUMBER;
fileName VARCHAR2 (50);
fileId NUMBER;
dupfileName VARCHAR2(50);
BEGIN
for i in 1 .. FILEARRAY.count
loop
fileName := FILEARRAY(i);
SELECT COUNT (T.FILEID), T.FILEID INTO dupCount,fileId FROM TB_COMPANY T, TB_COMPANY S
WHERE T.FILEID=S.FILEID
AND T.RPDT_ORI_FLE_NM = fileName AND T.RPDT_STA_CD IN ('PASS', 'FAIL')
GROUP BY T.FILEID;
IF dupCount>1
THEN
SELECT RPDT_ORI_FLE_NM INTO dupfileName FROM TB_RDTE_COMPANY_HDR_DT
WHERE RPDT_STA_CD IN ('PR15','PR16') AND RPDT_FLE_ID=fileId
AND RPDT_ORI_FLE_NM != fileName;
DBMS_OUTPUT.PUT_LINE(dupfileName);
DUPARRAY(DUPARRAY.LAST +1 ) :=dupfileName; --Here is the exception.
END IF;
end loop;
EXCEPTION
WHEN OTHERS THEN
PR_RDTE_ERRORS('PR_VALIDATE', SQLERRM);
ROLLBACK;
END;
/
Calling code:
DECLARE
DUPARRAY STRARRAY:=STRARRAY();
BEGIN
PR_VALIDATE (STRARRAY('abc.txt'),DUPARRAY);
END;
DUPARRAY.LAST will get the index of the last element of the array (and not the index of the last non-NULL value of the array) - so if you use DUPARRAY.LAST + 1 you will always exceed the array bounds.
Also, you have not extended the array - which you need to do to add an extra element.
You need to do:
DUPARRAY.EXTEND;
DUPARRAY(DUPARRAY.LAST) :=dupfileName;
You also need to initialise the DUPARRRY inside the procedure (instead of in the calling code):
So something like this:
CREATE OR REPLACE PROCEDURE PR_VALIDATE
(
FILEARRAY IN STRARRAY,
DUPARRAY OUT STRARRAY
)
IS
dupCount NUMBER;
fileName VARCHAR2 (50);
dupfileName VARCHAR2(50);
fileId NUMBER;
BEGIN
DUPARRAY := STRARRAY();
for i in 1 .. FILEARRAY.count loop
fileName := FILEARRAY(i);
SELECT COUNT (T.FILEID), T.FILEID
INTO dupCount,fileId
FROM TB_COMPANY T
INNER JOIN TB_COMPANY S
ON T.FILEID=S.FILEID
WHERE T.RPDT_ORI_FLE_NM = fileName
AND T.RPDT_STA_CD IN ('PASS', 'FAIL')
GROUP BY T.FILEID;
IF dupCount>1 THEN
SELECT RPDT_ORI_FLE_NM
INTO dupfileName
FROM TB_RDTE_COMPANY_HDR_DT
WHERE RPDT_STA_CD IN ('PR15','PR16')
AND RPDT_FLE_ID=fileId
AND RPDT_ORI_FLE_NM != fileName;
DBMS_OUTPUT.PUT_LINE(dupfileName);
DUPARRAY.EXTEND;
DUPARRAY(DUPARRAY.LAST) :=dupfileName;
END IF;
end loop;
END;
/
Then call it:
DECLARE
DUPARRAY STRARRAY;
BEGIN
PR_VALIDATE(STRARRAY('abc.txt'),DUPARRAY);
END;
/

Need to Write CLOB file data into ORACLE table with PLSQL

I have flat file inside a clob field and structure of the flat-file something like as below. and flat files containx million of records.
col1,col2,col3,col4,col5,col6
A,B,C,,F,D
1,A,2,B,B,C
Traditional ways I can't use like
1-fetch the data from clob in excel or something and the load the data into table with sql-loader.
2-currently I am able to print clob file with below code.
OPEN c_clob;
LOOP
FETCH c_clob INTO c;
EXIT
WHEN c_clob%notfound;
printout(c);
but problem in above code is if I use this variable into insert statement then it gives error due to CLOB to VAR insertion.
INSERT INTO Table1 VALUES(c);
commit;
ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 848239, maximum: 4000)
Is there any other option available to handle huge flat-file from clob field and dump into a table.
Currently I am using below code
declare
nStartIndex number := 1;
nEndIndex number := 1;
nLineIndex number := 0;
vLine varchar2(2000);
cursor c_clob is
select char_data from clob_table where seq=1022;
c clob;
procedure printout
(p_clob in out nocopy clob) is
offset number := 1;
amount number := 32767;
amount_last number := 0;
len number := dbms_lob.getlength(p_clob);
lc_buffer varchar2(32767);
line_seq pls_integer := 1;
-- For UNIX type file - replace CHR(13) to NULL
CR char := chr(13);
--CR char := NULL;
LF char := chr(10);
nCRLF number;
sCRLF varchar2(2);
b_finish boolean := true;
begin
sCRLF := CR || LF;
nCRLF := Length(sCRLF);
if ( dbms_lob.isopen(p_clob) != 1 ) then
dbms_lob.open(p_clob, 0);
end if;
amount := instr(p_clob, sCRLF, offset);
while ( offset < len )
loop
-- For without CR/LF on end file
If amount < 0 then
amount := len - offset + 1;
b_finish := false;
End If;
dbms_lob.read(p_clob, amount, offset, lc_buffer);
If b_finish then
lc_buffer := SUBSTR(lc_buffer,1,Length(lc_buffer)-1);
End If;
if (line_seq-1) > 0 then
amount_last := amount_last + amount;
offset := offset + amount;
else
amount_last := amount;
offset := amount + nCRLF;
end if;
amount := instr(p_clob, sCRLF, offset);
amount := amount - amount_last;
dbms_output.put_line('Line #'||line_seq||': '||lc_buffer);
line_seq := line_seq + 1;
end loop;
if ( dbms_lob.isopen(p_clob) = 1 ) then
dbms_lob.close(p_clob);
end if;
exception
when others then
dbms_output.put_line('Error : '||sqlerrm);
end printout;
begin
open c_clob;
loop
fetch c_clob into c;
exit when c_clob%notfound;
printout(c);
end loop;
close c_clob;
end;
Here line printout(c); (4th last line in code) showing me clob data line by line untill buffer gets overflow.
Expected result: To read data from clob flat-file and insert rows into table column wise, That's I am trying to achieve. Constraints is Flat-Files contains millions of records.
i'm using something like this
...
select * into ifile from clob_table where ...;
file_length := dbms_lob.getlength (ifile.char_data);
p_start :=1;
while p_start<>0 loop
end_pos := dbms_lob.instr (ifile.char_data, chr (10), p_start);
if end_pos > 0 then
strRow := dbms_lob.substr(ifile.char_data, least (end_pos - p_start, 240), p_start),chr (13)||chr (10);
p_start := end_pos + 1;
tabRow := strRow2tabRow(strRow);
else
strRow := dbms_lob.substr (ifile.char_data, file_length - p_start + 1, p_start);
p_start := 0;
tabRow := strRow2tabRow(strRow);
end if;
insert into myTable values tabRow;
end loop;
...
and functions
function strRow2tabRow(strRow varchar2) return myTable%rowtype is
tabRow myTable%rowtype;
begin
tabRow.col1:=valueIncolumn(strRow,1);
tabRow.col2:=valueIncolumn(strRow,2);
...
/*or maybe this may be better for you
select * into tabRow from (
select rownum rn, regexp_substr(strRow,'[^,]+', 1, level) hdn from dual connect by regexp_substr(strRow, '[^,]+', 1, level) is not null
) pivot (max(hdn) for rn in (1, 2, ...));
*/
return tabRow;
exception when others then
return tabRow;
end;
function valueIncolumn(strRow varchar2, pos in number) return varchar2 is
ret varchar2(1024);
begin
select hdn into ret from (
select rownum rn, regexp_substr(strRow,'[^,]+', 1, level) hdn from dual connect by regexp_substr(strRow, '[^,]+', 1, level) is not null
) where rownum=pos;
return ret;
exception when others then
return null;
end;
hope it helps

ORA-06550: line 1, column 7 (PL/SQL: Statement ignored) Error

I am getting following error for the stored procedure and not able to understand the issue (must be from db side) While googling, I found similar issues but couldn't get the solution. Can any one help me please find the error in PROCEDURE ??
Error :-
18:58:50,281 ERROR [STDERR] java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'SP_DIST_RETAILER_REMAP'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Stored Prodedure(SP_DIST_RETAILER_REMAP) :-
CREATE OR REPLACE PROCEDURE SMAPRD02.SP_DIST_RETAILER_REMAP (
i_old_dist_code IN VARCHAR2,
i_new_dist_code IN VARCHAR2,
i_territory_remapping IN NUMBER,
i_remapping_reason IN VARCHAR2,
i_trans_doneby_rolename IN VARCHAR2,
i_trans_doneby_id IN NUMBER,
i_trans_dist_rolename IN VARCHAR2,
i_trans_ret_rolename IN VARCHAR2,
i_activity_type IN VARCHAR2,
i_ret_list IN V_ARRAY,
result OUT VARCHAR2,
i_o_query OUT VARCHAR2
)
AS
--i_ret_codes OUT VARCHAR2;
v_dist_count NUMBER;
v_ret_count NUMBER;
v_ret_codes VARCHAR2(10000) := '';
v_flag VARCHAR2(10) := 'true';
v_trans_id NUMBER;
v_query VARCHAR2(10000);
BEGIN
IF i_territory_remapping = 1 then
SELECT count(*) into v_dist_count FROM tblemployee where EMPCODE = i_new_dist_code and circle_code = (select emp.circle_code
from tblemployee emp where emp.empcode = i_old_dist_code) and upper(user_type) like upper('%dist%') and upper(ACCESS_TO) in ('SALES','BOTH') and upper(stage) not in (upper('InActive'));
ELSE
SELECT count(*) into v_dist_count FROM tblemployee where EMPCODE = i_new_dist_code and circle_code = (select emp.circle_code from tblemployee emp
where emp.empcode = i_old_dist_code) and cluster_code = (select emp.cluster_code from tblemployee emp where emp.empcode = i_old_dist_code)
and upper(user_type) like upper('%dist%') and upper(ACCESS_TO) in ('SALES','BOTH') and upper(stage) not in (upper('InActive'));
END IF;
IF v_dist_count =0 THEN
result := 'invalid_new_dist_code';
v_flag := 'false';
ELSIF v_dist_count = 1 THEN
SELECT count(*) into v_ret_count FROM tblretailer t where t.DIST_CODE = i_old_dist_code and (upper(t.ACCESS_TO) = 'SALES' or upper(t.ACCESS_TO) = 'BOTH');
--SELECT count(*) into v_ret_count FROM tblretailer t where t.DIST_CODE = i_old_dist_code and upper(t.ACCESS_TO) = 'SALES' and upper(t.stage) in ('APPROVED','INACTIVE');
IF v_ret_count=i_ret_list.count THEN
IF i_territory_remapping = 1 THEN
result := 'no_ret_left';
v_flag := 'false';
END IF;
ELSE
IF i_territory_remapping != 1 THEN
result := 'ret_left';
v_flag := 'false';
END IF;
END IF;
END IF;
IF i_ret_list is null or i_ret_list.count = 0 THEN
result := 'empty retailers list';
v_flag := 'false';
END IF;
/*FOR i IN i_ret_list.FIRST .. i_ret_list.LAST
LOOP
IF v_ret_codes is null
THEN
v_ret_codes := ''''||i_ret_list(i)||'''';
ELSE
v_ret_codes := v_ret_codes||','''||i_ret_list(i)||'''';
END IF;
IF v_ret_codes is null
THEN
v_ret_codes := i_ret_list(i);
ELSE
v_ret_codes := v_ret_codes||','||i_ret_list(i);
END IF;
END LOOP;
i_ret_codes := v_ret_codes;
v_flag := 'false';
result := 'success';*/
IF v_flag = 'true' THEN
FOR i IN i_ret_list.FIRST .. i_ret_list.LAST
LOOP
IF v_ret_codes is null
THEN
v_ret_codes := ''''||i_ret_list(i)||'''';
ELSE
v_ret_codes := v_ret_codes||','''||i_ret_list(i)||'''';
END IF;
END LOOP;
--i_ret_codes := v_ret_codes;
--update tblretailer set dist_code=i_new_dist_code,DIST_ID=to_number(i_new_dist_code),cluster_code=(select cluster_code from tblemployee where empcode = i_new_dist_code),FOSID='',FOS_CODE='',DSR_ID='',DSR_CODE='',LAST_UPDATED_DATE=sysdate where retcode in (v_ret_codes);
v_query := 'update tblretailer set dist_code='||i_new_dist_code||',DIST_ID=to_number('||i_new_dist_code||'),cluster_code=(select cluster_code from tblemployee where empcode = '||i_new_dist_code||'),FOSID='''',FOS_CODE='''',DSR_ID='''',DSR_CODE='''',LAST_UPDATED_DATE=sysdate where retcode in ('||v_ret_codes||')';
execute immediate (v_query);
--i_query :='update tblretailer set dist_code='||i_new_dist_code||',DIST_ID=to_number('||i_new_dist_code||'),cluster_code=(select cluster_code from tblemployee where empcode = '||i_new_dist_code||'),FOSID='',FOS_CODE='',DSR_ID='',DSR_CODE='',LAST_UPDATED_DATE=sysdate where retcode in ('||v_ret_codes||');';
insert into TBL_TRANSFER_SUP_MASTER(MASTER_ID,TRANS_ID,TRANS_DONEBY_ROLENAME,TRANS_DONEBY_ID,TRANS_FROM_ROLENAME,TRANS_FROM,TRANS_TO_ROLENAME,TRANS_TO,ACTIVITY_CODE,TRANS_DATE,TRANSFER_REASON,LAST_UPDATED_DATE)
values(SUP_MASTER_TRANS_ID_SEQ.nextval,SUP_MASTER_TRANS_ID_SEQ.nextval,i_trans_doneby_rolename,i_trans_doneby_id,i_trans_dist_rolename,i_old_dist_code,i_trans_dist_rolename,i_new_dist_code,'101',sysdate,i_remapping_reason,sysdate) return TRANS_ID into v_trans_id;
FOR i IN i_ret_list.FIRST .. i_ret_list.LAST
LOOP
insert into TBL_TRANSFER_SUP_DTLS(DTLS_ID,TRANS_ID,TRANS_ON_ROLENAME,TRANS_ON_ID,LAST_UPDATED_DATE)
values(SUP_DTLS_ID_SEQ.nextval,v_trans_id,i_trans_ret_rolename,i_ret_list(i),sysdate);
END LOOP;
IF SQL%ROWCOUNT>0 THEN
result := 'success';
ELSE
result := 'failure';
END IF;
--update tblstock set NEW_DIST_CODE_REMAP=i_new_dist_code,REMAP_DATE=sysdate,LAST_UPDATED_DATE=sysdate where (DIST_CODE=i_old_dist_code or NEW_DIST_CODE_REMAP=i_old_dist_code) and RET_CODE in (v_ret_codes);
v_query := 'update tblstock set NEW_DIST_CODE_REMAP='||i_new_dist_code||',REMAP_DATE=sysdate,LAST_UPDATED_DATE=sysdate where (DIST_CODE='||i_old_dist_code||' or NEW_DIST_CODE_REMAP='||i_old_dist_code||') and RET_CODE in ('||v_ret_codes||')';
execute immediate (v_query);
i_o_query := v_query;
insert all into TBL_ACTIVITY_LOG (LOG_ID,TRANS_ID,ACTIVITY_DONEBY_ROLENAME,ACTIVITY_DONEBY_ID,ACTIVITY_REFERENCE_ID,ACTIVITY_CODE,ACTIVITY_DATE)
values(ACTIVITY_LOG_TRANS_ID_SEQ.NEXTVAL,ACTIVITY_LOG_TRANS_ID_SEQ.NEXTVAL,i_trans_doneby_rolename,i_trans_doneby_id,v_trans_id,
act_code,sysdate) select log_config.ACTIVITY_CODE act_code from TBL_ACTIVITY_LOG_CONFIG log_config
where upper(log_config.ACTIVITY_TYPE)= upper(i_activity_type);
END IF;
END;
/
Java Code :-
try{
if(ret_list.size()>0)
ret_code = ret_list.toArray();
con = ConnectionManager.getDirectConnection();
ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor(PropertyLoader.RET_SECONDARY_V_ARRAY,con);
ARRAY array_to_pass = new ARRAY( descriptor,con, ret_code );
cstmt = con.prepareCall("{ call SP_DIST_RETAILER_REMAP(?,?,?,?,?,?,?,?,?,?,?,?)}");
cstmt.setString(1,old_dist_code.trim());
cstmt.setString(2,new_dist_code.trim());
if(territory_remapping)
cstmt.setInt(3,1);
else
cstmt.setInt(3,2);
cstmt.setString(4,remapping_reason);
cstmt.setString(5,userVO.getRolename().trim());
cstmt.setInt(6,userVO.getEmpid());
cstmt.setString(7,PropertyLoader.DISTRIBUOTR_ROLENAME);
cstmt.setString(8,PropertyLoader.RETAILER_ROLENAME);
cstmt.setString(9,PropertyLoader.ACTIVITY_TYPES_RETAILER_REMAPPING);
cstmt.setArray(10,array_to_pass);
cstmt.registerOutParameter(11,Types.VARCHAR);
cstmt.registerOutParameter(12,Types.VARCHAR);
/*cstmt.registerOutParameter(13,Types.VARCHAR);*/
cstmt.execute();
status = cstmt.getString(11);
System.out.println("Remap Update Query "+cstmt.getString(12));
//System.out.println(cstmt.getString(13));
}
If the value stored in PropertyLoader.RET_SECONDARY_V_ARRAY is not "V_ARRAY", then you are using different types; even if they are declared identically (e.g. both are table of number) this will not work.
You're hitting this data type compatibility restriction:
You can assign a collection to a collection variable only if they have
the same data type. Having the same element type is not enough.
You're trying to call the procedure with a parameter that is a different type to the one it's expecting, which is what the error message is telling you.
The procedure which you are using is should be properly declared in the place which you are using it. For an example if it is under a user and in a package then it should be in that order. The username, package and procedurename.