我有一个查询,让我可以通过识别的 UserID 访问每个用户:
我的查询是:
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' )));
我想为此查询创建过程并将其结果保存在 ROW 中,并在 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;
你能帮帮我吗!!!