Connecting Tech Pros Worldwide Forums | Help | Site Map

How to transfer text file into oracle database by using php?

Member
 
Join Date: Sep 2007
Posts: 45
#1: Sep 29 '07
i have a text file like below: named "rez.text" and
i wnt to transfer each column into oracle database which have the same column name as views here.Every time it will goto database atomatecally after a certaintime like :5 hours.


Date Time Ext CO Dial Number Ring Duration Acc code CD

--------------------------------------------------------------------------------

03/30/02 04:12PM 201 10 7617707 00:00'22

03/30/02 04:12PM 166 01 7112786 00:01'26

03/30/02 04:12PM 200 09 8120500 00:01'20

Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,748
#2: Sep 29 '07

re: How to transfer text file into oracle database by using php?


Hi.

If you want to insert that into your database, you will have to parse it into an array, using the String functions, and insert it into your Oracle database, using the Oracle functions.

Have you made any attempts at this yourself?
Could you share them with us?
Member
 
Join Date: Sep 2007
Posts: 45
#3: Oct 2 '07

re: How to transfer text file into oracle database by using php?


hi atli,
thanks for co-operation
i have to develop a pbx call accounting software using oracle and php but i still i have not found any code how to read data from serial port and pull it into database autometically after a fixed amount of time periodiacly.acully i m new in php thats why i don,t know how to do it.

if u could help me by providing php code then i will be gratefull to u.
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,748
#4: Oct 3 '07

re: How to transfer text file into oracle database by using php?


To trigger a PHP script periodically you could set up a cron job. I have no experience with this but a Google search should provide the information you need.

I've personally never tried to interact with a serial port myself but, again, Google will provide some useful information on the subject.

I can't provide any code for you. Firstly because that is against TSDN posting policy and Secondly, because I don't have any.
Sorry.
Member
 
Join Date: Sep 2007
Posts: 45
#5: Oct 7 '07

re: How to transfer text file into oracle database by using php?


[hi,Atali

thank u for ur cooperation .it would be better for me if provide some clues to insert data(shown as before) from a textfile to database.so that i can understand easily.

or anyone in this forum who can help me?
Member
 
Join Date: Sep 2007
Posts: 45
#6: Oct 7 '07

re: How to transfer text file into oracle database by using php?


Hi Atli.
thanks for ur co operation.if u please send me smple code for insert data from text file to related fileds in a table of oracle db.Then it will be easy for me to understand.
i have tried a simple code that is :problem is it doesnt insert morethan 1 row.i want to insert every row in db.

Expand|Select|Wrap|Line Numbers
  1. $file = fopen("raw_data_31_03.txt","rb");
  2.  
  3. while(! feof($file))
  4.   {
  5.   //echo fgets($file). "<br />";
  6.   $first=trim($first.fgets($file));
  7.   //echo $first;
  8.   }
  9.     $first1= substr($first,0,8);
  10.     //$filewr = fwrite(fopen($first1,"r+"),$tonek,280);
  11.     //mysql_query("insert into test(name) values($first1)");
  12.   echo $first1;
  13. $file1 = fopen("raw_data_31_03.txt","rb");  
  14.   while(! feof($file1))
  15.   {
  16.   //echo fgets($file). "<br />";
  17.   $second=trim($second.fgets($file1));
  18.   //echo $first;
  19.   }
  20.     $second1= substr($second,9,7);
  21.     //mysql_query("insert into test(name1) values($second1)");
  22.   echo $second1;
  23.  
  24.   while(! feof($file2))
  25.   {
  26.   $third=trim($third.fgets($file2));
  27.   }
  28.     $third1 = substr($third,16,6);
  29.     mysql_query("insert into test(name2) values($third1)");
  30.  
  31.     echo $third1;
  32.  
  33.  
  34. fclose($file);
  35. fclose($file1);
  36. fclose($file2);
  37.  
  38. ?>
Text file that i want to insert:
03/31/02 04:21PM 136 11 9564499- 00:00'54 TR

03/31/03 04:22PM 202 10 9338340 00:00'00

03/31/04 04:22PM 202 10 8916116 00:00'05

03/31/05 04:23PM 142 06 <I> 0'00 00:00'31 TR

03/31/06 04:23PM 125 08 108 00:00'32

03/31/07 07:51AM 13 <I> 0'05 NA

03/31/08 04:23PM 180 05 9561760 00:03'45 TR

03/31/09 04:24PM 125 04 8126666 00:00'11

03/31/11 04:24PM 201 10 018222255 00:00'12

03/31/22 07:57AM 13 <I> 0'05 NA

03/31/33 04:24PM 202 07 <I> 0'07 00:01'42

03/31/44 04:24PM 201 10 018222255 00:00'02
Member
 
Join Date: Sep 2007
Posts: 45
#7: Oct 23 '07

re: How to transfer text file into oracle database by using php?


i have a text file called rez.txt .it contains a large no. of rows.
Each row contains several substrings or words.i want to read each and every substring from row by row and finally insert into a table respect related field.

can anybody help me how to do it by php?
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#8: Oct 23 '07

re: How to transfer text file into oracle database by using php?


Merged duplicate threads.
Reply


Similar PHP bytes