Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top