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

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

Postby 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
labate
 
Posts: 48
Joined: Tue 17 Jan 2006 13:57
Location: Switzerland, Sion

Postby 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.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby 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

Postby 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.
labate
 
Posts: 48
Joined: Tue 17 Jan 2006 13:57
Location: Switzerland, Sion

Postby Alexey » Thu 15 Feb 2007 07:19

Yes, for web services it is right solution.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43


Return to dotConnect for Oracle