Search Postgresql Archives

error in open cursor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux