我想删除一个名为id
的列,它是一个自动递增的主键。
SQL:
alter table "CO88GT"."XGLCTL" drop column id cascade;
我得到了:
Error: [SQL0952] Processing of the SQL statement ended. Reason code 10.
SQLState: 57014
ErrorCode: -952
我可能错了,但我认为这与防止表丢失数据有关。为了解决这个问题,我需要创建一个没有列的新表,并将数据从旧表复制到新表中,然后用新表替换旧表。
发布于 2011-01-12 22:45:27
信息
由于数据可能丢失,AS400将向您发出警告(查询消息),要求您取消或忽略请求的操作。因此,由于这是一个交互式请求,在JDBC/ODBC上你不能输入'I‘来忽略,AS抛给你一个ErrorCode:-952,SQLState: 57014,原因代码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.
如果您使用的是JDBC,并且SQL错误不是不言而喻的,那么您可以使用参数'errors=full',建立一个JDBC连接,这将提供有关该错误的更多信息。有关其他连接参数,请参阅this。
连接字符串示例:
jdbc:as400://serverName;libraries=*libl;naming=system;errors=full;
使用该连接,产生的错误将如下所示:
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
解决方案
因此,最后,如果您不能使用STRSQL,另一种解决方案是使用IBM,确切地说是它的"Run SQL scripts“(通常在这里--> "%Program Files%\ iSeries \Client Access\Shared\cwbundbs.exe")。
但首先你必须添加一个系统回复参数(每台机器只有一次)
地址类型序号(1500)消息I(CPA32B2) RPY('I')
这是在“绿屏”中完成的。这将在CPA32B2查询消息上设置默认答案('I')。CPA32B2是一个与drop column操作绑定的内部消息id。
(实际上它不需要在“绿屏”中完成,可以像CHGJOB命令一样使用它。示例:
cl: ADDRPYLE SEQNBR(1500) MSGID(CPA32B2) RPY('I');
)
现在您可以启动"Run SQL scripts",第一个要运行的命令是:
cl: CHGJOB INQMSGRPY(*SYSRPYL);
这会将当前作业参数INQMSGRPY更改为*SYSRPYL。*SYSRPYL导致在应显示查询消息时查看是否存在系统回复参数。
现在您可以运行alter来删除列。
不幸的是,我不知道如何删除列,只知道使用JDBC。如果有人知道,请让我知道。
参考文献:
https://stackoverflow.com/questions/4504548
复制相似问题