473,382 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Multiple queries in a single SQL string

KS
I am passing the following three queries in a string in VS.NET C# class

string sql = "SELECT A FROM TABLEA; SELECT B FROM TABLEB; SELECT C FROM
TABLEC;";
OdbcAdapter thisAdapter = new OdbcAdapter(sql, conn); (conn is my
connection object)
DataSet ds = new DataSet;
thisAdapter.Fill(ds);

If the second query fails, the third query doesn't get executed. If the
first one fails (sql +100) the second and third will never be executed.
But i would like the later occuring queries to execute even if the prior
ones have an SQL +100. How do i accomplish this ?

Thanks,
Karthik

Nov 12 '05 #1
3 21861
KS <ks@nospam.net> wrote:
I am passing the following three queries in a string in VS.NET C# class

string sql = "SELECT A FROM TABLEA; SELECT B FROM TABLEB; SELECT C FROM
TABLEC;";
OdbcAdapter thisAdapter = new OdbcAdapter(sql, conn); (conn is my
connection object)
DataSet ds = new DataSet;
thisAdapter.Fill(ds);

If the second query fails, the third query doesn't get executed. If the
first one fails (sql +100) the second and third will never be executed.
But i would like the later occuring queries to execute even if the prior
ones have an SQL +100. How do i accomplish this ?


An easy way would be to get the various queries to the point where no +100
is produced in the first place. Then you would have to handle the
situation in your application. If you extend your queries like that, you
should get at least one row - always:

SELECT a
FROM tableA
UNION
SELECT x
FROM TABLE ( VALUES(0) ) AS t(x)
WHERE NOT EXISTS ( SELECT 1
FROM tableA );
<second query in a similar fashion>

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #2
+100 is not an error, it's a warning. Are you inded seeing that +100
fails the batch?
I recall dimply that there is some CLI parameter (cli.ini file?) that
meedles with how ODBC handles warnings.
You may want to check the CLI docs.

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab

Nov 12 '05 #3
Hello,
what do what to get as a result of these queries. It seems that you
want to build a UNION of these selects, so the select would look like

select A from tableA
union
select B from tableB
union
select C from tableC

as long as A,B and C are of the same datatype.

Joerg

KS <ks@nospam.net> wrote in message news:<cZ*******************@nwrddc02.gnilink.net>. ..
I am passing the following three queries in a string in VS.NET C# class

string sql = "SELECT A FROM TABLEA; SELECT B FROM TABLEB; SELECT C FROM
TABLEC;";
OdbcAdapter thisAdapter = new OdbcAdapter(sql, conn); (conn is my
connection object)
DataSet ds = new DataSet;
thisAdapter.Fill(ds);

If the second query fails, the third query doesn't get executed. If the
first one fails (sql +100) the second and third will never be executed.
But i would like the later occuring queries to execute even if the prior
ones have an SQL +100. How do i accomplish this ?

Thanks,
Karthik

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: DG | last post by:
Hi, Can anyone advise how to execute multiple statements in a single query batch. For example- update customers set customer_name = 'Smith' where customer_name = 'Smyth'; select * from...
11
by: dskillingstad | last post by:
I've been struggling with this problem for some time and have tried multiple solutions with no luck. Let me start with, I'm a novice at Access and I'm not looking for someones help to design my...
1
by: Primo | last post by:
Hello, I am building a data management application with the following processes: Process 1 is a Windows service which uses FileSystemWatcher to monitor a directory. Process 2 opens a file...
0
by: rayone | last post by:
Hi folks. I need advice. 2 options, which do you think is the better option to display/retrieve/report on the data. Keep in mind reporting (Crystal), SQL Performance, VB Code, usability,...
4
by: Dave Edwards | last post by:
I understand that I can fill a datagrid with multiple queries, but I cannot figure out how to fill a dataset with the same query but run against multiple SQL servers, the query , table structure...
7
by: Daz | last post by:
Hi. I am trying to select data from two separate MySQL tables, where I cannot use join, but when I put the two select queries into a single query, I get an error telling me to check my syntax. Both...
7
by: =?Utf-8?B?QVRT?= | last post by:
HOWTO Run multiple SQL statements from ASP/ADO to an Oracle 10g. Please help, I'm trying to write an ASP page to use ADO to run a long query against an Oracle 10g database, to create tables,...
1
by: JosAH | last post by:
Greetings, Introduction This week we start building Query objects. A query can retrieve portions of text from a Library. I don't want users to build queries by themselves, because users make...
1
by: kadar2itse | last post by:
Hi, I am having multiple update queries inorder to update a records in single table. I am using VB6 and ADODB objects for connecting to DB2 database. I need to run all those queries in a single...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.