hi luis,
maybe a workaround would be to use a scripting language, such as bash,
to do all the string manipulation and pass the string query to monetdb
through the mclient -e option.
#> mclient -e 'select * from ....'
On Thu, Mar 16, 2017 at 3:12 PM, Joeri van Ruth
Hi Luis!
I'm afraid there is currently no support for executing a string as SQL in MonetDB.
Without the specifics of your use case it is hard to come up with a suggestion for an alternative approach. If it involves for example several user specific schemas which all share some data and functionality from one common schema, you might be able to play games with the default schema for a user: refer to the common items with an explicit schema qualifier and to the user specific items without. But it's hard to tell in general.
Joeri
On Wed, Mar 15, 2017 at 11:22:42PM +0000, Luis Larios wrote:
Hi,
I'm attempting to declare a query string to execute in MonetDB. The documentation is not clear if this is possible, but other engines allow this functionality (such as MySQL and MS SQL Sever). Trying the following
execute 'select * from tables';
fails with the message
Error: syntax error, unexpected STRING, expecting IDENT or sqlINT
The reason behind this is that I need to declare a variable *schema name*, such that I can execute a query in the following way:
declare s varchar(32); set s = 'the_schema'; execute 'select * from ' || the_schema || '.the_table';
Please let me know if this is even possible in MonetDB or if you have some tips about that. I tried with a *prepared statement*, as given in MonetDB's documentation -- but the following code cannot execute
prepare 'select * from ' || the_schema || '.the_table'; because prepare expects an actual query, not a string.
I'd like to achieve this with only SQL stored functions. The client I have has to execute the SQL functions directly, and there's no intermediate Java/PHP/etc scripts to build the SQL on the fly before they're being sent to MonetDB server. Thus, I should create a function like so:
create function getData( dataSchema varchar(32) ) returns bigint begin declare query varchar(128); set query = 'select count(*) from ' || dataSchema || '.the_table'; return( execute query ); end;
My function is more complicated than this, with other tables and even functions. The issue is that functions belong to one schema, and data tables belong to another schema, which is not known in 'compile' time.
Thanks for the help!
Luis Ángel
The information transmitted, including any attachments, is intended only for the individual or entity to which it is addressed, and may contain confidential and/or privileged information. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by individuals or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you have received this communication in error, please delete the information from any computer and notify the sender.
_______________________________________________ users-list mailing list users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list
_______________________________________________ users-list mailing list users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list