How to read binary code chars in pl/sql

How can I read binary code characters in my script. I need to ignore any binary chars before sending the output to a text file.
Thanks

If they are in fact characters in the 1-20 range, you can do somehting like this:
Create & populate the table:
create table badChar (
  buf VARCHAR2(1000)
insert into badChar values ( CHR(0) || CHR(1) )
insert into badChar values( CHR(2) || CHR(3) || CHR(4) || CHR(5) || CHR(6) || CHR(7) || CHR(8) );
insert into badChar values( CHR(9) || CHR(10) || CHR(11) || CHR(12) || CHR(13) || CHR(14) || CHR(15) );
insert into badChar values( CHR(16) || CHR(17) || CHR(18) || CHR(19) || CHR(20) || CHR(21) || CHR(22) );
insert into badChar values( 'Normal data' );View the data
SQL> select '*' || buf || '*' from badChar;
'*'||BUF||'*'
Normal dataTranslate the data, removing characters with ASCII values of 0-22
SQL> ed
Wrote file afiedt.buf
  1  select '*' ||
  2         translate( buf,
  3                    'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' ||
  4                        CHR(0)  || CHR(1)  || CHR(2)  || CHR(3)  || CHR(4)  || CHR(5)  ||
  5                        CHR(6)  || CHR(7)  || CHR(8)  || CHR(9)  || CHR(10) || CHR(11) ||
  6                        CHR(11) || CHR(12) || CHR(13) || CHR(14) || CHR(15) || CHR(16) ||
  7                        CHR(16) || CHR(17) || CHR(18) || CHR(19) || CHR(20) || CHR(21) ||
  8                        CHR(22),
  9                    'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' ) ||
10         '*'
11*   from badChar
SQL> /
'*'||TRANSLATE(BUF,'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'||CHR(0
Normal dataNote that I assume that the the "valid" values are a-z and A-Z. You can add numbers or other valid characters as needed.
If you were on Oracle 10g, you could use regular expressions to make this a lot simpler.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC

Similar Messages

  • How to read the code of html page

    Hi,
    I want to know how to read the code of html page through Java? And if anyone know the link of full implementation of Page Rank Algorithm in Java.
    Please let me know. I have to do the project on that topic.
    Regard
    Vivek

    Vivek_NITT wrote:
    I want to know how to read the code of html page through Java? Get the input stream from an HttpUrlConnection. Read from it like from any other stream.
    And if anyone know the link of full implementation of Page Rank Algorithm in Java.Which one?

  • How to create binary code ("10101") matrix with particles?

    Hi...I am trying to create a group of binary numbers that float across my composition in a loose group - the binary code should appear in lines of text, about 3 to 7 numbers wide (ideally constantly changing the number of digits as it animates).
    I was able to build ONE set of one alternating 1 and 0 with "numbers", but wasn't able to make the line of text wider then one digit. Also, the random number change animates very fast, and I don't know how to slow it down (is there an expression?).
    I then animated it with particular, but it looks more like a swarm of bees then moving and morphing  "lines" of 1's and 0's
    Any advice would be greatly appreciated....thank in advance!!

    http://www.redgiantsoftware.com/products/all/text-anarchy/
    http://www.motionscript.com/design-guide/binary-block.html
    http://aestuff.myleniumstuff.de/?p=82
    Mylenium

  • How to read in a char

    Hi,
    I am new to Java..
    How do i read in a char type..
    For reading lines of input that a user types at the console..
    We do for eg, name = console.readLine()
    what wld be the equiv for doing the same for a char ?
    pls help
    thanks

    import java.io.*;
    class ReadChar {
    public static void main (String[] args) throws IOException {
    char c = (char) System.in.read(); // ...

  • How to read a text file through pl/sql

    How to read a text file through pl/sql

    pl/sql runs inside the database. so your file also should be on the database server file system for you to be able to read.
    check out UTL_FILE package. This is the database package to read/write files on the database server.

  • How to read binary file ?

    Hi All,
    I want to read a binary file which has double data. The first byte is an unsigned byte. I have tried using DataInputStream readUnsignedByte method. But then how to convert this value into double.
    int hdop = _data.readUnsignedByte();

    Hi,
    I have managed to read the first byte i.e hdop. I am getting the values of first 2 bytes properly. But the values where I have to read more than 1 byte is creating problem. Can anyone let me know whats wrong in the code?
    import java.io.DataInputStream;
    import java.io.FileInputStream;
    import java.util.Vector;
    public class SBPParser {
         //RandomAccessFile _file = null;
         FileInputStream _file = null;
         DataInputStream _data = null;
         int eofmark = 0;
         public SBPParser(FileInputStream f, DataInputStream d) {
              _file = f;
              _data = d;
         public void parseSBPFile() {
              try {
                        int hd = _data.readUnsignedByte();
                        double douhd = (hd & 0xff) * 0.2;
                        int svid = (_data.readUnsignedByte()) & 0xff;
                        int utcsec = _data.readUnsignedShort();
                        double utcs = (utcsec & 0xff) * 0.001;
                        int utc = Integer.parseInt(utcdatetime);
                        int sec = utc & 0xFC000000;
                        int min = utc & 0x3F00000;
                        int hour = utc & 0xF8000;
                        int day = utc & 0x7C00;
                        int months = utc & 0x3FF;*/
                        int utc = _data.readInt();
                        int sec = utc & 0xFC000000; //For fetching first 6 bits
                        int min = utc & 0x3F00000;  //For fetching next 6 bits
                        int hour = utc & 0xF8000;    //For fetching next 5 bits
                        int day = utc & 0x7C00;   //For fetching next 5 bits
                        int months = utc & 0x3FF; //For fetching next 10 bits
                        int svidlist = (_data.readInt()) & 0xff;
                        int lat = (_data.readInt()) & 0xff;
                        double latitude = lat * 0.0000001;
                        int lon =(_data.readInt()) & 0xff;
                        double longitude = lon * 0.0000001;
                        int alt = (_data.readInt()) & 0xff;
                        System.out.println("Value of Hdop ==> " + douhd);
                        System.out.println("Value of SVIDCnt ==> " + svid);
                        System.out.println("Value of UtcSec ==> " + utcs);
                        System.out.println("Value of seconds ==> " + sec);
                        System.out.println("Value of minutes ==> " + min);
                        System.out.println("Value of hours ==> " + hour);
                        System.out.println("Value of day ==> " + day);
                        System.out.println("Value of months ==> " + months);
                        System.out.println("Value of SVIDList ==> " + svidlist);
                        System.out.println("Value of Latiutude ==> " + latitude);
                        System.out.println("Value of Longitude ==> " + longitude);
                        System.out.println("Value of Altitude ==> " + alt);
                        //_data.skipBytes(31);
              } catch(Exception e) {
                   e.printStackTrace();
         public void print() {
              for(int i = 0; i < hdopVct.size(); i++) {
                   System.out.println("HDOP => " + hdopVct.elementAt(i));
              /*System.out.println("SVIDCNT => " + svidlistVct.elementAt(0));
              System.out.println("UTCSEC1 => " + utcsecVct.elementAt(0));
              System.out.println("UTCSEC2 => " + utcsecVct.elementAt(1));*/
         public static void main(String [] args) {
              try {
                   FileInputStream file_input = new FileInputStream("000000000_GPSLOG_20090605_122548.sbp");
                  DataInputStream data_in    = new DataInputStream (file_input);
                   SBPParser sbp = new SBPParser(file_input, data_in);
                   sbp.parseSBPFile();
                   //sbp.print();
              } catch(Exception e) {
                   e.printStackTrace();
    }Thanks & Regards
    Sunil

  • How to read source code in Safari?

    How do I read a web page source code using Safari?
    Thanks.

    Safari > Preferences > Advanced > Show Develop in menu bar
    then
    Develop > Show Page Source

  • How to read binary file into a 2D float array??

    Hi All,
    I really need help to get this one as I am stuck and can't seem to find any way out of it. I am given a '.dat' file that has float values in it. I want to read this file in java and put it in a 2D float array. The file has basically a matrix of float values. What I want to do is to read this binary file and put all its data into 2D float array (float [] []) so that I can use it in my program. Is there a way to read file like this? I did find a similar matlab code (below) but cant seem to find anything in java and i really want to do this in java only.. I will appreciate ur help in this one.
    thanks very much
    Nitya
    fid = fopen('datafile.dat');
    A = fread(fid,[50 50],'float32');
    fclose(fid);

    I shud have shown the two ways that i Already tried. here they are..
    first one using DataInputStream and then trying to readFloat()
    DataInputStream dis = ....
    Float f = dis.readFloat();This code gives code gives me some random values like this.. (i had a loop)
    5.8758974E-14
    -0.41055492
    1.5724557E-30
    1.06822824E14
    -1.91934371E15
    3.43829601E13
    Other way i tried was this.. which seems right but here i have to convert byte to float and i thnk that code is giving some different results (slightly different float values) not sure why....may be my indexing of the array is wrong to make it a matrix.. or something else...
    is.read(bytes, offset....);
    int cnt = 0;
    int j = 0;
    for (int start = 0; start < offset; start = start + 4) {
      if(j<50){
           myarray[cnt][j] = this.arr2float(bytes, start);
             System.out.println(cnt + "-" + j + " = " + myarray[cnt][j]);
           j++;
    }else{
      if(cnt < 50){
           cnt++;
           j = 0;
      }else{
           break;
    public float arr2float (byte[] arr, int start) {
              int i = 0;
              int len = 4;
              int cnt = 0;
              byte[] tmp = new byte[len];
              for (i = start; i < (start + len); i++) {
                   tmp[cnt] = arr;
                   cnt++;
              int accum = 0;
              i = 0;
              for ( int shiftBy = 0; shiftBy < 32; shiftBy += 8 ) {
                   accum |= ( (long)( tmp[i] & 0xff ) ) << shiftBy;
                   i++;
              return Float.intBitsToFloat(accum);
    Not sure if i am missing some other way to do this...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to read binary file in Matlab

    "Hello all!
    Labview 7.0 has an example "Cont Acq to File (binary).vi" log the PCI 6014 card and writes the data to a binary file. How can I read that
    file in Matlab(6.5.0... R13)? Does anyone have a solution for this?

    Hello,
    Basically you can do it by saving the data in a file in MATLAB and reading it directly from LabVIEW, or vice versa. In MATLAB , the command "save" allows you to save the data in binary format (*.mat) or ASCII format. You also have an option of saving it in ASCII format using a tab delimiter between data points.
    There is a knowledge base which talks in detail about how to share data in between labview and matlab Import data from labview to Matlab and vice versa.
    Hope this helps. If not, please feel free to ask more questions.
    Good luck and have a great day!
    Koninika
    National Instruments

  • How to read binary files wrt specific BYTE size and length??

    Hello Everyone,
                                I have a project I want to accomplish. I have a binary file, and I would like to read the data and print on wfm in a specific order and size.
    The data is 16 bit binary type , and needs to be read in chunks of 2 bytes.
    i have 30 bytes of sample 1.
    followed by 2 bytes of sample 2.
    followed by another 2 bytes of sample 3.
    steps 2-4 should be repeated 10 times and then i should read sample 4 which is of 2 bytes.....
    How should I do it?? I don't have any VI build... all i have is the example VI...
    can anyone pleasehelp me???
    Now on LabVIEW 10.0 on Win7

    smercurio_fc, sorry for the confusion, i will try my best to explain...
    1. No, i don;t have to read the file again, once it has read, I used
    while loop just to see the data updating (i press run, and before i can
    visualize i have the waveforms; i can get rid of the while loop)
    2. I have 30 different values of 1 sample. actually, the data is cmg
    from tri-axial accelerometer; each axis is of 10 bytes(hence 3*10 =
    30bytes)
    3. I am repeating the steps 2-4 10 times because the data was written
    into the binary file after 10 times sampling the sensors(if first 3
    samples are read @ 1000hz, sample 4 was read at 1000/10 = 100hz)
    4. I am using the graphs to interpret the values, that's it. The
    values are already scaled when they were wrote to the binary file, I
    have to simply interpret it.
    I have made some changes in the VI, now i am reading only the first
    30bytes, that too, in chunks of 10-10-10 bytes, and plotting the 3
    samples simultaneously on a waveform chart. (will approach 1
    sensor/sample at a time) and running the loop for 10 times. I have changed I8 to I16 now.
    Please let me know if it makes sense to you now.
    P.S. each sample is a sensor data.
    Now on LabVIEW 10.0 on Win7
    Attachments:
    data_read.vi ‏24 KB

  • How to read binary floating point values from TCP/IP

    I am attempting to use a LabView application to read an array of binary single precision floating point numbers transferred through a TCP/IP connection from a Windows C++ program. The endianization occurs before the values are sent to the Labview application. When I read the values in LabView, some values are interpreted correctly, some are not. For instance, the C program is sending a 6 as one element, and 7 as another. Labview interprets both as 6. The difference between 6 and 7 in binary format is 1 bit (bit #21 if counting from 0 in LabView format). There are 2 other values that show the same error- 459.67 is being sent, 395.67 is read by labview (1 bit difference, exact same bit... 7.5 is being sent, 6.5 is being read by LabView (1 bit difference, exact same bit). LabView reads that bit as 0, when it should be 1.
    This seems very odd to me because most values are being read correctly, including other values with that same bit on. There are values being read correctly that are both before and after the incorrect values in the array, so it's not just an issue with an offset or something in the bit stream. Additionally, when attempting to read an array of values with all bits on, I get a strange pattern of 111110011111100111111001111110.
    We have also verified that the binary representation for the values is the same on both machines, once you account for the byte swapping. What am I missing here? How in the world can some values come across correctly and others incorrectly? Any help would be greatly appreciated! Our fallback is to transfer everything in ASCII, which is going to greatly increase packet sizes.
    Thanks,
    Jason

    Update:
    Problem fixed. I say fixed and not solved because I don't know why it's fixed. I had been storing the TCP/IP read in a string and passing it through a shift register after each read. I would then concatenate it with the TCP/IP read result in the next loop. After each read, it would search the concatenated string for ASCII flags. When it found them, it would strip off the flags and then type cast the rest as single precision floating points.
    I knew I would be getting the same number of bytes each time, so I ditched the ASCII flags and had just the binary values sent. This way, I expect to get all of the values in one TCP/IP read. No values are passed through a shift register to the next loop and there is no concatenation of the string outputs from TCP/IP read.
    I'm not sure if it was the ASCII flags being included or something with the way I was manipulating the string that was causing the binary values to be interpreted incorrectly. Hope this helps someone else.
    Jason

  • How to read binary file in developer 2000

    Hi,
    Is there any method through which i can read a binary file(pdf)
    in developer 2000
    Thanks in advance

    Hello,
    Basically you can do it by saving the data in a file in MATLAB and reading it directly from LabVIEW, or vice versa. In MATLAB , the command "save" allows you to save the data in binary format (*.mat) or ASCII format. You also have an option of saving it in ASCII format using a tab delimiter between data points.
    There is a knowledge base which talks in detail about how to share data in between labview and matlab Import data from labview to Matlab and vice versa.
    Hope this helps. If not, please feel free to ask more questions.
    Good luck and have a great day!
    Koninika
    National Instruments

  • How to read qr codes

    How do I scan a QR code with my 4S iphone?

    https://itunes.apple.com/us/app/redlaser-barcode-scanner-shopping/id474902001?mt =8

  • Read binary code doesnt work right

    hello,
    can anyone tell me why does the chart ony show the last data and not all?
    markus
    Attachments:
    BinaryData.zip ‏33 KB

    Hello,
    I think that your binary file is not ok.
    Your read function sometimes returns an array of 7 waveforms and sometimes an empty array.
    When you send values to a chart, you must make sure that you allays send the same amount of channels, otherwise it will clean up all the pass data and begin with the new channel number.
    Hope this helps,
    Paulo

  • How to read a PDF from within PL/SQL?

    we have a requirement like this: We have a Time Tracking and Project Monitoring System whose DB is a Oracle 10g R2. We want to automate our ''Meeting Minute'' processing.
    -- The project lead will write minutes into a form PDF.
    -- I.e. a PDF where people can type in information to fields.
    -- The PDF will be e-mailed to the project manager.
    -- Project manager will save the PDF in a HDD directory.
    -- Then he will run a program.
    -- Program will pickup all the PDFs in directory one-by-one.
    -- For each PDF, the program should read the fields.
    -- Read values will be inserted to the DB.
    Now, my problem is, HOW ON EARTH TO READ A "PDF"???
    One option is to CONVERT the PDF to XML and then read the XML. BUT, unfortunately after googling for over 4 hours I came up empty on converting PDF to XML.
    How can we do this???
    Any help would be greatly appreciated.

    >
    after googling for over 4 hours I came up empty on converting PDF to XML.
    >
    Glad I'm not paying you by the hour! You might need to switch to decaf.
    It only took a few seconds for me using 'convert pdf to xml'
    Right there on the first page was a link on how to use Adobe Acrobat to do the conversion.
    http://www.ehow.com/how_5806567_convert-xml-using-adobe-acrobat.html
    So then you use 'adobe acrobat convert pdf to xml' and it's amazing - there are links to the adobe site. One of them is about an XMl Plug-in for Windows.
    http://www.adobe.com/support/downloads/detail.jsp?ftpID=1209
    And an adobe forum question about it
    http://forums.adobe.com/thread/339814
    Maybe try searching again after the caffeine wears off a little?
    If it can be done with PDF Adobe has the tools to do it.

Maybe you are looking for