pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Devinder K Rajput <Devinder.Rajput@ipaper.com>
To: Farah <cwfarah@yahoo.com>
Cc: pgsql-admin@postgresql.org
Cc: pgsql-admin-owner@postgresql.org
Subject: Re: postgres & perl
Date: Thu, 2 Jan 2003 08:09:39 -0600
Message-ID: <OFA499F6D5.FFE35A08-ON86256CA2.004CE853@ipaper.com> (raw)

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@yahoo.com>
Sent by: pgsql-admin-owner@postgresql.org
01/01/2003 02:25 AM

 
        To:     pgsql-admin@postgresql.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

view thread (2+ messages)

Message-ID: <OFA499F6D5.FFE35A08-ON86256CA2.004CE853@ipaper.com>
Permalink:  ../OFA499F6D5.FFE35A08-ON86256CA2.004CE853@ipaper.com/
Also on:    postgresql.org/message-id/OFA499F6D5.FFE35A08-ON86256CA2.004CE853@ipaper.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: Devinder.Rajput@ipaper.com, cwfarah@yahoo.com, pgsql-admin-owner@postgresql.org
  Subject: Re: postgres & perl
  In-Reply-To: <OFA499F6D5.FFE35A08-ON86256CA2.004CE853@ipaper.com>
  References: <OFA499F6D5.FFE35A08-ON86256CA2.004CE853@ipaper.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox