1

After facing the problem:

ORA-32108: max column or parameter size not specified

I researched a little and I found these two questions: Why does Oracle 9i treat an empty string as NULL? and Oracle not distinguishing between nulls and empty strings? .


These questions explain the error I get. But this led me to the next question - how can I return empty string as a field value in a ResultSet in Oracle?


What I have so far is:

  • create the statement
  • register output parameter as oracle::occi::OCCICURSOR
  • execute the statement
  • the I call GetCursor to use the returned resultset

The execute fails, because of the error, described above.

So, how can I return such field in the resultset, which has value an empty string ('')?

In other words, I don't know how to apply the action, specified HERE - is it something server-side? Or I should add something in my code? Or in the stored procedure, that returns this resultset?


I use OCCI (Oracle C++ Call Interface). My current workaround is to return a string, containing a single space (' '), but I don't like it.

3
  • This means you want a completely null column returned? You could see if cast will work, cast( null as varchar2(1)). Commented Dec 17, 2012 at 11:28
  • Ah, this cast works like a charm! Thanks! Can you add it as an answer? Commented Dec 17, 2012 at 11:36
  • I'm glad! I've added it as an answer. Commented Dec 17, 2012 at 11:44

1 Answer 1

2

If you want a completely NULL column returned you can use CAST(), which converts one data type into another.

For instance the following would generate a completely null column.

select a.*, cast(null as varchar2(1)) as null_column
  from my_table a

But, the database now understands that this should be a column of VARCHAR2(1), whereas if you use null as null_column there has been no maximum length specified.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.