本文介绍了从临时表创建数据库表(按代码)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个称为tt的临时表.我想使用我的临时表创建具有相同字段名称和类型的数据库表.
I have a temp-table called tt. I want to create a database table with the same field names and types using my temp-table.
在 Progress-4gl 中我不知道该怎么做.这可能吗 ?
I can't figure out how to do in Progress-4gl. Is this possible ?
谢谢.
推荐答案
简短答案:是
通过代码执行此操作最安全的方法是创建一个增量df,然后加载它.这是一个很简单的起点,应该可以帮助您:
The safest way is to do this by code is to create an incremental df and then load this.Here is a very partial start that should get you going:
DEFINE TEMP-TABLE tt NO-UNDO
FIELD ii AS INT
FIELD cc AS CHAR
INDEX ttix IS UNIQUE PRIMARY ii.
DEF VAR hb AS HANDLE NO-UNDO.
DEF VAR hf AS HANDLE NO-UNDO.
DEF VAR ifield AS INT NO-UNDO.
hb = TEMP-TABLE tt:DEFAULT-BUFFER-HANDLE.
OUTPUT TO "tt.df".
PUT UNFORMATTED SUBSTITUTE( "ADD TABLE &1", QUOTER( hb:NAME ) ) SKIP.
DO ifield = 1 TO hb:NUM-FIELDS:
hf = hb:BUFFER-FIELD( ifield ).
PUT UNFORMATTED
SUBSTITUTE(
"ADD FIELD &1 OF &2 AS &3",
QUOTER( hf:NAME ),
QUOTER( hb:NAME ),
hf:DATA-TYPE
) SKIP.
/* to do: add other field attributes like label, initial value, decimals, format */
END.
/* to do: add indices */
OUTPUT CLOSE.
生成的df可以加载:
RUN prodict/load_df.p ( "tt.df" ).
这篇关于从临时表创建数据库表(按代码)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!