0
我,讓我通過識別用戶名每個用戶的訪問查詢創建過程如何從選擇查詢
SELECT A.ACTIONID,A.ACTIONNAME,A.ALLOWWRITE,A.ALLOWREAD
FROM THP.TBACTION A
WHERE A.ACTIONID IN (SELECT AP.ACTIONID
FROM THP.TBACTION_PROFILE AP
WHERE AP.PROFID IN(SELECT P.PROFID
FROM THP.TBPROFILE P
WHERE P.PROFID IN(SELECT U.PROFID
FROM THP.TBUSER U
WHERE U.USERID='1')));
,我想使程序此查詢並保存該結果在一排和ESQL
調用這個過程中,如IBM Message Broker的軟件,我用這個程序,但不適合結果:
create or replace
PROCEDURE SELECT_ACTION (
P_USERID IN NUMBER,
RESULT OUT NUMBER)IS
CNT NUMBER;
BEGIN
RESULT := 1;
CNT := 0;
SELECT COUNT(1) INTO CNT FROM THP.TBUSER WHERE USERID = P_USERID ;--AND SERIALTOKEN= P_SERIALTOKEN;
IF CNT = 1 THEN
BEGIN
SELECT A.ACTIONID,A.ACTIONNAME,A.ALLOWWRITE,A.ALLOWREAD
FROM THP.TBACTION A
WHERE A.ACTIONID IN (SELECT AP.ACTIONID
FROM THP.TBACTION_PROFILE AP
WHERE AP.PROFID IN(SELECT P.PROFID
FROM THP.TBPROFILE P
WHERE P.PROFID IN(SELECT U.PROFID
FROM THP.TBUSER U
WHERE U.USERID=P_USERID)));
COMMIT;
RESULT :=0; -- ROW was Found
END;
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RESULT := 3;
WHEN OTHERS THEN
RESULT := 4;
END SELECT_ACTION;
請你幫幫我!