表封装与初始化语句

Posted 修炼者

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了表封装与初始化语句相关的知识,希望对你有一定的参考价值。

SELECT ‘private ‘+A.MyDataType+‘ ‘+A.COLUMNNAME+‘;‘ FROM (
	Select A.name COLUMNNAME,
	B.name,
	CASE WHEN CHARINDEX(‘bigint‘,B.name)>0 then ‘Long‘
	  WHEN CHARINDEX(‘int‘,B.name)>0 then ‘Integer‘
	  WHEN CHARINDEX(‘float‘,B.name)>0 then ‘Double‘
	   WHEN CHARINDEX(‘decimal‘,B.name)>0 then ‘BigDecimal‘
	  WHEN CHARINDEX(‘char‘,B.name)>0 then ‘String‘
	  WHEN CHARINDEX(‘datetime‘,B.name)>0 then ‘Date‘
	  WHEN CHARINDEX(‘bit‘,B.name)>0 then ‘Boolean‘
	  WHEN CHARINDEX(‘money‘,B.name)>0 then ‘BigDecimal‘
	else ‘‘ end MyDataType from syscolumns  A
	LEFT JOIN systypes B
	ON A.xtype=B.xusertype
	Where A.ID=OBJECT_ID(‘CurrentStock‘) 
	--and a.name =‘strContractGUID‘
	and a.name not like ‘%ufts%‘ and a.name not like ‘%uniqueidentifier%‘
) A
 
 SELECT ‘_Stock.set‘+A.COLUMNNAME+‘(‘+
	 case when MyDataType=‘Long‘ then ‘0‘ 
	 when MyDataType=‘Integer‘ then ‘0‘ 
	 when MyDataType=‘Double‘ then ‘0.0‘ 
	 when MyDataType=‘BigDecimal‘ then ‘BigDecimal.ZERO‘ 
	 when MyDataType=‘String‘ then ‘String‘ 
	 when MyDataType=‘Date‘ then ‘new Date()‘ 
	 when MyDataType=‘Boolean‘ then ‘0‘ 
	 else ‘‘ end  +‘)‘ 
 FROM (
	Select A.name COLUMNNAME,
	B.name,
	CASE WHEN CHARINDEX(‘bigint‘,B.name)>0 then ‘Long‘
	  WHEN CHARINDEX(‘int‘,B.name)>0 then ‘Integer‘
	  WHEN CHARINDEX(‘float‘,B.name)>0 then ‘Double‘
	   WHEN CHARINDEX(‘decimal‘,B.name)>0 then ‘BigDecimal‘
	  WHEN CHARINDEX(‘char‘,B.name)>0 then ‘String‘
	  WHEN CHARINDEX(‘datetime‘,B.name)>0 then ‘Date‘
	  WHEN CHARINDEX(‘bit‘,B.name)>0 then ‘Boolean‘
	  WHEN CHARINDEX(‘money‘,B.name)>0 then ‘BigDecimal‘
	else ‘‘ end MyDataType from syscolumns  A
	LEFT JOIN systypes B
	ON A.xtype=B.xusertype
	Where A.ID=OBJECT_ID(‘CurrentStock‘) 
	--and a.name =‘strContractGUID‘
	and a.name not like ‘%ufts%‘ and a.name not like ‘%uniqueidentifier%‘
) A

  

以上是关于表封装与初始化语句的主要内容,如果未能解决你的问题,请参考以下文章

HashMap原理:哈希函数的设计

SQL Select 语句的用法

VSCode自定义代码片段14——Vue的axios网络请求封装

VSCode自定义代码片段14——Vue的axios网络请求封装

VSCode自定义代码片段14——Vue的axios网络请求封装

在BigQuery中封装复杂代码