Re: [SQL] Insert only if not found

2007-04-05 Thread Roger Tannous
It's also desirable that you use TRIM along with UPPER or LOWER. Roger. Don't pick lemons. See all the new 2007 cars at Yahoo! Autos. http://autos.yahoo.com/new_cars.html ---(end of

[SQL] Generating dates prior to generate_series

2007-04-04 Thread Roger Tannous
I'm using PostgreSQL version 7.3.2, and generate_series() is not available, so this is a function to generate a series dates. The function goes backwards if the second argument is less than the first one. Check the two select statements at the end. Best Regards, Roger Tannous. CREATE FUN

Re: [SQL] column names, types, properties for a table

2005-09-07 Thread Roger Tannous
R pg_constraint.conkey[3] = pg_attribute.attnum OR pg_constraint.conkey[4] = pg_attribute.attnum OR pg_constraint.conkey[5] = pg_attribute.attnum OR pg_constraint.conkey[6] = pg_attribute.attnum) OR pg_constraint.conkey[7] = pg_attribute.attnum OR pg_constraint.conkey[8] = pg_attribute.attnum) WHERE pg_class.rel

[SQL] column names, types, properties for a table

2005-09-07 Thread Roger Tannous
Hi, Is it possible to issue an SQL query that lists column names, types (int, varchar, boolean, etc.), properties (like NOT NULL or UNIQUE) for a given table name ? Regards, Roger Tannous. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the

Re: [SQL] A Table's Primary Key Listing

2005-08-22 Thread Roger Tannous
key[9]=pg_attribute.attnum ) ORDER BY pg_namespace.nspname, pg_class.relname,pg_attribute.attname; Regards, Roger Tannous. --- "D'Arcy J.M. Cain" wrote: > On Thu, 18 Aug 2005 09:40:57 -0700 (PDT) > Roger Tannous <[EMAIL PROTECTED]> wrote: > > Thanks for yo

Re: [SQL] A Table's Primary Key Listing

2005-08-19 Thread Roger Tannous
OUPS !! Things seem to be stuck now, since the DB version is 7.3.2, so no array_to_string method is available. Does anyone have any idea how to solve that ? Regards, Roger Tannous. --- Roger Tannous <[EMAIL PROTECTED]> wrote: > Hi to all, there was a BIG MISTAKE in my proposition reg

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread Roger Tannous
; I'm sure this should work :) Now we have the final WHERE statement like this: WHERE pg_attribute.attnum IN '(\'' || arr

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread Roger Tannous
WHERE pg_attribute.attnum IN (1,2) Finally, this WHERE statement: WHERE pg_attribute.attnum IN '(\'' || replace(pg_index.indkey, " ", "','") || '\')' [ Again, I should test: WHERE pg_attribute.attnum IN '(\'

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread Roger Tannous
Yes, I want only field names, not values. Thanks, Roger Tannous. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ---(end of broadcast)--- TIP

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread Roger Tannous
Thanks for your query :) But it only shows the first of the primary keys of tables having multiple primary keys :) This is apparently because of the pg_index.indkey[0] thing, so how can we manage this query in order to get all of the keys :) Thanks in advance, Roger Tannous. --- "D

[SQL] A Table's Primary Key Listing

2005-08-18 Thread Roger Tannous
Hi to all, Is there any means to get a list of the Primary Keys (or simply the Primary Key if there's only one :) ) for a given table using an SQL query ? Regards, Roger Tannous. __ Do you Yahoo!? Yahoo! Mail - You care

Re: [SQL] Locating ( FKs ) References to a Primary Key

2005-08-17 Thread Roger Tannous
lf.relkind = 'r') JOIN pg_catalog.pg_namespace nf ON (nf.oid = clf.relnamespace) JOIN pg_catalog.pg_attribute af ON (af.attrelid = ct.confrelid AND af.attnum = ct.confkey[1]) WHERE n.nspname = nf.nspname AND n.nspname = 'public' AND clf.relname like 'sip_emp' AND