![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
Adaptive Server Anywhere Database Engine Version 9.0.2.3228 on WinXP strange effect when select list includes function and the table selected from includes computed column that matches the function. Really simple reproducible shown below. create table ttt ( pk int default autoincrement, val text, change datetime compute(current timestamp), primary key(pk) ) insert into ttt(val) values ('t1'); insert into ttt(val) values ('t2'); insert into ttt(val) values ('t3'); select * from ttt; select current timestamp, * from ttt; -- The bizarre bit is that the first column name reported and the values for that column seem to have picked up on the 'change' computed column and decided just to use that -- by contrast the following query does exactly what you would expect: select current utc timestamp, * from ttt; Any ideas? TIA John Davey |
#4
| |||
| |||
|
I vote "bug" ...Just to be *absolutely* clear about what you have discovered: select current timestamp, * from ttt; returns this: change,pk,val,change '2006-04-07 08:04:12.234',1,'t1','2006-04-07 08:04:12.234' '2006-04-07 08:04:12.250',2,'t2','2006-04-07 08:04:12.250' '2006-04-07 08:04:12.250',3,'t3','2006-04-07 08:04:12.250' It has displayed ttt.change instead of CURRENT TIMESTAMP in the first column. Breck -- Breck Carter [Team iAnywhere] RisingRoad SQL Anywhere and MobiLink Professional Services www.risingroad.com The book: http://www.risingroad.com/SQL_Anywhe...ers_Guide.html breck.carter (AT) risingroad (DOT) com |
#5
| |||
| |||
|
|
I suspect what you intended when you created the table would have been accomplished with: create table ttt( pk int default autoincrement, val text, change datetime default timestamp, primary key(pk) ) The value of "change" will be updated whenever a row in ttt is modified. Whitepapers, TechDocs, bug fixes are all available through the iAnywhere Developer Community at http://www.ianywhere.com/developer "John Davey" <john.davey (AT) automationpartnership (DOT) com> wrote in message news:44364620 (AT) forums-2-dub (DOT) .. Adaptive Server Anywhere Database Engine Version 9.0.2.3228 on WinXP strange effect when select list includes function and the table selected from includes computed column that matches the function. Really simple reproducible shown below. create table ttt ( pk int default autoincrement, val text, change datetime compute(current timestamp), primary key(pk) ) insert into ttt(val) values ('t1'); insert into ttt(val) values ('t2'); insert into ttt(val) values ('t3'); select * from ttt; select current timestamp, * from ttt; -- The bizarre bit is that the first column name reported and the values for that column seem to have picked up on the 'change' computed column and decided just to use that -- by contrast the following query does exactly what you would expect: select current utc timestamp, * from ttt; Any ideas? TIA John Davey |
#6
| |||
| |||
|
|
I suspect what you intended when you created the table would have been accomplished with: create table ttt( pk int default autoincrement, val text, change datetime default timestamp, primary key(pk) ) The value of "change" will be updated whenever a row in ttt is modified. |
#7
| |||
| |||
|
|
transform a predicate |
#8
| |||
| |||
|
|
I understand what you are saying. For other reasons (in the real case from which this minimal example is abstracted) we chose not to use default timestamp. I think the behaviour given this choice is a bit odd. I can't right now come up with another example of the same problem that isn't avoided by the default timestamp approach, but I'm fairly sure such a thing could be found. The reason we avoided default timestamp is to do with the whole 'unique timestamp' behaviour this has. We have restricted timestamps in our database to 3dp precision (ie only to the millisecond) - this using TRUNCATE_TIMESTAMP_VALUES and DEFAULT_TIMESTAMP_INCREMENT options. Having done this we find that columns defined with default timestamp as a way of capturing change time start to diverge from real time when we have a high rate of row change (the unique constraint means that if we have more than 1 row being changed per ms the timestamps applied start to run ahead of real time - quite confusing). If we could solve this another way I guess we could revert to using default timestamp. John Davey "Bruce Hay" <h_a_y~a_t~i_a_n_y_w_h_e_r_e~d_o_t~c_o_m> wrote in message news:44366684$1 (AT) forums-2-dub (DOT) .. I suspect what you intended when you created the table would have been accomplished with: create table ttt( pk int default autoincrement, val text, change datetime default timestamp, primary key(pk) ) The value of "change" will be updated whenever a row in ttt is modified. Whitepapers, TechDocs, bug fixes are all available through the iAnywhere Developer Community at http://www.ianywhere.com/developer "John Davey" <john.davey (AT) automationpartnership (DOT) com> wrote in message news:44364620 (AT) forums-2-dub (DOT) .. Adaptive Server Anywhere Database Engine Version 9.0.2.3228 on WinXP strange effect when select list includes function and the table selected from includes computed column that matches the function. Really simple reproducible shown below. create table ttt ( pk int default autoincrement, val text, change datetime compute(current timestamp), primary key(pk) ) insert into ttt(val) values ('t1'); insert into ttt(val) values ('t2'); insert into ttt(val) values ('t3'); select * from ttt; select current timestamp, * from ttt; -- The bizarre bit is that the first column name reported and the values for that column seem to have picked up on the 'change' computed column and decided just to use that -- by contrast the following query does exactly what you would expect: select current utc timestamp, * from ttt; Any ideas? TIA John Davey |
#9
| |||
| |||
|
|
The server uses the value of a computed column whenever it sees an expression matching the column's COMPUTE definition. That includes the SELECT list as well as in predicates. It would be a serious limitation to do otherwise. |
#10
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |