Re: EXCEPT doesn't compare TIMESTAMP type? - Mailing list pgsql-general

From Alban Hertroys
Subject Re: EXCEPT doesn't compare TIMESTAMP type?
Date
Msg-id 9BFC4497-9234-40D9-ACA5-890E88B884F2@solfertje.student.utwente.nl
Whole thread Raw
In response to Re: EXCEPT doesn't compare TIMESTAMP type?  (dipti shah <shahdipti1980@gmail.com>)
Responses Re: EXCEPT doesn't compare TIMESTAMP type?
List pgsql-general
On 23 Apr 2010, at 14:28, dipti shah wrote:

> Great!  Thanks Alban, Alexander, and Thomas.
>
> That solved the issue but could you tell me what is the issue when I give brackets in second query?
>
> techdb=# INSERT INTO changelogtest (id, txid, txtime) values (5, 123, now())
> except select (id, txid, txtime)
> from changelogtest
> where id=5;
> ERROR:  each EXCEPT query must have the same number of columns
> LINE 2: except select (id, txid, txtime)

> I need brackets because this query actually I am using from trigger like below and it gives the same error: Could you
pleasehelp me with it. 
>
> CREATE OR REPLACE FUNCTION insert_history_info()
>   RETURNS VOID AS
> $BODY$
> my $query = (<<ENDQUERY);
>     INSERT INTO changelogtest(id, txid, txtime)
>     SELECT  (\$1, \$2, \$3)
>     EXCEPT
>     SELECT (id, txid, txtime)
>     FROM changelogtest
>     WHERE id = \$1
>     AND txid = \$2
>     AND txtime = \$3;
> ENDQUERY

You need to remove the braces from the query in your trigger too, they change the meaning of the query. You use
bracketsin this way if you need to reference fields from a composite type. 

Alban Hertroys

--
Screwing up is an excellent way to attach something to the ceiling.


!DSPAM:737,4bd1a0c310411470018361!



pgsql-general by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: Need help to identify stray row in a table
Next
From: Howard Cole
Date:
Subject: Upgrading 8.2.4 to 8.3 With TSearch2