Pass NULL to Oracle stored procedure

Hi,

I've got some server-side VBScript passing parameters to an Oracle stored procedure.

What I can't get to work, is passing a NULL value.

Lets say I have a stored procedure defined as:

        CREATE OR REPLACE PROCEDURE my_proc(date_in DATE)

And VBScript calling it:

      Set objCommand = Server.CreateObject("ADODB.Command")
      Set objCommand.ActiveConnection = objConnection
      On Error Resume Next
      With objCommand
            .CommandText = "my_proc"
            .CommandType = 4
            .Parameters.Append .CreateParameter("date_in", 133, 1, 4, date_val)
            .Execute()
      End With

Is it possible to pass a NULL to the stored procedure as the date is optional? Everything I've tried has failed.


Thanks in advance,

Leon
LVL 1
leonstAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
Set objCommand = Server.CreateObject("ADODB.Command")
     Set objCommand.ActiveConnection = objConnection
     On Error Resume Next
     With objCommand
          .CommandText = "my_proc"
          .CommandType = 4
          .Parameters.Append .CreateParameter("date_in", 133, 1, 4, NULL)
          .Execute()
     End With

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
leonstAuthor Commented:
When I execute this (by submitting a form) the browser throbber runs for 10 mins and then I get "This page contains no data".
0
Graham HirstIT EngineerCommented:
I know that NULL in Oracle is NVL, but I am not sure if this is the same as passing it through into a SP.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

hongjunCommented:
Another method is not to first give a default value to your parameter NULL.
    CREATE OR REPLACE PROCEDURE my_proc(date_in DATE=NULL)

Then in your asp, don't pass in a parameter.

hongjun
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>When I execute this (by submitting a form) the browser throbber runs for 10 mins and then I get "This page contains no data".

how long does the procedure run when you run in manually (sql*plus ...)?
0
leonstAuthor Commented:
Angellll: It's a simple procedure which takes <1s to run manually.
0
leonstAuthor Commented:
Well, I've tried this again and it's working fine now.

Very strange.

The working command is:

objCommand.Parameters.Append objCommand.CreateParameter("date_in", 133, 1, 4, NULL).

So points to Angellll, many thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.