Subject | Re: [IBO] Re: Entering Litterals, Expressions directly into TIBOQuery Update SQL |
---|---|
Author | Lester Caine |
Post date | 2006-06-23T08:33:23Z |
Tony Masefield wrote:
will only be used by Firebird when Field2 is missing from the query. By
putting it in the query you also need to supply a value for it.
Helen will probably slap my hand ;) but I think that you are being
pushed to do things that are far more complex than is needed. I have YET
to use OnNewRecord! The blank new record is created by the defaults set
up in the database, GeneratorLinks creates the record for me and gives
me a key to the new record, and all of the rest happens automatically :)
--
Lester Caine - G8HFL
-----------------------------
L.S.Caine Electronic Services - http://home.lsces.co.uk
Model Engineers Digital Workshop -
http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/
Treasurer - Firebird Foundation Inc. - http://www.firebirdsql.org/index.php
> Hi Helen, Lester,BECAUSE Field2 is in your SQL it MUST have a valid value. The DEFAULT
>
> Sorry I'm not the one being *clear* mainly because SQL is still a
> *Foreign* language to me and the nomenclature doesn't always come easy!
> Consider:
>
> I have a detail table with a composite primary key, Field1, Field2.
> Field2 is a date field, Field1 is a foreign key based on a master
> table/field.
> TIBOUpdateSql Insert is something like:
> Insert into XYZ (Field1, Field2, ....)
> Values (:Field1, :Field2, ...)
> To add a new record I use:
> TIBOQuery OnNewRecord
> Query1Field1.Value := Query2.Field1;
> Query1Field2.Value := NOW;
> This way is what I initially picked up from the 'methodoligy' based on
> downloaded 'How-tos'. It works OK. However:
> If I use a domain, default NOW, for Field2 and leave the second
> assignment out, I get an error on post (Primary Key Violation) - which
> would suggest that the default NOW value is not being added to the date
> field - not sure why.
>
> Alternatively, if I modify the TIBOUpdateSQL to read:
> Insert into XYZ (Field1, Field2, ....)
> Values (:Query2.Field1, 'NOW', ...)
> There is no need for the OnNewRecord Event and everything works (so
> far!) as expected.
> The app is a data logging one so the transaction is set to autocommit.
> Any 'Caveats' on the second method (as I haven't *seen* it in
> documentation)?
> Hope this adds clarity! Please excuse any incorrect formatting (still
> confused with apostrophes use etc)
>
> Thanks for your help thus far.
will only be used by Firebird when Field2 is missing from the query. By
putting it in the query you also need to supply a value for it.
Helen will probably slap my hand ;) but I think that you are being
pushed to do things that are far more complex than is needed. I have YET
to use OnNewRecord! The blank new record is created by the defaults set
up in the database, GeneratorLinks creates the record for me and gives
me a key to the new record, and all of the rest happens automatically :)
--
Lester Caine - G8HFL
-----------------------------
L.S.Caine Electronic Services - http://home.lsces.co.uk
Model Engineers Digital Workshop -
http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/
Treasurer - Firebird Foundation Inc. - http://www.firebirdsql.org/index.php