本文介绍了oracle查询给出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我声明了一个可变的即srID 然后从select查询传递给它然后我试图传递这个变量值插入 in insert statment但它给出了我跟随错误: PL / SQL:ORA-00984:此处不允许列 以下是我的查询---I have declare one varaible i.e. srIDthen passed value to it from select query then i am trying to pass this variable value insertin insert statment but it giving me following error:PL/SQL: ORA-00984: column not allowed herebelow is my query---declare srID Number; begin select max(ID)+1 as ID into srID from table1; end; INSERT INTO table2 (ID) VALUES(srID)推荐答案declare srID Number;BEGIN SELECT ID INTO srID FROM ( SELECT MAX(ID)+1 AS ID FROM table1 ) AS T;END; INSERT INTO table2 (ID) VALUES(srID) 秒方式:Second way:INSERT INTO table2 (ID)SELECT MAX(ID)+1 AS IDFROM table1 http://docs.oracle.com/cd/E17952_01/refman-5.1-en/insert-select.html [ ^ ]CREATE SEQUENCE mySequence MINVALUE 1 MAXVALUE 999999999999999999999999999 START WITH 1 INCREMENT BY 1 CACHE 20; 使用序列生成表的唯一主键:Use the sequence to generate unique primary keys for the table:INSERT INTO myTable (id, name)VALUES (mySequence.nextval, 'Oh my ;-)'); b $ b 最好的问候 Espen HarlinnBest regardsEspen Harlinn 这篇关于oracle查询给出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
05-16 00:17