passing Oracle Nulls into a parameter

C

Craig G

how do you pass a null into an oracle parameter?

i am doing the following which works fine when there is data to be passed in
but when the string is blank it wont accept "" or even as a system.dbnull

'Parameter for Address1

Dim parAddress1 As OracleClient.OracleParameter

parAddress1 = cmdInsert.Parameters.Add("strAddress1",
OracleClient.OracleType.VarChar)

parAddress1.Direction = ParameterDirection.Input



parAddress1.Value = Strings.UCase(strAddress1)



if have tried doing something like this

If strAddress1 = "" Then

parAddress1.Value = myDBNull (which is simply a variable as type
system.dbnull)

end if

but still no joy



Cheers,
Craig
 
D

David Browne

Craig G said:
how do you pass a null into an oracle parameter?

i am doing the following which works fine when there is data to be passed
in
but when the string is blank it wont accept "" or even as a system.dbnull

'Parameter for Address1

Dim parAddress1 As OracleClient.OracleParameter

parAddress1 = cmdInsert.Parameters.Add("strAddress1",
OracleClient.OracleType.VarChar)

parAddress1.Direction = ParameterDirection.Input



parAddress1.Value = Strings.UCase(strAddress1)



if have tried doing something like this

If strAddress1 = "" Then

parAddress1.Value = myDBNull (which is simply a variable as type
system.dbnull)

end if

but still no joy
Either

parAddress1.Value = ""
or
parAddress1.Value = DbNull.Value


will pass a NULL to Oracle.
As Oracle refuses to distinguish between a null and an empty string.

David
 
C

Craig G

if found that it didnt like parAddress.Value = ""

came back with an error saying the size was not set for that parameter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top