MySQL Forums
Forum List  »  Stored Procedures

Re: Default values to input parameters
Posted by: Jay Pipes
Date: November 23, 2005 10:55AM

Srivats Chandrasekaran wrote:
> Is there neway i can assign default values to
> input parameters without modifying the code too
> much.

I don't really know what qualitative value "too much" stands for, but you could use COALESCE in your INSERT statement, which will place the default value if there is a NULL received in the input parameter:

INSERT INTO nb_seller_master(
nb_seller_name,
nb_seller_addrress_1,
nb_seller_addrress_2,
nb_seller_city,
nb_seller_state,
nb_seller_zip
)
VALUES(
COALESCE(nb_seller_name_gb, 'No name'),
COALESCE(nb_seller_address_1_gb, 'No Address 1'),
COALESCE(nb_seller_address_2_gb, 'No Address 2'),
COALESCE(nb_seller_city_gb, 'No City'),
COALESCE(nb_seller_state_gb, 'No State'),
COALESCE(nb_seller_zip_gb, 'No Zip')
);

Jay Pipes
Community Relations Manager, North America, MySQL Inc.

Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Default values to input parameters
1894
November 23, 2005 10:55AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.