Thursday, January 26, 2012

Passing NULL Values to Oracle API's

Oracle API's (mostly TCA related) always retains the current value from that table(column) if there is no value passed. Also it will not accept values if explicitly passed like NULL or single quotes ''.

In order to nullify an existing value Oracle has provided the below variables.
FND_API.G_MISS_NUM for NUMBER datatype
FND_API.G_MISS_CHAR for VARCHAR datatype
FND_API.G_MISS_DATE for DATE datatype

Additionally, the same FND_API will provide the values for any standard API statuses as well.

FND_API.G_RET_STS_SUCESS FOR success
FND_API.G_RET_STS_ERROR FOR ERROR
FND_API.G_STS_UNEXP_ERROR FOR ANY unexpected ERROR.

Since we are at API's topic wanted to add the standard API used to retrieve the message stack.
if any API returns errors/warnings. Most of the standard API will have three common OUT variables
x_return_status -- Returns Sucess/Error/Warning
x_msg_data -- Returns error message stack
x_msg_count --Returns messages count.



IF (v_return_status <> fnd_api.g_ret_sts_success)
      THEN
         FOR i IN 1 .. v_msg_count
         LOOP
            fnd_msg_pub.get (p_msg_index          => i,
                             p_data               => v_msg_data,
                             p_encoded            => fnd_api.g_false,
                             p_msg_index_out      => v_msg_index_out
                            );
            FND_FILE.PUT_LINE(fnd_file.log,v_msg_data);
         END LOOP;
END IF;

Let me know any comments or questions.