Create function problem - Mailing list pgsql-general

From gustavo halperin
Subject Create function problem
Date
Msg-id 44D27DE7.30906@gmail.com
Whole thread Raw
Responses Re: Create function problem  (Michael Fuhr <mike@fuhr.org>)
List pgsql-general
*Hello I have a little question

 In order to know the names and data types of the table "mil_cien_diez"
from the schema "public" I run the next 'SELECT' but when I try to
create a SQL function and after it I run it, I receive an empty row. Can
you see the problem ??*

/mydb=> SELECT c.column_name, c.data_type, e.data_type AS element_type
mydb-> FROM information_schema.columns c LEFT JOIN
information_schema.element_types e
mydb->   ON ((c.table_catalog, c.table_schema, c.table_name, 'TABLE',
c.dtd_identifier)
mydb->     = (e.object_catalog, e.object_schema, e.object_name,
e.object_type, e.array_type_identifier))
mydb->  WHERE c.table_schema = 'public' AND c.table_name = 'mil_cien_diez'
mydb-> ORDER BY c.ordinal_position;
 column_name | data_type | element_type
-------------+-----------+--------------
 miles       | smallint  |
 cientos     | smallint  |
 decenas     | smallint  |
(3 rows)

/
 *The "CREATE FUNCTION" code is the next :*

/mydb=> CREATE OR REPLACE FUNCTION f_describe_tables (text, text
mydb(> ,OUT  text, OUT text, OUT text) as
mydb-> $$ SELECT c.column_name, c.data_type, e.data_type AS element_type
mydb$> FROM information_schema.columns c LEFT JOIN
information_schema.element_types e
mydb$>   ON ((c.table_catalog, c.table_schema, c.table_name, 'TABLE',
c.dtd_identifier)
mydb$>     = (e.object_catalog, e.object_schema, e.object_name,
e.object_type, e.array_type_identifier))
mydb$> WHERE c.table_schema = $1 AND c.table_name = $2
mydb$> ORDER BY c.ordinal_position;
mydb$> $$ LANGUAGE SQL;
CREATE FUNCTION
mydb=> SELECT * FROM f_describe_tables('pubilc', 'mil_cien_diez');
 column1 | column2 | column3
---------+---------+---------
         |         |
(1 row)


/
*Thank you,
       Gustavo
*

pgsql-general by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: Importance of re-index
Next
From: Ron Johnson
Date:
Subject: Re: Importance of re-index