Solved

CDataset and CRecordset DB2 errors

Posted on 2014-03-12
4
331 Views
Last Modified: 2014-03-19
Hi all,

My connection string is
"Driver={IBM DB2 ODBC DRIVER};Database=db;Hostname=host;Port=50000;Protocol=TCPIP;Uid=uid;Pwd=pwd"

I am trying to execute sql statements like these:
string sql="{CALL DBO.SP_ALERT(99,'1974-03-26-11.00.11.000','4754',334,445,1,85,16,22,0,0,0,0,0,17,9)}";
or
string sql="UPDATE FM.WARNING SET ACTIVE = 0 WHERE ID=99 and TYPEID = 2 and ACTIVE=1;";

CDatabase pDatabase=new CDatabase();
pDatabase->Open(_T(""),FALSE,FALSE,LPCTSTR(sCnString));
pDatabase->ExecuteSQL(sql.c_str());

I am receiving "CLI0115E  Invalid cursor state. SQLSTATE=24000" and "Function sequence error" all the time.

What am I doing wrong?
0
Comment
Question by:trustworthy
  • 2
4 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 39924694
What does 'Open()' return? You are not specifying a data source in your connection string, so you should pass that in the 1st parameter, which is empty in your case. See http://msdn.microsoft.com/en-us/library/7ca7bkdw.aspx ("CDatabase::Open")
0
 
LVL 24

Expert Comment

by:chaau
ID: 39925219
For ODBC calls date and time literals need to be escaped:
date literals:  {d 'yyyy-mm-dd'}
timestamp literals: {ts 'yyyy-mm-dd hh:mm:ss'}.
Try to convert you statement to this, and see how it goes:
string sql="{CALL DBO.SP_ALERT(99, {ts '1974-03-26 11:00:11.000'}, '4754', 334, 445, 1, 85, 16, 22, 0, 0, 0, 0, 0, 17, 9)}";

Open in new window

0
 

Author Comment

by:trustworthy
ID: 39926378
Actually, I moved a little further with this problem.

I got all select statements working, but I always get "Function sequence error"
on the update statements, like this one:
"UPDATE FM.WARNING SET ACTIVE = 0 WHERE ID=1228 and TYPEID = 2 and ACTIVE=1"

I tried to update the driver - IBM Data Server Driver Package (IBMDBCL1) - but that didn't help.

What else could be the reason for that error?
Am I installing the wrong driver?

Please help.
0
 
LVL 24

Accepted Solution

by:
chaau earned 500 total points
ID: 39927722
It is a weird DB2-specific error (bug). It requires you to set a certain ODBC/CLI parameter.
The parameter in question is PATCH1. Please scroll down the page at the hyperlink above and find a PATCH1 parameter value of 1024. Setting of this parameter makes:
Returns SQL_SUCCESS_WITH_INFO instead of SQL_NO_DATA_FOUND from the SQLExecute() and SQLExecDirect() functions if the executed UPDATE or DELETE statement affected no rows. This value might be needed by some Microsoft Visual Basic applications.
BTW, there are a ton other parameters you can set to make your driver work better. I recommend you to review them all.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem to adjust sheet 1 90
SNMP error No Such Object available on this agent at this OID 3 249
Least Squares Curve Fitting 4 77
Why is "packages element is not declared"? 2 223
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question