sql語句生成javabean類

數據庫環境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)
 
 
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章