Re: [SQL] sql subqueries problem

2002-08-19 Thread Mathieu Arnold
--On lundi 19 août 2002 09:45 -0700 Stephan Szabo <[EMAIL PROTECTED]> wrote: > > On Mon, 19 Aug 2002, Mathieu Arnold wrote: > >> Hi >> >> I have my accounting in a database, and I have a problem with subqueries, >> here is what I have : >> >> >> >> SELECT f.numero, >> f.id_clie

Re: [SQL] how to refer to tables in another database( or schema as

2002-08-19 Thread Stephan Szabo
On Mon, 19 Aug 2002, Jiaqing wrote: > Hello, > I'm still new here and new to PostgreSQL, I'd like to know that after I > have created two databases on my site, such as one is called backend, and > another one is called admin, how do I refer(query) the table from backend > while I'm connected to a

Re: [SQL] how to refer to tables in another database( or schema as oracle refers to)

2002-08-19 Thread Graeme Merrall
> Basically - you can't. There is a program in the contrib/dblink directory > that can help you though. > My take on this dblink program is to create SQL as a view. For example coming from Oracle you might do "SELECT one, two, FROM foo.bar". Convert that to a VIEW called simply "bar" or "foo_ba

Re: [SQL] Modify column type

2002-08-19 Thread Christopher Kings-Lynne
Hi Scott, I believe you can hack the catalogs: (disclaimer) update pg_attribute set atttypmod=104 where attname='email' and attrelid=(select oid from pg_class where relname='student'); Do this in a transaction and then \d the table to check that it has worked before committing. Chris > -

Re: [SQL] how to refer to tables in another database( or schema as oracle refers to)

2002-08-19 Thread Christopher Kings-Lynne
Hi Jiaqing, Basically - you can't. There is a program in the contrib/dblink directory that can help you though. Regards, Chris > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]]On Behalf Of Jiaqing > Sent: Tuesday, 20 August 2002 5:53 AM > To: [EMAIL PROTECTED

[SQL] how to refer to tables in another database( or schema as oracle refersto)

2002-08-19 Thread Jiaqing
Hello, I'm still new here and new to PostgreSQL, I'd like to know that after I have created two databases on my site, such as one is called backend, and another one is called admin, how do I refer(query) the table from backend while I'm connected to admin database, or is it possible to do that

Re: [ADMIN] [SQL] Urgent - SQL Unique constraint error (long)

2002-08-19 Thread Darrin Domoney
Stephen, I preemptivelty sensed your reply ;-) I took another look at the ERD and quickly revised phone, address, and email so they all reference the person without having to become intertwined with their extended "class". Ultimately this should prove more flexible as it will allow person

Re: [SQL] Urgent - SQL Unique constraint error (long)

2002-08-19 Thread Stephan Szabo
On Mon, 19 Aug 2002, Darrin Domoney wrote: > Thanks for the response but the answer is no. Owing to the > ongoing issue with inherited tables in 7.x I have opted to create three > tables: > Contains generic traits regardless of "class or role". > Person -> PK person_id > > Staff as certain

Re: [SQL] [NOVICE] Urgent - SQL Unique constraint error (long)

2002-08-19 Thread Darrin Domoney
Paul, See my earlier comments relating to the reasons behind the structure for the database. I know this is an issue but if inheritance is "not working" it seems like my only option. Darrin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of paul but

Re: [SQL] Urgent - SQL Unique constraint error (long)

2002-08-19 Thread Darrin Domoney
Stephan, Thanks for the response but the answer is no. Owing to the ongoing issue with inherited tables in 7.x I have opted to create three tables: Contains generic traits regardless of "class or role". Person -> PK person_id Staff as certain "class" of person. Staff -> PK staff_id

Re: [SQL] Urgent - SQL Unique constraint error (long)

2002-08-19 Thread Stephan Szabo
On Mon, 19 Aug 2002, Darrin Domoney wrote: > An admitted newbie to postgresql I am trying to commit a new design > my development server using pgAdminII. > > Everything appears to work OK but I am having real grief with my > SQL generating errors - most of which I have cleared myself but > one th

[SQL] Urgent - SQL Unique constraint error (long)

2002-08-19 Thread Darrin Domoney
An admitted newbie to postgresql I am trying to commit a new design my development server using pgAdminII. Everything appears to work OK but I am having real grief with my SQL generating errors - most of which I have cleared myself but one that I am unsure how to handle: UNIQUE constraint for

Re: [SQL] need assistance with multi-row matching expression

2002-08-19 Thread Mark Stosberg
On Mon, 19 Aug 2002, Nick Fankhauser wrote: > > This may not be the best way, but I couldn't resist taking a shot at it... Thanks for the response Nick. If only I knew I was going to get a response from a block away, I would have just come down to say hi. :) I had an "a ha" moment about this ov

Re: [SQL] need assistance with multi-row matching expression

2002-08-19 Thread Nick Fankhauser
Mark- This may not be the best way, but I couldn't resist taking a shot at it... If I understand correctly, your user selects 0-n features, so you are essentially querying against park_feature_map with your known parameters being the number of features and a feature_id list. suppose your park_f

Re: [SQL] sql subqueries problem

2002-08-19 Thread Stephan Szabo
On Mon, 19 Aug 2002, Mathieu Arnold wrote: > Hi > > I have my accounting in a database, and I have a problem with subqueries, > here is what I have : > > > > SELECT f.numero, > f.id_client, > f.date_creation, > (f.date_creation + (f.echeance_paiement||' days')::inter

[SQL] Modify column type

2002-08-19 Thread Scott David Walter
Is there a way to modify the type of an existing column? All I actually want to do is extend the length of the type from a VARCHAR(6) to VARCHAR(100). Column | Type | Modifiers +---+ ema

[SQL] sql subqueries problem

2002-08-19 Thread Mathieu Arnold
Hi I have my accounting in a database, and I have a problem with subqueries, here is what I have : SELECT f.numero, f.id_client, f.date_creation, (f.date_creation + (f.echeance_paiement||' days')::interval)::date AS echeance, f.montant_ttc, ROUND(

Re: [SQL] recursive function returning "setof"

2002-08-19 Thread Christopher Kings-Lynne
http://www3.us.postgresql.org/users-lounge/docs/7.2/postgres/plpgsql-control -structures.html Chris - Original Message - From: "Fritz Lehmann-Grube" <[EMAIL PROTECTED]> To: "Christopher Kings-Lynne" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Monday, August 19, 2002 11:22 PM Subjec

Re: [SQL] recursive function returning "setof"

2002-08-19 Thread Fritz Lehmann-Grube
Thanx Chris, but I can't find it. My Programmer's Guide (.../pgsql/doc/html/xfunc-sql.html) says "12.2. Query Language (SQL) Functions SQL functions execute an arbitrary list of SQL statements," Nothing about control structures in SQL functions additional to the normal command-line syn

[SQL] need assistance with multi-row matching expression

2002-08-19 Thread Mark Stosberg
Hello, I'm using Postgres 7.1 and have been enjoying the upgraded "sub-select" support in this release versus older versions. At the moment, I'm stuck with a SQL issue that I haven't run into before. I need to select the data for all the "parks" that match some search criteria. The parks are s

Re: [SQL] recursive function returning "setof"

2002-08-19 Thread Christopher Kings-Lynne
> The problem is: > A SQL-Function cannot be recursive because it cannot call itself, and it can > perform no loops. > A PLPGSQL-Function cannot return sets. It can perform loops. Check the manual- you can do FOR and WHILE loops. 7.3 will be able to return sets from PLPGSQL funcs it seems. Chri

[SQL] recursive function returning "setof"

2002-08-19 Thread Fritz Lehmann-Grube
Hello all, I'd like to create a recursive function returning a "setof". See the following situation: CREATE TABLE sections( is serial, data text, contained_in int NOT NULL REFERENCES sections(id) DEFERRABLE ); INSERT INTO sections VALUES(0,'ROOTSECTION',0) I have trig

Re: [SQL] performance comparison: DISTINCT and GROUP BY

2002-08-19 Thread Christopher Kings-Lynne
Hi Devrim, You can use the EXPLAIN ANALYZE syntax to find out quite easily. Chris - Original Message - From: "Devrim GUNDUZ" <[EMAIL PROTECTED]> To: "PostgreSQL Mailing Lists-SQL" <[EMAIL PROTECTED]> Sent: Monday, August 19, 2002 7:22 PM Subject: [SQL] performance comparison: DISTINCT

[SQL] performance comparison: DISTINCT and GROUP BY

2002-08-19 Thread Devrim GUNDUZ
Hi, We have two different queries: SELECT name,surname FROM my_table GROUP BY name; and SELECT DISTINCT on(name) name,surname * FROM my_table; which gives us the same result. Do these queries differ by their performances? I mean, which one works faster? DISTINCT or GROUP BY? Best rega

Re: [SQL] Ordering with GROUPs

2002-08-19 Thread Julian Scarfe
From: "Tom Lane" <[EMAIL PROTECTED]> > ISTM the problem here is the lack of any ordering operator for POINT, > which defeats GROUP BY, *plus* the lack of any aggregate you might use > for an aggregate-based solution. This is not really a language failing > but a problem with an impoverished data

Re: [SQL] Few Queries

2002-08-19 Thread Sugandha Shah
Hello Richard, I'm really thankful to you. It worked. Somehow I wasn't getting it to work. This line did the trick. set_time := current_date() - (var_history_age_limit::text || '' days '')::interval; Regards, -Sugandha - Original Message - From: "Richard Huxton" <[EMAIL PROTECTE