[odb-users] Generate "Valite_to" from next "valid_from"

Boris Kolpackov boris at codesynthesis.com
Mon Dec 30 09:22:40 EST 2019


Javier Gutierrez <javier.gutierrez at web.de> writes:

> I have a table only with a valid_from column, I need to make a range out of
> it, so the valid_to for current row is the valid_from of the next row. I am
> talking about timestamps if it makes any difference.
> 
> E.g.
> 
> ID, ITEM_ID,   VALID_FROM      -> VALID_TO
> 
> 1,   1,         2019.01.01      -> 2019.02.15
> 
> 2,   1,         2019.02.15      -> 2019.03.07
> 
> 3,   1,         2019.03.07      -> 2100.01.01 
> 
> I need to generate this column on the fly because I am querying against it.

You need to generate the *column* (as in, "ALTER TABLE ... ADD COLUMN ...")
or the *value in the column*? I am guessing it's the latter but your
imprecise language makes it hard to understand what exactly you mean (what
does "I am qurying against it" has to do with anything then).


> Additionally I need this to work on any database.
> 
> Any ideas how to do this using ODB or if it is possible at all ?

If it's the column value that you need to generate, I don't see a
difficulty: load/query the previous row and copy its VALID_TO value to
the VALID_FROM of the new row?



More information about the odb-users mailing list