Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: INSERT INTO if UPDATE SET fails (MySQL)

Re: INSERT INTO if UPDATE SET fails (MySQL)

From: Tor Houghton <torh_at_nextel.no>
Date: 1998/10/16
Message-ID: <362679BC.DADF500F@nextel.no>#1/1

I fixed this problem in the calling program. However, if there is a way to do this in SQL I am still interested.

Regards,

Tor.

Tor Houghton wrote:
>
> Hi all,
>
> I couldn't find an general SQL group, so I will try here. Shoot me if
> I'm babbling nonsense.
>
> I've got the following problem. I need to do
>
> UPDATE table SET counter=counter+A WHERE datestamp=NOW() AND
> constraint=B;
>
> If this meets the set criteria, this is no problem. But what I want
> is to create the table record if it doesn't exist. I thought I might
> use IF NOT EXISTS, but can't seem to get it to work.
>
> Some more information about the above, if unclear:
>
> A is an arbitrary INT(11). B is an arbitrary INT(11).
>
> The table 'table' is defined by the following:
>
> CREATE TABLE table (
> datestamp DATE NOT NULL,
> constraint INT,
> counter INT,
> KEY (date)
> );
>
> Hope someone can help!
>
> Thanks in advance.
>
> Tor Houghton.
  Received on Fri Oct 16 1998 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US