在执行更新SQL语句之后,SmallInt在sybase中保持无效

发布于 2025-01-28 18:26:30 字数 550 浏览 3 评论 0原文

DB是sybase。我执行了更新SQL语句喜欢

UPDATE table_name SET smallint_col = 0, 
datetime_col = CONVERT(datetime, '1999-09-09') WHERE some_col = 'sth';

将null SmallInt属性设置为非null值。

我通过JDBC在更新语句之后与Select语句一起检查了更新结果。

属性保持为空。只有DateTime属性已更新为预期值。

另外,这是我尝试过的:

  1. 将目标值设置为大于0的非null值。仍然与上述结果相同。
  2. 在中添加和SmallInt_Col为null 子句。这次,两个属性的更新都失败了。

我的更新SQL语句有什么问题吗?

这可能是什么原因?

是否有可能将表格的某个属性更新受到限制?

顺便说一句,我只能与JDBC访问DB,我正在尝试避免与DBA交谈。

The DB was Sybase. I executed update SQL statement like

UPDATE table_name SET smallint_col = 0, 
datetime_col = CONVERT(datetime, '1999-09-09') WHERE some_col = 'sth';

to set a null smallint attribute into a nonnull value.

I checked the update result with select statement right after the update statement via JDBC.

The attribute stayed null. Only the datetime attribute have been updated to intended value.

Also, here are what I have tried:

  1. Set the target value to a nonnull value larger than 0. Still same result as above.
  2. Added and smallint_col IS NULL in the WHERE clause. This time the update of both attributes failed.

Is there anything wrong with my update SQL statement?

What could be a possible reason for this?

Is there any possibility that the update of a certain attribute of a table is restricted?

Btw, I can only access to the DB with JDBC and I am trying to avoid talking to the DBA.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

彩扇题诗 2025-02-04 18:26:30

我只是在Sybase ASE数据库下的整个SQL语句下方检查了下面,更新操作没有问题。
如果您使用的是JDBC调用,则可以获取更新SQL执行的返回计数。检查受影响的计数。

create table table_name (id int not null, smallint_col smallint null, 

datetime_col datetime, some_col varchar(32) null)
go

insert into table_name values(1, null, '2020-05-05', 'sth')
go

select * from table_name
go

UPDATE table_name SET smallint_col = 0, 
datetime_col = CONVERT(datetime, '1999-09-09') WHERE some_col = 'sth'
go

select * from table_name
go

请仔细检查您的表定义。它与上面相同吗?

I just checked below whole SQL statements under Sybase ASE database, there is no problem on the update operation.
If you are using JDBC call, you can get the return count of the update SQL execution. to check the affected count.

create table table_name (id int not null, smallint_col smallint null, 

datetime_col datetime, some_col varchar(32) null)
go

insert into table_name values(1, null, '2020-05-05', 'sth')
go

select * from table_name
go

UPDATE table_name SET smallint_col = 0, 
datetime_col = CONVERT(datetime, '1999-09-09') WHERE some_col = 'sth'
go

select * from table_name
go

Please double check your table definition. Is it the same as the above?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文