Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 10 total
Thread Alter Column issue
Wed, Mar 31 2010 4:21 AMPermanent Link

Hershcu Sorin

Hello

On my old app. I use to set the date value of a date field on run time.
Now I want to modify the app. and update the field with the edb.
I alter the column to generated with current_date expresion but it's modify
all the previous date field values.
Can I alter this column and keep the old value?

Thanks Sorin

Wed, Mar 31 2010 9:12 AMPermanent Link

Uli Becker

Sorin,

> Can I alter this column and keep the old value?

Unless I misunderstand you: just alter the column, check "Generated", in
the tab Generation check "Generate As Expression" and write
"CURRENT_DATE". Then you should be done. Existing date values in the
column are not concerned.

Uli
Wed, Mar 31 2010 10:03 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Uli

>Unless I misunderstand you: just alter the column, check "Generated", in
>the tab Generation check "Generate As Expression" and write
>"CURRENT_DATE". Then you should be done. Existing date values in the
>column are not concerned.

That's what I thought, but I tested in EDBManager (b9) so I could post the syntax and 1) it alters all rows to CURRENT_DATE and 2) you can't edit them. There seems to be no way to select BY DEFAULT as you can with an "autoinc"

Roy Lambert [Team Elevate]
Wed, Mar 31 2010 10:42 AMPermanent Link

Hershcu Sorin

"Roy Lambert" <roy.lambert@skynet.co.uk> wrote in message >
> That's what I thought, but I tested in EDBManager (b9) so I could post the
> syntax and 1) it alters all rows to CURRENT_DATE and 2) you can't edit
> them. There >seems to be no way to select BY DEFAULT as you can with an
> "autoinc"

Yes that's my problem.
Any work around?

Thanks Sorin

Wed, Mar 31 2010 12:30 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Sorin


It depends on what you want to do. I guess from what you've posted so far you want to update the date field each time something is done to the record. If that's right then set as a standard datefield and use a before post trigger to update it. If I'm wrong can you explain what you're trying to achieve please.

Roy Lambert [Team Elevate]
Wed, Mar 31 2010 12:46 PMPermanent Link

Hershcu Sorin

"Roy Lambert" <roy.lambert@skynet.co.uk> wrote in message >
> It depends on what you want to do. I guess from what you've posted so far
> you want to update the date field each time something is done to the
> record. If that's right then set as a standard datefield and use a before
> post trigger to update it. If I'm wrong can you explain what you're trying
> to achieve please.

Thanks Roy

All I want is to alter the column of an old table.
I want to alter the column to generated expresion as current_date
but save the old field value of the column.

Thanks
Sorin

Wed, Mar 31 2010 1:37 PMPermanent Link

Uli Becker

Roy,

> That's what I thought, but I tested in EDBManager (b9) so I could post the syntax and
1) it alters all rows to CURRENT_DATE

I tested it as well and existing date values where not changed here (B8)

and 2) you can't edit them.

True. Frown

Uli
Wed, Mar 31 2010 1:43 PMPermanent Link

Hershcu Sorin


"Uli Becker" <johnmuller54@googlemail.com> wrote in message

>> That's what I thought, but I tested in EDBManager (b9) so I could post
>> the syntax and
> 1) it alters all rows to CURRENT_DATE
>
> I tested it as well and existing date values where not changed here (B8)
>
> and 2) you can't edit them.

Thanks Uli

Well here on ver(b9) it change all.
What do you mean on edit them?

Thanks
Sorin

Wed, Mar 31 2010 1:51 PMPermanent Link

Uli Becker

Sorin,

> All I want is to alter the column of an old table.
> I want to alter the column to generated expresion as current_date
> but save the old field value of the column.

As Roy indicated: If you want to generate the current date with each new
record, you can use a trigger "Before Insert":

TRIGGER "AddDate"
BEGIN
  Set NEWROW.MyDate = CURRENT_DATE;
END

If you want a change with each update of the record, you can modify the
trigger and use "Before Update":

Uli
Wed, Mar 31 2010 2:00 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Sorin,

<< On my old app. I use to set the date value of a date field on run time.
Now I want to modify the app. and update the field with the edb. I alter the
column to generated with current_date expresion but it's modify all the
previous date field values. Can I alter this column and keep the old value?
>>

Well, we've got an issue of "some want it this way, others want it another
way":

http://www.elevatesoft.com/incident?action=viewrep&category=edb&release=2.03&incident=3148

I'm inclined to lean in favor of the incident report fix, mainly because the
expression is "ALWAYS AS", not "BY DEFAULT AS".

What I can look into doing is adding the "BY DEFAULT AS" as an option in an
upcoming release, but for now the behavior is that it will always be updated
with the expression value.

The only workaround that I can think of is to keep both the new generated
column and the old column, and have the generated column expression be:

COALESCE(OriginalColumn,CURRENT_DATE())

--
Tim Young
Elevate Software
www.elevatesoft.com

Image