pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff <threshar@torgo.978.org>
To: Peter Galbavy <peter.galbavy@knowtion.net>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: how do i insert an empty string ?
Date: Tue, 15 Oct 2002 10:14:01 -0400 (EDT)
Message-ID: <20021015101157.X65014-100000@torgo> (raw)
In-Reply-To: <000901c27431$e02a8e20$4528a8c0@cblan.mblox.com>

On Tue, 15 Oct 2002, Peter Galbavy wrote:

> FAQ: A search yielded nothing explicit...
>
> I have an INSERT statement:
>
> INSERT INTO metadata (md5, origin, name, value)
>               VALUES ('fd859f263bd0579935f2146a22d24f32', 'EXIF',
> 'UserComment', '')
>
> but this fails (using Perl DBI, DBD::Pg) because $dbh->quote() returns two

Since you are using DBI, why not bind the variables and be done with it?

this would become
$query = $db->prepare("INSERT INTO metadata (md5, origin, name, value)
VALUES (?, ?, ?, ?)");
$query->execute($md5, $origin, $name, $value);

This way you don't have to deal with double quoting and all that. (You can
also call bind_param, but I find it easier to just pass args into execute)

------------------------------------------------------------------------------
Jeff Trout <jeff@jefftrout.com>                  http://www.jefftrout.com/
   Ronald McDonald, with the help of cheese soup,
       controls America from a secret volkswagon hidden in the past
-------------------------------------------------------------------------------





view thread (3+ messages)

Message-ID: <20021015101157.X65014-100000@torgo>
Permalink:  ../20021015101157.X65014-100000@torgo/
Also on:    postgresql.org/message-id/20021015101157.X65014-100000@torgo

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: threshar@torgo.978.org, peter.galbavy@knowtion.net
  Subject: Re: how do i insert an empty string ?
  In-Reply-To: <20021015101157.X65014-100000@torgo>

* 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