且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在oracle中为现有表插入给定数量的空列

更新时间:2023-11-30 19:40:22

构建emply列的c#代码。



  public   static   string  show( int  r)
{
if (r > 0
{
List< string> list = new List< string>();
for int i = 0 ; i < r; i ++)
{
list.Add( ''as emplty_column +(i + 1 ));
}

return string .Join( ,list);
}
return 跨度>;
}





  string  val = show( 5 ); 
string strquery = @ SELECT a。 str_typeid,a.str_typename,a.str_status,a.strlst_user,
a.dt_entdate
+((val == )? + val)+ @
FROM ref_productitem_disc a
;





你的strQuery将是查询。


I have an integer variable called x. I want a select query with creating x number of empty columns. How can I write this ? I can't use loop because I have to use this query as a c# string in my application.

as an example I can create one empty column as below

SELECT a.str_typeid, a.str_typename, a.str_status, a.strlst_user,
       a.dt_entdate, '' as empty_column
  FROM ref_productitem_disc a




Then I want use x to number of empty columns. In other words , how can I create x number of empty columns?

Your c# code to construct the emply column.

public static string show(int r)
        {
            if (r > 0)
            {
                List<string> list = new List<string>();
                for (int i = 0; i < r; i++)
                {
                    list.Add("'' as emplty_column" + (i + 1));
                }

                return string.Join(",", list);
            }
            return "";
        }



string val = show(5);
            string strquery = @"SELECT a.str_typeid, a.str_typename, a.str_status, a.strlst_user,
       a.dt_entdate" + ((val == "") ? "" : ","+val) + @"
  FROM ref_productitem_disc a";



Your strQuery will the query.