• Marc G. Fournier's avatar
    From: Anton de Wet <adw@obsidian.co.za> · 17b5bd33
    Marc G. Fournier authored
    Subject: [HACKERS] Small patch to pgtclCmds.c
    
    Hi I have made the following small change to the extensions I made to
    pgtclCmds.c quite a while ago.
    
    At the moment there is a -assignbyidx option to pg_result assigning the
    returned tuples to an array by using the 1st field of the select statement
    as the key to the array.
    eg "select name,age from vitalstatistics" will result in an array with
    
    myarray(peter) = 32
    myarray(paul)  = 45
    
    Often I need to have a pseudo-multi dimentional
    array eg. "select name,age from vitalstatistics where occupation='plummer'
    
    I would like to be able to generate an array
    newarray(peter,overpaid) = 32
    
    So to add a arbitrary string to the key value I have extended
    
      pg_result $res -assignbyidx $arrayname
    
    to have an optional argument
    
      pg_result $res -assignbyidx $arrayname $appendstr
    
    So that that string is appended to the key value.
    17b5bd33
pgtclCmds.c 32.9 KB