on 2012 Feb 15 11:10 PM
Our client has a column defined in the Oracle database as SYS.XMLTYPE. That column is defined in our SQL Anywhere database as LONG VARCHAR.
An upload to Oracle produces the following error:
E. 2012-02-15 11:11:01. Error code from MobiLink server: -10002 E. 2012-02-15 11:11:01. Server error: Message: ODBC: [Sybase][iAnywhere Solutions - Oracle][Oracle]ORA-01461: can bind a LONG value only for insert into a LONG column (ODBC State = HY000, Native error code = 1461). Table Name: MEMO_SYNC_DETAILS. Primary Key(s😞 ACKN 201 E. 2012-02-15 11:11:01. Error code from MobiLink server: -10002 E. 2012-02-15 11:11:01. Server error: Message: ODBC: [Sybase][iAnywhere Solutions - Oracle][Oracle]ORA-01461: can bind a LONG value only for insert into a LONG column (ODBC State = HY000, Native error code = 1461). Table Name: MEMO_SYNC_DETAILS. Primary Key(s😞 ACKN 201
We do have a similar sync running with CLOB data type on Oracle, but our client prefers to keep this data type definition due to already completed programming on their end. Is there a solution short of changing the Oracle schema definition?
SQL Anywhere MobiLink Client Version 11.0.1.2652 MobiLink SQL Anywhere 11.0.1.2376 Oracle 10G 10.2.0.1.0
Thanks, Bill
This should be the script corresponding to the error. (Several different versions have been tried).
CALL ml_add_table_script('ScriptVersion12.00.00', 'MEMO_SYNC_DETAILS', 'upload_insert', NULL); CALL ml_add_table_script('ScriptVersion12.00.00', 'MEMO_SYNC_DETAILS', 'upload_insert', ' INSERT INTO MEMO_SYNC_DETAILS ( ACTION_TYPE, MEMO_SYNC_SID, PAYLOAD, SEND_DATE, PROCESSED_DATE) SELECT {ml r.ACTION_TYPE}, {ml r.MEMO_SYNC_SID}, sys.xmltype.createxml({ml r.PAYLOAD}), {ml r.SEND_DATE}, {ml r.PROCESSED_DATE} from dual');
I did some experiments and found it works, if we write the upload_insert and download_cursor scripts in the following way:
Assume we have a synchronization table, test that is defined as
CREATE TABLE test ( pk integer primary key not null, c1 integer, c2 long varchar )
in the remote databas, and
CREATE TABLE test ( pk integer primary key not null, c1 integer, c2 XMLType )
in the Oracle consolidated database.
Here are the upload_insert and download_cursor scripts for the test table
call ml_add_table_script( 'my_version', 'test', 'upload_insert', 'declare p_pk integer; p_c1 integer; p_c2 clob; v_c2 xmltype; begin p_pk := {ml r.pk}; p_c1 := {ml r.c1}; p_c2 := {ml r.c2}; v_c2 := XMLTYPE.createXML( p_c2 ); insert into test values( p_pk, p_c1, v_c2 ); end;' );
and
call ml_add_table_script( 'my_version', 'test', 'download_cursor', 'select pk,c1,XMLSERIALIZE( content c2 ) from test' );
I also need to tell the MobiLink server the data types of the columns in test, because I am using named-parameters in the upload and download scripts. So calling the following SQL statements to add the column types of the test table into the ml_column table in Oracle
call ml_add_column( 'my_version', 'test', 'pk', 'INT' ); call ml_add_column( 'my_version', 'test', 'c1', 'INT' ); call ml_add_column( 'my_version', 'test', 'c2', 'CLOB' );
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks Guys for your comprehensive, quick response. I tested this and it worked for all but one of our test cases. The test case that we're still failing on includes a very large payload (in excess of >33K). We're getting the following error:
E. 2012-02-16 12:20:57. <3126> [-10002] Consolidated database server or ODBC error: ODBC: [Sybase][iAnywhere Solutions - Oracle][Oracle]ORA-06550: line 1, column 37: PLS-00215: String length constraints must be in range (1 .. 32767)
Would you be willing to retest your posted solution with a very large payload.
I did a test and tried to upload a 64K XML string and I got an error from Oracle, "ORA-01460: unimplemented or unreasonable conversion requested" We may need to find another Oracle conversion function. I am currently using SA12.0.1 and Oracle 11g.
What versions of SA and Oracle software are you using?
Okay, here is a work around and the steps are:
1) Create a global temporary table in the Oracle consolidated database, as
create global temporary table my_temp ( pk int not null primary key, c1 int not null, c2 clob );
we still use the same table definitions as described in my previous post.
2) Create an upload_insert script to upload the rows into the temporary table,
call ml_add_table_script( 'my_version', 'test', 'upload_insert', 'insert into my_temp values( ?,?,? )' );
3) Create an end_upload_rows script to convert the data from clob to XML,
call ml_add_table_script( 'my_version', 'test', 'end_upload_rows', 'insert into test (pk,c1,c2) (select pk,c1,XMLTYPE.createXML(c2) from my_temp' );
4) The previous download_cursor script works fine and it does not need to be changed.
This work-around works well on my system, when the data length of the xml column is less than 100 MB. But Oracle gives me an error, "ORA-27163: out of memory" when the MobiLink server was trying to execute the end_upload_rows script. If this problem occurs, you may need to increase the amoun of memory on your system.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
71 | |
10 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.