Can you convert data types in stored procedures?
Posted in 2003
Topics: Stored Procedures & SPL, Data Types & Schema Design, Triggers, Constraints & Referential Integrity
Hello All, I'm tracking changes to several tables in one log table. I want to keep the log table as concise as possible. It appears that the trigger is converting the values (decimal, date, integer, ...) to char for me when I insert them into the log table, but is this a safe assumption. If it isn't a 'feature'. Is there a way to convert from say decimal to char in a stored procedure. This way I can track before and after values with two character fields. I want to be forward compatible. Currently using Informix 7.3 Thanks,
"M.D. Larsen" <NospaM@Spammers_suck.com> wrote in message news:WxJBa.4113$ws4.1383523448@twister2.starband.net... > Hello All, > > I'm tracking changes to several tables in one log table. I want to keep > the log table as concise as possible. It appears that the trigger is > converting the values (decimal, date, integer, ...) to char for me when > I insert them into the log table, but is this a safe assumption. > > If it isn't a 'feature'. Is there a way to convert from say decimal to > char in a stored procedure. This way I can track before and after > values with two character fields. I want to be forward compatible. > assuming you declare two variables, one char and one decimal. let char_field = decimal_field ; will automatically convert the decimal field to char field. Just make sure that the char field is big enuf to hold the value.
Thanks, especially since that's what I wanted to hear/read. rkusenet wrote: > "M.D. Larsen" <NospaM@Spammers_suck.com> wrote in message > news:WxJBa.4113$ws4.1383523448@twister2.starband.net... > >>Hello All, >> >>I'm tracking changes to several tables in one log table. I want to keep >>the log table as concise as possible. It appears that the trigger is >>converting the values (decimal, date, integer, ...) to char for me when >>I insert them into the log table, but is this a safe assumption. >> >>If it isn't a 'feature'. Is there a way to convert from say decimal to >>char in a stored procedure. This way I can track before and after >>values with two character fields. I want to be forward compatible. >> > > > assuming you declare two variables, one char and one decimal. > > let char_field = decimal_field ; > > will automatically convert the decimal field to char field. Just make > sure that the char field is big enuf to hold the value. > >