Bartek, Thanks. The reason I use the cursor is that I want to check the table is in the pg_tables or not, If it exists, the function will execute successfully, if not, it will raise the message that the table doesn't exist. For the schema part, I assume the people has set the search_path to that schema which the table is in and because our database only has one schema. So I assume they have the right search_path. Thanks for your advice. It helps me a lot. -- View this message in context: http://postgresql.1045698.n5.nabble.com/Please-help-me-to-take-a-look-of-the-erros-in-my-functions-Thanks-tp5613507p5615238.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general