Re: [SQL] Most efficient way to hard-sort records

2006-05-07 Thread PFC
Is it possible to do this : CREATE TABLE sorted (order_no SERIAL PRIMARY KEY, other columns...) INSERT INTO sorted (columns) SELECT * FROM main_table INNER JOIN key_table ON main_table.id = key_table.main_table_id WHERE key = 'param' ORDER BY value SELECT The SERIAL will automat

Re: [SQL] Returning String as Integer

2006-05-07 Thread Markus Schaber
Hi, Ben, Ben K. schrieb: > I tried int8(id) but java didn't take it as Integer. (It took int8 as > something like Long.) Yes, and that's good, as PostgreSQL int8 and java long actually are the same datatype (64-bit signed two's-complement). PostgreSQL int4 and Java int are the same (32-bit), as

Re: [SQL] Most efficient way to hard-sort records

2006-05-07 Thread Ben K.
CREATE TABLE sorted (order_no SERIAL PRIMARY KEY, other columns...) INSERT INTO sorted (columns) SELECT * FROM main_table INNER JOIN key_table ON main_table.id = key_table.main_table_id WHERE key = 'param' ORDER BY value SELECT The SERIAL will automatically generate the order_no you wa

Re: [SQL] Most efficient way to hard-sort records

2006-05-07 Thread PFC
Another version along that line ? # create sequence counterseq start 1; -- (set/reset whenever a counter is needed) # select main_table.*, nextval('counterseq') as position2 into sorted_main_table from main_table, keytable where main_table.id = keytable.main_table_id order by value

Re: [SQL] Creating nested functions with plpgsql

2006-05-07 Thread Alvaro Herrera
Jorge Godoy wrote: > I have some real case examples where this could be useful, if it is needed. > I haven't pasted them here because the smallest one has 176 LOC, after > refactoring with nested functions. > > If it is not possible, are there any plans to allow this kind of thing? > (Even with

Re: [SQL] Creating nested functions with plpgsql

2006-05-07 Thread Jorge Godoy
Em Domingo 07 Maio 2006 20:33, Alvaro Herrera escreveu: > > We don't support nested functions at present, but you can create a > separate function and invoke it as you would call any external function. Yeah, I know it and that's how I use some things today, but even so, having nested functions he