ltannous
4th May 2005, 22:17
I am trying to use the qptool with my perl script and i can create a file with the qptool, but I need to get rid of the ' or use them as the field seperators.
When in perl, I say my file is split(/\'/) but that returns no value. Is there a simple way in the qptool command to change the ' to maybe a | or if someone knows what the proper command is in perl.
This is my qptool command:
system "/apps/baan/bse/bin/qptool6.1 -o /apps/baan/bse/tmp/wetpart -c 210 -q \"select tcedi306.item from tcedi306 where tcedi306.reno = '$cuno' and tcedi306.dsca = '$cpno' ";
I dont see an easy way to do this... but if you have a field which isnt a string you would not have ' ' as the separators.
Here is an example -
[DEV:bsp]/app/lms/lmss/opt/bse/bin>qptool6.2 -c000 -q "select * from ttaad200
where ttaad200.user = 'nprao' "
'nprao ' 'N. Prashanth Rao ' 'nprao' 1 1
' ' 0 2400 2 2
' ' 2 6 0 1 'b52amlgd'
0 '2' 'zm' 'adm' '00000003' 0 1 1 2 2
'ISO-8859-1 ' 2 ' ' 1 1 ' ' ' ' 1 2 1 ' ' ' ' 'BAANADMIN ' 'DEFAULT ' ' ' ' ' ' ' ' ' 'ULTRAEDIT ' ' ' 1 2 ' ' 'intapps.world.com/help ' 1 1 2 '%s : %S [%c] ' 1 ' ' 0
[DEV:bsp]/app/lms/lmss/opt/bse/bin>
Alternatively, you can use SQL queries and then re-direct the output of that report into an Excel device.
Brendan Shine
5th May 2005, 22:04
You could send the qptool output from stderr (2>) to Unix tr command (see man tr) and translate the ' to a |.
qptool6.1 -c100 -q'select tdsls040.orno from tdsls040' 2> | tr "'" "|"
jeroen.bos
1st December 2005, 17:43
I once wrote a PHP function that translates a qptool record into an array. It should be easy to translate it into Perl:
function qptool_fetch_row($record_string) {
//First, split the string into chunks that are surrounded by quotes (')
//and chunks that aren't. Adding the delimiter (space) to the ends
//simplifies the logic further down:
$chunks = explode('\'', " $record_string ");
//Then, process each chunk. $instring toggles, so we know if the
//current chunk is a quoted string or not:
$instring = 0;
while (list($index, $chunk) = each($chunks)) {
if ($instring==1) {
//This chunk is a quoted string.
//Add the whole chunk to the array $record_row:
$record_row[] = $chunk;
$instring = 0;
} else {
//This chunk is NOT a quoted string.
//Break up the chunk into separate fields. Each chunk has extra
//spaces around it (inc the ones added above), so trim:
$chunk_fields = split(' ', trim($chunk));
while(list($index2, $field) = each($chunk_fields)) {
$record_row[] = trim($field);
}
$instring = 1;
}
}
return $record_row;
}