Qua*_*ion 15 db2 db2-400 ibm-midrange
我想删除一个名为id自动递增PK的列.
SQL:
alter table "CO88GT"."XGLCTL" drop column id cascade;
Run Code Online (Sandbox Code Playgroud)
我得到:
Error: [SQL0952] Processing of the SQL statement ended. Reason code 10.
SQLState: 57014
ErrorCode: -952
Run Code Online (Sandbox Code Playgroud)
我可能错了,但我认为它与防止表丢失数据有关.为了解决这个问题,我需要创建一个没有列的新表,并将旧表中的数据复制到新表中,然后用新表替换旧表.
dav*_*orp 23
AS400因为可能的数据丢失而向您发出警告(查询消息),要求您取消或忽略请求的操作.所以,由于这是一个交互式请求,在JDBC/ODBC上你不能输入'I'来忽略,而AS会抛出一个ErrorCode:-952 with SQLState:57014和Reason code 10.
在SQL0952的文档中说:
Message Text: Processing of the SQL statement ended. Reason code &1.
Cause Text: The SQL operation was ended before normal completion. The reason code is &1. Reason codes and their meanings are:
* 1 - An SQLCancel API request has been processed, for example from ODBC.
* 2 - SQL processing was ended by sending an exception.
* 3 - Abnormal termination.
* 4 - Activation group termination.
* 5 - Reclaim activation group or reclaim resources.
* 6 - Process termination.
* 7 - An EXIT function was called.
* 8 - Unhandled exception.
* 9 - A Long Jump was processed.
* 10 - A cancel reply to an inquiry message was received.
* 11 - Open Database File Exit Program (QIBM_QDB_OPEN).
* 0 - Unknown cause.
Run Code Online (Sandbox Code Playgroud)
如果您使用JDBC并且SQL错误不是不言自明的,那么您可以使用参数' errors = full ' 建立JDBC连接,这将提供有关错误的更多信息.对于其他连接参数看这个.
示例连接字符串:
JDBC:AS400://服务器;库=*LIBL;命名=系统; 错误=满 ;
通过该连接,产生的错误将如下所示:
Error: [SQL0952] Processing of the SQL statement ended. Reason code 10.
Cause . . . . . : The SQL operation was ended before normal completion.
The reason code is 10.
Reason codes and their meanings are:
1 -- An SQLCancel API request has been processed, for example from ODBC.
2 -- SQL processing was ended by sending an exception.
3 -- Abnormal termination.
4 -- Activation group termination.
5 -- Reclaim activation group or reclaim resources.
6 -- Process termination.
7 -- An EXIT function was called.
8 -- Unhandled exception.
9 -- A Long Jump was processed.
10 -- A cancel reply to an inquiry message was received.
11 -- Open Database File Exit Program (QIBM_QDB_OPEN).
0 -- Unknown cause.
Recovery . . . : If the reason code is 1, a client request was made to cancel SQL processing. For all other reason codes, see previous messages to determine why SQL processing was ended.
SQLState: 57014
ErrorCode: -952
Run Code Online (Sandbox Code Playgroud)
最后,如果你不能使用STRSQL,另一个解决方案就是使用iSeries Navigator,确切地说是它的"运行SQL脚本"(通常在这里 - >"%Program Files%\ IBM\Client Access\Shared\cwbundbs.exe ").
但首先你必须添加一个系统回复参数(每台机器只有一次)
ADDRPYLE SEQNBR(1500)MSGID(CPA32B2)RPY('I')
这是在"绿屏"中完成的.这在CPA32B2查询消息上设置了一个deafult答案('I').CPA32B2是一个内部按摩id,与drop column操作相关联.
(它实际上不必在"绿屏"中完成,像CHGJOB命令一样使用它.例如:
cl:ADDRPYLE SEQNBR(1500)MSGID(CPA32B2)RPY('I');
)
现在您可以启动"运行SQL脚本",第一个运行的命令是:
cl:CHGJOB INQMSGRPY(*SYSRPYL);
这会将当前作业参数INQMSGRPY更改为*SYSRPYL.*SYSRPYL会在显示查询消息时查看是否存在系统回复参数.
现在您可以运行删除列的alter.
不幸的是,我不知道如何使用JDBC来删除列.如果有人知道,请告诉我.
参考文献:
小智 5
最后我找到了解决方案:
CALL QSYS2.QCMDEXC('ADDRPYLE SEQNBR(1500) MSGID(CPA32B2) RPY(''I'')');
CALL QSYS2.QCMDEXC('CHGJOB INQMSGRPY(*SYSRPYL)');
ALTER TABLE <tablename> DROP COLUMN <column_name>;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12983 次 |
| 最近记录: |