Link to home
Start Free TrialLog in
Avatar of Kingetje
Kingetje

asked on

How to execute Interbase SQL commands with Delphi code

Last week, I bought Delhi 3 Professional, which comes with a local InterBase database server, but sadly without any manuals concerning how to use Interbase databases from within Delphi.

Until now, I succesfully created some tables, one named documents, and one named objects.  The documents table was created using the folowing SQL statement :
 
 CREATE TABLE DOCUMENTS (
   DOC_ID INTEGER NOT NULL,
   DOC_TYPE CHAR(25),
   DOC_NBR_OBJ INTEGER NOT NULL,
   DOC_ROOT_OBJ INTEGER,
   DOC_INFO_OBJ INTEGER,
   DOC_CRE_DATE DATE DEFAULT "NOW" NOTNULL,
   DOC_MOD_DATE DATE
 )
 
I also created a generator, which gives a unice incremental number to each document record :
 
 CREATE GENERATOR DOC_ID_GEN;
 SET GENERATOR DOC_ID_GEN TO 14
 
 The trigger :
 
 CREATE TRIGGER SET_DOC_ID FOR DOCUMENTS BEFORE INSERT POSITION 0 AS
 BEGIN
      NEW.DOC_ID = Gen_ID (DOC_ID_GEN, 1);
 END
 
 Now I used an SQL command from withing the Database explorer to test if this trigger works correctly :

 INSERT INTO DOCUMENTS (DOC_TYPE, DOC_NBR_OBJ)
 VALUES ('Cre w SQL in DB Explorer', 3);
 
 Until here everything works correctly.  The record is added, and it is given a unique number which increments for each added record.
 
 Now comes my question : How can I code such commands into Delphi ? Is there some way I can execute SQL commands from withing the code of a Delphi program, which components should I use, and how do I code it.

If anybody can help me with this problem, I would really appreciate it.
 
 Any comments or help can be sent to :
 
 --
 
 Stefaan Lesage
 Fotek nv; Belgium
 Stefaan@fotek.com
ASKER CERTIFIED SOLUTION
Avatar of RBertora
RBertora
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial