Subject RE: [firebird-support] stored procedure error.
Author Helen Borrie
At 11:29 AM 21/12/2005 -0800, you wrote:
>It was done in IBO Console not in a C++ Compiler of any kind. So pretty
>much I just hit Create Procedure, Added input Variable a, Added output
>variable b. Then in the body had that whole text which didn't work at all.

Here's a repost of my reply from yesterday:

It's not legal PSQL. You have to have a procedure header and declare
variables, either as procedure arguments or local variables. So, e.g.

create procedure duh (b integer)
returns (a integer)
as
begin
a = b;
/* and for this to make any sense */
suspend;
end

Another one:

create procedure duh1
returns (a integer)
as
declare variable b integer = 99;
begin
a = b;
suspend;
end

Have you read the LangRef.pdf at all?

More recently you wrote:

> begin
> b = a;
> return b;
> end
>
> > thats the entire procedure.
> > a is input variable.
> > b is output var.

Try this:

create procedure duh2
(a integer)
returns (b integer)
as
begin
b = a;
suspend;
end

> >
> > I guess I just cant figure out what I am doing wrong since this is
> > very basic, its almost hello world and yet it gives me an error. Is
> > there some syntax i am not writing? (if it helps i wrote this in ibo
> > console that came with firebird)

It helps insofar as IBOConsole (a fairly bare-bones 3rd-party DB Admin tool
that DOES NOT come with Firebird) had only a DSQL interface last time I
looked - no code generator. But, in case it does now have some kind of
code generator, it should have done something like the above with your
inputs. Who knows? since all you've shown so far is a procedure body
containing an illegal keyword ("return") and no sign of any declarations.

In SQL, objects are created (and altered and dropped) with DDL (data
definition language) statements. These begin with one of the words
CREATE/ALTER/DROP. In the case of a procedure, it's a complex statement
consisting of a header and a body. The header begins CREATE PROCEDURE and
is followed by the declarations of input and output arguments (if any) and
then declarations of local variables (if any). Providing the syntax is
correct, committing the statement "compiles" it - converts the SQL into a
RTI language called BLR and stores your source code.

There's a bit more to it, though. There's a chapter near the end of
LangRef.pdf that spells out the formalities. You'll find the Firebird
language enhancements in the release notes.

./heLen
(about to leave for Christmas hols)