Re: [eclipse-clp-users] Issue with Dbi

From: Kish Shen <kisshen_at_...5...>
Date: Tue, 30 Dec 2014 17:37:35 +0000
Hi Shrirang,

On 26/12/2014 06:31, Edgaonkar, Shrirang wrote:


>
> 2. Test Code is as follows:-
>
> This is a case where the result of the query is known and we expect the where clause constraint to be evaluated based on the result.
>

I am not sure if I understand your intention here, but it looks to me 
you are expecting the dbi library to do some extra evaluation at the 
ECLiPSe level for the SQL query you are sending. Dbi does not do this -- 
the SQL statements are sent directly to MySQL, and must be complete
and valid for MySQL. I am not that familiar with SQL, but I think you 
must specify a name following "name=", and MySQL will then return 
matching tuples from the test.new_table that you specified.

> % Connect to DB  user/password
> session_start("root", "admin", [], Session),
>
> % SQL
> SQLTemp = "select pass from test.new_table where name=",
> concat_string([SQLTemp, Key], SQL),
>

 From what follows, it looks like you left Key as a variable here, 
expecting dbi to instantiate it to "Taro"? There are two problems with this:

1) The first argument to concat_string/2 must be a ground list (i.e. 
have no uninstantiated variables in it), so if Key is still a variable, 
this will lead to an instantiation fault. Is this the "abort" you are 
seeing? If so, you should have seen an error message like

instantiation fault in concat_string([SQLTemp, Key], SQL)

showing the problem is with using concat_string/2, before your SQL query 
was sent to MySQL.

2) As I mentioned earlier, I think you need to specify a name following 
"name=" to make a valid SQL query, so Key needs to be instantiated to a 
name, e.g. "Taro".

If you want MySQL to return all the tuples in the table, then I think 
you need to write a different SQL query.

Hope this helps,

Kish

> % Template
> Template = tbl(""),
>
> % Execute SQL
> session_sql_query(Session, Template, SQL, Cursor),
>
> % Get Results
> cursor_all_tuples(Cursor, Result),
> Result = [tbl("aaa")],
>
> % Close Cursor
> cursor_close(Cursor),
>
> % Close DB Connection
> session_close(Session).
>
>
>
>
>
> 3. Output is as follows:-
>
> Actual: Abort
>
> Expected: Value of Key is evaluated as "Taro"
>
>
>
> Your help will be valuable.
>
>
>
> Thanks and Regards,
>
> Shrirang Edgaonkar
>
> ______________________________________________________________________
> Disclaimer: This email and any attachments are sent in strictest confidence
> for the sole use of the addressee and may contain legally privileged,
> confidential, and proprietary data. If you are not the intended recipient,
> please advise the sender by replying promptly to this email and then delete
> and destroy this email and any attachments without any further use, copying
> or forwarding.
>
>
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming! The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net
>
>
>
> _______________________________________________
> ECLiPSe-CLP-Users mailing list
> ECLiPSe-CLP-Users_at_lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users
>
Received on Tue Dec 30 2014 - 17:37:55 CET

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:30 CEST