Michael Fuhr wrote:
[Please copy the mailing list on replies so others can contribute
to and learn from the discussion.]

On Fri, Aug 04, 2006 at 11:20:55AM +0300, gustavo halperin wrote:
Michael Fuhr wrote:
You've hardcoded the strings 'v_tbl_schm' and 'v_tbl_name' instead
of using the function's arguments.  I don't think SQL functions
support named arguments so you'll need to use $1 and $2.  You'll
also need to use "RETURNS SETOF record" if you want to return more
than one row.
*OK thank you, I did it. But I receive actually one row, same as you say, and I need a set of rows for two columns. I don't know how to use 'RETURNS SETOF' for two columns, This is possible ??, see the function below:*
/CREATE OR REPLACE FUNCTION f_describe_tables (text, text
OUT text, OUT text) as -- How to use RETURNS SETOF with *two text columns*??
$$ SELECT c.column_name, c.data_type
FROM information_schema.columns c
WHERE c.table_schema = $1 AND c.table_name = $2
$$ LANGUAGE SQL;/

Since the function has OUT parameters you can use "RETURNS SETOF record"
like this:

CREATE FUNCTION funcname(<params>) RETURNS SETOF record AS $$
<body>
$$ LANGUAGE SQL
What do you mean with the word "record", can you give an example of how this "record" looks for two columns ?


 Thank you,
      Gustavo

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply via email to