2014-10-31 6 views
0

내가 선택한 쿼리에서 호출되는 함수를 가지고, 아래는 완벽하게 작동하는 함수입니다.함수에서 PLSQL 호출 프로 시저

create or replace FUNCTION isLoggedIn(x IN VARCHAR2, y IN VARCHAR2) 
RETURN number IS 
boolean number(1) := 0; 
BEGIN 
SELECT count(*) into boolean 
FROM VIEWLOGIN 
WHERE username = x AND password = y; 

IF boolean = 1 THEN 
    PROCDURELOGIN 
    RETURN boolean;  
ELSE 
    RETURN 0; 
END IF; 
END; 

이 내 절차 : 나는 부울 로그인 테이블에 값을 삽입 1 = 경우 아래의 프로 시저를 호출 할

create or replace PROCEDURE PROCDURELOGIN 
IS 
BEGIN 
    INSERT INTO "SW3"."LOGIN" (LOGINID, MEMBERID) 
    VALUES (seqLogin.NEXTVAL, '1'); 
    Commit; 
END; 

Create view VIEWLOGIN 
SELECT firstname, surname, username, password 
FROM member 

하지만 쿼리를 실행할 때 오류를 얻을 :

Error starting at line : 1 in command - 
SELECT firstname, surname, isLoggedIn(username, password) 
FROM VIEWLOGIN 
WHERE username = 'fionawalshe' AND password = 'qwertyu8' 
Error report - 
SQL Error: ORA-14551: cannot perform a DML operation inside a query 
ORA-06512: at "SW3.PROCDURELOGIN", line 4 
ORA-06512: at "SW3.ISLOGGEDIN", line 10 
14551. 00000 - "cannot perform a DML operation inside a query " 
*Cause: DML operation like insert, update, delete or select-for-update 
      cannot be performed inside a query or under a PDML slave. 
*Action: Ensure that the offending DML operation is not performed or 
      use an autonomous transaction to perform the DML operation within 
      the query or PDML slave. 
+1

전화 해주세요. 질문은 무엇입니까? – OldProgrammer

+0

질문을 편집하고 VIEWLOGIN보기의 소스를 추가하십시오. 감사. –

답변

2

오라클은 오류 메시지에서 무엇이 문제인지 분명히 말합니다. 이것을 시도하십시오 :

create or replace PROCEDURE PROCDURELOGIN 
IS 
pragma autonomous_transaction; 
BEGIN 
    INSERT INTO "SW3"."LOGIN" (LOGINID, MEMBERID) 
    VALUES (seqLogin.NEXTVAL, '1'); 
    Commit; 
END; 

그런데 나는 그러한 절차가 마음에 들지 않으며 가능하면 사용하지 않을 것을 권장합니다.

+0

완벽하게 분류했습니다. –