Is someone able to help, please? I can't run a procedure from Visual Basic if I use any log-in to Oracle other than the one which created it.
I log into Oracle from VB as follows (not as the package / procedure creator, not in that schema):
Set OraSession = CreateObject("OracleInProcServer.XOraSession")
Set OraDatabase = OraSession.OpenDatabase("CPAYT", "myname/mypassword", ORADB_DEFAULT)
OraDatabase.Parameters.Add "pDept", "Init", ORAPARM_INPUT
OraDatabase.Parameters("pDept").serverType = ORATYPE_VARCHAR
OraDatabase.Parameters("pDept").Value = strDepartment
OraDatabase.Parameters.Add "pSurname", "Init", ORAPARM_INPUT
OraDatabase.Parameters("pSurname").serverType = ORATYPE_VARCHAR
OraDatabase.Parameters("pSurname").Value = UCase(Me.txtSurname.Text)
Set OraDynaset = OraDatabase.CreatePlsqlDynaset _
("BEGIN Pkg9.spPersonSearchpDept, Surname, :Surret); End;", _
"SurRet", 0&)
and so on.
On Oracle I have created the following package / procedure:
CREATE OR REPLACE PACKAGE Pkg9 AS
TYPE empcur IS REF CURSOR;
PROCEDURE spPersonSearch
(
pDept IN varchar2,
pSurname IN varchar2,
SurRet IN OUT empcur
) ;
END Pkg9;
/
CREATE OR REPLACE PACKAGE BODY Pkg9
AS
PROCEDURE spPersonSearch
( pDept IN varchar2,
pSurname IN varchar2,
SurRet IN OUT empcur )
IS
BEGIN
if SurRet%ISOPEN
then
close SurRet;
end if;
open SurRet for
SELECT DISTINCT TUER_PEOPLE_V.PERSONAL_REFERENCE, TUER_PEOPLE_V.SURNAME Surname, TUER_PEOPLE_V.FORENAME1 Forename
FROM
TUNIT_STRUCT_V TUV, TPARTY_LNK RDL,
TPARTY RDN, TPARTY POSITION_NAME, TUER_PEOPLE_V TUER_PEOPLE_V, TPER_PARTY TPER_PARTY, TPARTY CONTRACT_NAME, TPARTY_LNK TPARTY_LNK
WHERE
RDL.PARTY_ID2 = RDN.PARTY_ID
AND TUV.LEAF = RDN.PARTY_ID
AND RDL.PARTY_ID = POSITION_NAME.PARTY_ID
AND TUER_PEOPLE_V.PERSON_ID = TPER_PARTY.PERSON_ID
AND TPER_PARTY.PARTY_ID = CONTRACT_NAME.PARTY_ID
AND CONTRACT_NAME.PARTY_ID = TPARTY_LNK.PARTY_ID
AND POSITION_NAME.PARTY_ID = TPARTY_LNK.PARTY_ID2
AND (TPARTY_LNK.PARTY_LNK_D <=sysdate OR TPARTY_LNK.PARTY_LNK_D Is Null) AND TUV.UNIT_NM_01 = 'COL'
AND TUV.UNIT_ID_02= pDept AND TPARTY_LNK.LINK_TYPE_ID = 'CONT' AND
TPARTY_LNK.TEAM_PARTY_ID Is Null AND RDN.OBJECT_TYPE = 'UNIT'
AND TUER_PEOPLE_V.SURNAME = pSurname
ORDER BY TUER_PEOPLE_V.SURNAME, TUER_PEOPLE_V.FORENAME1;
EXCEPTION
when NO_DATA_FOUND then
Null;
END spPersonSearch;
END Pkg9;
/
I received the following error message:
ORA-06550: line 1, column 7: PLS-00201: identifier 'PKG9.SPPERSONSEARCH' must be declared
I've tried granting permissions on the package and the procedure, in many ways, but without success. e.g.
SQL> grant execute on spPersonSearch to PUBLIC;
grant execute on spPersonSearch to PUBLIC
*
ERROR at line 1:
ORA-04042: procedure, function, package, or package body does not exist
SQL> grant execute on Pkg9.spPersonSearch TO PUBLIC
2 /
grant execute on Pkg9.spPersonSearch TO PUBLIC
*
ERROR at line 1:
ORA-04042: procedure, function, package, or package body does not exist
SQL> grant execute on Pkg9 TO PUBLIC
2 /
Grant succeeded.
SQL> grant execute on spPersonSearch To PUBLIC
2 /
grant execute on spPersonSearch To PUBLIC
*
ERROR at line 1:
ORA-04042: procedure, function, package, or package body does not exist
If anyone can help, I'd be very grateful.
Thanks
Mike
I log into Oracle from VB as follows (not as the package / procedure creator, not in that schema):
Set OraSession = CreateObject("OracleInProcServer.XOraSession")
Set OraDatabase = OraSession.OpenDatabase("CPAYT", "myname/mypassword", ORADB_DEFAULT)
OraDatabase.Parameters.Add "pDept", "Init", ORAPARM_INPUT
OraDatabase.Parameters("pDept").serverType = ORATYPE_VARCHAR
OraDatabase.Parameters("pDept").Value = strDepartment
OraDatabase.Parameters.Add "pSurname", "Init", ORAPARM_INPUT
OraDatabase.Parameters("pSurname").serverType = ORATYPE_VARCHAR
OraDatabase.Parameters("pSurname").Value = UCase(Me.txtSurname.Text)
Set OraDynaset = OraDatabase.CreatePlsqlDynaset _
("BEGIN Pkg9.spPersonSearchpDept, Surname, :Surret); End;", _
"SurRet", 0&)
and so on.
On Oracle I have created the following package / procedure:
CREATE OR REPLACE PACKAGE Pkg9 AS
TYPE empcur IS REF CURSOR;
PROCEDURE spPersonSearch
(
pDept IN varchar2,
pSurname IN varchar2,
SurRet IN OUT empcur
) ;
END Pkg9;
/
CREATE OR REPLACE PACKAGE BODY Pkg9
AS
PROCEDURE spPersonSearch
( pDept IN varchar2,
pSurname IN varchar2,
SurRet IN OUT empcur )
IS
BEGIN
if SurRet%ISOPEN
then
close SurRet;
end if;
open SurRet for
SELECT DISTINCT TUER_PEOPLE_V.PERSONAL_REFERENCE, TUER_PEOPLE_V.SURNAME Surname, TUER_PEOPLE_V.FORENAME1 Forename
FROM
TUNIT_STRUCT_V TUV, TPARTY_LNK RDL,
TPARTY RDN, TPARTY POSITION_NAME, TUER_PEOPLE_V TUER_PEOPLE_V, TPER_PARTY TPER_PARTY, TPARTY CONTRACT_NAME, TPARTY_LNK TPARTY_LNK
WHERE
RDL.PARTY_ID2 = RDN.PARTY_ID
AND TUV.LEAF = RDN.PARTY_ID
AND RDL.PARTY_ID = POSITION_NAME.PARTY_ID
AND TUER_PEOPLE_V.PERSON_ID = TPER_PARTY.PERSON_ID
AND TPER_PARTY.PARTY_ID = CONTRACT_NAME.PARTY_ID
AND CONTRACT_NAME.PARTY_ID = TPARTY_LNK.PARTY_ID
AND POSITION_NAME.PARTY_ID = TPARTY_LNK.PARTY_ID2
AND (TPARTY_LNK.PARTY_LNK_D <=sysdate OR TPARTY_LNK.PARTY_LNK_D Is Null) AND TUV.UNIT_NM_01 = 'COL'
AND TUV.UNIT_ID_02= pDept AND TPARTY_LNK.LINK_TYPE_ID = 'CONT' AND
TPARTY_LNK.TEAM_PARTY_ID Is Null AND RDN.OBJECT_TYPE = 'UNIT'
AND TUER_PEOPLE_V.SURNAME = pSurname
ORDER BY TUER_PEOPLE_V.SURNAME, TUER_PEOPLE_V.FORENAME1;
EXCEPTION
when NO_DATA_FOUND then
Null;
END spPersonSearch;
END Pkg9;
/
I received the following error message:
ORA-06550: line 1, column 7: PLS-00201: identifier 'PKG9.SPPERSONSEARCH' must be declared
I've tried granting permissions on the package and the procedure, in many ways, but without success. e.g.
SQL> grant execute on spPersonSearch to PUBLIC;
grant execute on spPersonSearch to PUBLIC
*
ERROR at line 1:
ORA-04042: procedure, function, package, or package body does not exist
SQL> grant execute on Pkg9.spPersonSearch TO PUBLIC
2 /
grant execute on Pkg9.spPersonSearch TO PUBLIC
*
ERROR at line 1:
ORA-04042: procedure, function, package, or package body does not exist
SQL> grant execute on Pkg9 TO PUBLIC
2 /
Grant succeeded.
SQL> grant execute on spPersonSearch To PUBLIC
2 /
grant execute on spPersonSearch To PUBLIC
*
ERROR at line 1:
ORA-04042: procedure, function, package, or package body does not exist
If anyone can help, I'd be very grateful.
Thanks
Mike