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


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to