简体   繁体   English

使用php将数据infile加载到oracle表中

[英]Load data infile in to oracle table using php

I want load data from text file to oracle database using php , what function to be used here to prevent this warning?我想使用 php 将数据从文本文件加载到 oracle 数据库,这里使用什么函数来防止出现此警告?

    $myFile = "local.txt";
    $fh = fopen($myFile, 'r') or die("Could not open: " . mysql_error());
    echo " file opened<br>";
    $sql ="LOAD DATA infile".$myFile. "INTO TABLE test FIELDS TERMINATED BY ',' optionally enclosed by".'" ' ."(acc_nbr)";
    $result = odbc_execute($connect_cc,$sql) or die("Couldn't execute query! ".odbc_errormsg());

    if(!$result)
    {
        echo " file has not been uploaded to database";
    }
    else
    {
        echo " File has been uploaded successfully to database";
    }

    fclose($fh);

Warning: odbc_execute() expects parameter 2 to be array, string given in C:\\xampp\\htdocs\\FTP\\Monthly_Segmentation_process.php on line 59 Couldn't execute query!警告:odbc_execute() 期望参数 2 为数组,字符串在 C:\\xampp\\htdocs\\FTP\\Monthly_Segmentation_process.php 第 59 行无法执行查询!

This:这个:

LOAD DATA infile".$myFile. "INTO TABLE test FIELDS TERMINATED BY ',' optionally enclosed ...

looks like SQL*Loader's control file.看起来像 SQL*Loader 的控制文件。

I don't think you can use it elsewhere.我不认为你可以在其他地方使用它。

It means that这意味着

  • you have to call SQLLDR.EXE你必须调用SQLLDR.EXE
  • which will call the control file (such as MY_LOAD.CTL )它将调用控制文件(例如MY_LOAD.CTL
  • which contains all those options you wrote above其中包含您在上面写的所有选项

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM