[SQL] obtaining the query string inside a trigger

2008-01-15 Thread Gerardo Herzig
Hi all. Im working on a "on each statement" update trigger, so NEW and OLD are NULL. Suppose a simple query like 'update mytable set id=id+500 where id < 50'...There is a way to obtaining the 'set id=..' and the where clause in some way? Thanks! Gerardo ---(end of broad

Re: [SQL] SQL dealing with subquery

2008-01-15 Thread Rodrigo E. De León Plicet
On Jan 15, 2008 1:04 PM, Bryan Emrys <[EMAIL PROTECTED]> wrote: > In other words, in the sample above, I only want to return: > 'Canada','Ireland',0 > 'Canada','Netherlands',5 Try (untested): SELECT t2.* FROM (SELECT payor FROM treaty_rates WHEREpayee IN ('Netherlands'

Re: [SQL] Update PK Violation

2008-01-15 Thread Scott Marlowe
On Jan 15, 2008 3:03 PM, Franklin Haut <[EMAIL PROTECTED]> wrote: > Hi all, > > i have a problem with one update sentence sql. > > example to produce: > > create table temp (num integer primary key, name varchar(20)); > > insert into temp values (1, 'THE'); > insert into temp values (2, 'BOOK'); >

[SQL] Update PK Violation

2008-01-15 Thread Franklin Haut
Hi all, i have a problem with one update sentence sql. example to produce: create table temp (num integer primary key, name varchar(20)); insert into temp values (1, 'THE'); insert into temp values (2, 'BOOK'); insert into temp values (3, 'IS'); insert into temp values (4, 'ON'); insert into t

Re: [SQL] Is DATETIME an ANSI-SQL type?

2008-01-15 Thread Joost Kraaijeveld
Hi, On Tue, 2008-01-15 at 10:53 -0500, Tom Lane wrote: > =?ISO-8859-1?Q?Magne_M=E6hre?= <[EMAIL PROTECTED]> writes: > > Joost Kraaijeveld wrote: > >> Can anyone tell me if DATETIME is an ANSI SQL type? > > > No. > > The Datetime types defined in SQL (ISO/IEC 9075:2003) are > > > DATE > > TIME W

[SQL] SQL dealing with subquery comparison

2008-01-15 Thread Bryan Emrys
Hi all, I'm having a conceptual problem with a subquery here - any help would be appreciated. I have a table treaty_rates with columns payor, payee, rate where payor and payee are countries. Sample set: 'US','UK',5 'US','Ireland',5 'US','Netherlands',5 'US','China',10 'Canada','US',0 'Canada','Ire

[SQL] SQL dealing with subquery

2008-01-15 Thread Bryan Emrys
Hi all, I'm having a conceptual problem with a subquery here - any help would be appreciated. I have a table treaty_rates with columns payor, payee, rate where payor and payee are countries. Sample set: 'US','UK',5 'US','Ireland',5 'US','Netherlands',5 'US','China',10 'Canada','US',0 'Canada','Ire

Re: [SQL] UTF8 encoding and non-text data types

2008-01-15 Thread John Hasler
Joe writes: > The Arabic language is written right-to-left, except ... when it comes to > numbers. Perhaps they read their numbers right to left but use a little-endian notation. -- John Hasler [EMAIL PROTECTED] Elmwood, WI USA ---(end of broadcast)--

Re: [SQL] Is DATETIME an ANSI-SQL type?

2008-01-15 Thread Tom Lane
=?ISO-8859-1?Q?Magne_M=E6hre?= <[EMAIL PROTECTED]> writes: > Joost Kraaijeveld wrote: >> Can anyone tell me if DATETIME is an ANSI SQL type? > No. > The Datetime types defined in SQL (ISO/IEC 9075:2003) are > DATE > TIME WITHOUT TIME ZONE > TIME WITH TIME ZONE > TIMESTAMP WITHOUT TIME ZONE > TIM

Re: [SQL] JOIN a table twice for different values in the same query

2008-01-15 Thread Colin Wetherbee
Magne Mæhre wrote: Colin Wetherbee wrote: Colin Wetherbee wrote: Phillip Smith wrote: As a side note - all the IATA codes are unique for each airport - wouldn't it be better to use these as the Primary Key and Foreign Keys? Then you wouldn't have to even join the tables unless you wanted the p

Re: [SQL] Is DATETIME an ANSI-SQL type?

2008-01-15 Thread Magne Mæhre
Joost Kraaijeveld wrote: Hi, Well the subject says it all: Can anyone tell me if DATETIME is an ANSI SQL type? No. The Datetime types defined in SQL (ISO/IEC 9075:2003) are DATE TIME WITHOUT TIME ZONE TIME WITH TIME ZONE TIMESTAMP WITHOUT TIME ZONE TIMESTAMP WITH TIME ZONE --Magne -

Re: [SQL] JOIN a table twice for different values in the same query

2008-01-15 Thread Magne Mæhre
Colin Wetherbee wrote: Colin Wetherbee wrote: Phillip Smith wrote: As a side note - all the IATA codes are unique for each airport - wouldn't it be better to use these as the Primary Key and Foreign Keys? Then you wouldn't have to even join the tables unless you wanted the port names (not just

[SQL] Is DATETIME an ANSI-SQL type?

2008-01-15 Thread Joost Kraaijeveld
Hi, Well the subject says it all: Can anyone tell me if DATETIME is an ANSI SQL type? TIA -- Groeten, Joost Kraaijeveld Askesis B.V. Molukkenstraat 14 6524NB Nijmegen tel: 024-3888063 / 06-51855277 fax: 024-3608416 web: www.askesis.nl ---(end of broadcast)--

Re: [SQL] UTF8 encoding and non-text data types

2008-01-15 Thread Gregory Stark
"Joe" <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> Oh? Interesting. But even if we wanted to teach Postgres about that, >> wouldn't there be a pretty strong risk of getting confused by Arabic's >> right-to-left writing direction? Wouldn't be real helpful if the entry >> came out as 4321 whe