Solved

updating more than 2K of data to a LONG datatype Oracle field using Perl/ODBC module

Posted on 1998-08-09
4
244 Views
Last Modified: 2012-05-04
Hello, I am trying to update a datatype LONG field in an Oracle table (can hold 2G of char data), but the SQL UPDATE statement will only allow 2K thru a quoted string (eg UPDATE tickets SET comments = '$body'  -- and $body > 2k of data).  I have heard something about binding a variable to a database column thru some other mechanism than SQL, but the only examples I have ever seen are thru C call interface.  There must be some way to do it with Perls ODBC module for windows 32.
0
Comment
Question by:dsweeney
  • 2
4 Comments
 
LVL 4

Expert Comment

by:mitek
ID: 1209167
I once did it this way:

==============================================================
  $c = &ora_open($l,"BEGIN dda.dda_alist(:1,:2,:3); END;");
  $c->bind_param_inout(1, \$tab_name,32) || die "bind_param: $ora_errstr";
  $c->bind_param_inout(2, \$alist,32000) || die "bind_param: $ora_errstr";
  $c->bind_param_inout(3, \$rec_id,255) || die "bind_param_out: $ora_errstr";
  $c->execute || die "execute: $ora_errstr";
  &ora_close($c);
================================================================

It looks like it CAN handle 32K variables, but I didn't really pushed it to the limit to find out how long a variable can get.


So, the solution would look like something like this:

  $c = &ora_open($l,"BEGIN UPDATE tab1 SET long_col = :1 WHERE sid = :2; END;");
  $c->bind_param_inout(1, \$tab_name,32000) || die "bind_param: $ora_errstr";
  $c->bind_param_inout(2, \$alist,32) || die "bind_param: $ora_errstr";
  $c->execute || die "execute: $ora_errstr";
  &ora_close($c);

This is just like binding sql variables in Pro*C, but within the Perl engine.

Let me know if it worked for you, and if not, reopen the question. Also, if it did, tell me how long a variable can get if one uses this technology.

 
0
 
LVL 4

Expert Comment

by:mitek
ID: 1209168
Also ... It just came to me ...
bind_param_inout may work only for stored procedures, for variables it maybe just bind_param or something ...

0
 

Author Comment

by:dsweeney
ID: 1209169
I am decent at perl but new to programming, need more than code fragments.  I am upping it to 300 but I need more info/example.  Here is my code fragment to do it the old (2K quoted string) way in case it helps ($body is the > 2k body of the text I want to store, $DSN is my ODBC connect string) :

#HERES WHERE WE CONNECT TO THE DATABASE
#------------------------------------------------------------------------
if (!($db = new Win32::ODBC($DSN))){
      print "Content-type: text/html\n\n Error connecting to $DSN\n";
      print "Error: " . Win32::ODBC::Error() . "\n";
      exit;
}
$statement = "UPDATE tickets SET comments = '$body'";
if ($db->Sql($statement)){
      sqlerror();
}

$db->Close();

0
 

Accepted Solution

by:
matthewallum earned 300 total points
ID: 1209170
I know with SQL server you can use an 'UPDATETEXT' statement rather than a normal UPDATE for large amounts of data maybe theres something similar on Oracle?
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question