数据库:服务端 ORACLE9.0.0.1,客户端ORACLE10.0.0.0
使用DELPHI6.0的TADOQUERY进行数据库查询时报“多步操作产生错误,请检查每一步的状态”的异常( Run-time error '-2147217887(8004e21)': Multiple-step operation generated errors. Check each status value. )
SQL语句如下:
'采油第一作业区队',
'{B6B7B454-AFFB-4CF2-9283-861A57F21816}',
'采油第二作业区队',
'{7EF7472B-6C0C-46F6-8EBE-DCB6A8D3A727}',
'采油第三作业区队',
'{F815C55A-262B-47DA-869C-B0E8B2E530F7}',
'采油第四作业区队',
'{16F554AF-0EEC-4DC4-89B4-D30E4F3F92F1}',
'采油第五作业区队',
'{16F554AF-0EEC-4DC4-89B4-D30E4F3F92F1}',
'采油第六作业区队',
'{0DD12581-6DAB-42E7-A734-ED9018198372}',
'全厂',
'{BCFEB249-EB3D-4CFB-BB29-AA9198C145A1}',
'')
FROM DUAL
经检查不是以下这些情况:
1.无主键
2.字段允许为空
3.字段类型不匹配
查了好一番资料,发现TADOQUERY有一个CursorLocation的属性,默认值为“clUseClient”,设为“clUseServer”时该问题得以解决。
帮助文档资料如下:
Use CursorLocation to indicate whether the cursors that use the connection object to connect to the ADO datastore use a client-side or server-side cursor library. CursorLocation only affects connections opened after the property is set. The default value for CursorLocation is clUseClient.
A client-side cursor offers more flexibility. All data is retrieved to the local machine and then operated on there, allowing operations not normally supported by servers like sorting and resorting the data and additional filtering. SQL statements are executed at the server, so for statements that restrict the result set with a WHERE clause, only the reduced result set is retrieved to a local cursor.
A server-side cursor offers less flexibility, but may be more advantageous (or necessary) for large result sets. Using a server-side cursor becomes necessary when the sheer size of a result set exceeds the available disk space that would be needed to create the client-side cursor. Also, many servers only support unidirectional cursors. This would preclude moving the record pointer in the dataset backward (even one record) through the result set.
简单翻译一下:
CursorLocation 是用来确认数据库连接对象是使用服务端还是客户端游标库的属性,默认值为clUseClient。
客户端光标提供更多的灵活性,所有的数据是下载到本地后再进行操作,允许进行一些服务端不允许的操作,如排序、重置和过滤等等。SQL语句本身是在服务端执行,并且只返回WHERE子句限制下的结果集。
服务端光标的灵活性较差,但是比较利于执行大数据量的操作。但如果返回的结果集超过了设定的磁盘缓冲空间就必须使用客户端光标了。而且很多数据库服务器只支持单向游标,这就意味着,你只能从头到尾遍历一次数据集(即使是一条记录)。