Page 1 of 1

TOraObjects and member function/procedure

Posted: Tue 31 Jan 2012 13:16
by URIOS
Hello,

my question is in the subject : how can we call a member function or procedure of an Oracle object ?

We can modify attributes etc., but I don't see anything about members (not static members)...

Thanks for all,

Posted: Wed 01 Feb 2012 06:47
by AlexP
Hello,

For work with object methods, you can use ToraStoredProc, for example

Code: Select all

CREATE OR REPLACE TYPE MY_TYPE AS OBJECT
(MY_FIELD NUMBER
, MEMBER FUNCTION MY_METHOD RETURN NUMBER
)

OraStoredProc.StoredProcName := 'MY_TYPE.MY_METHOD';
When calling object method, the first parameter always must be a pointer to the object.

OraStoredProc.ParaByName('SELF') := <- reference to the created object
OraStoredProc.Execute;

Small bug

Posted: Wed 01 Feb 2012 20:53
by URIOS
Hello,

thanks for all.

I have found a little bug in TOraStoredProc and OraClasses.pas :

Line 10228, in TOciCommand.InitProcParams8 procedure,
TypeName:=PtrToStringOci, I added QuoteIfNeed the same as it is in
GetFieldDesc8.

Thank you,

Problem is...

Posted: Thu 02 Feb 2012 08:47
by URIOS
I cannot execute two member procedures... I've got an access violation
on OraClient10.dll in InitProcParams8 , line 9975 of oraClasses unit
Check(OCIAttrGet1(hParam, OCI_DTYPE_PARAM, ValuePtr, nil,
OCI_ATTR_LIST_ARGUMENTS, hOCIError));

My Code :

Code: Select all

OraType:=TOraType.Create(OraSession.OCISvcCtx,'"Mail"');
OraObject:=TOraObject.Create(OraType);
OraProc:=TOraStoredProc.Create(OraSession);
OraProc.Session:=OraSession;
OraProc.StoredProcName:='"Mail"."Init"';
OraProc.PrepareSQL;
OraProc.ParamByName('SELF').AsObject:=OraObject;
OraProc.ExecProc;
OraProc.StoredProcName:='"Mail"."AddSender"';
OraProc.PrepareSQL; 
OraProc.ParamByName('SELF').AsObject:=OraObject;
OraProc.ParamByName('SRECIPIENT').AsString:='[email protected]';
OraProc.ExecProc;
Error is at the second PrepareSQL...
Member procedure Init modifys Object...
Thanks for all,

Posted: Thu 02 Feb 2012 13:29
by AlexP
Hello,

Thank you for the information.
We have added the advised fix in OraClasses.
A script for creating your "Mail" object would be appriciated for reproducing the problem

Posted: Thu 02 Feb 2012 14:53
by URIOS
AlexP wrote:Hello,

Thank you for the information.
We have added the advised fix in OraClasses.
A script for creating your "Mail" object would be appriciated for reproducing the problem
Hello,

script is here :
http://dral.free.fr/Mail.7z
password is devart.com
just replace values in "Init" member function of "Mail" object to send mails.
You probably needs some rights :
grant execute on sys.utl_tcp
grant execute on sys.utl_smtp
GRANT EXECUTE ON SYS.DBMS_LOB

Thanks for all,

Posted: Fri 03 Feb 2012 11:12
by AlexP
Hello,

I created the objects you have presented, and the following code was executed with no errors.

Code: Select all

var
  OraStoredProc: TOraStoredProc;
  OraObject: TOraObject;
begin
  OraObject:= TOraObject.Create(TOraType.Create(OraSession1.OCISvcCtx,'"Mail"'));
  OraObject.AllocObject;
  OraObject.IsNull := False;
  OraStoredProc:= TOraStoredProc.Create(nil);
  OraStoredProc.Session := OraSession1;
  OraStoredProc.StoredProcName:='"Mail"."Init"';
  OraStoredProc.PrepareSQL;
  OraStoredProc.ParamByName('SELF').AsObject:=OraObject;
  OraStoredProc.ExecProc;
  OraStoredProc.StoredProcName:='"Mail"."AddSender"';
  OraStoredProc.PrepareSQL;
  OraStoredProc.ParamByName('SELF').AsObject:=OraObject;
  OraStoredProc.ParamByName('SSENDER').AsString:='[email protected]';
  OraStoredProc.ExecProc;
If any errors occur when executing this code, try calling these methods in the following anonymous block

Code: Select all

DECLARE
  MAIL "Mail";
BEGIN
  MAIL := "Mail"(); 
  MAIL."AddSender"('[email protected]'); 
END;
for example, in the standart SQL Plus
If the same errors occur, you probably have problems with the Oracle server.

Posted: Wed 08 Feb 2012 15:30
by URIOS
Hello,

you tried with 10g client (mine is 10.2.0.5)?
In fact, with
BEGIN
END;
it works well,
but it's not in my idea : we wants to generalize use of Oracle Objects
in our Database...

Thanks for all,

Posted: Thu 09 Feb 2012 13:32
by AlexP
Hello,

We have checked the code above at several client versions and didn't find the problem you have described.

Posted: Fri 24 Feb 2012 10:45
by URIOS
Hello,

OK, thank you...

Posted: Fri 24 Feb 2012 10:48
by URIOS
Just another question please...

Do you have some tutorials using ODAC with DATASNAP ?
I think that we have to use TOraProvider, but if you have any information that should help me,
It's a pleasure...


Thank you,

Posted: Fri 24 Feb 2012 11:33
by AlexP
Hello,

We have no examples of our products' work with DataSnap, however, you can use the standart Delphi DataSnap samples by replacing the Delphi DB components with appropriate ODAC components.