cancel
Showing results for 
Search instead for 
Did you mean: 

run q-sql as string

analyst_tech_jo
New Contributor
I want to run q-sql which is inputted as string to the program. ALL of them run fine in the console. I can use eval ( parse queryString) however the big ones dont parse fine and hence dont run. Is there a way to just run them without using eval/parse ?
3 REPLIES 3

david_demner
New Contributor
To: analyst valuevalue"1+1"(works for a lot more than strings like value(+;1;1) works)� Original Message �From: analystSent: Friday, October 30, 2015 12:52To: Kdb+ Personal DevelopersReply To: personal-kdbplus@googlegroups.comSubject: [personal kdb+] run q-sql as stringI want to run q-sql which is inputted as string to the program. ALL of them run fine in the console. I can use eval ( parse queryString) however the big ones dont parse fine and hence dont run. Is there a way to just run them without using eval/parse ?-- You received this message because you are subscribed to the Google Groups "Kdb+ Personal Developers" group.To unsubscribe from this group and stop receiving emails from it, send an email to personal-kdbplus+unsubscribe@googlegroups.com.To post to this group, send email to personal-kdbplus@googlegroups.com.Visit this group at http://groups.google.com/group/personal-kdbplus.For more options, visit https://groups.google.com/d/optout.

parse and value do not work well with "\n".  do your 'big ones' have "\n"?

eg. 
 q)value "x:1\nx+1"
 'type

in this example:

 q)last value each "\n"vs"x:1\nx+1"
 2

It doesn’t sound like you’ll need it but another option is to write to a temp file:

 

q){hsym[`$f:"c:\\temp\\blah.q"] 0: enlist x; system"l ",f}"x:1\nx+1"

2

q)x

1

 

This approach will work if there are multi-line function definitions.

 

The main disadvantage is you can’t grab the final output, only see it on screen (but you see intermediate outputs too) unlike value.

 

From: personal-kdbplus@googlegroups.com [mailto:personal-kdbplus@googlegroups.com] On Behalf Of Jack Andrews
Sent: Friday, October 30, 2015 9:18 PM
To: Kdb+ Personal Developers
Subject: Re: [personal kdb+] run q-sql as string

 

parse and value do not work well with "\n".  do your 'big ones' have "\n"?

 

eg. 

 q)value "x:1\nx+1"

 'type

 

in this example:

 

 q)last value each "\n"vs"x:1\nx+1"

 2

 

 

On 31 October 2015 at 07:07, David Demner <david.demner@aquaq.co.uk> wrote:

value

value"1+1"

(works for a lot more than strings like value(+;1;1) works)

  Original Message  
From: analyst
Sent: Friday, October 30, 2015 12:52
To: Kdb+ Personal Developers
Reply To: personal-kdbplus@googlegroups.com
Subject: [personal kdb+] run q-sql as string


I want to run q-sql which is inputted as string to the program. ALL of them run fine in the console. I can use eval ( parse queryString) however the big ones dont parse fine and hence dont run. Is there a way to just run them without using eval/parse ?

--
You received this message because you are subscribed to the Google Groups "Kdb+ Personal Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to personal-kdbplus+unsubscribe@googlegroups.com.
To post to this group, send email to personal-kdbplus@googlegroups.com.
Visit this group at http://groups.google.com/group/personal-kdbplus.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Kdb+ Personal Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to personal-kdbplus+unsubscribe@googlegroups.com.
To post to this group, send email to personal-kdbplus@googlegroups.com.
Visit this group at http://groups.google.com/group/personal-kdbplus.
For more options, visit https://groups.google.com/d/optout.

 

--
You received this message because you are subscribed to the Google Groups "Kdb+ Personal Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to personal-kdbplus+unsubscribe@googlegroups.com.
To post to this group, send email to personal-kdbplus@googlegroups.com.
Visit this group at http://groups.google.com/group/personal-kdbplus.
For more options, visit https://groups.google.com/d/optout.