This is a discussion on Multiple queries in a single SQL string within the DB2 forums, part of the Database Server Software category; --> I am passing the following three queries in a string in VS.NET C# class string sql = "SELECT A ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| |||
| 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 |
| |||
| +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 |
| ||||
| 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:<cZoNb.16210$4l3.10950@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 |
| Thread Tools | |
| Display Modes | |
|
|