Subject | Re: Entering Litterals, Expressions directly into TIBOQuery Update SQL |
---|---|
Author | Tony Masefield |
Post date | 2006-06-23T07:41:03Z |
Hi Helen, Lester,
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.
Regards,
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.
Regards,