Re: [eclipse-clp-users] Problem with session_sql_prepare_query

From: Kish Shen <kisshen_at_cisco.com>
Date: Wed, 21 Oct 2015 19:43:12 +0100
Hi Shrirang,

On 21/10/2015 06:09, Edgaonkar, Shrirang wrote:
> Dear clp users,
>
>
>
>    I have been using session_sql_query for the database interface all this while without any issues. But now I wish to use session_sql_prepare_query instead. Following code makes TkEclipse to crash. For security reasons, I have changed the details but following is a basic implementation of the API.

Your included picture of the TkECLipSe pop-up window with the crash is 
not particularly useful, as it does not give any more information than 
saying ECLiPSe crashed.

It would be helpful if you can report which particular goal caused 
ECLiPSe to crash (I assume it is either session_sql_prepare_query or 
cursor_all_tuples), and any messages that might be printed by ECLiPSe -- 
in many cases, you can't see these with TkECLiPSe, so run your program 
using TTY (the command line) ECLiPSe instead.

I am not able to reproduce a crash running ECLiPSe on Linux (that the 
only platform where we have a MySQL server running). [I used my own 
code. If you want your code to be tested, please include all code needed 
to reproduce the error, including code that create the table and fields]

However, the code you show is incorrect:
>
>
>
> :-lib(dbi).
>
> solve(Result_db001):-
>
> % Connect to DB  user/password
> session_start("rsuser1"@"sim-blahblah<mailto:"rsuser1"@"sim-blahblah>", "blahblah", [dbname:"blahblah"], Session),
>
> % SQL
> SQL = "SELECT * FROM DummyTableName WHERE  goodsname = ? ",
>
> % Template
> DummyTableName = dummyTableName("AA", "AA", 10, "AA", 10, 10, "AA", "AA", 10),
>
> INPUT = input("laptop"),
>
> writeln(INPUT),
>
> % Execute SQL
> session_sql_prepare_query(Session, INPUT, DummyTableName, SQL, Cursor),
>

session_sql_prepare_query does NOT execute the SQL as your comment 
suggest. Instead, it "prepares" a prepared SQL query, which then needs 
to be executed, using, e.g.  cursor_next_ececute -- this is described in 
the manual.

However, there is a bug in session_sql_prepare_query that I found while 
trying to reproduce your error, in which the predicate incorrectly 
aborts if the results template contain string fields.

> % Get Results
> cursor_all_tuples(Cursor, Result_db001),
>

Calling cursor_all_tuples without cursor_next_execute should also result 
in an ECLiPSe error, and not the crashing of ECLiPSe.

Cheers,

Kish

> % Close Cursor
> cursor_close(Cursor).
>
>
>
>
>
> I am using the version as mentioned in the attachement.
>
>
>
>
>
> 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.
>
>
>
> ------------------------------------------------------------------------------
>
>
>
> _______________________________________________
> ECLiPSe-CLP-Users mailing list
> ECLiPSe-CLP-Users_at_lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users
>
Received on Wed Oct 21 2015 - 19:18:50 CEST

This archive was generated by hypermail 2.2.0 : Thu Oct 22 2015 - 00:13:13 CEST