how to create function in PostgreSQL am using below code
create table sample(id int primary key)
create table sample2(id int primary key)
create view sampleall
As
select id from sample
union
select id from sample2
while creating below function for above tables
Create FUNCTION CheckFunction (ID INT)
RETURNS BIT AS
$$
BEGIN
IF EXISTS (SELECT 1 FROM sampleall WHERE id = @ID)
BEGIN
RETURN 1
END
RETURN 0
END
$$
LANGUAGE plpgsql;
CREATE TABLE sample3 (ID INT NOT NULL CONSTRAINT CHK_ID CHECK (dbo.CheckFunction(ID) = 1))
and getting below error
ERROR: syntax error at or near "BEGIN"
LINE 8: BEGIN
^
********** Error **********
ERROR: syntax error at or near "BEGIN"
SQL state: 42601
Character: 132
please help to solve the issue
THEN...