Re: Problem creating stored procedure

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Ted Byers <r(dot)ted(dot)byers(at)rogers(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Problem creating stored procedure
Date: 2005-12-27 18:04:38
Message-ID: 20051227180438.GA70453@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Dec 27, 2005 at 12:41:44PM -0500, Ted Byers wrote:
> I am puzzled. Can ayone explain why I get an error from Postgres
> on this simple stored procedure?

There are several mistakes in the code you posted:

* PostgreSQL doesn't have a CREATE PROCEDURE command. Use CREATE
FUNCTION.

* You didn't declare a return type or any OUT or INOUT parameters.

* You didn't quote the function body.

* Several statements are missing terminating semicolons.

* You wrote "SELECT int" instead of "SELECT INTO".

* You wrote "INSERT INTO addys(...)" instead of providing a column
list. If this is the actual code then it's a syntax error, and
if it's not the actual code then we need to see what you're
really doing.

* You wrote plpgsql code but declared the function to be sql.

> Judging from the examples in the manual (around page 600), my
> procedure ought to be fine, but clearly Postgres doesn't like it.

What section of the manual are you looking at, and for what version
of PostgreSQL (many of us use the online documentation so page
numbers don't mean anything)? Are you mixing Oracle syntax with
PL/pgSQL syntax?

--
Michael Fuhr

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Rysdam 2005-12-27 18:58:46 EXPLAIN ANALYZE output
Previous Message Jaime Casanova 2005-12-27 17:53:32 Re: Problem creating stored procedure