Type Conversion in Informix 4GL

杀马特。学长 韩版系。学妹 提交于 2019-12-12 18:26:59

问题


I want to convert a variable of type VARCHAR to INTEGER and vice versa (i.e. from INTEGER type to VARCHAR) in Informix 4GL.


回答1:


DEFINE v VARCHAR(20)
DEFINE i INTEGER

LET v = "12345"
LET i = v
DISPLAY "i = ", i, "; v = ", v

LET i = 123456
LET v = i
DISPLAY "i = ", i, "; v = ", v

Easy, huh?

You run into problems if the string can't be converted to a number (run time errors, etc).

In essence, I4GL will automatically convert between types if it is possible, only generating an error if it is impossible. Some conversions are impossible. For example, I don't think you'd be able to convert a DECIMAL or INTEGER into an INTERVAL YEAR TO MONTH.



来源:https://stackoverflow.com/questions/10012874/type-conversion-in-informix-4gl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!