Create function problem

From: gustavo halperin <ggh(dot)develop(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Create function problem
Date: 2006-08-03 22:51:19
Message-ID: 44D27DE7.30906@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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
*

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ron Johnson 2006-08-03 22:56:33 Re: Importance of re-index
Previous Message Scott Marlowe 2006-08-03 22:46:44 Re: Importance of re-index