ошибка в функции

Alexandre

PHPПенсионер
ошибка в функции

в чем может быть ошибка, работаю через консоль
выдает ERROR: syntax error at or near "select" у символа 7
СТРОКА 2: select count(*) INTO res FROM responses where objects_id...

[sql]CREATE FUNCTION responses_count( int ) RETURNS int AS
declare
res int;
BEGIN
select count(*) INTO res FROM responses where objects_id = $1 and lang= false
end;[/sql]
 

Alexandre

PHPПенсионер
пробовал так:
PHP:
CREATE FUNCTION responses_count( int ) RETURNS int
AS select count(*) as result FROM  responses   where objects_id = $1  and lang= false
  
 LANGUAGE 'pgsql';
ERROR: syntax error at or near "select" у символа 55
СТРОКА 2: AS select count(*) as result FROM responses where objects...

-~{}~ 11.10.05 13:12:

вот получилось
[sql]CREATE FUNCTION responses_count( int ) RETURNS bigint
AS 'select count(*) as result FROM responses where objects_id = $1 and lang= false'
LANGUAGE 'sql';
[/sql]
 
Сверху