I have the following function in PLSQL which connects remotely to different Database Links to change passwords:
FUNCTION fun_change_password(DB_LINK_VARIABLE varchar2)
RETURN binary_integer IS
jobid binary_integer;
BEGIN
dbms_job.submit@DB_LINK_VARIABLE (jobid,'begin execute immediate ''alter user MYUSER identified by mypassw''; end;');
COMMIT;
RETURN jobid;
END;
My goal is to specify which DB Link to use sending its name in a varchar2 variable called *DB_LINK_VARIABLE*. But when I compile this into a package, the parser sends me an error:
PLS-00352: Unable to access another database 'DB_LINK_VARIABLE'
Obviously, I pre-configured and tested all my datalinks and works perfectly.
How can I use variable 'DB_LINK_VARIABLE' into this code?
CREATE OR REPLACE FUNCTION pro_test (pv_dblink VARCHAR2) IS emp_refcur SYS_REFCURSOR; empno VARCHAR2(20); ename VARCHAR2(20); BEGIN OPEN emp_refcur FOR 'SELECT empno, ename FROM emp@'||pv_dblink; LOOP FETCH emp_refcur into empno,ename; EXIT WHEN emp_refcur%NOTFOUND; DBMS_OUTPUT.PUT_LINE('Employee no: '||empno||'/ Employee name: '||ename); END LOOP; END;