File: plshellsql.html

package info (click to toggle)
ploticus 2.0.3-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 3,696 kB
  • ctags: 2,035
  • sloc: ansic: 40,100; perl: 456; sh: 186; makefile: 129
file content (162 lines) | stat: -rw-r--r-- 3,833 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<html>
<head>
<!-- This file has been generated by unroff 1.0, 09/17/01 08:47:32. -->
<!-- Do not edit! -->

<STYLE TYPE="text/css">
<!--
        A:link{text-decoration:none}
        A:visited{text-decoration:none}
        A:active{text-decoration:none}
-->
</STYLE>
<title>ploticus: using #shell and #sql in ploticus scripts</title>
<body bgcolor=D0D0EE vlink=0000FF>
<br>
<br>
<center>
<table cellpadding=2 bgcolor=FFFFFF width=550 ><tr>
<td>
  <table cellpadding=2 width=550><tr>
  <td><br><h2>Using #shell and #sql in ploticus scripts</h2></td>
  <td align=right>
  <small>
  <a href="../doc/Welcome.html"><img src="../doc/ploticus.gif" border=0></a><br>
  <a href="../doc/Welcome.html">Welcome</a> &nbsp; &nbsp;
  <a href="../gallery/index.html">Gallery</a> &nbsp; &nbsp;
  <a href="../doc/Contents.html">Handbook</a> 
  <td></tr></table>
</td></tr>
<td>
<br>
<br>

<title>Manual page for Using_#shell_and_#sql_in_ploticus_scripts(PL)</title>
</head>
<body>

<h2>#shell and #sql</h2>
These are two new directives that can be used in scripts with ploticus 2.00
and higher.  They both work similary, and can either stream results into
the script, or set variables.  
<a href="shell.html">
 #shell
</a>
is an interface for running external commands and capturing the results.<tt> </tt>
<a href="sql.html">
 #sql
</a>
will allow ploticus to operate as a client to SQL databases, and works with
pocketSQL.  
Interface to other databases (MySQL, Oracle, etc.) is not yet available;
code contributions are sought in these areas (see <tt>dbinterface.c</tt>).<tt> </tt>

<br><br><br>

<h2>STREAMING DATA</h2>
Here is an example of how 
<a href="sql.html">
 #sql
</a>
is to be used with 
<a href="getdata.html">
 proc getdata
</a>
:
<pre>
 	#proc getdata
 	delim: tab
       data:
 	#sql #dumptab select * from trialresults where trialnum = @TRIALNUM
</pre>
<p>
For longer SQL commands a multi-line construct is available:
<pre>
 	#proc getdata
 	delim: tab
       data:
 	#sql #dumptab 
 		select trialnum, age, sex, weight, time1, time2
 		 from trialresults 
 		where trialnum = @TRIALNUM and trialdate = @TDATE
       #endsql
</pre>
The
<a href="shell.html">
 #shell
</a>
directive can be used similary, but this is redundant since 
<a href="getdata.html">
 proc getdata
</a>
already has a <tt>command</tt> attribute.<tt> </tt>

<br><br><br>

<h2>SETTING VARIABLES</h2>
These directives may be used to set variables for plot labels, etc.<tt> </tt>
For example:
<pre>
 	#sql #load select fullname from tsyms where tickersym = @TSYM
 
       #proc annotate
       location: min max-0.2
       text: @fullname
 
</pre>
<p>
Here is an example where the results of a shell command may be used to
set variables:
<pre>
       // 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

<br><br><br>

</pre>
<h2>DRIVING LOOPS</h2>
These directives may be used to drive loops that iterate once per
row of results.  For example:
<pre>
 	// 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
</pre>
<p>
<a href="shell.html">
 #shell
</a>
may be used similary.<tt> </tt>

<br>
<br>
</td></tr>
<td align=right>
<a href="Welcome.html">
<img src="../doc/ploticus.gif" border=0></a><br><small>data display engine &nbsp; <br>
<a href="../doc/Copyright.html">Copyright Steve Grubb</a>
<br>
<br>
<center>
<img src="../gallery/all.gif">
</center>
</td></tr>
</table>
<p><hr>
Markup created by <em>unroff</em> 1.0,&#160;<tt> </tt>&#160;<tt> </tt>September 17, 2001.
</body>
</html>