[SQL] week ending

2006-07-05 Thread Keith Worthington
Hi All, I just finished writing a query that groups data based on the week number. SELECT EXTRACT(week FROM col_a) AS week_number, sum(col_b) AS col_b_total FROM foo WHERE foobar GROUP BY EXTRACT(week FROM col_a) ORDER BY EXTRACT(week FROM col_a); I would like to generate the starti

Re: [SQL] Foreign Key: what value? -- currval()

2006-07-05 Thread Davi Leal
A. Kretschmer wrote: > Davi Leal folgendes: > > Hi, > > How to know the value which I must set in the foreign key field?. I have > > two tables: > > > > > > CREATE TABLE AA ( > > Id SERIAL PRIMARY KEY, > > data char(9) > > ); > > > > CREATE TABLE BB ( > > BB_Id integer REFERENCES

Re: [SQL] Problem with array subscripts in plpgsql trigger function

2006-07-05 Thread Erik Jones
Aaron Bono wrote: On 7/5/06, *Erik Jones* <[EMAIL PROTECTED] > wrote: Aaron Bono wrote: > On 7/5/06, *Erik Jones* <[EMAIL PROTECTED] >> wrote: > > Ok, I have a tri

Re: [SQL] "CASE" is not a variable

2006-07-05 Thread Keith Worthington
On Wed, 28 Jun 2006 10:48:31 -0700, Bricklen Anderson wrote > Keith Worthington wrote: > >>> "Keith Worthington" <[EMAIL PROTECTED]> writes: > >>> The following is a section of code inside an SQL function. > >> On Wed, 28 Jun 2006 12:16:29 -0400, Tom Lane wrote > >> SQL, or plpgsql? It looks to me

Re: [SQL] Problem with array subscripts in plpgsql trigger function

2006-07-05 Thread Aaron Bono
On 7/5/06, Erik Jones <[EMAIL PROTECTED]> wrote: Aaron Bono wrote:> On 7/5/06, *Erik Jones* <[EMAIL PROTECTED] [EMAIL PROTECTED]>> wrote:>> Ok, I have a trigger set up on the following (stripped down) table: >> CREATE TABLE members (> member_id   bigint,> member_status_id   smallint

Re: [SQL] Problem with array subscripts in plpgsql trigger function

2006-07-05 Thread Erik Jones
Aaron Bono wrote: On 7/5/06, *Erik Jones* <[EMAIL PROTECTED] > wrote: Ok, I have a trigger set up on the following (stripped down) table: CREATE TABLE members ( member_id bigint, member_status_id smallint, member_is_deletedboolean );

Re: [SQL] Problem with array subscripts in plpgsql trigger function

2006-07-05 Thread Aaron Bono
On 7/5/06, Erik Jones <[EMAIL PROTECTED]> wrote: Ok, I have a trigger set up on the following (stripped down) table:CREATE TABLE members (member_id   bigint,member_status_id   smallint,member_is_deletedboolean);Here's a shortened version of the trigger function: CREATE OR REPLACE FUNCTION updat

[SQL] Problem with array subscripts in plpgsql trigger function

2006-07-05 Thread Erik Jones
Ok, I have a trigger set up on the following (stripped down) table: CREATE TABLE members ( member_id bigint, member_status_id smallint, member_is_deletedboolean ); Here's a shortened version of the trigger function: CREATE OR REPLACE FUNCTION update_member() RETURNS TRIGGER AS $um$ DECL

Re: [SQL] Foreign Key: what value?

2006-07-05 Thread A. Kretschmer
am 05.07.2006, um 17:19:26 +0200 mailte Davi Leal folgendes: > Hi, > How to know the value which I must set in the foreign key field?. I have two > tables: > > > CREATE TABLE AA ( > Id SERIAL PRIMARY KEY, > data char(9) > ); > > CREATE TABLE BB ( > BB_Id integer REFERENCES A

[SQL] Foreign Key: what value?

2006-07-05 Thread Davi Leal
Hi, How to know the value which I must set in the foreign key field?. I have two tables: CREATE TABLE AA ( Id SERIAL PRIMARY KEY, data char(9) ); CREATE TABLE BB ( BB_Id integer REFERENCES AA(Id) NOT NULL, field char(5) ); I insert a register on table AA, IN