Subject | Re: Anyone help me with a Delphi 7 & Firebird question? |
---|---|
Author | Adam |
Post date | 2005-09-02T04:15:15Z |
--- In firebird-support@yahoogroups.com, "Myles Wakeham" <myles@t...>
wrote:
component.
There are two ways to do it
You CAN use the execute procedure syntax if it is returning ONLY a
single record using RETURNING_VALUES.
If you have a suspend call inside the stored procedure, then you can
run a query with the select from method.
SELECT OutputParam1, OutputParam2
from SP_Name(InputParam1, InputParam2)
But if you don't have suspend, it wont return anything.
When you are returning a single record, you should probably use the
execute procedure method, however I do not see any problem with using
the select method (invitation to point one out).
The structure of the procedure will be something like this
CREATE PROCEDURE SP_NAME
(
InputParam1 integer,
InputParam2 varchar(100)
)
returns
(
ID integer
)
AS
BEGIN
ID = GEN_ID(GEN_NAME,1);
INSERT INTO TABLEA (ID, AMOUNT, DESCR) VALUES
(:ID, :INPUTPARAM1, :INPUTPARAM2);
SUSPEND; -- only if you are calling it using a select, if you are
using execute procedure skip this line.
END
^
Hope that helps
Adam
wrote:
> I have what I think is a pretty simple question about how to call aFirebird
> Stored Procedure and get back a result in Delphi. I wish to add arecord to
> a Firebird 1.5 database from a D7 application. I am using FIBPlusto
> connect to the database.for the
>
> I have a form that has a number of non-data aware component objects
> field data entry, and the user simply fills out the form and clickson a
> SAVE button to save it to the database.ID of the
>
> The stored procedure that is called returns back the unique record
> newly created record after it creates the record through agenerator.
>to setup
> What I'm not sure how to do is to structure the procedure that has
> the SQL and get the single result back from it. I believe I cannotuse the
> syntax EXECUTE PROCEDURE for this because it will only return backthe no of
> rows affected. I believe I have to use a SELECT * FROM SP_NAME(arg1, arg2)
> type syntax, but I'm not sure how to structure the D7 code to setupthe
> transaction parameters for a write to the database, structure theSQL
> statement, have it executed and handle a single result value comingback.
>I am not sure how FIBPlus works, there may well be a stored procedure
component.
There are two ways to do it
You CAN use the execute procedure syntax if it is returning ONLY a
single record using RETURNING_VALUES.
If you have a suspend call inside the stored procedure, then you can
run a query with the select from method.
SELECT OutputParam1, OutputParam2
from SP_Name(InputParam1, InputParam2)
But if you don't have suspend, it wont return anything.
When you are returning a single record, you should probably use the
execute procedure method, however I do not see any problem with using
the select method (invitation to point one out).
The structure of the procedure will be something like this
CREATE PROCEDURE SP_NAME
(
InputParam1 integer,
InputParam2 varchar(100)
)
returns
(
ID integer
)
AS
BEGIN
ID = GEN_ID(GEN_NAME,1);
INSERT INTO TABLEA (ID, AMOUNT, DESCR) VALUES
(:ID, :INPUTPARAM1, :INPUTPARAM2);
SUSPEND; -- only if you are calling it using a select, if you are
using execute procedure skip this line.
END
^
Hope that helps
Adam