IF v_docType = 3 THEN
update T_PATIENT_INFO set USER_NAME =userName ,SEX = v_sex,BIRTHDAY = to_date(brithday,'YYYYMMDD'), ID_NUMBER = idNumber,PROVINCE_NO = provinceId,CITY_NO = cityId,COUNTRY_NO = countryId,
ADDRESS = address,CREATE_USER_ID = addUserId,DOCTOR_ID = addUserId
where MOBILE = phone;
ELSE if v_docType=2 then
update T_PATIENT_INFO set USER_NAME =userName ,SEX = v_sex,BIRTHDAY = to_date(brithday,'YYYYMMDD'), ID_NUMBER = idNumber,PROVINCE_NO = provinceId,CITY_NO = cityId,COUNTRY_NO = countryId,
ADDRESS = address,CREATE_USER_ID = addUserId,DOCTOR_ID = addUserId,COMMUNITY_ID = addUserId
where MOBILE = phone;
else
update T_PATIENT_INFO set USER_NAME =userName ,SEX = v_sex,BIRTHDAY = to_date(brithday,'YYYYMMDD'), ID_NUMBER = idNumber,PROVINCE_NO = provinceId,CITY_NO = cityId,COUNTRY_NO = countryId,
ADDRESS = address,CREATE_USER_ID = addUserId,COMMUNITY_ID = addUserId
where MOBILE = phone;
end if;
END IF;
這里BIRTHDAY 傳過來的是'YYYYMMDD'類型的字符串,貳表里面該字段的存儲類型是Date,就需要在sql里面進行類型轉換,這就是一個轉換的語句,可以供其他地方參考!
下面這種情況是取得時候直接在sql里面把date轉為vcharge
SELECT A.RECORD_ID,A.PAPER_ID,TO_CHAR(A.CREATE_TIME,'yyyy-mm-dd hh24:mi') CREATE_TIME,B.PAPER_TITLE,v_advice_txt ADVICE_CONTENT,v_wj_score SCORE,v_score_desc SCOREDESC
FROM T_RECORD_PAPER A INNER JOIN T_PAPER B
ON A.PAPER_ID=B.PAPER_ID WHERE A.Record_Id=v_recordId;
這里的TO_CHAR to_date 都是oracle的內置函數,沒試過在mysql中能不能適用,應該是不區分大小寫的
再來一點
v_start IN NUMERIC,
v_end IN NUMERIC,
and to_char(a.create_time, 'YYYYMMDD') >= v_start
and to_char(a.create_time, 'YYYYMMDD') <= v_end
這里也是可以的,字符與數值進行運算,v_start的格式是160809,oracle的強大靈活,服了吧!
再來一點
--插入醫生用戶信息表
insert into T_DOCTOR_INFO(DOCTOR_ID,USER_NAME,MOBILE,EMAIL,SEX,BIRTHDAY,HOSPITAL_ID,DEPT_ID,JOBTITLE_ID,INTRODUCE,SOURCE,DOCTOR_TYPE)
values(v_userId,USER_NAME,MOBILE,EMAIL,SEX,to_date(BIRTHDAY,'yyyy/mm/dd'),HOSPITAL_ID,DEPT_ID,JOBTITLE_ID,INTRODUCE,SOURCE,DOCTOR_TYPE);
這里表中的BIRTHDAY是 date ,貳傳過來的參數是yyyy/mm/dd的字符串
還有這個:
INSERT INTO T_FRIEND_GROUP_INFO
(GROUP_ID,GROUP_NAME,GROUP_TYPE,USER_ID,CREATE_TIME)
VALUES
(1,'我的病人',1,v_userId,SYSDATE);
自動獲取當前時間SYSDATE
又一個轉換: vWTTime:=TO_DATE(v_Time,'yyyy-mm-dd,hh24:mi:ss');
