Question

Stored procedures in Firebird/Interbase

Asked by: Ghanisen

Hi,

I've been using MS Access for 2 years as the database in my VB.NET applications.

I've decided now to use Firebird or Interbase.

Can someone provide me with code to build and use, from within VB.NET, stored procedures for insert, update and delete records in these databases.

Best regards

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2006-05-17 at 12:38:28ID21854322
Tags

firebird

,

procedure

,

stored

,

interbase

Topic

Interbase / Firebird Database

Participating Experts
3
Points
500
Comments
9

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Is FireBird runned or not ?
    I would like to use a Delphi function that returns True if there is FireBird runned and False if it's not. Thanks !
  2. Firebird UDF - generates error
    I am trying to access an external function in Firebird, but get this error: invalid request BLR at offset 59 -function CALCEXPR is not defined -module name or entrypoint could not be found I am using rfunc.dll and it seems to be finding it.. though I cannot be sure. I am ...
  3. Charset Problem in Firebird
    Hi there I've got a big problem in my Firebird VB.net environment. I have a firebird databases witch i connect from VB.net over the Firebird .NET Provider 1.7.1 RC3. The FB Server is a 1.5.1 version server. There are tables with content äöüéàè ect. in the fields. If i read a...
  4. Embedded Firebird
    How do I embed firebird into vb.net? What connection string do I use?
  5. [VB.NET] Use a datagridview linked to a firebird db
    Hi, I use a datagridview linked to a dataset loaded by a table stored on a firebird db. The table contains a coluimn deifne as boolean but in the datagridview vb.net displays it as textbox and not as a checkbox column. I thik the datagridview considers the firebird boolean ...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: phuocnhPosted on 2006-05-17 at 22:44:44ID: 16706082

You can visit http://sourceforge.net/project/showfiles.php?group_id=9028 to download firebird-net-provider. In the VB.NET application you can access firebird/interbase database same as MS Access. If you want to learn how to write SQL to process data in database I think you should read the document.
Client tool to play with Firebird/InterBase database is IBConsole http://info.borland.com/devsupport/interbase/opensource/#ibconsole (Open Source Software).
or
IBExpert (It is very good but commercial work) http://www.ibexpert.com/
You can write store procedure for databse normally.

 

by: GhanisenPosted on 2006-05-18 at 01:37:46ID: 16706743

Thank you for this information but I already have done all that and also downloaded EMS SQL Manager 2005 that allows to d a lot.

But my question is how can I create stored procedures in a Firebird/Interbase database in code from within my VB.NET application.

Thank

 

by: NickUpsonPosted on 2006-05-18 at 02:03:14ID: 16706871

creating stored procedures in your vb code is unnecessary and not a good idea, use ibexpert

 

by: phuocnhPosted on 2006-05-18 at 02:13:55ID: 16706923

Create stored procedures is execution a SQL
Please read SQL reference  

 

by: kacorPosted on 2006-05-18 at 12:08:41ID: 16711919

Hi Ghanisen,

in InterBase you can create a stored procedure using the command CREATE PROCEDURE with the following syntax:

CREATE PROCEDURE ProcedureName InputParameterList
      RETURNS OutputParameterList
      AS
            DeclaringLocalVariabels
      BEGIN
            ProcedureBody
      END

ProcedureName conforms the InterBase naming convention and is unique within the database.


The easiest way to execute a procedure is: EXECUTE  PROCEDURE ProcedureName InputParameterList.

If you'd like to execute a procedure in an InterBase application (in other procedure or trigger) the syntax is:

EXECUTE  PROCEDURE  ProcedureName InputParameterList
     RETURNING_VALUES ParameterList

UPDATE example

In this example assume that a row was inserted or deleted. As input parameter gets the total of the invoice and the table Orders is modified with the new value of StockTotal.

SET TERM ^;
CREATE PROCEDURE SP_StockTotalModify    /*SP - Stored Procedure*/
      ( WhichOrder INTEGER, StockIncr DECIMAL(8,2) )
AS
BEGIN
      UPDATE Orders
            SET StockTotal = StockTotal + :StockIncr
            WHERE OrderID = :WhichOrder;
      EXIT;
END^
SET TERM ;^

In the query the variable WhichOrder is used in the WHERE condition and the variable StockIncr in the SET command. If the change increases the number is positiv, if decreases, negativ .
 
INSERT example

This example inserts a new row in the table InvoiceItems to an existing order. It calls the procedure SP_StockTotalModify above and transfers to the procedure the incrementation:

SET TERM ^;
CREATE PROCEDURE SP_NewInvoiceItemInsert
      ( WhichOrder INTEGER, WhichStockItem CHAR(10),
        UnitPrice DECIMAL(8,2), Quantity INTEGER )
AS
      DECLARE VARIABLE InterimTotal DECIMAL(8,2);
BEGIN
      /* stores the result of the interim calculation */
      InterimTotal = UnitPrice * Quantity;
      /* insert new row */
      INSERT INTO InvoiceItems
            VALUES( :WhichOrder, :WhichStockItem, :UnitPrice, :Quantity);
      /* calls an other procedure to modify the table containing the primary key */
      EXECUTE PROCEDURE SP_StockTotalModify
            :WhichOrder, :InterimTotal;
END^
SET TERM ;^

In this procedure the UnitPrice is multiplied by the Quantity, and the result will be stored in a variable. In the next step a new row is inserted in a normal way. At the end the value of the variable is transmitted to an embedded procedure to modify the sum value in the table Orders.

In this case you can see one advantage of the stored procedure: more operation is replaced by one called procedure.

I hope this will be sufficient but if you need more help write here.

wbr Janos

 

by: phuocnhPosted on 2006-05-18 at 16:34:11ID: 16714056

I think kacor gave you some details to manipulate in FB/IB databse. However, it is not enough for you to write an application using FB/IB database. I thinks you should visit here http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_download_documentation to download some document and read it over.
About SQL in FB/IB you can read http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_60_sqlref. You should remember that this document for IB version 6.0 or FB version 1.0x. Now IB version 7.5 and FB version 2.0 so they change very much. You should read change log document to get new features.
I hope you become an expert on IB/FB soon
Phuoc H. Nguyen

 

by: GhanisenPosted on 2006-05-19 at 02:11:55ID: 16716317

Hi Kacor and phuocnh,

Thanks to both of you and I really appreciate your efforts.

Before posting this question I had already roamed the internet and found many document including the ibphoenix ones.

If I'm asking how to create procedures from within VB.NET apps, that is for writing patches that may drop or add procedures to databases silently, i.e. without user intervention. Therefore IbExpert, EMS SQL 2005 etc. are not an option.

With Access databases, I do write or drop stored procedures in the database from within my VB.NET apps. I'd like to be abale to do the same, that is execute de CREATe procedure, from within my VB.NET apps.

Thanks.

 

by: phuocnhPosted on 2006-05-19 at 03:17:49ID: 16716599

I think the above hints make you understand how to solve your question. Play the IB/FB database same as Access database but different SQL (CREATE PROCEDURE statement,DROP PROCEDURE statement).
Now I show you clearer:
1. Install Visual Studio .NET 2005.
2. Install Firevird version 2.0
(http://prdownloads.sourceforge.net/firebird/Firebird-2.0.0.12654-0-Win32.exe?download)
3. Install Firebird-net-provider (http://prdownloads.sourceforge.net/firebird/FirebirdClient-2.0-RC4.exe?download)
4. Register Firebird items (FBCommand, FBCommandBuilder, FBConnection,FBDataAdapter,FBDataConnectionUIControl)
+Right click on ToolBox > Choose Items >"Choose Toolbox Items" windows appears >In ".NET Framework Components" tab, select all items starting with Firebird namespace > click on "OK" button.
+Now on Toolbox pane, you can see the above Firebird items appear.
5. Start a new VB.NET appication.
6. Drag and drop FBConnection  named FBConnection1 on the form, right click on it to change its properties and make connection to Firebird database.
7. Drag and drop FBCommand on form, right click on it to change its properties.
+CommandText property: You enter the CREATE PROCEDURE statement you want to create a store procedure.
+CommandType property: You select "StoredProcedure".
+Connection property: You select FBConnection1.
8. Now in the code you just call to execute the FbCommand1.
That's all
Phuoc H. Nguyen

 

by: NickUpsonPosted on 2006-05-19 at 05:51:31ID: 16717459

please note: firebird 2.0 is still beta, so you may run into problems, 1.5.3 is the most recent release

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...