How to execute Interbase SQL commands with Delphi code
Posted on 1997-05-20
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_NBR_OBJ INTEGER NOT NULL,
DOC_CRE_DATE DATE DEFAULT "NOW" NOTNULL,
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
NEW.DOC_ID = Gen_ID (DOC_ID_GEN, 1);
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 :
Fotek nv; Belgium