Forum

Kognitio Console issues, advice, etc.
Contributor
Offline
Posts: 184
Joined: Wed May 29, 2013 2:10 pm
Location: Bracknell

Kog Scripts: how do I use quotation marks within variables?

by MikeAtkinson » Tue Jul 16, 2013 8:45 am

I'm using variables within SQL statements, but I'm finding it hard to get single-quotes and double-quotes to work correctly.
Reply with quote Top
Contributor
Offline
Posts: 184
Joined: Wed May 29, 2013 2:10 pm
Location: Bracknell

Re: Kog Scripts: how do I use quotation marks within variabl

by MikeAtkinson » Wed Jul 17, 2013 4:16 pm

Sometimes you may want to include single quotes in a variable. For example:

Code: Select all

a = "'"; /* quote in a double-quote string */
b = '"'; /* double-quote in a single-quote string */
select $(a)me$(a) as $(b)you$b; /* note use of () to delimit variable names */
Which returns 'me' in a column 'you'.
Reply with quote Top
Contributor
Offline
Posts: 184
Joined: Wed May 29, 2013 2:10 pm
Location: Bracknell

Re: Kog Scripts: how do I use quotation marks within variabl

by MikeAtkinson » Fri Jul 19, 2013 3:37 pm

It is also possible to use the Lua double square bracket delimiters for strings

Code: Select all

x = [[ 'xxx' as "yyy" ]]
select $x;
Reply with quote Top

Who is online

Users browsing this forum: No registered users and 1 guest

cron