SQL with Unix Arguments

SQL with Unix Arguments

How do I pass arguments from a Unix shell onto SQL for various SQL statements (e.g., select * from $tablename, create table $TABS, etc.)?

Also, how do I get output from SQL within a SPL to several different files? So SQL executes many times and creates a different file each time. Tried to use OUTPUT, but gives some error.

You can pass the variables into an Informix dbaccess session by using a UNIX “here file.” Create an ascii file called doit:

dbaccess databasename <

Now, chmode doit to allow execution. Execute it by typing "doit tablename." The "tablename" is passed into the doit here-document as $1.

As to your stored procedure question, there are a few provisions in SPL for generating output. Some programmers use the TRACE statement to provide rudimentary output. Some simply populate tables with the results of the SP and then run other programs to generate the output from those tables. Another way would be using the SYSTEM functionality in SPL to let the OS do the output.

See also  How to Create and Deploy QR Codes Online: A Comprehensive Guide

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist