﻿insert into tb_columnandcaptionandtype
  select *
  from   (select a.column_name,
                 b.comments,
                 case
                   when a.data_type like 'VAR%' then
                    'System.String'
                   when a.data_type = 'NUMBER' then
                    'System.Double'
                   when a.data_type = 'DATE' then
                    'System.DateTime'
                   else
                    'System.String'
                 end,
                 60
          from   user_tab_columns a
          left   join user_col_comments b on a.column_name =
                                             b.column_name
          where  a.table_name = 'SLM_ORDER_DELIVERY_TRANSIT'
          and    b.table_name = 'SLM_ORDER_DELIVERY_TRANSIT'
          
          order  by a.column_id) a
  where  1 = 1
  and    not exists (select 1
          from   tb_columnandcaptionandtype b
          where  b.columnname = a.column_name);
          
          
          select  'hs.Add('||rownum||','|| 'new string[]{' || '"' || t.columnname || '",' || '"' ||
       t.columncaption || '",' || '"' || t.columntype || '",'||'"'||t.columnlength||'"});'
from   tb_columnandcaptionandtype t;
