I am using Sybase DB and using dblib interface( C++ Interface) to connect and pass commands to Sybase DB. I have one stored procedure added to Sybase DB. Below is the signature of stored procedure:
create procedure process_write @id varchar(35), @pTime datetime,@status tinyint
and I am calling this stored procedure with below :
process_write '000000100', '22/9/2022 10:18:37', 1
Now when I run my code I do not see error on console and the stored procedure executes successfully, But when I run this in isql command prompt, I get below error:
Msg 247, Level 16, State 1: Server 'ABCXYZ', Procedure 'process_write': Arithmetic overflow during implicit conversion of VARCHAR value '22/9/2022 10:18:37' to a DATETIME field . (return status = -6)
I am not able to figure out how this is working in code but failing in isql console?
tl;dr
ASEdefaults to processing strings of the formatX/Y/ZasM/D/Yand this likely explains why yourisqlsession is generating an error (ie, yourisqlsession is running withmdyas its defaultdateformat). My guess is that somewhere in yourdblib/C++code you've either modified thedateformator thelanguageused by thedblib/C++session which in turn insures your proc call works (ie, no conversion errors are generated).I don't work with
dblib/C++so I don't know if you need to modify a db connection attribute or if you just issue aT-SQLcommand upon successful connection, eg:In Sybase
ASEwhen processing strings as dates it's necessary to tellASEthe ordering of the date components in strings likeX/Y/Z.From a strictly
T-SQLpoint of view there are twosetoptions that can tellASEhow to interpretX/Y/Zas a date:set dateformat <format>- where<format>is one of'mdy','myd','ymd','ydm','dmy'and'dym'; default is'mdy'set languange <language>- where<language>is going to be based on what languages you've loaded intoASE; default is'us_english'which causes the dateformat to default to'mdy'[I don't have details on if/how individual languages may modify thedateformatso you would need to run some tests in your environment]NOTES:
dateformatin use for your session:select get_appcontext('SYS_SESSION','dateformat')Demonstrating the use of
set dateformatwith a stored proc: