Re: [SQL] function returning result set of varying column

2008-06-03 Thread Bart Degryse
Hi Maria, Try something like CREATE OR REPLACE FUNCTION myfunction() RETURNS SETOF RECORD AS $body$ DECLARE rec record; BEGIN FOR rec IN ( SELECT * FROM sometable) LOOP RETURN NEXT rec; END LOOP; RETURN; END; $body$ LANGUAGE 'plpgsql' VOLATILE; As you can see, the number and

Re: [SQL] function returning result set of varying column

2008-06-03 Thread maria s
Hi Friends, Thanks for all your for the reply. I tried the function and when I execute it using select * from myfunction() it says ERROR: a column definition list is required for functions returning record Could you please help me to fix this error? Thanks so much for your help. -maria On

Re: [SQL] function returning result set of varying column

2008-06-03 Thread Bart Degryse
As I wrote before you will have to define your fields when querying the function, eg. select * from myfunction() as (field1 integer, field2 text, ...) So suppose you have a table like this CREATE TABLE sometable ( id serial, sometextfield text, aninteger int, andavarchar varchar(20) );

Re: [SQL] function returning result set of varying column

2008-06-03 Thread Ivan Sergio Borgonovo
On Tue, 3 Jun 2008 09:01:02 -0400 maria s [EMAIL PROTECTED] wrote: Hi Friends, Thanks for all your for the reply. I tried the function and when I execute it using select * from myfunction() it says ERROR: a column definition list is required for functions returning record Could you

Re: [SQL] function returning result set of varying column

2008-06-03 Thread maria s
Thanks for all your replies. Actually I don't know the number of columns that I am going to return. I have 2 tables. For a single entry E1 in one table(t1), I have to fetch all the matching entries for E1 from the other table(t2), K1,..Kn. and finally the function should return E1, K1..Kn. So

Re: [SQL] cross-database references are not implemented

2008-06-03 Thread Pavel Stehule
Hello it works for me postgres=# create schema export; CREATE SCHEMA Time: 45,918 ms postgres=# create table public.a(a varchar); CREATE TABLE Time: 91,385 ms postgres=# create table export.a(a varchar); \CREATE TABLE Time: 9,462 ms postgres=# create function ftrg() returns trigger as $$begin

Re: [SQL] function returning result set of varying column

2008-06-03 Thread Ivan Sergio Borgonovo
On Tue, 3 Jun 2008 09:41:27 -0400 maria s [EMAIL PROTECTED] wrote: Thanks for all your replies. Actually I don't know the number of columns that I am going to return. I have 2 tables. For a single entry E1 in one table(t1), I have to fetch all the matching entries for E1 from the other

[SQL] cross-database references are not implemented

2008-06-03 Thread Paul Dam
Hoi, I have a database with 2 schemas: - public - export In the export schema I have tables that are filled during an export process. There is some data I want to have in a table in the public schema as well. I wrote a trigger function that after insert in the export table does an

Re: [SQL] cross-database references are not implemented

2008-06-03 Thread Adrian Klaver
On Tuesday 03 June 2008 6:12 am, Paul Dam wrote: Hoi, I have a database with 2 schemas: - public - export In the export schema I have tables that are filled during an export process. There is some data I want to have in a table in the public schema as well. I wrote a trigger

Re: [SQL] function returning result set of varying column

2008-06-03 Thread maria s
Hi Ivan, If I have to know the column names then I can't use the Functions. As I said before, the columns will vary. or As Pavel Stehule said I will use arrays. Is anyone can show an example of returning a record with string and array? Thanks, Maria On Tue, Jun 3, 2008 at 9:57 AM, Ivan Sergio

Re: [SQL] cross-database references are not implemented

2008-06-03 Thread Paul Dam
Thanks Adrian, I casted a column to a type with value::schema.table.column%type That was the problem. Met vriendelijke groet, Paul Dam -Oorspronkelijk bericht- Van: Adrian Klaver [mailto:[EMAIL PROTECTED] Verzonden: dinsdag 3 juni 2008 15:57 Aan: pgsql-sql@postgresql.org CC: Paul Dam

Re: [SQL] function returning result set of varying column

2008-06-03 Thread Pavel Stehule
2008/6/3 maria s [EMAIL PROTECTED]: Thanks for all your replies. Actually I don't know the number of columns that I am going to return. I have 2 tables. For a single entry E1 in one table(t1), I have to fetch all the matching entries for E1 from the other table(t2), K1,..Kn. and finally

Re: [SQL] function returning result set of varying column

2008-06-03 Thread Ivan Sergio Borgonovo
On Tue, 3 Jun 2008 10:06:45 -0400 maria s [EMAIL PROTECTED] wrote: Hi Ivan, If I have to know the column names then I can't use the Functions. As I said before, the columns will vary. or As Pavel Stehule said I will use arrays. Is anyone can show an example of returning a record with

Re: [SQL] function returning result set of varying column

2008-06-03 Thread maria s
Hi Pavel Stehule, Thanks for your reply. If I want to return a string and an array how should I do it? The problem is as I explained before. I have 2 tables. For a single entry E1 in one table(t1), I have to fetch all the matching entries for E1 from the other table(t2), K1,..Kn,

Re: [SQL] function returning result set of varying column

2008-06-03 Thread Pavel Stehule
2008/6/3 maria s [EMAIL PROTECTED]: Hi Ivan, If I have to know the column names then I can't use the Functions. As I said before, the columns will vary. or As Pavel Stehule said I will use arrays. Is anyone can show an example of returning a record with string and array? postgres=# create

Re: [SQL] function returning result set of varying column

2008-06-03 Thread Pavel Stehule
2008/6/3 maria s [EMAIL PROTECTED]: Hi Pavel Stehule, Thanks for your reply. If I want to return a string and an array how should I do it? The problem is as I explained before. postgres=# create or replace function foo(j integer, out a varchar, out b varchar[]) as $$ begin a := 'kuku'; b :=

[SQL] Update problem

2008-06-03 Thread samantha mahindrakar
Hi Iam facing a strange issue One of the functions in my program is running an update statement. The statement is running cross-schema. What i mean is that the program resides in one schema where as it updates a table from another schema. How ever these scehmas are on the same database.

Re: [SQL] Update problem

2008-06-03 Thread samantha mahindrakar
I tried getting the output of the execute statements by printing the FOUND variable. It is returning the value as false. However i used PEFORM instead of EXECUTE for the update statement. It On 6/3/08, samantha mahindrakar [EMAIL PROTECTED] wrote: Hi Iam facing a strange issue One of

Re: [SQL] Update problem

2008-06-03 Thread samantha mahindrakar
Iam sorry for the previous mail..it was in complete. Please do not consider it. I think i could figure out the problem for the updates not happening. Following is the function that does the update : BEGIN IF flag=1 THEN tempQuery:='UPDATE '||thepartition||' SET