I am creating a stored procedure in Mysql. How can I pass value that will accept null?

I know that in SQL Server 2008 R2, I do like this

@name varchar(10) = null

but how can I do this in Mysql?

    DELIMITER $$
         CREATE PROCEDURE `ipm_website`.`uspInsertFuelBuyDetails`( promotion_code VARCHAR(45)=NULL,eventid INT,Erid INT, first_name VARCHAR(255)=NULL,last_Name)
     BEGIN
       INSERT INTO ipm_fuel.TBL_EVENT_PAYMENTS 
      (promotion_code, EVENT_ID, EVENT_RATE_ID, FIRST_NAME, LAST_NAME, PHONE_NUMBER, EMAIL, ADDRESS1, ADDRESS2,
       CITY, STATE, ZIPCODE, card_type, card_number, exmonth, exyear, total_amount,
        admin_fee, license_plate, guid, date_added) 
VALUES (promotion_code, eventid, Erid ,first_name ,last_Name ,phoneNo , email, address1, address2, city , state, ZIPCODE, card_type, card_no, exmonth, exyear, total_amount, admin_fee, licanse_plate,
         guid, date_added);
       END$$
    DELIMITER ;

How can I do that, and how to allow null value in parameters?

有帮助吗?

解决方案

In your query there's no need to pass the NULL, you can simply skip the column where you want to put NULL in the insert clause.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top