Search Postgresql Archives

Create function problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



*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
*


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux