Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

odd behaviour of prepared statement: msg#00189

db.postgresql.jdbc

Subject: odd behaviour of prepared statement

this piece of code is the second PreparedStatement in a bean function.
All code before it seems to work perfectly. no amount of tinkering
with this one will avoid an SQLException "parser: parse error at end
of input" on the executeQuery();
The code executes fine in psql.
db is 7.3.2. java is sun hotspot 1.41.

Any ideas why the code fails parsing?

<code>
String strSQL;
String strSQL_SalesAndReturns;
PreparedStatement pstmtSR = null;
ResultSet results = null;

String strStockid=null;
String strGroup=null;
String strDesc=null;
String strType=null;
int iSales=0;
int iReturns=0;

String strSQL_SalesAndReturns =
"SELECT stock, " +
" p.description, " +
" p.stockgroup, " +
" s.saleqty, " +
" r.returned " +
" FROM " +
" (SELECT stockid as stock, " +
" sum(saleqty) as saleqty " +
" FROM dailysales s " +
" WHERE s.saledate = '2003-08-22' " +
" AND s.custid = ' 5' " +
" GROUP BY s.stockid ) AS s " +
" FULL OUTER JOIN " +
" (SELECT stock, " +
" ordercurrent as returned " +
" FROM orderlines ol " +
" WHERE ol.theorder = 'A 5 12003-08-15' " +
" AND ol.TYPE='R') as r " +
" USING (stock) " +
" INNER JOIN stockitems p ON (p.id=r.stock) " +
" WHERE p.status='N' " +
" ORDER BY ";

strSQL = strSQL_SalesAndReturns;
pstmtSR = livedb.prepareStatement(strSQL);

// global character switch for grouping
switch(cSelectOrder) {
case cDESCRIPTION_SEQ : strSQL = strSQL +
"p.description;";
break;
case cGROUP_SEQ : strSQL = strSQL +
"p.stockgroup,p.description;";
break;
case cCODE_SEQ : strSQL = strSQL + "stock;";
break;
default : strSQL = strSQL +
"p.description;";
break;
}

results = pstmtSR.executeQuery();

while( results.next() ) {
strStockid = results.getString(1);
strDesc = results.getString(2);
strGroup = results.getString(3);
iSales = results.getInt(4);
iReturns = results.getInt(5);
... code to process resultset.
</code>

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
qnx.openqnx.dev...    gcc.libstdc++.c...    solaris.opensol...    information-ret...    misc.misterhous...    web.catalyst.ge...    apache.webservi...    redhat.release....    hardware.lirc/2...    kernel.autofs/2...    technology.sust...    linux.vdr/2003-...    editors.lyx.gen...    org.user-groups...    netbsd.devel.pk...    xdg.devel/2004-...    version-control...    jakarta.slide.d...    debian.packages...    creativecommons...    ports.ppc.embed...    bug-tracking.bu...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe