Re: Object description at Client Window - Mailing list pgsql-sql

From George Weaver
Subject Re: Object description at Client Window
Date
Msg-id 005f01c394bd$ea11f100$2a0da18e@cleartag
Whole thread Raw
In response to Object description at Client Window  ("Kumar" <sgnerd@yahoo.com.sg>)
List 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



pgsql-sql by date:

Previous
From: achill@matrix.gatewaynet.com
Date:
Subject: Re: Object description at Client Window
Next
From: Rodrigo Gesswein
Date:
Subject: new max function