Re: [GENERAL] Insert Data Into Tables Linked by Foreign Key

2010-01-05 Thread Alban Hertroys
ERT INTO Order (Customer_ID, Price) VALUES (_customer_id, _price); END; $body$; > --- On Mon, 1/4/10, Alban Hertroys > wrote: > >> From: Alban Hertroys >> Subject: Re: [GENERAL] Insert Data Into Tables Linked by Foreign Key >> To: "Yan Cheng Cheok" >> C

Re: [GENERAL] Insert Data Into Tables Linked by Foreign Key

2010-01-04 Thread Yan Cheng Cheok
Can you please provide me an example of a stored procedures to achieve that? Thanks and Regards Yan Cheng CHEOK --- On Mon, 1/4/10, Alban Hertroys wrote: > From: Alban Hertroys > Subject: Re: [GENERAL] Insert Data Into Tables Linked by Foreign Key > To: "Yan Cheng Cheok"

Re: [GENERAL] Insert Data Into Tables Linked by Foreign Key

2010-01-04 Thread Grzegorz Jaƛkiewicz
insert into foo(a) with recursive t(n) AS (SELECT 10 AS n UNION ALL SELECT n-1 FROM t WHERE n > 0) select n from t; works on 8.5 -- GJ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Insert Data Into Tables Linked by Foreign Key

2010-01-04 Thread A. Kretschmer
In response to Alban Hertroys : > On 4 Jan 2010, at 13:15, A. Kretschmer wrote: > > > In response to Alban Hertroys : > >> On 4 Jan 2010, at 9:53, Yan Cheng Cheok wrote: > >> > >>> For example, "John" place "1.34" priced order. > >>> > >>> (1) Get Customer_ID from Customer table, where name is "

Re: [GENERAL] Insert Data Into Tables Linked by Foreign Key

2010-01-04 Thread Alban Hertroys
On 4 Jan 2010, at 13:15, A. Kretschmer wrote: > In response to Alban Hertroys : >> On 4 Jan 2010, at 9:53, Yan Cheng Cheok wrote: >> >>> For example, "John" place "1.34" priced order. >>> >>> (1) Get Customer_ID from Customer table, where name is "John" >>> (2) If there are no Customer_ID return

Re: [GENERAL] Insert Data Into Tables Linked by Foreign Key

2010-01-04 Thread Sam Mason
On Mon, Jan 04, 2010 at 04:53:16AM -0800, Yan Cheng Cheok wrote: > From general point of view, having 3 SQL statement wrapped in a > single stored procedure shall perform better due to reduced overhead > to communicate with SQL server. Is that true? Or that is my false > assumption? I'd be tempted

Re: [GENERAL] Insert Data Into Tables Linked by Foreign Key

2010-01-04 Thread Yan Cheng Cheok
ys wrote: > From: Alban Hertroys > Subject: Re: [GENERAL] Insert Data Into Tables Linked by Foreign Key > To: "Yan Cheng Cheok" > Cc: pgsql-general@postgresql.org > Date: Monday, January 4, 2010, 7:57 PM > On 4 Jan 2010, at 9:53, Yan Cheng > Cheok wrote: > > &

Re: [GENERAL] Insert Data Into Tables Linked by Foreign Key

2010-01-04 Thread A. Kretschmer
In response to Alban Hertroys : > On 4 Jan 2010, at 9:53, Yan Cheng Cheok wrote: > > > For example, "John" place "1.34" priced order. > > > > (1) Get Customer_ID from Customer table, where name is "John" > > (2) If there are no Customer_ID returned (There is no John), insert "John" > > (3) Get Cu

Re: [GENERAL] Insert Data Into Tables Linked by Foreign Key

2010-01-04 Thread Alban Hertroys
On 4 Jan 2010, at 9:53, Yan Cheng Cheok wrote: > For example, "John" place "1.34" priced order. > > (1) Get Customer_ID from Customer table, where name is "John" > (2) If there are no Customer_ID returned (There is no John), insert "John" > (3) Get Customer_ID from Customer table, where name is "

[GENERAL] Insert Data Into Tables Linked by Foreign Key

2010-01-04 Thread Yan Cheng Cheok
Customer == Customer_ID | Name Order == Order_ID | Customer_ID | Price To insert an order, here is what I need to do usually, For example, "John" place "1.34" priced order. (1) Get Customer_ID from Customer table, where name is "John" (2) If there are