Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2005
    Posts
    220

    Unanswered: Parsing a text field

    I have a table with a description field that contains some data such as you see here. Is there a function I can use to strip out the division codes (3400, 3300, 3600, 3800, 3900, and 4200) from the following string?

    BF LOIN NY STYLE SIRLOIN D3400-S9-I1347,D3300-S9-I1347,D3600-S9-I1347,D3800-S9-I1347,D3900-S9-I1347,D4200-S9-I1347

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    It can be done by PL/SQL.
    This is a prime example of the "cost" for not designing to Third Normal Form.
    A field should only ever contain a single value.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    If you can find a way to remove the first bit ('BF LOIN NY STYLE SIRLOIN '), then the rest can be done like this:
    Code:
    declare
       l_string long := 'D3400-S9-I1347,D3300-S9-I1347,D3600-S9-I1347,D3800-S9-I1347,D3900-S9-I1347,D4200-S9-I1347';
       l_table wwv_flow_global.vc_arr2;
       l_division varchar2(10);
    begin
       l_table := apex_util.string_to_table (l_string, ',');
       for i in 1..l_table.count
       loop
          l_division := substr (l_table(i), 2, 4);
          dbms_output.put_line (l_division);
       end loop;
    end;
    /
    output:
    3400
    3300
    3600
    3800
    3900
    4200

    (wwv_flow_global and apex_util are packages that come as standard with 10G).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •