Subject Re: why default value is failed?
Author Adam
Yang,

Using a simple example

CREATE TABLE test (
id bigint,
somedata integer default 5
);

COMMIT;

Now,

INSERT INTO TEST (ID, SOMEDATA) VALUES (1,1);

Would put a 1 in the somedata field (obviously)

INSERT INTO TEST (ID, SOMEDATA) VALUES (1,null);

Would put a NULL in the somedata field (less obvious)

INSERT INTO TEST (ID) VALUES (1);

Would put the default value of somedata (what you are expecting).

The ONLY time the default value is used is when you run an insert
statement and you do not list the field in the insert statement. It
is not a value that is substituted for NULL.

If you want to do it that way, you could of course use a before
insert trigger, but above is how Firebird implements default.

Adam


--- In firebird-support@yahoogroups.com, Yang Jin <ojinyang@y...>
wrote:
>
> First,thank your reply.
>
> Alan McDonald <alan@m...> дµÀ£º
> >>your application needs to omit the field >>from the insert
statement to make
> >>the default take effect.
>
> >>Your applicatoin is obviously setting the field >>value to NULL
which is also
> >>acceptable by your definition.
>
>
> Re:The truth is my app is suit for the old table struct that don't
add the Filed,So I think it is omit the Field.The old app can insert
record to the new table.
>
>
> >>If you set the field to NOT NULL, you would >>get an exception
when you tried
> >>to post your data.
>
> Re:Ok,I see.But The error happen when I update the record that
Field value is null.constriant's error happened.So I think the key is
I insert a record that Field omit,Why the server don't set the
default to Field?
>
>
> >>There is no bug here.
>
> Re:It happened after I update Firebird from 1.03 to 1.5.3.4854,so I
think it can been impacted by new server.It's just my personal judge.
>
>
> Alan
>
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://firebird.sourceforge.net and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>
>
>
>
> SPONSORED LINKS
> Technical support Computer technical support Compaq computer
technical support Compaq technical support Hewlett packard technical
support Microsoft technical support
>
> ---------------------------------
> YAHOO! GROUPS LINKS
>
>
> Visit your group "firebird-support" on the web.
>
> To unsubscribe from this group, send an email to:
> firebird-support-unsubscribe@yahoogroups.com
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.
>
>
> ---------------------------------
>
>
>
>
>
> ---------------------------------
> ÑÅ»¢Ãâ·ÑGÓÊÏ䣭No.1µÄ·À¶¾·ÀÀ¬»ø³¬´óÓÊÏä
> ÑÅ»¢ÖúÊÖ¡§DËÑË÷¡¢É±¶¾¡¢·ÀɧÈÅ
>
> [Non-text portions of this message have been removed]
>