Re: [SQL] join question - three tables, two with foreign keys to the first

2002-06-13 Thread Dmitri Colebatch
maybe just to qualify, I get this: select emp.name, lv.from_date, lv.to_date, pay.amount from employee as emp left join employee_leave as lv on emp.id = lv.employee_id left join employee_pay as pay on emp.id = pay.employee_id where emp.id = 1; name | from_date | to_date | amount --+

Re: [SQL] Rule problem

2002-06-13 Thread Tom Lane
Svenn Helge Grindhaug <[EMAIL PROTECTED]> writes: > create rule a_delete as > on delete to a do > delete from b where id1 = old.id1; > create rule c_delete as > on delete to c do > delete from a where id1 = (select id1 from b where id2 = old.id2); The a_delete rule is run before the actual "DELE

Re: [SQL] join question - three tables, two with foreign keys to the first

2002-06-13 Thread Manfred Koizar
On Fri, 14 Jun 2002 00:13:22 +1000, "Dmitri Colebatch" <[EMAIL PROTECTED]> wrote: >select emp.name, lv.from_date, lv.to_date, pay.amount >from employee as emp >left outer join employee_leave as lv on emp.id = lv.employee_id >left outer join employee_pay as pay on emp.id = pay.employee_id >where em

Re: [SQL] join question - three tables, two with foreign keys to

2002-06-13 Thread Stephan Szabo
On Fri, 14 Jun 2002, Dmitri Colebatch wrote: > maybe just to qualify, I get this: > > select emp.name, lv.from_date, lv.to_date, pay.amount > from employee as emp > left join employee_leave as lv on emp.id = lv.employee_id > left join employee_pay as pay on emp.id = pay.employee_id > where emp.i

[SQL] how do i provide array parameters for my functions in php

2002-06-13 Thread joseph
i have just finished creating a function that has an array of integers as its parameter. what i would like to know is how do i declare/execute my function in php. i tried several syntax e.g. $arrvalue - an array of integers $strquery = "select functionname($arrvalue)"; $strquery = "select fun

Re: [SQL] Another postgres 'file not found' error

2002-06-13 Thread Josh Berkus
Ian, > This is the second time within a week I've been hit by a peculiar > 'file not > found' error. I've been replacing a few existing Oracle servers with > Postgres. I'm wondering if that was a wise decision :/ Not if you don't know how to run PostgreSQL or your machines, no. Migrating to a

Re: [SQL] Another postgres 'file not found' error

2002-06-13 Thread Ian Cass
> Not if you don't know how to run PostgreSQL or your machines, no. > Migrating to a new platform without sufficient testing or expertise > is always unwise (sorry, but you deserved that for the dig at > Postgres). Heh. Well it's most certainly the case I'm still learning about Postgres (aren't

Re: [SQL] make a unique index for foreign keys?

2002-06-13 Thread Beth Gatewood
Chris/ Josh- OK-response to Chris below. Synopsis heresimply by creating a foreign key will not create an index. On large tables I SHOULD put a non-unique index on the foreign key (right?) Hmm...nope. Creating a foreign key doesn't create an index. However, creating a primary key does

Re: [SQL] how do i provide array parameters for my functions in php

2002-06-13 Thread Achilleus Mantzios
On Thu, 13 Jun 2002 [EMAIL PROTECTED] wrote: > i have just finished creating a function that has an array of integers as its > parameter. what i would like to know is how do i declare/execute my function > in php. i tried several syntax > e.g. > $arrvalue - an array of integers > > $strquery

Re: [SQL] make a unique index for foreign keys?

2002-06-13 Thread Jan Wieck
Beth Gatewood wrote: > > Chris/ Josh- > > OK-response to Chris below. Synopsis heresimply by creating a foreign > key will not create an index. On large tables I SHOULD put a non-unique > index on the foreign key (right?) Right, because on DELETE or UPDATE to the primary key, the

Re: [SQL] Another postgres 'file not found' error

2002-06-13 Thread Josh Berkus
Ian, > Debian Woody with 2.4.18 Linux kernel. Postgres install from apt-get > (7.2.1). Hmmm. I might suggest polling both the Debian mailing lists and the pgsql-hackers mailing list. I remember vaguely hearing about some bug with Postgres on Debian, but I can't remember where I heard it.

[SQL] Isn't there a better way?

2002-06-13 Thread Josh Berkus
Folks, Given the following tables: --DROP TABLE teams_desc; create table teams_desc ( teams_id INT4 NOT NULL DEFAULT NEXTVAL('users_user_id_sq') PRIMARY KEY, teams_name VARCHAR(75) NOT NULL, teams_code VARCHAR(20) NOT NULL, notes TEXT NULL ); --drop table teams_t

[SQL] serial column vs. explicit sequence question

2002-06-13 Thread Charlie Toohey
I'm having a problem and there seems to be 2 solutions. It is simple and straighforward, but will take several paragraphs to explain. I have a schema with a master-detail design. The master table does not have an expicit id, so I have a column of type serial. Lets say I need to insert a row i

Re: [SQL] Another postgres 'file not found' error

2002-06-13 Thread Tom Lane
"Ian Cass" <[EMAIL PROTECTED]> writes: > inbound=# update store set state = 0, timestamp = 'now' where timestamp < > (CURRENT_TIMESTAMP - interval '30 seconds') and accountid = '6'; > ERROR: cannot open segment 1 of relation store_ix1 (target block > 1576985508): No such file or directory and la

[SQL] Please help me out on this insert error

2002-06-13 Thread Vernon Wu
Command: Insert into profile (userid, haveChildren)values('id98', 'No'); Error: ERROR: Relation 'profile' does not have attribute 'havaChildren' Table: Table "profile" Column| Type | Modifiers --+---+-- useri

Re: [SQL] serial column vs. explicit sequence question

2002-06-13 Thread Stephan Szabo
On Thu, 13 Jun 2002, Charlie Toohey wrote: > I'm having a problem and there seems to be 2 solutions. It is simple and > straighforward, but will take several paragraphs to explain. > > I have a schema with a master-detail design. The master table does not have > an expicit id, so I have a column

Re: [SQL] serial column vs. explicit sequence question

2002-06-13 Thread Josh Berkus
Charlie, > Lets say I need to insert a row into the master table and N rows into the > detail table. After inserting a row into master, and before detail, I need to > read the master table to obtain the value of the id for the row just > inserted, so I can insert this id as the foreign key v

Re: [SQL] serial column vs. explicit sequence question

2002-06-13 Thread Tom Lane
Charlie Toohey <[EMAIL PROTECTED]> writes: > A better solution would seem to use a sequence explicitly, rather than a id > column of type serial. I would obtain the id value from the sequence, and > then insert this id into the master table and into the detail table. Yup. But there's no need t

Re: [SQL] Another postgres 'file not found' error

2002-06-13 Thread Oliver Elphick
On Thu, 2002-06-13 at 19:01, Josh Berkus wrote: > > Debian Woody with 2.4.18 Linux kernel. Postgres install from apt-get > > (7.2.1). > > Hmmm. I might suggest polling both the Debian mailing lists and the > pgsql-hackers mailing list. I remember vaguely hearing about some bug with > Postgre

Re: [SQL] Please help me out on this insert error

2002-06-13 Thread Joe Conway
Vernon Wu wrote: > Command: > > Insert into profile (userid, haveChildren)values('id98', 'No'); > > Error: > > ERROR: Relation 'profile' does not have attribute 'havaChildren' ^^^ From the error message, looks like you spelled haveChild

Re: [SQL] serial column vs. explicit sequence question

2002-06-13 Thread Charlie Toohey
If session A and session B are concurrently doing the same master-detail transaction, wouldn't currval possibly reflect the sequence value used by the other session ? Or are you saying that since this will be an explicit transaction that currval won't reflect the fact that the sequence may have

Re: [SQL] serial column vs. explicit sequence question

2002-06-13 Thread Jason Earl
Charlie Toohey <[EMAIL PROTECTED]> writes: > I'm having a problem and there seems to be 2 solutions. It is simple > and straighforward, but will take several paragraphs to explain. > > I have a schema with a master-detail design. The master table does > not have an expicit id, so I have a column

Re: [SQL] serial column vs. explicit sequence question

2002-06-13 Thread Charlie Toohey
that definitely helps ! thank you Jason --- the key thing that I didn't undertand, and you have now enlightened me, is that currval was connection dependent --- I didn't think this would be guaranteed to work with concurrent transactions, but now I understand. Just prior to receiving your mess

Re: [SQL] serial column vs. explicit sequence question

2002-06-13 Thread Stephan Szabo
On Thu, 13 Jun 2002, Charlie Toohey wrote: > If session A and session B are concurrently doing the same master-detail > transaction, wouldn't currval possibly reflect the sequence value used by the > other session ? Or are you saying that since this will be an explicit > transaction that currval

Re: [SQL] Please help me out on this insert error

2002-06-13 Thread Stephan Szabo
On Thu, 13 Jun 2002, Vernon Wu wrote: > I, however, didn't use double quote mark when I created the table at all. If you used an interface to generate the table def, alot of them add the quote marks behind your back when they do the creation. In general, it's safer to just use all lowercase nam

Re: [SQL] Please help me out on this insert error

2002-06-13 Thread Stephan Szabo
On Thu, 13 Jun 2002, Vernon Wu wrote: > > Command: > > Insert into profile (userid, haveChildren)values('id98', 'No'); You presumably used double quotes when creating the column, so you need to use them to refer to the column from that point on: insert into profile(userid, "haveChildren") ...

Re: [SQL] Please help me out on this insert error

2002-06-13 Thread Manfred Koizar
On Thu, 13 Jun 2002 13:16:29 +0800, Vernon Wu <[EMAIL PROTECTED]> wrote: > >Command: > >Insert into profile (userid, haveChildren)values('id98', 'No'); > >Error: > >ERROR: Relation 'profile' does not have attribute 'havaChildren' ^

Re: [SQL] Please help me out on this insert error

2002-06-13 Thread Vernon Wu
You are right, Steve. It needs the double quote mark. After I use the double quote mark, an error message is: ERROR: ExecAppend: Fail to add null value in not null attribute ... which is right since I don't have non-null value to non-null field yet. I, however, didn't use double quote mark w

Re: [SQL] join question - three tables, two with foreign keys to the first

2002-06-13 Thread Dmitri Colebatch
> why do you expect nulls? probably because my sql is extremely rusty (o: > SELECT ... FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col2; > > returns nulls for the b-columns in the select list, if you have a row > in t1 with a value t1.col1, that does not appear as col2 in any row of > t2. In your exam

Re: [SQL] Please help me out on this insert error

2002-06-13 Thread Vernon Wu
6/14/2002 6:31:16 AM, Stephan Szabo <[EMAIL PROTECTED]> wrote: > >On Thu, 13 Jun 2002, Vernon Wu wrote: > >> I, however, didn't use double quote mark when I created the table at all. > >If you used an interface to generate the table def, alot of them add the >quote marks behind your back when the

[SQL] simple recursive function in plpgsql fails

2002-06-13 Thread Andrew Hammond
ians=# SELECT version(); version --- PostgreSQL 7.1.3 on i686-pc-linux-gnu, compiled by GCC 2.95.4 My goal is to find the last occurance of a pattern in a string. As a helper function, I wrote this: DROP F

Re: [SQL] join question - requesting for a simple C program where it can INSERT data into database as reference

2002-06-13 Thread joo
My problem is, i am writing a simple retrieval program using C, to retrieve a set of records from database. Then i'll make certain calculation based on the data that i have retrieved and write it on a new database. I have follow the sample program to do the retrieval and it works. But i don't see

Re: [SQL] make a unique index for foreign keys?

2002-06-13 Thread Christopher Kings-Lynne
> Chris/ Josh- > > OK-response to Chris below. Synopsis heresimply by creating a foreign > key will not create an index. On large tables I SHOULD put a non-unique > index on the foreign key (right?) For large tables, I guess you may as well. You can be more scientific about it if you you u

Re: [SQL] simple recursive function in plpgsql fails

2002-06-13 Thread Tom Lane
Andrew Hammond <[EMAIL PROTECTED]> writes: > [ problems with a recursive plpgsql function ] Yeah, there are some known bugs there :-(. AFAICS this cannot be fixed properly until we get around to doing the querytree restructuring that I keep ranting about --- in particular, making a clean distinc