简体   繁体   中英

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?

    $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!

This:

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

looks like SQL*Loader's control file.

I don't think you can use it elsewhere.

It means that

  • you have to call SQLLDR.EXE
  • which will call the control file (such as MY_LOAD.CTL )
  • which contains all those options you wrote above

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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