Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: DBI delete, long data type insert into Oracle DB table

Re: DBI delete, long data type insert into Oracle DB table

From: <devnull_at_arkansas.net>
Date: Sun, 03 Oct 1999 23:00:00 GMT
Message-ID: <37f7dd2f.7174172@news.anc.net>


I'm not sure about your ability to delete; check your autocommit variable is set and that your condition and datatype is correct in your delete query.

However, inserting "long" data requires the use of placeholders. Use a question mark (?) in your values clause for every variable you're inserting. Then, define an array which holds the values you're inserting. In the $sth->execute() statement, pass the array as an argument. Every question mark will be replaced by the values you have in your array, in order.

For example:

$values[0] = "value1";
$values[1] = "value2";

$query = qq{

    INSERT INTO table ( col1, col2 ) values ( ?, ? ) };

$sth = $dbh->prepare($query);
$sth->execute(@values);


That should get you going in the right direction.

John

On Sat, 02 Oct 1999 20:30:10 GMT, weiq3777_at_my-deja.com wrote:

>Hi, All
>
>I have some difficult to use DBI, perl to delete a record in oracle
>database.
>
>for example, $SQL = "delete from testTable where id = 1";
> &RunSQLStatement($SQL);
>
> sub RunSQLStatement($)
> {
> local ($sth) = $dbh-> prepare($_[0]);
> if ( !defined $sth ) {
> die "Cannot prepare statement: $DBI::errstr\n";
> }
> $sth->execute;
> }
>I can use the above RunSQLStatement function to insert, update tables,
>except for long database type. However, I can not call the above
>RunSQLStatement function to delete a record.
>
>I would be very grateful if anyone cold help me,
>
>1....how to modify the above function to let me execute a delete SQL
> statement
>2....how to modofy the above function to let me insert data into a
> table which has long data type and the long data type field has
> more than 2000 chars.
>
>Thanks and have a nice weekend.
>
>Wei
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.
Received on Sun Oct 03 1999 - 18:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US