monks,

#!/usr/bin/perl $file = shift; open ( FH , "$file" ) or die "$!"; #open ( NT , ">new_table" ) or die "$!"; open ( OUT , ">>out" ) or die "$!"; $old_started = 0; print OUT "New_schema | Old_schema\n"; while ( <FH> ) { chomp; $line = $_; next if ( $line =~ /^--/ or $line =~ /^$/ or $line =~ /^\s+$/); if ( $line =~ /^INSERT INTO/i ) { $line =~ /INSERT INTO (.*)\((.*),/; $new_table = $1; $column = $2; $column =~ s/,//g; push @new_columns, $column; } while ( 1 ) { chomp($line = <FH>); $line =~ s/,//g; $line =~ s/\)//g; if ( $line =~ /^SELECT/ || $old_started == 1 ) { if ( $line =~ /^FROM/ ) { $line =~ /FROM (.*);/; $old_table = $1; $old_started = 0; $index = 0; while ( $new_columns[$index] ) { print OUT "$new_table.$new_columns[$index] | $old_table.$old_c +olumns[$index]\n"; $index++; } $index = 0; #print "$new_table => @new_columns : $#new_columns\n"; #print "$old_table => @old_columns : $#old_columns\n"; last; } push @old_columns, $line if ( $line !~ /^SELECT/); $old_started = 1; next; } push @new_columns,$line; } }
Inout would be something like this
-- 2) 206: The specified table (xxxxx) is not in the database -- 111: ISAM error: no record found. -- Solution : You have to install the SGN3. INSERT INTO nokia_scp_address_camel_1_raw(nc_id, scp_address_id, day, sgsncamelactivepdpcontexts, sgsncamelactivesmses, sgsncamelcapdialforpdpcontexts, sgsncamelcapdialoguesforsmses, sgsncamelcapfailwithpdpcontext) SELECT nc_id, scp_address_id, day, sgsncamelactivepdpcontexts, sgsncamelactivesmses, sgsncamelcapdialforpdpcontexts, sgsncamelcapdialoguesforsmses, sgsncamelcapfailwithpdpcontext FROM nokia_scp_address_camel_raw;
From the above input the script produce the output as
nokia_scp_address_camel_1_raw.nc_id + nokia_scp_address_camel_raw.nc_id nokia_scp_address_camel_1_raw.scp_address_id nokia_scp_ +address_camel_raw.scp_address_id nokia_scp_address_camel_1_raw.day nokia_scp_address +_camel_raw.day nokia_scp_address_camel_1_raw.sgsncamelactivepdpcontexts nokia_ +scp_address_camel_raw.sgsncamelactivepdpcontexts nokia_scp_address_camel_1_raw.sgsncamelactivesmses nokia_sc +p_address_camel_raw.sgsncamelactivesmses nokia_scp_address_camel_1_raw.sgsncamelcapdialforpdpcontexts no +kia_scp_address_camel_raw.sgsncamelcapdialforpdpcontexts nokia_scp_address_camel_1_raw.sgsncamelcapdialoguesforsmses nok +ia_scp_address_camel_raw.sgsncamelcapdialoguesforsmses nokia_scp_address_camel_1_raw.sgsncamelcapfailwithpdpcontext no +kia_scp_address_camel_raw.sgsncamelcapfailwithpdpcontext
Is ther any simply way will i be able to acheive the task.


In reply to need a intelligence way of parsing the file by greatshots

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.