UPDATE r_CloudBillQuery SET FFieldKeys = N'/*dialect*/  
select m1.FNumber MTRL_ID,ml.FName MTRL_NAME,FSpecification MTRL_DESC,FErpClsID PROD_MTYPE,FMinPackCount PACK_QTY,ul.FNAME MUNIT
	,''B'' MTRL_LEV,case m1.FForbidStatus when ''A'' then ''N'' else ''Y'' end DISABLE,case mq.FCheckIncoming when 1 then ''Y'' else ''N'' end IS_STS,s.FNumber STORE_ID
	,sp.FNumber MF_NAME,CASE f.FIsEnable WHEN 1 THEN ''Y'' ELSE ''N'' END IS_ERPMTRLVER,m1.F_PKGR_ItemVersion MTRL_VER,b.FDATAVALUE STATION_ID
	,case ms.FIsBatchManage when 1 then ''Y'' else ''N'' end IS_ERPLOTNO,F_HUMIDITYSENSITIVITYLEVEL MSD_LV_ID,cast(ms.FSafeStock as float) as LOW_QTY
	,case F_PKGR_Components when ''A'' then ''Y'' else ''N'' end IS_MSD,d.FDATAVALUE MSD_SI_ID,e.FNUMBER SL_ID,ml.fname + ''_'' + mg.FName + ''_'' + ml.fname PROD_ALLNAME
	,m1.F_PNDR_Text_tzk ''CUST_SNAME''
	,CASE WHEN m1.F_PNDR_Assistant_apv = '''' THEN '''' ELSE (SELECT t1e_l.FDATAVALUE FROM T_BAS_ASSISTANTDATAENTRY_L t1e_l WHERE t1e_l.FENTRYID = m1.F_PNDR_Assistant_apv) END ''MTRL_SNAME''
	,m1.F_PNDR_Text_83g  ''CAR_MODEL''
	,CASE WHEN m1.F_PNDR_Assistant = '''' THEN '''' ELSE(SELECT t1e_l.FDATAVALUE FROM T_BAS_ASSISTANTDATAENTRY_L t1e_l WHERE t1e_l.FENTRYID = m1.F_PNDR_Assistant) END ''MTRL_TYPE_ID''
	,t0p1.FISSUETYPE MAT
from T_BD_MATERIAL m1
	INNER JOIN T_BD_MATERIALBASE m2 on m2.FMATERIALID=m1.FMATERIALID
	INNER JOIN T_BD_MATERIAL_L ml on ml.FMATERIALID=m1.FMATERIALID
	INNER JOIN T_BD_MATERIALPURCHASE mp on mp.FMATERIALID=m1.FMATERIALID
	INNER JOIN T_BD_MATERIALSTOCK ms on ms.FMATERIALID=m1.FMATERIALID
	INNER JOIN T_BD_MATERIALQUALITY mq on mq.FMATERIALID=m1.FMATERIALID
	INNER JOIN T_BD_MATERIALPRODUCE t0p1 on t0p1.FMATERIALID = m1.FMATERIALID
	INNER JOIN T_BD_UNIT u on u.FUnitID=ms.FStoreUnitID
	INNER JOIN T_BD_UNIT_L ul on ul.FUNITID=u.FUNITID
	LEFT JOIN T_BD_MATERIALGROUP_L mg on mg.fid=m1.FMaterialGroup
	LEFT JOIN T_BD_STOCK s on s.FStockId=ms.FStockId
	LEFT JOIN T_BD_SUPPLIER sp on sp.fsupplierid=mp.FDEFAULTVENDORID
	LEFT JOIN T_BAS_ASSISTANTDATAENTRY a on a.FENTRYID=m1.F_PKGR_Station and a.FID=''635b5552a1a973''
	LEFT JOIN T_BAS_ASSISTANTDATAENTRY_L b on b.FENTRYID=a.FENTRYID and b.FLOCALEID=2052
	LEFT JOIN T_BAS_ASSISTANTDATAENTRY c on c.FENTRYID=m1.F_PKGR_ElementSize and c.FID=''635b5651a1a977''
	LEFT JOIN T_BAS_ASSISTANTDATAENTRY_L d on d.FENTRYID=c.FENTRYID and d.FLOCALEID=2052
	LEFT JOIN T_BAS_ASSISTANTDATAENTRY e on e.FENTRYID=m1.F_WAUG_SettlementMethod and e.FID=''638032127e89ee''
	LEFT JOIN T_BD_MATERIALAUXPTY f on f.FMATERIALID=m1.FMATERIALID and f.FAuxPropertyId=100001
	LEFT JOIN T_BD_MATERIALINVPTY g on g.FMATERIALID=m1.FMATERIALID and g.FINVPTYID=10004
WHERE m1.FDocumentStatus=''C''    
	AND (CONVERT(VARCHAR(10),m1.FAPPROVEDATE,23)=CONVERT(VARCHAR(10),GETDATE(),23) or CONVERT(VARCHAR(10),m1.FMODIFYDATE,23)=CONVERT(VARCHAR(10),GETDATE(),23))
	AND m1.FUSEORGID=@defaultorgid
'
WHERE FID = 3