SQL with Unix Arguments

Question:
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.

Answer:
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.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may