250 likes | 422 Views
CGI-SQL. Retrieve Informix data directly into Excel where your users really want it Faster and more flexible than reporting packages such as Crystal or Cognos No drivers or any other PC setup required More secure and controlled than ODBC
E N D
CGI-SQL • Retrieve Informix data directly into Excel where your users really want it • Faster and more flexible than reporting packages such as Crystal or Cognos • No drivers or any other PC setup required • More secure and controlled than ODBC • Natively compiled ESQL-C program which therefore performs excellently • Used for many years in major UK corporation • Low cost solution only available from Oninit
Oninit CGI-SQL Test System In this presentation, we will be using Oninit’s publicly accessible CGI-SQL test system at: www.cgisql.com We will use default database “stores_demo”, which is the standard demonstration database provided with Informix. Example screen-shots are based on Excel 2007, although CGI-SQL works with any version that supports Web Queries (Excel 97 onwards). All versions of Informix are supported.
CGI-SQL / Examples / Web Based: Purpose This demonstration page uses a conventional HTML form to pass parameters to CGI-SQL once you press the submit button. It shows how the SQL content (which can only be a single SELECT statement) can be passed dynamically together with login details, database name, and the maximum number of rows to be returned. The results are shown on the next slide.Tip: if you need to use CGI-SQL with a very large and complex SELECT statement, create a VIEW.
Accessing CGI-SQL inside Excel Now suppose you want this query to be run automatically from within an Excel workbook, so that, when it is opened, it will automatically refresh the contents from the Informix database via CGI-SQL. Note that the HTML submit produced a URL equivalent to the following (with redundant parameters removed):http://www.cgisql.com/cgi-bin/cgi-sql.cgi?SQL=SELECT+company,+city+FROM+customer+ORDER+BY+1
Specifying an Excel Web Query: Process Choose Data / Get External Data / Web Based from the Excel 2007 ribbon menu, or Data / Import External Data / New Web Query from the Excel 2003 menu. Type or paste in the URL in the “Address” box and press the “Go” button. Click the yellow arrow next to the data table. Click the “Options” button and deselect “Treat consecutive delimiters as one”. You sometimes also need to “Disable date recognition” (do this later only if the data is being misinterpreted). Press “OK” and “Import”.
Excel Web Query Properties: Example Click on “Properties”. Enter a more suitable “Name” for the query. Enable “Refresh data when opening the file”. Make sure “Preserve cell formatting” is enabled. Disable “Adjust column width” if you intend to set this manually. Change other settings as desired. Press “OK twice”.
Auto-Refreshing Excel Workbooks: Process Try closing and reopening the workbook. Depending on your security settings, you may get a warning such at the one shown on the next slide. Click on “Options”. Select “Enable this content”. Click “OK”.
Parameterized Web Queries: IQY Files What if your users need to enter search criteria? This is achieved by first creating a plain text IQY (Internet Query) definition file, for example: WEB 1 http://www.cgisql.com/cgi-bin/cgi-sql.cgi Param1=["State","State code (%=all)"]&SQL=["SQL","Select statement"]&Format=Excel Variables should be named “Param1”, “Param2”, etc. It is recommended that the SQL statement is also treated as a dynamic parameter in an IQY file or it is otherwise difficult to change later. “Format=Excel” in always required in this context. The process for creating a Web Query using this file is illustrated in the next few slides. For further reading, see: http://support.microsoft.com/kb/157482
Parameterized Web Queries: Process Choose Data / Get External Data / Existing Connections from the Excel menu. Click “Browse for more”, locate and select your IQY file. Change “Properties” as for simple Web Queries. Enter parameter values in turn. You can reference cell locations if you wish and tick “Use this value/reference for future refreshes” so that you are not prompted next time. The data is returned into the worksheet. The next slide shows the results with cell and column formatting to produce a more finished look – and “Filters” to display subsets – all of which will be retained when the data is refreshed if specified in “Properties”.
CGI-SQL Parameter List The following is the complete list of optional CGI parameters: User / Password – Informix authentication details Database – Informix database name Format – “Text” or “Excel” to force MIME type Heading – fixed first line (“None” suppresses column headings) MaxRows – maximum rows to return (default “65535”) The following server-side environment variables also apply: CGISQLUSER / CGISQLPASSWORD / CGISQLDATABASE – defaults for above parameters CGISQLTIMEOUT – maximum seconds the query is allowed to run before being automatically terminated
CGI-CSV A companion server-side CGI script is also provided to enable pre-prepared results of scheduled jobs to be returned to a Web Query. CGI-CSV is given a single parameter representing the report directory name. The latest Gzip-compressed CSV (Comma Separated Value) file in this folder is located, expanded and returned. For example: http://www.cgisql.com/cgi-bin/cgi-csv.cgi?name=test
How It All Works: Detail Routine reports - particularly those with long run times - can be run overnight every week or month by the UNIX scheduler. These Shell scripts, which either have embedded SQL statements or call 4GL programs in more complex cases, create zipped CSV files on a public FTP server. Users would typically access these files - and Excel templates into which they can be loaded - via Web links, but they can equally be accessed directly from the FTP server. Reports that require parameters from the user can be accessed via Web pages that use the CGI generic SQL “SELECT” statement runner CGI-SQL to return dynamic results displayed with the Internet Explorer Excel plug-in. Alternatively, Excel applications can be designed to refresh their contents automatically, either directly from the database via CGI-SQL, or using the CGI-CSV script to return the contents of the latest CSV file in a specified folder from the public FTP server. Web Queries embedded in Excel applications that allow parameters to be entered by the user are created using Import Data with IQY query definition files.
Next Steps Contact Oninit via www.oninit.com and we will: Discuss your requirements with you. Assist with the installation of Apache on existing hardware if no suitable Web server is available. Locally compile CGI-SQL for your platform and install all associated scripts. Develop Excel reports for you or give on-site training on relevant Excel techniques. Provide remote support.