Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

Commonmark migration
Source Link

I try to create function

CREATE OR REPLACE FUNCTION public.my_sql_function3(IN inputval integer)
 RETURNS TABLE("ID" integer, name character varying, cnt integer) AS
$BODY$
 select t.id, t.name, CAST(count(*) AS INTEGER)
 from test t
 where t.id < inputval
 group by t.id, t.name $BODY$
 LANGUAGE plpgsql VOLATILE;

and get error:

ERROR: syntax error at or near "select"

LINE 4: select t.id, t.name, CAST(count(*) AS INTEGER)

How to fix it?

I try to create function

CREATE OR REPLACE FUNCTION public.my_sql_function3(IN inputval integer)
 RETURNS TABLE("ID" integer, name character varying, cnt integer) AS
$BODY$
 select t.id, t.name, CAST(count(*) AS INTEGER)
 from test t
 where t.id < inputval
 group by t.id, t.name $BODY$
 LANGUAGE plpgsql VOLATILE;

and get error:

ERROR: syntax error at or near "select"

LINE 4: select t.id, t.name, CAST(count(*) AS INTEGER)

How to fix it?

I try to create function

CREATE OR REPLACE FUNCTION public.my_sql_function3(IN inputval integer)
 RETURNS TABLE("ID" integer, name character varying, cnt integer) AS
$BODY$
 select t.id, t.name, CAST(count(*) AS INTEGER)
 from test t
 where t.id < inputval
 group by t.id, t.name $BODY$
 LANGUAGE plpgsql VOLATILE;

and get error:

ERROR: syntax error at or near "select"

LINE 4: select t.id, t.name, CAST(count(*) AS INTEGER)

How to fix it?

Source Link
user7267200
user7267200

Error at create function

I try to create function

CREATE OR REPLACE FUNCTION public.my_sql_function3(IN inputval integer)
 RETURNS TABLE("ID" integer, name character varying, cnt integer) AS
$BODY$
 select t.id, t.name, CAST(count(*) AS INTEGER)
 from test t
 where t.id < inputval
 group by t.id, t.name $BODY$
 LANGUAGE plpgsql VOLATILE;

and get error:

ERROR: syntax error at or near "select"

LINE 4: select t.id, t.name, CAST(count(*) AS INTEGER)

How to fix it?

lang-sql

AltStyle によって変換されたページ (->オリジナル) /