Professional Documents
Culture Documents
A brief discussion of how to use IDS with a wide variety of Open Source languages - Perl, Tcl/Tk, Python, PHP, etc.
Agenda
Open Source Connecting to IDS Perl, DBI, and DBD::Informix Tcl/Tk and isqltcl PHP Aubit 4GL SQLCMD SQSL Python Ruby
2
Open Source
What is Open Source?
Which rock have you been hiding under? Software released under an Open Source license
Conformant with the Open Source Definition Found at http://www.opensource.org/
Free Redistribution Source Code Derived Works Permitted No Discrimination Against People or Groups No Discrimination Against Fields of Endeavour Distribution of License
ODBC
Originally defined by Microsoft. Standardized (as CLI) by ISO/IEC 9075-3:1996.
JDBC
Java analogue of ODBC. Standardized by Sun.
All of these are proprietary. But can be used with Open Source software.
ESQL/C
Preprocessor that converts extended C into pure C. Links with specific libraries. Separates static and dynamic SQL.
Even though Informix does not really do so.
int main(void) { EXEC SQL WHENEVER ERROR STOP; EXEC SQL DATABASE Stores; EXEC SQL BEGIN WORK; EXEC SQL DROP TABLE Customer; EXEC SQL ROLLBACK WORK; return(0); }
ODBC
Database agnostic.
Separates driver manager from drivers. Different drivers can be loaded at run time. You can avoid database-specific features. But sometimes you want to use them.
JDBC
Database agnostic. Drivers have different levels of Java-ness.
Type 4: pure Java usually the best type to use.
10
11
12
13
14
14
This deletes all (most) rows from the table! Use $dbh->quote($name) if you must. Better to use placeholders (?) in the SQL
$sth = $dbh->prepare(qq{ DELETE FROM Customer WHERE Lname LIKE ? AND ZipCode IS NULL });
15
SQL Injection is a serious problem in many systems it is not peculiar to Perl or IDS.
15
16
17
18
19
19
Tcl/Tk Extensions
Tcl/Tk is designed to be easily extended Many extensions available for all jobs For example
Expect
Designed to handle scripting of processes Used for automating testing ftp://expect.nist.gov/
20
20
Loading ISQLTCL
Load the ISQLTCL extension
load isql.so
21
21
ISQLTCL Connections
Connect to a database
sql connect dbase as conn1 user \ $username password $password
Connect to given database
22
22
ISQLTCL Statements
Executable statements
Statements that return no data
23
23
ISQLTCL Cursors
SELECT, EXECUTE PROCEDURE set stmt [sql open {select * from sometable}]
Does PREPARE, DECLARE, and OPEN Returns a statement number (id) or a negative error Optionally takes arguments for placeholders
24
24
ISQLTCL Cursors
sql reopen $stmt ?arg1? ?arg2?
Reopens the statement, with new parameters
25
25
What is PHP?
Hypertext Processor
Was once Personal Home Page
Version 4.4.1 released October 2005 Version 5.0.5 released September 2005 Version 5.1.1 released November 2005 An HTML scripting language
Server-side Cross-platform Embedded in HTML documents Extensible
26
26
What is PHP?
Built into the Apache Web Server
Using DSO (dynamic shared objects) mod_php
Or as a CGI binary
With any web server
27
27
What is PHP?
Built-in access to:
Email XML HTTP (cookies, sessions)
And databases:
ODBC
DB2, Adabas-D, Empress, Solid, Velocis
28
28
What is PHP?
IBM also provides modern PDO drivers PDO PHP Data Objects
PHP analogue of Perl DBI Article on DeveloperWorks
http://tinyurl.com/eycg2
For DB2
Via PDO_ODBC
29
29
30
30
Must be explicitly compiled into PHP. 30 core functions. 8 functions to manipulate SBLOBs.
31
31
Basic Operations
ifx_prepare ifx_query ifx_fetch_row ifx_do ifx_free_result
32
32
33
33
34
34
35
35
36
36
Embedded SQL for database access High productivity, easy to learn Licensed under GPL/LGPL Includes 4GL-based Open Source software For commercial and non-commercial applications
37
37
38
38
Platform independent
(POSIX, UNIX, Windows)
39
39
40
40
41
41
SQLCMD
Originally called RDSQL in 1987.
Renamed SQLCMD in 1992.
Designed for interactive use. Available from the IIUG Software Archive.
42
42
43
43
http://www.4glworks.com/sqsl.htm
44
44
Ruby
http://www.ruby-lang.org/ Version 1.8.3 September 2005. No known Informix support
Lots of different database support packages. No unifying concept like DBI or PDO.
45
45
46
46
http://www.ibm.com/software/data/informix http://www.iiug.org/software
47
47
http://www.ibm.com/software/data/informix http://www.iiug.org/software
48
48
Jonathan Leffler
IBM Information Management jleffler@us.ibm.com
49
49