1
I created a script in Oracle that runs on an Owner, selects on several others and updates on another Owner on another server through a linkedserver.
Due to the fact of making select in multiple Wners I created the selects in this way:
vSQL_STMT := 'SELECT campo1, campo2... FROM empresa.TBLTABELA A WHERE CDNIVELCTL = 0 AND STCOTEJ = 'S' ...'
vSQL_STMT2 := REPLACE( vSQL_STMT, 'empresa', 'XXXX' || rec.CDBASEDADOS );
EXECUTE IMMEDIATE vSQL_STMT2 into vNRITENSCOT,vNRITENSSOBRASCTB,vNRITENSSOBRASFIS,vNRCOTDIRETO,...
The variable empresa
is changed at runtime to select in the correct Owner.
And executed INSERT
through LINKEDSERVER.
INSERT INTO TABELA@LINKEDSERVER VALUES( vCDJOB, vNRITENSCOT,....
If I run the script manually in Sqldeveloper everything runs normally and works as expected.
However, if I turn this script into Procedure to run it automatically through a program, although no error occurs the script does not work, ie the server table is not fed.
Does anyone know how to resolve this issue?
I had similar problems when the Owner where the package was created did not have Grants for the other Owners, there was no exception, only when the immediate run was accompanied by a block of Exception.
– Confundir