How do you join lines in a container (CGUPE)

Pierre Sahores psahores at easynet.fr
Sat Jun 14 08:33:00 EDT 2003


Sadhunathan Nadesan a écrit :
> 
--snip--

What this is,
> is a utility program, a filter that takes a stream of input data from
> a front end data collection program, then looks up something in the
> data base which the data collection program is unable to do (without
> extensive re-engineering), inserts that value into the data stream,
> and passes it on to something else (a back end formatting program).
> So it is a pipe line like
> 
> collect data | metacard filter | report formatter

aka :

1.- Use the SQL database back-end at his best level : parse SQL insert,
update, delete and select statements ("the Xtalk-aware" part of SQL),

2.1.- Avoid to use any other part of the SQL syntax, each time, metatalk
can do better and faster (SQL stocked procs, views or built-in
functions, etc...),

2.2.- Let Metatalk handle all the "AI-style" manipulations on the datas
before sending them back to the ERP's or Web's client-side front-end,
trough a TCP/IP stream.

Comment : There are lots of expensive products, on the market, that are
dedicated to handle the "2.x" part. Most of these tools are mistaking,
about how to do the job, in choosing to clone the bad part of the SQL
methods instead of using an original great syntax (XTalk as my first
choice and PHP as an "emergency wheel"...) to get the expected power in
manipulating the SQL output streams....

Bests, Pierre

> And writing this filter was a lot easier than re-engineering the collect
> data part.
> 
> Sadhu
> 
> ps, I'm sure the code could be improved further, for example, using a
> function call rather than globals, but it's good enough.
> 
> #!/usr/local/bin/mc
> ###############################################################################
> #
> #                            -=< Payroll II >=-
> #         Copyright (c) Cast & Crew Entertainment Services, Inc. 2003
> #
> #     Program name:     sony_filter
> #        File name:     sony_filter.mt
> #           Author:     Sadhunathan Nadesan
> #     Date started:     06/11/2003
> #
> #     Description:
> #       Get Walker Numbers from Data Base and replace tselect field
> #
> ###############################################################################
> 
> global sqlData, keywords
> 
> on startup
>   global sqlData, keywords
> 
>   -- Grab the tselect output in preparation for translation
>   read from stdin until empty
>   put it into inputData
>   -- Now get the translation table from the data base
>   sqlFetch
> 
>   -- Put the real product number into the data stream
>   repeat for each line thisLine in inputData
>     put thisLine into dataArray
>     split dataArray by "|"
>     -- The set code is in the 5th field, space padded
>     put dataArray[5] into setCode
>     replace space with empty in setCode
>     -- Input data has constant 'walker number' instead of product code
>     replace "WALKER_NUMBER" with sqlData[setCode] in thisLine
>     -- Send the data on to RPT
>     put thisLine
>   end repeat
> 
> end startup
> 
> ----------------------------------------------------------
> on sqlFetch
> -- get the list of set codes and product numbers from the data base
>   global sqlData, keywords
> 
>   -- build sql query
>   put "lines 0" & cr into sqlQuery
>   put "select sub_code, string_value from proptl" & cr after sqlQuery
>   put "where option_code = 'SONYACCT' /" & cr after sqlQuery
>   put sqlQuery into url "file:/tmp/sonylist.sql"
> 
>   -- run sql query and capture results
>   put "SQL /tmp/sonylist.sql " into command_string
>   set shellCommand to "/bin/sh"
>   put shell(command_string) into sqlData
> 
>   -- prepare data to be placed in an associative array
>   replace space with empty in sqlData
>   split sqlData by linefeed and "|"
>   put keys(sqlData) into keywords
> 
>   -- cleanup
>   put "rm -f /tmp/sonylist.sql" into command_string
>   put shell(command_string)
> 
> end sqlFetch
> ----------------------------------------------------------
> _______________________________________________
> metacard mailing list
> metacard at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/metacard

--
Cordialement, Pierre Sahores

Inspection académique de Seine-Saint-Denis.
Optimiser les processus de concrétisation
des résultats, sinon rien...



More information about the metacard mailing list