我需要加载具有动态列的平面文件(列不固定,有时会更改)。如何创建将这些平面文件加载到sql表的存储过程。这些文件近100个,位于一个位置。
答案 0 :(得分:0)
这只是一个想法!!!
好的,所以你的文件看起来像这样;
case 1
col1;col2;col3;col4;col5
1;s;c;2;3
4;s;c;7;3
case 2
col1;col2;col3;col4
2;p;2;3
2;s;7;3
case 3
col1;col2;col3
1;p;2
20;s;7
I Step
1- read the file and get only the header into a table
exple:
Table_my_dyn_header contains
in case 1: col1;col2;col3;col4;col5
in case 2: col1;col2;col3;col4
2- save the file header into a variable (its not a must)
you would get in case 1 : col1;col2;col3;col4;col5
or case 2 : col1;col2;col3;col4
3-transform the header you get in variables
in cas 2 'col1;col2;col3;col4' would become
col1 -> variable 1
col2
col3
col4 -> variable 4
4- so with those new variables you can build you control-file dynamically
( with cursor or for-iteration)
II Step reload the data-file because you have your control file build