By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,742 Members | 1,570 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,742 IT Pros & Developers. It's quick & easy.

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

P: 45
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
Sep 29 '07 #1
Share this Question
Share on Google+
7 Replies


Atli
Expert 5K+
P: 5,058
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?
Sep 29 '07 #2

P: 45
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.
Oct 2 '07 #3

Atli
Expert 5K+
P: 5,058
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.
Oct 3 '07 #4

P: 45
[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?
Oct 7 '07 #5

P: 45
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
Oct 7 '07 #6

P: 45
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?
Oct 23 '07 #7

pbmods
Expert 5K+
P: 5,821
Merged duplicate threads.
Oct 23 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.