【问题标题】:Load excel sheet into oracle db through forms 6i通过表单 6i 将 excel 表加载到 oracle db
【发布时间】:2014-08-17 02:36:59
【问题描述】:

我有一个链接,其中包含通过 oracle 表单将 excel 数据加载到 db 表的代码,

DECLARE   
 application OLE2.OBJ_TYPE;   
 workbooks OLE2.OBJ_TYPE;   
 workbook OLE2.OBJ_TYPE;   
 worksheets OLE2.OBJ_TYPE;   
 worksheet OLE2.OBJ_TYPE;   
 cell OLE2.OBJ_TYPE;   
 args OLE2.OBJ_TYPE;   
 ctr NUMBER(12);   
 cols NUMBER(2);  
 name_var1 VARCHAR2(2000);   
 name_var2 VARCHAR2(2000);   
 name_var3 VARCHAR2(2000);   
 name_var4 VARCHAR2(2000);   
 filename varchar2(100);  

 PROCEDURE OLEARG IS  
 args OLE2.OBJ_TYPE;   
 BEGIN  
 args := OLE2.CREATE_ARGLIST;   
 ole2.add_arg(args,ctr); -- row value  
 ole2.add_arg(args,cols); -- column value  
 cell := ole2.GET_OBJ_PROPERTY(worksheet,'Cells',args); -- initializing cell  
 ole2.destroy_arglist(args);   
 END;  

 BEGIN  
 filename :=GET_FILE_NAME('c:\', File_Filter=>'Excel Files (*.xls)|*.xls|'); -- to pick the file  
 application := OLE2.CREATE_OBJ('Excel.Application');   
 ole2.set_property(application,'Visible','true');   
 workbooks := OLE2.GET_OBJ_PROPERTY(application, 'Workbooks');   
 args := OLE2.CREATE_ARGLIST;   
 ole2.add_arg(args,filename); --'c:\13s002.xls'); -- file path and name  
 workbook := ole2.GET_OBJ_PROPERTY(workbooks,'Open',args);   
 ole2.destroy_arglist(args);   
 args := OLE2.CREATE_ARGLIST;   
 ole2.add_arg(args,'Sheet1');   
 worksheet := ole2.GET_OBJ_PROPERTY(workbook,'Worksheets',args);   
 ole2.destroy_arglist(args);   

 ctr := 2; --row number  
 cols := 1; -- column number  

 FIRST_RECORD;   

 LOOP   
 OLEARG;  
 name_var1 := ole2.get_char_property(cell,'Value'); --cell value of the argument  
 cols := cols+1;  

 OLEARG;  
 name_var2 := ole2.get_char_property(cell,'Value'); --cell value of the argument  
 cols := cols+1;  

 OLEARG;  
 name_var3 := ole2.get_char_property(cell,'Value'); --cell value of the argument  
 cols := cols+1;  

 OLEARG;  
 name_var4 := ole2.get_num_property(cell,'Value'); --cell number value of the argument  

 IF ctr = 1 then   
 :tf1 := name_var1;   
 :tf2 := name_var2;   
 :tf3 := name_var3;   
 :tf4 := name_var4;   
 ELSE   
 NEXT_RECORD;   
 :tf1 := name_var1;   
 :tf2 := name_var2;   
 :tf3 := name_var3;   
 :tf4 := name_var4;  
 END IF;   

 EXIT WHEN length(name_var1) = 0 or length(name_var1) is null;   
 ctr := ctr + 1;   
 cols := 1;  

 END LOOP;   
 OLE2.INVOKE(application,'Quit');   
 OLE2.RELEASE_OBJ(cell);   
 OLE2.RELEASE_OBJ(worksheet);   
 OLE2.RELEASE_OBJ(worksheets);   
 OLE2.RELEASE_OBJ(workbook);   
 OLE2.RELEASE_OBJ(workbooks);   
 OLE2.RELEASE_OBJ(application);   
 END;   

我有 oracle 表格 6i 问题是我应该用值替换一些参数,而我不知道应该用值替换哪些参数?你能告诉我吗?

-- 我创建了 4 个文本项(:tf1、:tf2、:tf3、:tf4)。 -- 我在分区 "d:\" 上有一个名为 "employees" 的 .xls 文件。 --这些行

name_var1 := ole2.get_char_property(cell,'Value'); --cell value of the argument 
cols := cols+1;
OLEARG;
name_var2 := ole2.get_char_property(cell,'Value'); --cell value of the argument 
cols := cols+1;
OLEARG;
name_var3 := ole2.get_char_property(cell,'Value'); --cell value of the argument 
cols := cols+1;
OLEARG;
name_var4 := ole2.get_num_property(cell,'Value'); --cell number value of the argument  , 

我认为“价值”论点应该替换为某些东西,但我不知道它是什么?以及“参数的单元格值”是什么意思和

"参数的单元格编号值"

?

【问题讨论】:

标签: oracle plsql oracleforms


【解决方案1】:

您将不得不找到有关该课程的更多信息。看起来'Value' 是您想要从单元格返回的数据:值或公式。 OLEARG; 是一个内联过程,它必须是开始块中的最后一个定义。 cols 用于遍历每一列,ctr 用于遍历 xls 文件的行。 OLEARG; 期望这些变量名存在于您的代码中。如果您有更多列,那么您需要为每个附加列设置一组这三个语句

OLEARG; name_var3 := ole2.get_char_property(cell,'Value'); cols := cols+1;

您确实意识到,当您迁移到 6i 以上的其他表单版本时,您将不得不删除所有这些代码?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-30
    • 2017-12-31
    • 1970-01-01
    • 2023-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-23
    相关资源
    最近更新 更多