Book a Demo

Author Topic: SqlQuery from JAVA API returning nothing  (Read 2875 times)

derekwallace

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
SqlQuery from JAVA API returning nothing
« on: August 23, 2012, 06:23:16 pm »
Hi,
Im using the JAVA api to export information from EA.
Im now extending it and want to use the Repository command SqlQuery.

Using the EA GUI i can construct the SQL query in the Model Search window and it runs correctly.
Trivial example here.
SELECT t_object.ea_guid AS GUID FROM t_object


When i try to use the JAVA API i get nothing back. here is my script.

org.sparx.Repository oRepos = new org.sparx.Repository()
oRepos.OpenFile(sReposName);

String sSqlQuery  = "SELECT t_object.ea_guid AS GUID  FROM t_object";
String sTmp = oRepos.SQLQuery(sSqlQuery);
System.out.println(sTmp);


What i get back in sTmp is this. (empty xml)
<?xml version="1.0"?>
<EADATA version="1.0" exporter="Enterprise Architect">
</EADATA>

Ive tried putting a broken SQL command in and i still get same back the same.
String sSqlQuery  = "SELECT t_object.XXXXXea_guid AS GUID  FROM t_object";


Any suggestions?

Thx
Derek
« Last Edit: August 23, 2012, 06:28:03 pm by derekwallace »

derekwallace

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: SqlQuery from JAVA API returning nothing
« Reply #1 on: August 23, 2012, 06:33:22 pm »
found issue in my code. It works fine.
My error was that i was constructing the SQL Search on multi lines.

             sSqlQuery  = "SELECT";
             sSqlQuery += "   t_object.ea_guid AS GUID,";
             sSqlQuery += "   t_object.name AS Name,";
             sSqlQuery += "   t_object.Object_Type AS Type,";
             sSqlQuery += "   t_object.Author AS Author";
             sSqlQuery += "FROM ";                                 <----- this line was issue.
             sSqlQuery += "   t_object";


I had to put a space in front of the FROM.

             sSqlQuery  = "SELECT";
             sSqlQuery += "   t_object.ea_guid AS GUID,";
             sSqlQuery += "   t_object.name AS Name,";
             sSqlQuery += "   t_object.Object_Type AS Type,";
             sSqlQuery += "   t_object.Author AS Author";
             sSqlQuery += " FROM ";
             sSqlQuery += "   t_object";