Re: [eclipse-clp-users] Dbi Query with more than 1 columns

From: Edgaonkar, Shrirang <Shrirang.Edgaonkar_at_nttdata.com>
Date: Fri, 30 Jan 2015 02:11:38 +0000
Dear Kish,

  Yes. That was a mistake but the problem is still the same. Even if the template is correct as per the documentation as follows, eclipse still crashes.

SQL = "select enum, ename, esalary, ejob from employees where esalary > 1000",
Template = emp(1234,"some name",1000.0,’some job’),
session_sql_query(H, Template, SQL, Cursor),
cursor_next_tuple(Cursor,Tuple),

Following is the example I am running,.

Table Structure:-

CREATE TABLE `goodsinfo` (
  `goodsid` int(11) NOT NULL,
  `goodsname` char(100) DEFAULT NULL,
  `price` double DEFAULT NULL,
  `salesdate` datetime DEFAULT NULL,
  `term` char(100) DEFAULT NULL,
  `zaikoamount` double DEFAULT NULL,
  `registerdate` datetime DEFAULT NULL,
  `categoryid` int(11) DEFAULT NULL,
  `searchViews` char(100) DEFAULT NULL,
  PRIMARY KEY (`goodsid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


Eclipse script:-

:- lib(dbi).
solve(Result) :-
 
session_start("root", "", [], Session),
SQL = "SELECT goodsid, goodsname, term FROM simulator.goodsinfo",
Template = goodsinfo1(101, "fdfdfddsdad", "dsdsadsds"),
session_sql_query(Session, Template, SQL, Cursor),
cursor_all_tuples(Cursor, Result),
cursor_close(Cursor),
session_close(Session).

Since gooodsname and term are character string fields, eclipse will crash, whereas the following code will work.


:- lib(dbi).
solve(Result) :-
 
session_start("root", "", [], Session),
SQL = "SELECT goodsid, goodsname FROM simulator.goodsinfo",
Template = goodsinfo1(101, "fdfdfddsdad"),
session_sql_query(Session, Template, SQL, Cursor),
cursor_all_tuples(Cursor, Result),
cursor_close(Cursor),
session_close(Session).

Please help.

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.
Received on Fri Jan 30 2015 - 02:12:52 CET

This archive was generated by hypermail 2.2.0 : Fri Jan 30 2015 - 12:13:13 CET