Subject Re: [IBO] New user - IB_Query help
Author emgfyah2002
Dear Helen

I have done all your instructions, and I made some progress. But I
found 2 problems:
1 - if I do not define the insert SQL string, and try to use the
instructions above
> >
> > Ib_transaction1.StartTransaction;
> > ib_query1.insert;
> > ib_query1.fieldbyname('.....MyField1').value := '1111111'; {PK}
> > ib_query1.fieldbyname('.....MyTime').value := Now;
> > ib_query1.fieldbyname('.....MyValue').Value := 'Test value';
> > ib_query1.Post;
> > ib_Transaction1.CommitRetaining;
> >
I get an error. Using your sugestion of put a IB-Monitor, it shows
the following output:

/*---
START TRANSACTION
DB HANDLE COUNT 1
TR_HANDLE = 14607176
----*/
/*---
EXECUTE STATEMENT
TR_HANDLE = 14607176
STMT_HANDLE = 14606848
PARAMS = [ ]
----*/
/*---
PREPARE STATEMENT
TR_HANDLE = 14607176
STMT_HANDLE = 14600960

INSERT INTO TABGRUPOESTOQUE
( TABGRUPOESTOQUE.GRUPO
, TABGRUPOESTOQUE.DESCRICAO
, TABGRUPOESTOQUE.DESCCURTA)
VALUES
( ? /* TABGRUPOESTOQUE.GRUPO */
, ? /* TABGRUPOESTOQUE.DESCRICAO */
, ? /* TABGRUPOESTOQUE.DESCCURTA */ )

FIELDS = [ Version 1 SQLd 2 SQLn 31
RDB$RELATION_FIELDS.RDB$FIELD_NAME = <NIL>
RDB$RELATION_FIELDS.RDB$RELATION_NAME = <NIL> ]

SECONDS = 0,010

ERRCODE = 335544569
----*/
/*---
PREPARE STATEMENT
TR_HANDLE = 14607176
STMT_HANDLE = 14600960

INSERT INTO TABGRUPOESTOQUE
( TABGRUPOESTOQUE.GRUPO
, TABGRUPOESTOQUE.DESCRICAO
, TABGRUPOESTOQUE.DESCCURTA)
VALUES
( ? /* PRM_0 */
, ? /* PRM_1 */
, ? /* PRM_2 */ )

FIELDS = [ Version 1 SQLd 2 SQLn 31
RDB$RELATION_FIELDS.RDB$FIELD_NAME = <NIL>
RDB$RELATION_FIELDS.RDB$RELATION_NAME = <NIL> ]

ERRCODE = 335544569
----*/
/*---
INTERPRETE BUFFER =

ERRCODE = 17
----*/
/*---
INTERPRETE BUFFER = Dynamic SQL Error

ERRCODE = 21
----*/
/*---
INTERPRETE BUFFER = SQL error code = -104

ERRCODE = 31
----*/
/*---
INTERPRETE BUFFER = Token unknown - line 2, char 18

ERRCODE = 1
----*/
/*---
INTERPRETE BUFFER = .

ERRCODE = -1
----*/

and an error ( ...token unknown ... refering to the point between the
table name and the field name). I had an impression of had read
something about that, related with the final release of Firebird 1,
but, where I can not remeber.
But if I generate the SQL strings double-cliking the query and using
the IBO utility, everithing works fine (?). Am I doing something
wrong, since you had said that I would not need the strings to work
directly with the fields? There are some inconvenient of doind that ?

2 - Second problem: I have several tables in which the primary key
is a smallint generated by a "before insert" triger with a generator
(to have an autoincrement unique field). I did not found a way of
inserting records in these tables, by code or using the insert
button. Using external tools ( ibconsole, ibexpert ) it works fine.
A tipical trigger that I use is like this, in which "COR" is the PK
of the table:
AS
BEGIN
IF (NEW.COR IS NULL) THEN
NEW.COR = GEN_ID(GEN_TABCOR_ID,1);
END

Is it possible to use this with IBO ? How ? If I set the field to
null in the insert operation I get an error. If I omited the field:
error. If I put a valid value it works, but the trigger becomes
without use.
Thank you very very much for you patient with my questions and
congratulations for your extraordinary hability of understand
my "english".
my best regards
Edison