From: | Jeremy Buchmann <jeremy(at)wellsgaming(dot)com> |
---|---|
To: | "Kovalcik, Mike A [ITS]" <mkoval01(at)sprintspectrum(dot)com> |
Cc: | pgsql admin <pgsql-admin(at)postgresql(dot)org> |
Subject: | Re: Perl DBI question |
Date: | 2003-06-18 17:44:10 |
Message-ID: | 77905A80-A1B4-11D7-A908-000502E740BA@wellsgaming.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
> I'm trying to setup some scripts that will allow me to use Perl DBI to
> INSERT into my table. However, I have not had any success at all. I'm
> using perl CGI as well so I've granted ALL permissions on my table to
> the apache user and I still can't INSERT. I can, however, UPDATE and
> SELECT on the table, just not INSERT.
>
> Here is a piece of my code:
>
> #--Establish the DB connection
> #--Assign the DB name
> $dbName = 'checkbook';
>
> #--Connect to the Pg DB using DBI
> my $dbh = DBI->connect("dbi:Pg:dbname=$dbName");
>
> $sth = $dbh->do("INSERT INTO transactions
> (date,description,amount,confirmation,nameid,typeid) VALUES
> ('$datePaid','$description','$amount','$confirmation',$nameid,$typeid)"
> )
> ;
What kind of error message are you getting?
With just a quick glance, I would say check your quoting. i.e., is
$amount supposed to be quoted?
You can do parameter binding on $dbh->do statements also, like this:
$dbh->do("INSERT INTO transactions
(date,description,amount,confirmation,nameid,typeid) VALUES
(?,?,?,?,?,?)", undef, ($datePaid, $description, $amount,
$confirmation, $nameid, $typeid));
That takes care of all your quoting so you don't have to worry about it.
Also, you probably want to post this to the INTERFACES list.
--Jeremy
From | Date | Subject | |
---|---|---|---|
Next Message | Bruno Wolff III | 2003-06-18 17:46:48 | Re: Perl DBI question |
Previous Message | scott.marlowe | 2003-06-18 17:42:11 | Re: PostgreSQL calibration |