| From: | "George Weaver" <georgew1(at)mts(dot)net> | 
|---|---|
| To: | "Kumar" <sgnerd(at)yahoo(dot)com(dot)sg> | 
| Cc: | <pgsql-sql(at)postgresql(dot)org> | 
| Subject: | Re: Object description at Client Window | 
| Date: | 2003-10-17 14:49:13 | 
| Message-ID: | 005f01c394bd$ea11f100$2a0da18e@cleartag | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-sql | 
Kumar,
pg_class.relname is type "name". You are trying to compare it to p_tablename
which is type "varchar".  Try changing your function definition to:
CREATE OR REPLACE FUNCTION public.desc_table(name)
^^^^
HTH
George
SNIP
> CREATE OR REPLACE FUNCTION public.desc_table(varchar)
>   RETURNS refcursor AS
> 'DECLARE
>
> ref                         REFCURSOR ;
> p_tablename                 ALIAS FOR $1;
>
> BEGIN
> OPEN ref FOR
>  SELECT a.attname,
>   format_type(a.atttypid, a.atttypmod),
>   a.attnotnull,
>   a.atthasdef,
>   a.attnum
>  FROM pg_class c, pg_attribute a
>  WHERE c.relname = p_tablename
>  AND a.attnum > 0
>  AND a.attrelid = c.oid
>  ORDER BY a.attnum;
>
> RETURN ref;
> END;'
>   LANGUAGE 'plpgsql' VOLATILE;
>
>
> While trying to execute this
> select desc_table('companies');
>
> I got the following error.
> WARNING:  Error occurred while executing PL/pgSQL function desc_table
> WARNING:  line 7 at open
>
> ERROR:  Unable to identify an operator '=' for types 'name' and 'character
> varying'
>  You will have to retype this query using an explicit cast
>
SNIP
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Rodrigo Gesswein | 2003-10-17 18:13:18 | new max function | 
| Previous Message | achill | 2003-10-17 14:33:15 | Re: Object description at Client Window |