Click here to Skip to main content
15,891,942 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am getting error:syntax error at or near "SELECT"
SQL
 CREATE FUNCTION fngetlastcodeofvillage( IN districtname text,
    IN talukname text,
    IN villagenam text)  RETURNS setof text AS
    $BODY$ 
   BEGIN
    SELECT schcd FROM villagerural_school_form  where districtna=$1 and talukname=$2 and villagenam=$3 order by id desc limit 1
    IF schcd IS NULL THEN
       RETURN census2011||01  from villagerural where districtna=$1 and talukname=$2 and villagenam=$3 
       else
      return schcd+01 from villagerural_school_form where districtna=$1 and talukname=$2 and villagenam=$3 
     END IF;

   END;
  
 $BODY$
 LANGUAGE sql VOLATILE
 COST 100
  ROWS 1000;
ALTER FUNCTION fngetlastcodeofvillage(text, text, text)
  OWNER TO postgres;


can any one tell why i am getting that error.whtas is wrong

What I have tried:

i have tried with syntax missing and all but still getting same error
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900