## Using #shell and #sql in ploticus scripts

Version 2.32

Manual page for Using_#shell_and_#sql_in_ploticus_scripts(PL)

## #shell and #sql

The #shell script directive may be used to invoke a shell command and capture the results.``

The #sql script directive invokes an SQL command and captures the results.`` The #sql directive is currently available only for builds related to the QUISP/SHSQL package.`` Interfaces to other databases (MySQL, Oracle, etc.) not yet available but should be possible by coding in `dbinterface.c`.``

Note that both of these are of limited value in ploticus... proc getdata already has a `command` attribute for getting data from shell command results, and it also has a `sql` attribute for running an SQL command. They should be viewed as providing an alternative approach.``

## STREAMING DATA

Here is an example of how #sql is to be used with proc getdata :

     	#proc getdata
     	delim: tab
           data:
     	#sql #dumptab select * from trialresults where trialnum = @TRIALNUM

For longer SQL commands a multi-line construct is available:

     	#proc getdata
     	delim: tab
           data:
     	#sql #dumptab
     		select trialnum, age, sex, weight, time1, time2
     		 from trialresults
     		where trialnum = @TRIALNUM and trialdate = @TDATE
           #endsql

The #shell directive can be used similary, but this is redundant since proc getdata already has a `command` attribute.``

## SETTING VARIABLES

These directives may be used to set variables for plot labels, etc.`` For example:

     	#sql #load select fullname from tsyms where tickersym = @TSYM

           #proc annotate
           location: min max-0.2
           text: @fullname

Here is an example where the results of a shell command may be used to set variables:

           // submit the command..
           #shell #processrows cat mydata | grep "^Jan"
           // get one result rows and parse out fields..
           #call $shellrow( A, B, C )

     	#proc annotate
     	location: min max-0.2
     	text: @A @B

## DRIVING LOOPS

These directives may be used to drive loops that iterate once per row of results. For example:

     	// get a list of cases
     	#sql #processrows select caseid from cases
     	#while $sqlrow() = 0
     	  // get data for a case
     	  #proc getdata
     	  delim: tab
     	  data:
     	    #sql2 #dumptab select * from casedata where caseid = @caseid
     	    ... plot the case

     	#endloop

#shell may be used similary.``
data display engine
Copyright Steve Grubb

Markup created by unroff 1.0, `` `` August 23, 2005.