new line/line feed in stored procedure
Posted in 2011
Topics: Stored Procedures & SPL, Server Administration, Security, Permissions & Auditing
1150.FC8 I am trying to include a new line in a text string in a sp, for some reason it seems to be 'escaped'. I've tried single quotes and double quotes and line feed , no luck. I have ALLOW_NEWLINE 1 in $ONCONFIG i.e. Username: root \\\\\\ Action: Created an Index. This event occured on : 2011-11-11 09:49:28.000 on database object: ctmaudit uix_auditlog The intended desired output: Username: root Action : Created an Index. This event occurred on ... code snip: LET g_email_body="Username: "||g_username||"\\ "||"Action: "|| trim(g_event_descr)||" "||trim(g_email_occurred)||" " ||g_date_time||" on database object: "||trim(g_dbname)|| " "||trim(g_objname) ;
Suggestion: Write a small "C" routine to generate the string for you, compile it, build it into a shared library, and install it as a UDR. To make it generic pass in the name of a table containing one row for each line in the output string to the routine and have it build a result string inserting newlines between the records in the table. Then the calling routine can build a temp table with the strings, call the UDR, and poof! Art Art S. Kagel Advanced DataTools (www.advancedatatools.com) Blog: http://informix-myview.blogspot.com/ Disclaimer: Please keep in mind that my own opinions are my own opinions and do not reflect on my employer, Advanced DataTools, the IIUG, nor any other organization with which I am associated either explicitly, implicitly, or by inference. Neither do those opinions reflect those of other individuals affiliated with any entity with which I am affiliated nor those of the entities themselves. On Fri, Nov 11, 2011 at 10:03 AM, MARK JALKIEWICZ < mark.jalkiewicz@verizon.net> wrote: > 1150.FC8 > > I am trying to include a new line in a text string in a sp, for some > reason it > seems to be 'escaped'. I've tried single quotes and double quotes and line > feed , no luck. > > I have ALLOW_NEWLINE 1 in $ONCONFIG > > i.e. > > Username: root \\\\\\ Action: Created an Index. This event occured on > : 2011-11-11 09:49:28.000 on database object: ctmaudit uix_auditlog > > The intended desired output: > > Username: root > Action : Created an Index. This event occurred on ... > > code snip: > > LET g_email_body="Username: "||g_username||"\\ "||"Action: "|| > > trim(g_event_descr)||" "||trim(g_email_occurred)||" " > > ||g_date_time||" on database object: "||trim(g_dbname)|| > > " "||trim(g_objname) ; > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > --e89a8f3ba2ad581c3204b1772373
On Fri, Nov 11, 2011 at 07:03, MARK JALKIEWICZ
<mark.jalkiewicz@verizon.net>wrote:
> 1150.FC8
>
> I am trying to include a new line in a text string in a sp, for some
> reason it
> seems to be 'escaped'. I've tried single quotes and double quotes and line
> feed , no luck.
>
> I have ALLOW_NEWLINE 1 in $ONCONFIG
>
> i.e.
>
> Username: root \\\\\\
Action: Created an Index. This event occured on
> : 2011-11-11 09:49:28.000 on database object: ctmaudit uix_auditlog
>
> The intended desired output:
>
> Username: root
> Action : Created an Index. This event occurred on ...
>
> code snip:
>
> LET g_email_body="Username: "||g_username||"\\
"||"Action: "||
>
> trim(g_event_descr)||" "||trim(g_email_occurred)||" "
>
> ||g_date_time||" on database object: "||trim(g_dbname)||
>
> " "||trim(g_objname) ;
>
EXECUTE PROCEDURE ifx_allow_newline('t');...your CREATE PROCEDURE statement...
See:
http://publib.boulder.ibm.com/infocenter/idshelp/v117/topic/com.ibm.sqls.doc/ids
_sqs_1570.htm
And:
http://publib.boulder.ibm.com/infocenter/idshelp/v117/topic/com.ibm.sqls.doc/ids
_sqs_1615.htm
--
Jonathan Leffler <jonathan.leffler@gmail.com> #include <disclaimer.h>
Guardian of DBD::Informix - v2011.0612 - http://dbi.perl.org
"Blessed are we who can laugh at ourselves, for we shall never cease to be
amused."
--14dae9340b7febd08d04b17876c6
that kind of did the trick, I was able to get a newline but there was still an escape "\\\\" char displayed at the end of the first line. What I wound up doing to get rid of it was this : after g_username I inserted a <control-v, control-m> inside the string "Action" (instead of the "\\ "). (The <control-v> will not be shown).Not sure if this has anything to do with my env or not, but it works. LET g_email_body="Username: "||g_username||"\\ "||"Action: "|| .... changed to LET g_email_body="Username: "||g_username||"^MAction: "||.... Thanks to everyone who responded.