Re: postgres & perl

From: "Devinder K Rajput" <Devinder(dot)Rajput(at)ipaper(dot)com>
To: Farah <cwfarah(at)yahoo(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org, pgsql-admin-owner(at)postgresql(dot)org
Subject: Re: postgres & perl
Date: 2003-01-02 14:09:39
Message-ID: OFA499F6D5.FFE35A08-ON86256CA2.004CE853@ipaper.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

here is some sample code:

use Pg; # perl module for PostgreSQL

# connect to the database
$conn = Pg::connectdb("dbname = $database_name");
# make sure connection to db was established
if (PGRES_CONNECTION_OK ne $conn->status) {
print $conn->errorMessage;
exit(-1);
}
print "connected to db $database_name\n";

# Build query:
$sql_query = ("UPDATE items \
SET vendor_group = " . $group . " \
WHERE number = '" . $row[ITEM_NUMBER] . "' \
and hub_id = " . $row[HUB_ID] . " \
");

#Execute query:
$result = $conn->exec("$_[0]");

#Error Checking:
if($result->resultStatus ne PGRES_COMMAND_OK &&
$result->resultStatus ne PGRES_TUPLES_OK) {
...
}

You can build your delete statements and any other queries just by
modifying the "Build query:" section.

regards,

Devinder Rajput
Stores Division Corporate Offices
Chicago, IL
(773) 442-6474

Farah <cwfarah(at)yahoo(dot)com>
Sent by: pgsql-admin-owner(at)postgresql(dot)org
01/01/2003 02:25 AM


To: pgsql-admin(at)postgresql(dot)org
cc:
Subject: [ADMIN] postgres & perl

admin, (sorry if my english is not well)
i want to know the perl source code for delete and editing the table
values from pgsql. i have a problem of that. can you help me...?

Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now

Browse pgsql-admin by date

  From Date Subject
Next Message Campano, Troy 2003-01-02 20:55:53 Viewing connections
Previous Message Senthil 2003-01-02 05:45:54 Some more doubts in postgresql -- Urgent