Thread: Re: pl/pgsql docs 37.4.3. Row Types -- how do I use this
>Unless your function parameter is an integer you must quote it... eq: > >select use_two_tables('tablename'); > Hrm... That does not work either: # select use_two_tables('tablename'); ERROR: function use_two_tables("unknown") does not exist HINT: No function matches the given name and argument types. You may need to add explicit type casts. # select use_two_tables('tablename'::text); ERROR: function use_two_tables(text) does not exist HINT: No function matches the given name and argument types. You may need to add explicit type casts. I am not really sure... just learning this, but I believe the parameter type is tablename, right? >>CREATE TABLE tablename( ... >>CREATE or REPLACE FUNCTION use_two_tables(tablename) RETURNS text AS ' >>... Do I need to cast the string to something? # \df use_two* List of functions Result data type | Schema | Name | Argument data types ------------------+--------+----------------+--------------------- text | lee | use_two_tables | tablename (1 row) # select use_two_tables('tablename'::tablename); ERROR: cannot cast type "unknown" to tablename # select use_two_tables(tablename::tablename); ERROR: column "tablename" does not exist Thanks for your help. _________________________________________________________________ MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus
Lee Harr <missive@hotmail.com> said: > >Unless your function parameter is an integer you must quote it... eq: > > > >select use_two_tables('tablename'); > > > > Hrm... That does not work either: > > # select use_two_tables('tablename'); > ERROR: function use_two_tables("unknown") does not exist > HINT: No function matches the given name and argument types. You may need > to add explicit type casts. > # select use_two_tables('tablename'::text); > ERROR: function use_two_tables(text) does not exist > HINT: No function matches the given name and argument types. You may need > to add explicit type casts. Why not just use a text type in your definition? CREATE or REPLACE FUNCTION use_two_tables(text) RETURNS text AS ... You can always do a cast inside the procedure if you need to. Best regards, Jim Wilson