CASE SQL STMT IBM ISERIES



IBM's flagship relational database management system

CASE SQL STMT IBM ISERIES

Postby dee » Thu Feb 04, 2010 9:12 pm

Hi all,

I am writing an web app to load data from DB2 ISeries. I wrote this query and put in a string:


      queryStr = "DECLARE @TEMP CHAR(50)";
               queryStr += " CASE WHEN (address1='' AND Adress2='') THEN SET @TEMP ='(Adress1||Adress2||Adress3) AS Address,' ";
               queryStr += " WHEN (address1='' AND Adress2 <>'') THEN SET @TEMP ='(Adress2||Adress2||'<br />'||Adress3) AS Address,' ";
               queryStr += " WHEN (address1<>'' AND Adress2 ='') THEN SET @TEMP ='(Adress2||'<br />'||Adress2||Adress3) AS Address,' ";
                queryStr += " WHEN (address1<>'' AND Adress2 <>'') THEN SET @TEMP ='(Adress2||'<br />'||Adress2||'<br />'||Adress3) AS Address,' ";
                queryStr += " END ";

                queryStr = "select ID AS StudendID,key AS studentKey, @TEMP ,";
                queryStr += "CUCYST AS City,CUSTE AS State,ZIPCD9 AS Zipcode  ";
                queryStr += "from studendTable WHERE ID like '%" + StuNoTxt.Text.Trim().ToUpper() + "%'";


when I run the query, I got error

Error! SQL0418 Use of parameter marker not valid.

How can I make this query work?????

Please help. Thanks

Dee
dee
 
Posts: 1
Joined: Thu Feb 04, 2010 9:02 pm
Has thanked: 0 time
Been thanked: 0 time

Re: CASE SQL STMT IBM ISERIES

Postby dick scherrer » Fri Feb 05, 2010 1:01 am

Hello and welcome to the forum,

Where did the SQL0418 error originate?

I suspect it is also shown somewhere as a -418. Look here:
http://publibz.boulder.ibm.com/cgi-bin/ ... /2.1.6.167

If you show some sample data rows containing the various conditions you want to handle, and post what you want as the output form that sample data when the query is executed, someone may have a suggestion.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post