sql - date comparison in mysql procedure -


i comparing date static values , variables here code

if v_next_date >= str_to_date('15/2/2014', '%m/%d/%y')        set v_next_date = date_format(v_date,'%2000-%m-%d'); elseif v_next_date = v_date  leave last_update; else   set v_next_date = date_add(v_next_date,interval 1 month); end if; 

in first if want compare static date , assign v_date v_next_date year should 2000. in second want compare 2 variables in third if want assign next month same date v_next_date.

edit: procedure don't complete, think there problem in comparison or assignment

edit: here full code ( procedure ):

create procedure accidents.`task_7_proce`() begin    declare v_finished integer default 0;   declare v_pkid integer;   declare v_mine integer;   declare v_date datetime;   declare v_lat integer;   declare v_lng integer;   declare v_next_date date;   declare integer default 0;   declare msg varchar(100) default 'no message';  declare weather_cursor cursor select pkid, mine_id, accident_dt, lat, lng                               test_unfilteredfull                               pkid = 46953; declare continue handler      not found set v_finished = 1; open weather_cursor;       fetch weather_cursor v_pkid, v_mine, v_date, v_lat, v_lng;      set v_next_date = date_add(v_date,interval 1 month);  last_update: loop         -- ******** update statement **************       update mytable mt inner join myvalues mv       on mv.date = v_next_date ,       mt.pkid = v_pkid        set mt.tmax = mv.tmax, mt.tmin = mv.tmin, mt.dayl= mv.dayl ,       mt.prcp = mv.prcp , mt.srad = mv.srad, mt.swe=mv.swe, mt.vp=mv.vp       mv.longitude_max >= v_lng ,        mv.longitude_min <= v_lng ,        mv.latitude_max >=  v_lat ,         mv.latitude_min <= v_lat;  if row_count() > 0    set msg = 'successfully updated!';    leave last_update; end if;  if v_next_date >= str_to_date('2/15/2014', '%m/%d/%y')    set v_next_date = date_format(v_date,'%2000-%m-%d'); elseif v_next_date = v_date   leave last_update; else   set v_next_date = date_add(v_next_date,interval 1 month);  end if;  end loop last_update; close weather_cursor; commit;    end; 


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -