CREATE FUNCTION Fails with an Insert Statement in it

From: "Jasbinder Singh Bali" <jsbali(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: CREATE FUNCTION Fails with an Insert Statement in it
Date: 2007-01-23 16:51:00
Message-ID: a47902760701230851w132a0ae3u21d4b38af7d297ca@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have created the following function :

CREATE OR REPLACE FUNCTION sp_insert_tbl_l_header(int4,text)
RETURNS bool AS
$BODY$
INSERT INTO tbl_xyz
(unmask_id,email_from)
VALUES ($1,$2)
$BODY$
LANGUAGE 'sql' VOLATILE;

when i try to create this fucntion by running this script, i get the
following error:

ERROR: return type mismatch in function declared to return boolean
DETAIL: Function's final statement must be a SELECT.
CONTEXT: SQL function "sp_insert_tbl_xyz"

So i think there is some problem with the return type of the function
when it has an insert statement but really don't know what should be
the return type of this function.

Thanks,
Jas

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2007-01-23 17:01:04 Re: CREATE FUNCTION Fails with an Insert Statement in it
Previous Message Michael Schmidt 2007-01-23 16:50:39 PostgreSQL 8.2 utilities with Java app on Windows XP