Главная страница | назад





Article #25669: Can I create stored procedures via Delphi or C++ Builder?

Problem:
Can I create InterBase stored procedures in my InterBase database using Delphi or C++ Builder?
Solution:
*******************************************************
This document refers to:
* InterBase versions 4.X and above.
*******************************************************
Yes, you can create stored procedures via Delphi. You can use the TQuery component to pass the
SQL statements needed to create the stored procedure on the InterBase server. One caveat you
will want to be aware of is that you need to have two colons in front of memory variables instead of
one when you call the stored procedure.
Listed below are steps to create an example of defining stored Procedures via Delphi or C++ Builder:
1. Select File | New Application from the menu.
--This will bring up a new application with a blank form.
2. Click on the button icon on the standard tab of the component
palette.
3. Click on the "Data Access" tab.
4. Click on the Query icon.
5. Hit  to bring up the Object Inspector.
6. Set the DatabaseName property to your InterBase alias.
7. Click on the three dots in the space next to the "SQL" property.
8. You can now enter the text of your stored procedure.
9. Type in the text of the stored procedure definition code:
create procedure myproc returns (a integer)
as
begin
a=5;
end
10. After you have entered the code for your stored procedure,
click on the  button.
11. Next, you will need to tell Delphi to run your stored
procedure code. To that, do the steps listed below:
a. Click on the button.
b. Hit  to bring up the Object Inspector.
c. Click on the Events tab.
d. DoubleClick on the space next to "OnClick"
e. Enter in the following code after the line
with the word 'begin' on it:
query1.execSQL;
12. Push  to run the program.

Last Modified: 23-OCT-00