TOraObjects and member function/procedure

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
URIOS
Posts: 9
Joined: Tue 31 Jan 2012 10:08

TOraObjects and member function/procedure

Post by URIOS » Tue 31 Jan 2012 13:16

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,

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Wed 01 Feb 2012 06:47

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;

URIOS
Posts: 9
Joined: Tue 31 Jan 2012 10:08

Small bug

Post by URIOS » Wed 01 Feb 2012 20:53

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,

URIOS
Posts: 9
Joined: Tue 31 Jan 2012 10:08

Problem is...

Post by URIOS » Thu 02 Feb 2012 08:47

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,

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Thu 02 Feb 2012 13:29

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

URIOS
Posts: 9
Joined: Tue 31 Jan 2012 10:08

Post by URIOS » Thu 02 Feb 2012 14:53

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,

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Fri 03 Feb 2012 11:12

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.

URIOS
Posts: 9
Joined: Tue 31 Jan 2012 10:08

Post by URIOS » Wed 08 Feb 2012 15:30

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,

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Thu 09 Feb 2012 13:32

Hello,

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

URIOS
Posts: 9
Joined: Tue 31 Jan 2012 10:08

Post by URIOS » Fri 24 Feb 2012 10:45

Hello,

OK, thank you...

URIOS
Posts: 9
Joined: Tue 31 Jan 2012 10:08

Post by URIOS » Fri 24 Feb 2012 10:48

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,

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Fri 24 Feb 2012 11:33

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.

Post Reply