Skip to content

gbase nvl判断时间语法错误 #1953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
zxr6367587 opened this issue Dec 20, 2024 · 11 comments
Closed

gbase nvl判断时间语法错误 #1953

zxr6367587 opened this issue Dec 20, 2024 · 11 comments

Comments

@zxr6367587
Copy link
Contributor

问题描述及重现代码:

UPDATE table SET startday = '2024-12-20 16:57:10.908', endday = (nvl(endday, '1970-01-01 00:00:00') + (days) units day)
WHERE id = 1

// c# code
fsql.Update<Model>()
                .Set(p => p.StartDay, DateTime.Now)
                .Set(p => p.EndDay.AddDays(p.Days))
                .Where(p => p.Id== Id);

数据库版本

gbase8s

安装的Nuget包

3.5.101

.net framework/. net core? 及具体版本

@zxr6367587
Copy link
Contributor Author

将'1970-01-01 00:00:00' 改为current可以执行

@2881099
Copy link
Collaborator

2881099 commented Dec 20, 2024

是什么问题,不生效,还是报错?

@zxr6367587
Copy link
Contributor Author

报语法错误
image

@2881099
Copy link
Collaborator

2881099 commented Dec 21, 2024

正确的语法应该是什么

@2881099
Copy link
Collaborator

2881099 commented Dec 21, 2024

用自定义表达式解析解决一下

@zxr6367587
Copy link
Contributor Author

我也不知道 ,感觉是字符串没有正确的转为datetime ,用current当前时间是可以执行这个语句的,自定义表达式是在哪里配置?

@2881099
Copy link
Collaborator

2881099 commented Dec 21, 2024

@zxr6367587
Copy link
Contributor Author

可以改为 datetime(1970-01-01 00:00:00) year to second 替换 '1970-01-01 00:00:00'

@zxr6367587
Copy link
Contributor Author

image

@2881099
Copy link
Collaborator

2881099 commented Dec 24, 2024

为了最大兼容功能,被迫在 IsNull override 方法中使用正则表达式处理,请看代码:e7e169a

@2881099
Copy link
Collaborator

2881099 commented Dec 24, 2024

valueStr 一般是使用 GBaseAdo.cs 转化后的 SQLString,不会为 null

2881099 added a commit that referenced this issue Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants