Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function call in a pl-sql block

Status
Not open for further replies.

Thiko

Programmer
Mar 9, 2001
49
GB
I have this function and I would like to call it in a pl-sql block in a script to see if the userid is in the permissions table, which is what the function does. How do I call this procedure in a pl-sql block?

CREATE OR REPLACE PACKAGE BODY dba_services AS
FUNCTION permissions (current_user IN VARCHAR2) RETURN NUMBER
IS
result NUMBER;
result2 NUMBER;
BEGIN
SELECT COUNT(user_id) INTO result FROM dba_users
WHERE username = current_user;
IF result > 0 THEN
SELECT user_id INTO result FROM dba_users
WHERE username = current_user;
END IF;
SELECT count(userid) INTO result2 FROM permissions
WHERE userid = result;
IF result2 > 0 THEN
SELECT userid INTO result2 FROM permissions
WHERE userid = result;
END IF;
RETURN result2;
END permissions;
Many Thanks.

Thiko!
 
Err, well
Code:
 result:=dba_services.permissions(user)
should work. Is that what you were asking for?

If you want to use real user, you can have it by doing
Code:
 SELECT user FROM dual;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top