[SQL] Re: unique sequences

2000-06-26 Thread K Parker
> Rather, each time you wish to do an insert, > query the existing data to see what the > maximum value is existing in the database. > Add 1 to that and use this as your new value. > This is guaranteed to not have any holes in > the sequence. True, but alas it _doesn't_ guarantee uniqueness, sinc

[SQL] Sub_select problem

2000-06-26 Thread Bernie Huang
Good day, everyone, I have 2 tables and 1 datafile as following: vehicle_tb --- v_idint4 primary key display_idint4 yeartext maketext modeltext ... vehicle_borrow_log employee_idint4 (foreign key to emp_tb) v_idint4 (foreign key to vehic

Re: [SQL] Merging two columns into one

2000-06-26 Thread Gary MacMinn
All, Many thanks for your thoughts on the merging of columns. The tr method would have killed all the delimiters as a few people noted. The || method in SQL was the winner, although the final table this has to be done to (4 million records) should kill the system for a while! Must make sur

Re: [SQL] A subselect in an aggregate

2000-06-26 Thread Tom Lane
"Bryan White" <[EMAIL PROTECTED]> writes: > This is very slow (acutally I killed it after about 5 minutes): > select o.date,sum(d.qty * d.price) from orderdetail d,orders o where o.date > = '6/1/2000' group by o.date; > This is quick (it takes a couple of seconds): > select o.date,(select sum(od.

Re: [SQL] A subselect in an aggregate

2000-06-26 Thread Bryan White
> Bryan White wrote: > > > > This statement works: > > select date, (select sum(qty * price) from orderdetail d where d.orderid = > > orders.orderid) from orders > > > > But when I try to do something like this: > > > > select date, sum(select sum(qty * price) from orderdetail d where d.orderid

Re: [SQL] pg_dump problem

2000-06-26 Thread Ed Loehr
Graham Vickrage wrote: > > I am trying to backup a production database running on v6.5 and restore it > on our test machine running v6.5. > > The largest table has about 750,000 rows, the other 5 tables are very small > approx 100 rows. > > When I try to restore the database using "psql -e dat

[SQL] pg_dump problem

2000-06-26 Thread Graham Vickrage
I am trying to backup a production database running on v6.5 and restore it on our test machine running v6.5. The largest table has about 750,000 rows, the other 5 tables are very small approx 100 rows. When I try to restore the database using "psql -e database < db.out" I get the error message

Re: [SQL] A subselect in an aggregate

2000-06-26 Thread Ed Loehr
Bryan White wrote: > > This statement works: > select date, (select sum(qty * price) from orderdetail d where d.orderid = > orders.orderid) from orders > > But when I try to do something like this: > > select date, sum(select sum(qty * price) from orderdetail d where d.orderid > = orders.orderi

[SQL] A subselect in an aggregate

2000-06-26 Thread Bryan White
This statement works: select date, (select sum(qty * price) from orderdetail d where d.orderid = orders.orderid) from orders But when I try to do something like this: select date, sum(select sum(qty * price) from orderdetail d where d.orderid = orders.orderid) from orders group by date I get ER

[SQL] finding (and recycling) holes in sequences

2000-06-26 Thread Kyle Bateman
  If one has a unique-id generating sequence that sometimes is bound to have holes in it (ie: it could happen that a nextval(seq) happens without a corresponding INSERT in the table), then how could one efficiently scan for these holes to recycle them in subsequent INSERTs? I'm just looking for