WYAE - FWTOOLS Mailing List Archive


Re: [fwtools] Suggestion - Null Values in Templates
From:Reto Schuettel
Date: Thu, 7 Oct 2004 19:48:02 +0200

Hi Dan

You wrote:
>  ITEM 1=========
>  
> I use Templates to Load into MySQL 

Hm, you could use the templates for creating sql code directly :)?

> Accordingly, at times I need to find fields that have "null" ( empty)
> values.  
>  
> Perhaps a change in code 
>  
> around line 3267
> 
> ## For DB Nulls
>         if ( $access_comment[$i] ) {
>         $line =~ s/<<>>/$access_comment[$i]/g;
>         }  else {
>         $line =~ s/<<>>/NULL/g;
>      fi
>         }

Hm, in my opinion this solution is quiet ugly, because it breaks
everything :). You have to implement that as an optional parameter, like
--print-nulls or something like that, you should never change the default
behavior!

As an temporary workaround (until somebody implement this features - who
volunteers? :)) you could use a postprocess script, which replaces the
'empty' values with a NULL. 

If you use tabs as delimiter:
# fwtool.pl ...
# perl -i -pe 's/\t\t/\tNULL\t/g' output.tsv # these both commands
# perl -i -pe 's/\t\n/\tNULL\n/g' output.tsv # replaces all the empty
                                             # strings with NULL
					     # (untested)
# mysql 'LOAD INTO FILE .. bla bla output.tsv'

> ITEM 2 ========
>  
> COMMENTS that are entered with just a numerical value - DO NOT SHOW UP
> when used with templates. It appears CP add's a "quote" to any
> "character string" - but not a numerical value:
>  
> Therefore IF you add a comment such as a tracking number ie:   2766  
>  It will not show up in your template output.
> However, IF you added a comment such as : #2766  it will show up.

Hm, atm I don't have an fw rulebase with such comments, but if I have
time I'll try to verify that tomorrow. Empty comments are exported
correctly:
(i used vim with ':set list' output, with this options all the tabs are represended with '^I') 
9^I160.59.191.192/27^I194.69.181.57^Itcp22^ISSH admin access for NCC / ENG.$ 
5^I192.168.190.126^I192.168.190.126^Itcp18191, tcp256, udp6372^I$

as you can see, the rule nr 5 has an 'emtpy' field. 


- reto

--- StripMime Report -- 
Plain text mail. Excellent! Won't be converted or stripped.
---