Concatenation (Building a string)
Posted in 1999
Topics: Stored Procedures & SPL
I'm trying to build a string inside a stored procedure in a FOR EACH loop. Can someone explain the behavior of the following: strDetail = strDiary This works strDetail = strDetail || strDiary This doesn't work? strDetail = "MyText" || strDiary This works strDetail = strDiary || "MyText" This doesn't work? Sorry... VB programmer, not an Informix guy. Nick __________________________________________________ This message is intended only for the use of the Addressee and may contain information that is PRIVILEGED and CONFIDENTIAL. If you are not the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, please erase all copies of the message and its attachments and notify us immediately. Thank You. ___________________________________________________
I'm guessing strDetail is defined as a char(), not a varchar. Chars are padded to fill width with blank spaces, so it's not surprising the "doesn't work" settings below "fail"; anything after the width of the char string is ignored. Varchar should work for you, but better is to use the trim() function in recent engine versions, or find the stored procedure posted in the archive to clip char values for earlier engine versions (or ... email me and I'll send it to you, with appropriate warnings). nanson@paulweiss.com wrote in message <7bmt51$8ta$1@news.xmission.com>... > >I'm trying to build a string inside a stored procedure in a FOR EACH loop. >Can someone explain the behavior of the following: > >strDetail = strDiary This works > >strDetail = strDetail || strDiary This doesn't work? > >strDetail = "MyText" || strDiary This works > >strDetail = strDiary || "MyText" This doesn't work? > > >Sorry... VB programmer, not an Informix guy. > >Nick > > > > >__________________________________________________ > >This message is intended only for the use of the Addressee and may >contain information that is PRIVILEGED and CONFIDENTIAL. > >If you are not the intended recipient, you are hereby notified that any >dissemination of this communication is strictly prohibited. If you have >received this communication in error, please erase all copies of the >message and its attachments and notify us immediately. > >Thank You. >___________________________________________________ > >