将.xlxs导入Oracle PL / SQL数据库

时间:2015-10-22 10:18:26

标签: excel oracle vba excel-vba

我遇到VBA将数据导入Oracle PL / SQL数据库的问题。我有这个脚本:

sql = "insert into my_table (Name, Surname,Phone,Email,Date, time_1,Time_2,Note, Source, Change,State,Result) 
       values ( '" & Cells(cellNumber, 1) & "' , '" & Cells(cellNumber, 2) & "' ,  '" & Cells(cellNumber, 3) & "' ,  '" & Cells(cellNumber, 4) & "', to_date('" & Cells(cellNumber, 5) & "'," & "'DD.MM.YYYY')," & " to_date('" & Cells(cellNumber, 6) & "'," & "' HH24:MI:SS')," & " to_date('" & Cells(cellNumber, 7) & "'," & "' HH24:MI:SS'),"  & "to_date('" & Cells(cellNumber, 8) & "'," & "'DD.MM.YYYY HH24:MI:SS') , '" & Cells(cellNumber, 9) & "' ,  '" & Cells(cellNumber, 10) & "' ,  '" & Cells(cellNumber, 11) & "' ,  '" & Cells(cellNumber, 12) & " ') "## Heading ##

time_1time_2外,一切正常。 Excel中的格式为HH24:MI:SS,VBA将其转换为单个数字,例如:0,0754234。 我需要保留HH24:MI:SS格式。

有没有人可以帮助我?

1 个答案:

答案 0 :(得分:1)

  

sql ="插入mytable(姓名,姓,电话,电子邮件,日期,   time_1,Time_2,Note,Source,Change,State,Result)值('"&   细胞(cellNumber,1)& "' ,'" &安培;细胞(cellNumber,2)& "' ,'" &安培;   细胞(cellNumber,3)& "' ,'" &安培;细胞(cellNumber,4)& "&#39 ;,   to_date('"& Cells(cellNumber,5)&"',"&"' DD.MM.YYYY&#39 ;),'" &安培;   CStr(格式(Cells(cellNumber,6),"长时间"))& "''" &安培;   CStr(格式(Cells(cellNumber,7),"长时间"))& "',to_date('"&   细胞(cellNumber,8)& "'" &安培; "' DD.MM.YYYY HH24:MI:SS'),'" &安培;   细胞(cellNumber,9)& "' ,'" &安培;细胞(cellNumber,10)& "' ,'" &安培;   细胞(cellNumber,11)& "' ,'" &安培;细胞(cellNumber,12)& " ')"