Subject My First Procedure
Author inoffensive_2009
Hi Folks:

Developing on XP Home, VS2008 Pro, C++, Firebird 2.1.1.17910-0
SuperServer, ibpp-2-5-3-1.

I'm actually more interested in a trigger, but I'm working through
Helen's great book and getting my first procedure going will be a big
step.

The application uses DSQL for all accesses to the database.

Question 1:

My application has a function called alter_database_if_needed().
This function allows changes in the spec to be applied to the existing
database. Users have asked that information be included that has
resulted in columns being added to tables and tables being added to
the database.

Before adding a table, of course, a test must be performed to see
if the table needs to be added.

The business end of my table_exists() function looks like this, if
testing for a table called "TABLE_NAME",

SELECT
1
FROM
RDB$RELATIONS
WHERE
RDB$RELATION_NAME = 'TABLE_NAME'

This text would be passed to IBPP's st->Execute();

I believe I'll need to alter my existing database to insert a
procedure or trigger. But I only want to do it once for any
particular procedure or trigger. How do I test for the existance of
the procedure or trigger name? Passing the name to table exists
returned false, even though I'd just successfully run CREATE PROCEDURE
for Helen's sample procedure IS_PORK_SAFE? And I received the error
"Procedure IS_PORK_SAFE already exists".

Question 2.

When I include "SET TERM ^;" as the first line of the DSQL passed
to st->Execute(), I get an error. Deleting this statement, and using
";" to terminate the procedure's final END;, results in the CREATE
FUNCTION being executed without error.

Because DSQL does not recognize terminators for statements (P574 PP
6), can I safely dispense with SET TERM statements?

It's 3:00 in the morning here on the US West coast, I'm calling it
a day, and will attempt to run this procedure when I wake up. I'm
sure I'll have many more questions.

Thanks
Larry