Re: [SQL] Getting FK relationships from information_schema

2004-06-08 Thread Peter Eisentraut
Tom Lane wrote: > Kyle <[EMAIL PROTECTED]> writes: > > I think this is only an issue when the user relies on postgres to > > choose a constraint name automatically. Seems like a reasonable > > approach would be to have postgres choose a name for the constraint > > that happens to be unique in the

[SQL] Last insert id

2004-06-08 Thread mixo
I have three tables which are related a serial field, table1_id, in on of the tables. Updating the tables is done through a transaction. My problem is, once I have insert a row in the first tables with table1_id, I need for the other two tables. How can I get this? Is it safe to use "select ma

Re: [SQL] Getting FK relationships from information_schema

2004-06-08 Thread Tom Lane
Kyle <[EMAIL PROTECTED]> writes: > I think this is only an issue when the user relies on postgres to choose > a constraint name automatically. Seems like a reasonable approach would > be to have postgres choose a name for the constraint that happens to be > unique in the schema (like tablename_

Re: [SQL] Postgres DB

2004-06-08 Thread Sumita Biswas
Hi Tom, I have read that template1 is the default DB that gets installed with Postgres. But when I type the command "psql" and don't specify a DB name, it says that: psql: FATAL: Database "postgres" does not exist in the system catalog. This is the reason why I guessed that it expects the postg

[SQL] Input Arguments

2004-06-08 Thread Sumita Biswas
One more query: Cant I do something like this: $2 := $2 + interval ''86399 seconds''; Where $2 is one of my input variables to the function. It gives me an error: ERROR: $2 is declared CONSTANT ---(end of broadcast)--- TIP 9: the planner will i

Re: [SQL] Convert INT to INTERVAL?

2004-06-08 Thread Michael Chaney
On Fri, Feb 27, 2004 at 11:54:04AM -0500, Brian Knox wrote: > Is it possible within pl/pgsql, to convert an integer to an interval in > months? IE, if num_months is an INT set to 48, can it be converted to an > interval? select (1||' months')::interval; You should be able to replace the "1" wit

Re: [SQL] simple addition of constraints problem

2004-06-08 Thread Stephan Szabo
On Tue, 8 Jun 2004, Michelle Murrain wrote: > I'm trying to do something which seems really simple to me. (Postgres 7.3.4) > > I've got this table: > > charter_dev2=# \d rcourseinfo > Table "public.rcourseinfo" > Column| Type |

[SQL] a query question

2004-06-08 Thread Jaime Casanova
hi all, i was trying to migrate some data into a new structure i created. so i execute this exact query: insert into rec_t_ordenpago("ent_codigo", "sec_codigo", "ani_codigo", "orp_numero", "orp_tipopersona", "orp_persona", "cic_codigo", "esp_

[SQL] simple addition of constraints problem

2004-06-08 Thread Michelle Murrain
Hi All, I'm trying to do something which seems really simple to me. (Postgres 7.3.4) I've got this table: charter_dev2=# \d rcourseinfo Table "public.rcourseinfo" Column| Type | Modifiers -+--

Re: [SQL] Query becoming slower on adding a primary key

2004-06-08 Thread Rajesh Kumar Mallah
Hi, Is there any solution to this issue ? I am facing it every week. Warm Regds Mallah. Rajesh Kumar Mallah wrote: Tom Lane wrote: [EMAIL PROTECTED] writes: tradein_clients=# explain analyze select email_id ,email ,contact from t_a a join email_source f using(email_id) join email_subscriptions

Re: [SQL] Getting FK relationships from information_schema

2004-06-08 Thread Kyle
Tom Lane wrote: Kyle <[EMAIL PROTECTED]> writes: The problem is, the constraint names ($1, $2, etc.) are not unique so I don't know how to join the third query into the fourth. Hmm, this is messy :-(. The SQL spec requires constraint names to be unique within a schema

Re: [SQL] Last day of month

2004-06-08 Thread Frank Bax
At 11:30 PM 2/25/04, Joe Conway wrote: Greg Sabino Mullane wrote: How to find the last sunday/mon/sat of any given month. There is probably a smoother way to do it, but here is a quick little function to do what you ask. Feed it a date and a number, where 0 is Sunday, 1 is Monday, etc. oops...f

Re: [SQL] Last day of month

2004-06-08 Thread Joe Conway
Greg Sabino Mullane wrote: How to find the last sunday/mon/sat of any given month. There is probably a smoother way to do it, but here is a quick little function to do what you ask. Feed it a date and a number, where 0 is Sunday, 1 is Monday, etc. How about this: regression=# select date_trun