Re: [SQL] How To Create Temporary Table inside a function

2012-03-02 Thread Philip Couling
Hi Rehan I suggest attempting to drop the table before you create the temp table: DROP TABLE IF EXISTS table1; See: http://www.postgresql.org/docs/current/static/sql-droptable.html Also if you're using an actual TEMP table, PostgreSQL can automatically drop the table or just empty it once the t

Re: [SQL] No sort with except

2012-03-01 Thread Philip Couling
Hi Reto You are right to assume that you're query is ordering the second select and not the whole query. To order the query as a whole it in parentheses and put the ORDER BY at the end: ( SELECT foo FROM X EXCEPT SELECT foo FROM Y ) ORDER BY foo; Hope this helps On 01/03/2012 08:56, reto.buc.

Re: [SQL] Another constant in foreign key problem.

2012-02-22 Thread Philip Couling
Hi Gary In short you can't have a foreign key here because foreign keys are just that: a *key* from another table. fl_level is not a key, it is not unique and requires fl_f_id to be unique. If you want a foreign key between these two tables then you must add the facility id to the document libra

Re: [SQL] Calling Postgresql Function to delete user data

2012-02-12 Thread Philip Couling
On 11/02/2012 19:53, Rehan Saleem wrote: > Hi , > I have created this function to remove UserDataAccountid > from both tables > UserAccountDetails and UserAC > CREATE OR REPLACE FUNCTION DeleteUserData(ACDetailsID int[]) > RETURNS void AS $$ > DECLARE _id int; > BEGIN > -- postgresql has no tabl