i am executing a sql query " select * from emp select * from customer ".
in ms sql server 2005's query browser it is showing result from both tables separably but while executing the same query
using prepared statement in java it is not showing data of emp table only.
so anybody please tell me how to solve this problem.
select * from emp select * from customer
this query will give ORA-00933: SQL command not properly ended found exception
how it is working for you ?
i think this will give error in oracle database but i am using ms sql server 2005 which is compiling query properly and giving result of both the queries.
Query Analyzer is making it appear that these two queries can be run as one. On its own its not valid SQL. If you want to run two queries in JDBC, run them as two PreparedStatements.
Paul Sturrock wrote:Query Analyzer is making it appear that these two queries can be run as one. On its own its not valid SQL. If you want to run two queries in JDBC, run them as two PreparedStatements.
the problem with this is the query is dynamic and we don't know that it is containing how many queries
so how will i find out the number of queries.
Paul Sturrock wrote:So how do you get the SQL for these queries? Can you explain a bit more about your logic?
i am developing an online sql query analyzer in which client will test his queries by writing queries into a textarea
and accordingly the result will be shown in tabular format to the user,
i am fetching query by using request.getParameter ("query");
and executing the query using praparestatement.executeQuery(query)
OK, then you will need to perform the same logic Query Analyzer does whereby it parses the Transact SQL before running it. The easiest way to do this is to require proper statement ends (batch seperator in SQL Server speak). If you can't do that then you will need to parse the input with a Transact SQL grammar and break it down into seperate statements.
Paul Sturrock wrote:OK, then you will need to perform the same logic Query Analyzer does whereby it parses the Transact SQL before running it. The easiest way to do this is to require proper statement ends (batch seperator in SQL Server speak). If you can't do that then you will need to parse the input with a Transact SQL grammar and break it down into seperate statements.
please tell me how can i parse the input query or validate the input query.
I don't know parsing using transact sql grammar.
Well, you could go looking for an existing grammar and use an existing parser technology like Antrl. Unfortunately, I don't know of any TSQL grammars out there, so you may have to define you own.