Subject Re: [IBO] Entering Litterals, Expressions directly into TIBOQuery Update SQL
Author Helen Borrie
At 04:07 PM 23/06/2006, you wrote:
>Hi All,
>
>I *discovered* that I can enter litterals, such as dates (NOW - for
>current timestamp) or expressions (such as the primary key of the
>master table in a detail table query) in a TIBOQuery UPdateSQL Insert
>rather than using a domain with NOW default, or using *OnUpdateRecord*
>respectively.
>I'm relatively new to SQL and CS so just wondering if there are any
>problems I didn't anticipate doing it this way (which may manifest
>themselves further down the line) rather than the *traditional* way (as
>per the example documents I have) of using domain defaults and
>OnUpdateRecord?

Forgive me if I'm not totally clear what you're asking here...

You can - and MUST - use a valid SQL statement for an UpdateSQL. The
word 'now' happens to be a valid date literal in IB/FB SQL. As a
date literal, it must be enclosed in single quotes. There are a
number date literals available besides 'now', for example, 'today',
'yesterday', 'tomorrow' and all of the date literal formats that are
recognised by the engine, e.g. single-quoted strings in the formats
MM/DD/CCYY, DD.MM.CCYY, DD-MMM-CCYY and a number of others.

Also available are context variables, which are symbolic constants
and do not take quotes. For example, CURRENT_DATE,
CURRENT_TIMESTAMP, CURRENT_TIME, et al.

It's not a requirement to have a domain in order to enforce a default
on inserts. You can define any DATE, TIME or TIMESTAMP column in a
table with its own default, which can be CURRENT_DATE, etc., or CAST
('some_date_literal' AS DATE). Domains are an elegant way to take a
unified approach to it, though.

Helen