lundi 31 août 2015

how to trim incoming values in a stored procedure in mysql?

I have my stored procedure defined as following:

CREATE PROCEDURE `customers`(
IN `in_customer_name` VARCHAR(255),
IN `in_primary_contact` VARCHAR(255), 
IN `in_phone` VARCHAR(255),
IN `in_email` VARCHAR(255), 
IN `in_address` VARCHAR(255),
IN `in_city` VARCHAR(255), 
IN `in_state` VARCHAR(255),
IN `in_zip` VARCHAR(255),
IN `in_tenant_id` INT(11),
IN `cus_id` INT(11),
IN `con_id` INT(11),
IN `loc_id` INT(11),
IN `usr_id` INT(11))


BEGIN

    DECLARE cont_name, cont_phone, cont_email, loc_address, loc_city, loc_state, loc_zip, cont_id VARCHAR(255);

the problem is that sometimes the incoming values have trailing spaces in left or right. I've heard of LTRIM and RTRIM, but I'm not sure if I can use them in incoming values and not just values selected from the database, and if so I can use them I don't know exactly how I can use them. Any ideas?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire