Re: "SQL" REPLACE SYNTAX - Mailing list pgsql-php

From Christopher Kings-Lynne
Subject Re: "SQL" REPLACE SYNTAX
Date
Msg-id GNELIHDDFBOCMGBFGEFOOECHCBAA.chriskl@familyhealth.com.au
Whole thread Raw
In response to Re: "SQL" REPLACE SYNTAX  (Francisco Reyes <lists@natserv.com>)
Responses Re: "SQL" REPLACE SYNTAX  (Andrew McMillan <andrew@catalyst.net.nz>)
List pgsql-php
> Why so many? It is simple enough to attempt a delete and then do an
> insert.

DELETE WHERE what?  Alternatively you can attempt and update then do an
insert - question is UPDATE WHERE what?

If the insert fails you need to select from the postgres system catalogs to
find the primary key on the table (if there is one).  Next, you need to find
the fields that that primary key is defined over.  Next, you need to parse
the insert statement and find the fields being inserted that match the
primary key.  Lastly you need to modify the insert statment to an update
statment, take out the values that are part of the primary key and make them
part of the where clause of the update or delete statement.

Chris


pgsql-php by date:

Previous
From: Francisco Reyes
Date:
Subject: Re: Long running queries and timeouts
Next
From: Manuel Lemos
Date:
Subject: Re: "SQL" REPLACE SYNTAX