Create A View Column with Data Type varchar2(32) and NULL Value

I am trying to create a view in Oracle, inside the view there is a column with null value, but I want the column to be varchar2(32) data type, I try to use cast but the data type still remain as varchar2(0), please advise, the code is roughly as below

create view a
as
select <column>,null from <table>

I make it as below but the data type is still varchar2(0) for the null value
create view a
as
select <column>,cast(null as varchar2(32)) from <table>


scissorhandAsked:
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.

johnsoneSenior Oracle DBACommented:
Not sure why you want it to show as VARCHAR2(32), but you are going to have to fool Oracle into getting it that way.  Oracle knows that null can only ever be 0, so that is why you are getting that.  If you fool Oracle into thinking it can have an actual value other than null, the cast will work.

Something like this:

select <column>, cast(decode('A', 'A', null) as varchar2(32)) from <table>

It will always be null, but the datatype will show as varchar2(32).
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
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
Oracle Database

From novice to tech pro — start learning today.