如何代码创建临时表?

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

如何代码创建临时表?

// 创建临时表

            string tempTbName = AppServiceContext.DBService.CreateTemporaryTableName(this.Context);

            string strsql = "/*dialect*/create table " + tempTbName + " as select FRECINVBILLNO,FIVCODE,FBILLTYPENAME,FBILLNO from 临时表的模型表 where 1 <> 1";

// 临时表的模型表需要在BOS内绘制一个表模型,实际作用不为存储数据

            DBServiceHelper.Execute(this.Context, strsql);

            Dictionary<string, DbType> columnInfos = new Dictionary<string, DbType>();

            columnInfos.Add("字段1", DbType.String);

            columnInfos.Add("字段2", DbType.String);

            BulkInsertAdapter bulkInsertAdapter = new BulkInsertAdapter(base.Context, columnInfos, tempTbName, recDataTb.Rows.Count);

// recDataTb为数据 (DataTable)

            foreach (DataRow dc in recDataTb.Rows)

            {

                DataRow newRow = bulkInsertAdapter.NewRow;

                newRow["字段1"] = Convert.ToString(dc["字段1"]);

                newRow["字段2"] = Convert.ToString(dc["字段2"]);

                bulkInsertAdapter.Insert(newRow);

            }

            bulkInsertAdapter.Finish();

注意:BOS内绘制临时表模型

      ① 临时表实际作用不为存储数据,只为搭建一个表模型

      ② 表中的字段的创建,需要自行判断创建。依据为:后续sql查数的条件字段

      ③ 注意主键是否需要按照标准产品创建,即为FID,不需要的话,则指定某唯一的字段为主键



我这会报错image.webp


在哪里可以创建临时表?
优秀,厉害,大佬

谢谢你解决了困扰我一个月的问题,今晚可以睡个好觉了!


请教一下,具体的使用场景


学习

如何代码创建临时表?

// 创建临时表 string tempTbName = AppServiceContext.DBService.CreateTemporaryTableName(this.Context); ...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息