473,400 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

help with Perl code to insert a long string (> 32512 chars) via stored procedure

hi,

I have the following Perl code that inserts a string to an Oracle DB via a stored procedure:
Expand|Select|Wrap|Line Numbers
  1.      #!/usr/local/bin/perl   ## Perl v5.8.6 built for sun4-solaris
  2.      use strict;
  3.      BEGIN {
  4.          $ENV{'TNS_ADMIN'}   = '/auto/engweb/oracle/sqlnet';
  5.          $ENV{'ORACLE_HOME'} = '/usr/packages/dbdoracle/9.2.0';
  6.      }
  7.      use lib qw( /usr/packages/dbdoracle/9.2.0 );
  8.      use DBI;
  9.      use DBI qw(:sql_types);
  10.      use DBD::Oracle qw(:ora_types);
  11.      ...
  12.   1  $pk = "<some_unique_value>";
  13.   2  $string = "<a very long string....>";  
  14.   3  $stmt = 'BEGIN my_package.my_proc(:primary_key, :value); END;';
  15.        #   see near bottom for details of "my_proc"
  16.   4  $sth = $dbh->prepare ($stmt);
  17.   5  $sth->bind_param(":primary_key", $pk);
  18.   6  $sth->bind_param(":value", "$string");
  19.   7  $sth->execute();
  20.     ...
  21.  
for strings < 32512 chars, the code works fine.

For strings >= 32513 chars, I see the following error messages. How do I resolve these errors?

-------------------------------

DBD::Oracle::st execute failed: ORA-01460: unimplemented or unreasonable conversion requested (DBD ERROR: OCIStmtExecute)

-------------------------------

I changed line 6 to:

$sth->bind_param(":value", "$string", SQL_LONGVARCHAR );

but saw the same error.

-------------------------------

I then tried:

$sth->bind_param(":value", "$string", SQL_LONGVARBINARY);

which produced:

DBD::Oracle::st execute failed: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments

-------------------------------

Next, I tried:

$sth->bind_param(":value", "$string", { ora_type => ORA_CLOB } );

but got:

DBD::Oracle::st execute failed: ORA-01403: no data found (DBD ERROR: LOB refetch
attempted for unsupported statement type (see also ora_auto_lob attribute))


Is there anything else I can try? Any pointer is appreciated.


--Andrew

================================================== ================================

my stored proc is very simple:
Expand|Select|Wrap|Line Numbers
  1.   PROCEDURE my_proc
  2.   (
  3.      pk            IN VARCHAR2,
  4.      col_val       IN CLOB
  5.   )
  6.   IS
  7.      v_stmt        VARCHAR2(100);
  8.  
  9.   BEGIN
  10.      v_stmt := ' INSERT INTO my_table ( pk, clob_col ) ' ||
  11.                ' VALUES (:1, :2)';
  12.  
  13.      EXECUTE IMMEDIATE v_stmt
  14.              USING     pk, col_val;
  15.  
  16.      COMMIT;
  17.   END;
  18.  
  19. --------------------------------------------
  20.  

the table is:
Expand|Select|Wrap|Line Numbers
  1.  
  2.   CREATE TABLE my_table
  3.   (
  4.     pk                      VARCHAR2 (100) NOT NULL,
  5.     clob_col                CLOB
  6.   );
  7.  
  8.  
Jan 7 '08 #1
3 4148
amitpatel66
2,367 Expert 2GB
From where you are reading these lines of data? from a file or some where else?
Is it possible for you to read the data 32512 length string and do an insert in oder to avoid this error?
Jan 8 '08 #2
amitpatel66
2,367 Expert 2GB
Hi Andrew,

Welcome to TSDN!!

Please make sure you follow POSTING GUIDELINES every time you post in this forum

Thanks
MODERATOR
Jan 8 '08 #3
debasisdas
8,127 Expert 4TB
Instead of using CLOB try to use LONG.
Jan 8 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jeff | last post by:
I am getting Unable to find operator in query string. Query string currently is INSERT INTO Results (Name,Email,Comments,File) VALUES ('::Name::','::Email::','::Comments::','::File::') Here...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
7
by: Siv | last post by:
Hi, I have a stored procedure that I want to execute and then wait in a loop showing a timer whilst it completes and then carry on once I get notification that it has completed. The main reason...
15
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
4
by: Christian Maier | last post by:
Hi After surfing a while I have still trouble with this array thing. I have the following function and recive a Segmentation fault, how must I code this right?? Thanks Christian Maier
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
0
by: SOI_0152 | last post by:
Hi all! Happy New Year 2008. Il hope it will bring you love and happyness I'm new on this forum. I wrote a stored procedure on mainframe using DB2 7.1.1 and IBM language c. Everything works...
1
by: pitjpz | last post by:
We have moved our Database to another server. The server it was on used SQL 4 and the new one its on now uses SQL5 the only problem we can find is that when you attempt to delete a record from...
3
by: jonathan184 | last post by:
The code seems to be working fine for some records but I am thinking it is finding some other records with special characters and so on. I am looking for a way to insert the xml string with escaping...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.