Re: shell to perform dbaccess
Posted in 1997
Topics: Server Administration, Migration, Import/Export & Data Conversion
On Thu, 24 Apr 1997, Joe Lumbley wrote:
>
> Teresa Crowl (tjc@umbra.pvh.org) wrote:
>
> : Does anyone know how I would write a shell program to
> : take sql statements from a file and execute them
> : via dbaccess?
>
<snip>
Try your own version of the below within a bourne shell script:
# ... (other script commands above)
# $SDB contains the path to the the desired informix *.dbs directory
# Note that the shell expands all variables referenced (e.g., $f1)
# dbaccess -e $SDB - << STOP 2>&1 | tee /tmp/drm # she's a screamer
# dbaccess $SDB - << STOP 2>/dev/null # she's real quiet dbaccess $SDB - << STOP # she only whimpers
UNLOAD TO "$f1" DELIMITER "^"
SELECT inv_stk_no new_stock_item, inv_keyword, inv_date,
inv_unit_cost cost_ea, inv_bal_on_hand on_hand,
(inv_bal_on_hand * inv_unit_cost) tl_value
FROM inv_file
WHERE inv_date BETWEEN "$bdate" AND "$edate"
INTO TEMP new;
SELECT new_stock_item, inv_keyword, inv_date setup_on, on_hand
FROM new ORDER BY new_stock_item;
SELECT COUNT(*) new_stock_item FROM new; SELECT SUM (tl_value) total_val_ordered FROM new;
STOP
# ... (other script commands below)
Dan
+-----------------------------------------------------------------+
| Striving to be what the liberals call a "tax-cuts-for-the-rich, |
| mean-spirited, intolerant, radical, religious-right, extremist" |
+-----------------------------------------------------------------+