In Delphi, how to create a OracleParameter with a integer value?

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
labate
Posts: 48
Joined: Tue 17 Jan 2006 13:57
Location: Switzerland, Sion

In Delphi, how to create a OracleParameter with a integer value?

Post by labate » Mon 12 Feb 2007 17:22

Hi,

I'm working in Delphi 2006, and I would like to call a Oracle stored procedure that takes two parameters. The 1st one is a string and the 2nd one an integer.

For the string one, there's no problem, I do :

Code: Select all

command.Parameters.Add('p_mystring', mystring);
Now for the integer paramter, I don't know how to pass it, because the value must be of type TObject and Integer is a primitive type, not a class.

So the following code fails, and the compiler tells that Object and Integer are incompatible types :

Code: Select all

command.Parameters.Add('p_myInteger', OracleDbType.Integer).Value := myInteger;
I've asked a Delphi programmer here, and he told me that integer is a primitive type, and there is no wrapper class that inherits from TObject.

So if you have a suggestion about how to create a OracleParameter with an integer value in Delphi, thank you to tell me.

Thanks.
Adriano

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Mon 12 Feb 2007 17:57

What type of project do you create?
OraDirect .NET is ADO.NET data provider, so you should create "Delphi for .NET" application.

labate
Posts: 48
Joined: Tue 17 Jan 2006 13:57
Location: Switzerland, Sion

Post by labate » Mon 12 Feb 2007 18:07

Hi Alexey,

When I created the project, I choose :
.NET Delphi Projects > ASP.NET Web Service Application

My application is in fact a web service, and I use Core Lab OraDirect .NET in direct mode.

Adriano

labate
Posts: 48
Joined: Tue 17 Jan 2006 13:57
Location: Switzerland, Sion

Post by labate » Tue 13 Feb 2007 09:24

Ok, I finally found the solution.

The correct code is :

Code: Select all

command.Parameters.Add('p_nbPrintUnits', OracleDbType.Integer).Value := System.Object(nbPrintUnits);
In fact I was misguided by the fact that the Value property is referenced by Delphi to be a TObject, not an System.Object.

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Thu 15 Feb 2007 07:19

Yes, for web services it is right solution.

Post Reply