如何在Sybase上投射或转换为VARCHAR数据类型?
DECLARE
@k numeric,
@acc numeric
SET
@k = 651393561522 ,
@acc = 1231234560
WHILE (@k < 651393563552)
BEGIN
SET @k = @k + 1 ,
@acc = @acc + 1
insert into recipients (id, client_id, inn, name, bic, bill, version)
VALUES(@k, 1, @acc, 'clientid'+ cast(@k as varchar), 300335, 'bill'+cast(@acc as varchar), 1)
END
有这样的错误:
[42000] [257]不允许从数据类型'数字'到“ varchar”&gt;的隐式转换。使用转换函数运行此查询。
[42000] [257]不允许从datatype'int'到'varchar'的隐式转换。使用转换函数运行此查询。
DECLARE
@k numeric,
@acc numeric
SET
@k = 651393561522 ,
@acc = 1231234560
WHILE (@k < 651393563552)
BEGIN
SET @k = @k + 1 ,
@acc = @acc + 1
insert into recipients (id, client_id, inn, name, bic, bill, version)
VALUES(@k, 1, @acc, 'clientid'+ cast(@k as varchar), 300335, 'bill'+cast(@acc as varchar), 1)
END
Have such errors:
[42000][257] Implicit conversion from datatype 'NUMERIC' to 'VARCHAR' >is not allowed. Use the CONVERT function to run this query.
[42000][257] Implicit conversion from datatype 'INT' to 'VARCHAR' is >not allowed. Use the CONVERT function to run this query.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
错误消息提及 隐式 转换错误,因此这往往排除 显式 。代码> cast()调用。
这给我们留下了其他列/值的数据类型不匹配问题。 OP将需要对
收件人
列的数据表进行二次检查:第一个错误消息提及
数字到varchar
,并且由于唯一的数字值是@k < /code>和
/p>@acc
,我猜想ID
或inn
列定义为varchar
第二个错误消息提及
varchar
的整数,以及sybase(ASE) )对待1
和300335
作为整数,我猜是client_id
,bill
或列定义为
varchar
The error messages mention implicit conversion errors so this would tend to rule out the explicit conversions being performed by the
cast()
calls.This leaves us with datatype mismatch issues for the other columns/values; OP will want to doublecheck the datatypes of the
recipients
columns:the 1st error message mentions
numeric to varchar
and since the only numeric values are@k
and@acc
, I'm guessing either theid
orinn
column is defined asvarchar
the 2nd error message mentions
integer to varchar
and since Sybase (ASE) treats1
and300335
as integers, I'm guessing either theclient_id
,bill
orversion
column is defined asvarchar