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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • boss1
    New Member
    • Sep 2007
    • 45

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

    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
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    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?

    Comment

    • boss1
      New Member
      • Sep 2007
      • 45

      #3
      How to develop a call accounting software for pbx?

      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.acu lly 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.

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        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.

        Comment

        • boss1
          New Member
          • Sep 2007
          • 45

          #5
          [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?

          Comment

          • boss1
            New Member
            • Sep 2007
            • 45

            #6
            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.

            [code=php]
            $file = fopen("raw_data _31_03.txt","rb ");

            while(! feof($file))
            {
            //echo fgets($file). "<br />";
            $first=trim($fi rst.fgets($file ));
            //echo $first;
            }
            $first1= substr($first,0 ,8);
            //$filewr = fwrite(fopen($f irst1,"r+"),$to nek,280);
            //mysql_query("in sert into test(name) values($first1) ");
            echo $first1;
            $file1 = fopen("raw_data _31_03.txt","rb ");
            while(! feof($file1))
            {
            //echo fgets($file). "<br />";
            $second=trim($s econd.fgets($fi le1));
            //echo $first;
            }
            $second1= substr($second, 9,7);
            //mysql_query("in sert into test(name1) values($second1 )");
            echo $second1;

            while(! feof($file2))
            {
            $third=trim($th ird.fgets($file 2));
            }
            $third1 = substr($third,1 6,6);
            mysql_query("in sert into test(name2) values($third1) ");

            echo $third1;


            fclose($file);
            fclose($file1);
            fclose($file2);

            ?>[/code]

            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
            Last edited by pbmods; Oct 23 '07, 12:30 PM. Reason: Added CODE tags.

            Comment

            • boss1
              New Member
              • Sep 2007
              • 45

              #7
              how to read substrings from large number of lines or rows of a textfile

              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?

              Comment

              • pbmods
                Recognized Expert Expert
                • Apr 2007
                • 5821

                #8
                Merged duplicate threads.

                Comment

                Working...