Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
cookbooks:transformations:devel [2010/04/30 21:19]
92.231.105.106
cookbooks:transformations:devel [2011/11/09 12:34] (current)
193.146.38.124 old revision restored
Line 66: Line 66:
  
 <code> <code>
-xlog("MD4 over From username: $(fU{s.md5})");+xlog("md5 over From username: $(fU{s.md5})");
 </code> </code>
 +
 ==== {s.substr,offset,length} ==== ==== {s.substr,offset,length} ====
  
Line 153: Line 154:
  
 Return string after removing ending 'len' characters. Parameter 'len' can be positive integer or pseudo-variable holding a positive integer. Return string after removing ending 'len' characters. Parameter 'len' can be positive integer or pseudo-variable holding a positive integer.
 +
 +==== {s.prefixes[,len]} ====
 +
 +Return series of comma separated prefixes of the pv. Parameter 'len' is optional and will limit the maximum prefix length.
 +
 +Example:
 +<code c>
 +$var(x) = "123456";
 +$(var(x){s.prefixes}) => 1,12,123,1234,12345,123456
 +$(var(x){s.prefixes,4} => 1,12,123,1234
 +</code>
 +
 +
 +==== {s.prefixes.quoted[,len]} ====
 +
 +Return series of comma separated quoted prefixes of the pv. Parameter 'len' is optional and will limit the maximum prefix length.
 +
 +Example: 
 +<code c>
 +$var(x) = "123456";
 +$(var(x){s.prefixes.quoted} => '1','12','123','1234','12345','123456'
 +$(var(x){s.prefixes.quoted,4} => '1','12','123','1234'
 +</code>
  
 ===== URI Transformations ===== ===== URI Transformations =====
Line 332: Line 356:
 <hi #c0c0c0>This transformation class is exported by **textops** module.</hi> <hi #c0c0c0>This transformation class is exported by **textops** module.</hi>
  
-Access parts of a ToBody-like structure. 
-  
  
 ==== {re.subst,expression} ==== ==== {re.subst,expression} ====
Line 361: Line 383:
     * s - match within multi-lines strings     * s - match within multi-lines strings
     * g - replace all matches     * g - replace all matches
 +
 +===== SQL Transformations =====
 +
 +<hi #c0c0c0>The transformations in this class are exported by the **sqlops** module.</hi>
 +
 +==== {sql.val} ====
 +
 +This transformation outputs valid SQL values for various PV values:
 +  * <null> values are output as NULL
 +  * integers are output as integers
 +  * everything else is output as quoted and escaped string
 +    
 +<code c>
 +    $var(null) = $null;
 +    $avp(null) = $null;
 +    $avp(str) = "String with \ illegal \\characters";
 +    $avp(nr) = 12345;
 +    $avp(strnr) = "12345";
 +    
 +    xlog("$$rm = $rm = $(rm{s.sql})");
 +    xlog("$$var(null) = $var(null) = $(var(null){s.sql})");
 +    xlog("$$avp(null) = $avp(null) = $(avp(null){s.sql})");
 +    xlog("$$avp(str) = $avp(str) = $(avp(str){s.sql})");
 +    xlog("$$avp(nr) = $avp(nr) = $(avp(nr){s.sql})");
 +    xlog("$$avp(strnr) = $avp(strnr) = $(avp(strnr){s.sql})");
 +
 +  Output:
 +    $rm = ACK = 'ACK'
 +    $var(null) = 0 = 0
 +    $avp(null) = <null> = NULL
 +    $avp(str) = String with \ illegal \characters = 'String with \\ illegal \\characters'
 +    $avp(nr) = 12345 = 12345
 +    $avp(strnr) = 12345 = '12345'
 +</code>
 +
 +==== {sql.val.int} ====
 +
 +Like sql.val, but output number 0 for null values.
 +
 +==== {sql.val.str} ====
 +
 +Like sql.val, but output string '' for null values.
  
 ===== Examples ===== ===== Examples =====

Navigation

Wiki

Other

QR Code
QR Code cookbooks:transformations:devel (generated for current page)