数据库环境sqlserver
sql语句如下
declare @tb nvarchar(100)
set @tb='Shop_OrderItem'
Select 'private '+
(case when st.name ='decimal' then 'double'
when st.name='int' then 'int'
when st.name='float' then 'double'
else 'String'
end
)
+' ', col.name +';' from syscolumns col
inner join systypes st on st.xusertype=col.xtype
Where ID=OBJECT_ID(@tb)
union all
Select 'public '+
(case when st.name ='decimal' then 'double'
when st.name='int' then 'int'
when st.name='float' then 'double'
else 'String'
end
)
+' get'+UPPER(substring(col.name,1,1))+substring(col.name,2,len(col.name)-1)+'() { return '+col.name+'; }'
,'public void set'+UPPER(substring(col.name,1,1))+substring(col.name,2,len(col.name)-1)
+'('+
(case when st.name ='decimal' then 'double'
when st.name='int' then 'int'
when st.name='float' then 'double'
else 'String'
end
)
+' '+col.name+') { this.'+col.name+' = '+col.name+'; }'
from syscolumns col
inner join systypes st on st.xusertype=col.xtype
Where ID=OBJECT_ID(@tb)