Pass Null value for Number field in PL/SQL from C#

ASPDEV
ASPDEV used Ask the Experts™
on
Hello Experts,

I have a issue while inserting null into oracle database from .NET application. I have a field Phone  which is number in database, but want to insert null  when it's passed as parameter value and from application I also need to format the data(string value) and remove any symbols and insert just number.

E.g. 123-456-7890 should be 1234567890
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Distinguished Expert 2018
Commented:
If you aren't using ODP.Net as your data provider, you need to be.  The new Managed Client doesn't require any client install.

You can get it here:
https://www.oracle.com/database/technologies/appdev/dotnet/odp.html

To get a null, use DBNull.Value as the parameter value:
https://docs.oracle.com/cd/E85694_01/ODPNT/ParameterValue.htm


As for formatting your string, that should be left to the .Net code.  Should be a simple regex replace?

Quick example here:
http://www.beansoftware.com/NET-Tutorials/format-string-phone-number.aspx

Author

Commented:
Thanks, it works.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial