Hello all, I am getting a syntax error near open cursor, can anybody please point me what is missing. i am using Postgresql 8.2
CREATE OR REPLACE FUNCTION sp_gen_foreign_keys_tables(OUT par_result integer, OUT par_childtables text, IN par_colname character varying , IN par_colvalue integer) AS $BODY$ DECLARE tablename varchar(300); columnname varchar(300); countno integer; curfroeign cursor (columnname varchar(300)) is select distinct(fk_relation),fk_column from foreign_keys where pk_relation in (select pk_relation from foreign_keys where pk_column=columnname); var_str1 varchar(300); BEGIN open curforeign(par_colname); FETCH curforeign INTO tablename,columnname; var_str1:='select count(*) into'||countno||'from' ||tablename || 'where' ||columnname||'='||parcolvalue; execute var_str1; if countno >0 then par_childtables:=par_childtables || ',' ||tablename; endif ; close curfroeign ; END; $BODY$ LANGUAGE 'plpgsql' VOLATILE; ____________________________________________________________________________________ Need a quick answer? Get one in minutes from people who know. Ask your question on www.Answers.yahoo.com ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings