Next Previous Up Contents
Next: sqlskymatch: Crossmatches table on sky position against SQL table
Up: sqlclient: Executes SQL statements
Previous: Usage

B.19.2 Examples

Here are some examples of sqlclient:

stilts -classpath lib/drivers.jtds-1.1.jar \
       -Djdbc.drivers=net.sourceforge.jtds.jdbc.Driver \
       -Djava.net.preferIPv4Stack=true \
       sqlclient \
           db='jdbc:jtds:sqlserver://amenhotep:1433/twomass' \
           user='guest1' \
           ofmt=csv-nohead \
           sql='SET SHOWPLAN_TEXT ON' \
           sql='SELECT ra,dec FROM twomass_psc WHERE ra BETWEEN 21.7 AND 21.8 \
                                                 AND dec BETWEEN 9.1 AND 9.12'
This sends two commands to a SQL Server database; the first one (SET SHOWPLAN...) sets a flag which causes the DB to return an execution plan rather than the result for subsequent queries, and the second makes the query itself. Since the password is not provided on the command line, a prompt for it will be issued before execution. The result is SQL Server's execution plan for the SELECT statement expressed as a headerless comma-separated value table sent to the terminal. CSV is chosen for the output format since it does not truncate wide columns.


Next Previous Up Contents
Next: sqlskymatch: Crossmatches table on sky position against SQL table
Up: sqlclient: Executes SQL statements
Previous: Usage

STILTS - Starlink Tables Infrastructure Library Tool Set
Starlink User Note256
STILTS web page: http://www.starlink.ac.uk/stilts/
Author email: m.b.taylor@bristol.ac.uk
Mailing list: topcat-user@jiscmail.ac.uk