Empty string being stored as null and need to differentiate between null and empty string in Orade

53 views Asked by At

I have a stored procedure which is receiving the data from an API.

The stored procedure looks like this:

Demo_proc(Id in number,
          First_name in varchar2,
          Middle_name in varchar2,
          Last_name in varchar2)

This middle_name parameter can contain null as well as empty string but first_name and last_name parameters are not null. The data that is received from the API, I am directly storing into a database table demo which looks like this:

Create table Demo
(
    Id number primary key,
    First_name varchar2 (100),
    Last_name varchar2 (100),
    Middle_name varchar2 (100)
)

I have another stored procedure that is retrieving the data from the database table Demo and returning it to the API:

     Demo_ret(Id in number,
              P_demo_dtls sys_refcursor)

This p_demo_dtls will return first_name, middle_name, last_name columns from the demo table for the Id passed in as input.

The issue is since middle_name column contains null value even if API passes empty string, then it return null value through demo_ret procedure, because of which in API middle_name column is not getting displayed.

They want me to make changes in the database to differentiate between empty string and null value, sSuch that if they have passed an empty string in input they receive empty string in output via the demo_ret stored procedure.

0

There are 0 answers