Re: Weird SQL Problem

From: David <dbree(at)duo-county(dot)com>
To: operationsengineer1(at)yahoo(dot)com
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Weird SQL Problem
Date: 2005-09-08 02:01:19
Message-ID: 20050908020119.GA2803@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Wed, Sep 07, 2005 at 04:48:36PM -0700, operationsengineer1(at)yahoo(dot)com wrote:
> hi all,
>
> i'm baffled by a sql issue.
>
> i use adodb and the code is as follows (the sql should
> be pretty evident - even if you don't follow adodb).
>
> $result_update = $db->Execute('UPDATE t_defect SET
> reworker_id = ' . $reworker_id . ', rework_completed =
> \'t\', rework_notes = ' . $rework_notes . ',
> rework_date = '. $db->DBDate(time()) . 'WHERE
> t_defect.defect_id = ' . $defect_id );
>
> my problem is this... the text input for
> $rework_notes kicks out a pgsql error as follows...
>
> 'ERROR: column "aaaaaaaaaaaaaa" does not exist'

As Josh Berkus replied, it's a quoting issue. I _think_ this is what
you might need (untested)

$result_update = $db->Execute('UPDATE t_defect SET reworker_id = ' .
$reworker_id . ', rework_completed = \'t\', rework_notes = \'' .
$rework_notes . '\', rework_date = '. $db->DBDate(time()) .
'WHERE t_defect.defect_id = ' . $defect_id );

And the same for rework_date and/or t_defect.defect_id if either should
be a string.

One idea.. if this is in php, or a language that allows the use of
either single or double quotes for strings, I think I'd quote the query
string here with double quotes. That would make it much easier to catch
the missing single quotes that should appear in the query (and avoid the
need to escape the single quotes.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message operationsengineer1 2005-09-08 04:09:18 Re: Weird SQL Problem
Previous Message Walter Kaan 2005-09-08 01:16:18 Re: Weird SQL Problem