...

Поиск
Список
Период
Сортировка
От Jeff MacDonald
Тема ...
Дата
Msg-id Pine.LNX.4.10.9909161129070.27527-100000@penguin.hub.org
обсуждение исходный текст
Ответы Re: your mail
Список pgsql-sql
Got a presumably very quick question.

I'm writing a perl script. lets say i have a variable that's > 8k
, for arguments sake it's 64k.

How can i insert this into a database, do i need large objects ?
and if so, do i use the lo_import ? for some reason it seems that 
this is only for files..

below is what i have but it doesn't seem to work..

jeff=> \d test
Table    = test
+----------------------------------+----------------------------------+-------+
|              Field               |              Type                | Length|
+----------------------------------+----------------------------------+-------+
| blurb                            | text                             |   var |
| message                          | oid                              |     4 |
+----------------------------------+----------------------------------+-------+

***************** code ********************

#!/usr/bin/perl

use strict;
use DBI;


my $dbh = DBI->connect("dbname=narf host=narf port=narf",'narf','','Pg',{'AutoCommit' => 0});
if (!$dbh) {       exit print "Could not connect: $DBI::errstr\n";
}


## lets create the large value here...
## this string is 64K (2^16)


my $largestring = 'x';
for (my $i=0;$i < 16 ;$i++) {       $largestring = $largestring . $largestring;       }


my $statement = $dbh->prepare("INSERT INTO test values('something',lo_import($largestring));");  $statement->execute();
$statement->finish();
 

$dbh->commit;
$dbh->disconnect;

thanks for the help.

======================================================
Jeff MacDonaldjeff@hub.org    webpage: http://hub.org/~jeffjeff@pgsql.com    irc: bignose on EFnet
======================================================



В списке pgsql-sql по дате отправления:

Предыдущее
От: José Soares
Дата:
Сообщение: Re: [SQL] CREATE FUNCTION
Следующее
От: xiaopeng.zhang@asu.edu
Дата:
Сообщение: Help, install 6.5 on Linux2.0.35