用于选择列值的SQL过程

时间:2015-11-24 08:44:22

标签: sql oracle

我想用一些select和insert语句编写一个sql过程。但是我收到了一些错误。我无法弄清问题是什么。请帮助我。

以下是我得到的错误:

  

错误(15,1):PL / SQL:语句被忽略
  错误(15,22):PLS-00201:必须声明标识符'PROJECT_ID'

代码:

INSERT INTO #t1 (IDBG1, BG1, IDBG2, BG2, IDBG3, BG3, IDBG4, BG4)
VALUES (102, 'BS', 302, 'SL', 345, 'AS', 75, 'LT')
    , (103, 'BS', 302, 'SL', 345, 'AS', 75, 'LT')

INSERT INTO #t2 (IDBG1, BG1, IDBG2, BG2)
VALUES (900, 'SM', 789, 'CS')
    , (901, 'SM', 789, 'CS')

INSERT INTO #t3(IDBG1, BG1, IDBG2, BG2, IDBG3, BG3, IDBG4, BG4, IDBG5, BG5, IDBG6, BG6) 
SELECT t1.IDBG1, t1.BG1, t1.IDBG2, t1.BG2, t1.IDBG3, t1.BG3, t1.IDBG4, t1.BG4 
    , [IDBG5] = t2.IDBG1, [BG5] = t2.BG1, [IDBG6] = t2.IDBG2, [BG6] = t2.BG2
FROM #t1 t1 CROSS JOIN #t2 t2

SELECT * FROM #t1
SELECT * FROM #t2
SELECT * FROM #t3

2 个答案:

答案 0 :(得分:4)

您在project_id声明中遇到语法错误。

create or replace
PROCEDURE UPDATION 
(
 NO_IN IN VARCHAR2  
) IS 
project_id defects.reference_id%type;

BEGIN
Select REFERENCE_ID INTO project_id from DEFECTS where ID=NO_IN;
dbms_output.put_line(project_id );

if project_id is not null then
dbms_output.put_line('proj not null');
end if;
end;

答案 1 :(得分:0)

  第6行    poject _id defects.reference_id%type;

     

项目*