To connect to a database, you use the connect function, which yields a valid database handle if it is successful. In Version 1. This is of most value to web-based applications. The DBI connect method strips the 'dbi:' prefix from the first argument and loads the DBD module identified by the next string Informix in this case.
The string following the second colon is all that is passed to the DBD::Informix code. With this format, you do not have to specify the username or password.
Note that if you specify the username but not the password, DBD::Informix will silently ignore the username. You can also specify certain attributes in the connect call.
These attributes include:. You cannot suppress replication by using the following statement. When the value is changed, the last transaction is committed and a new one is started with the correct statement. You could therefore specify that the database is not to operate in AutoCommit mode, but errors should be reported automatically by specifying:. Note that the AutoCommit behavior is not affected by the type of Informix database to which you are connecting, except that you will be unable to connect to an unlogged database with AutoCommit set to off.
Note that the test code in DBD::Informix::TestHarness does supply the names of test databases implicitly, but this is strictly only the test harness. An additional string, ". Note that the ". Once you have a database handle, you can interrogate it for some basic information about the database. Note that to determine these values, DBD::Informix interrogates the system catalog, which represents a small performance hit. The server version number is retrieved from the entry in "informix".
It is not always precisely the version that is reported by the oninit program, for example, but the difference is usually small and not critical. DBD::Informix cannot use the Informix utilities to determine the database version more accurately because there is no guarantee that the database server is on the same machine as the DBD::Informix code. It also does not use the DBINFO 'version','full' statement because not all available servers support it and the behaviour is sometimes reprehensible when the server does not.
The message might extend over several lines and is generally formatted so that it can be displayed neatly within 80 columns. Note that DBD::Informix allows you to obtain any of the driver attributes from a database handle too. You can call two methods using the DBI func to get at some basic Informix metadata relatively conveniently.
The lists of tables are all qualified as "owner". The leading arguments qualify the list of names returned. Private synonyms are reported for just the current user.
If no tables are listed, all columns in the database are listed. The previous example will roll back any uncommitted work. Note that this example does not destroy the database handle.
Any statements you prepare with this handle are finished see below and cannot be used again. All space associated with the statements is released. Given a database connection, you can execute a variety of simple statements with a variety of different calls:. These two operations commit or roll back the current transaction.
If the database is unlogged, the two operations do nothing. If AutoCommit is set to 1, the two operations do nothing useful. The values in parameters or the separate values are bound to the question marks in the statement string. The only reliable way to embed an arbitrary string inside a statement is to use the quote method:. The string is enclosed in single quotes, and any embedded single quotes are doubled up, which conforms to the SQL standard.
You might typically use this method in a context such as:. Note that the alternative assignment below does not work! You create a statement handle another reference using:. The prepare call accepts an optional attributes parameter that is a reference to a hash. Starting with version 1.
PC1, the following attributes are recognized:. For a noncursory statement, this simply executes the statement. If the statement is executed successfully, the number of rows affected will be returned.
If an error occurs, the returned value will be undef. If the statement does not affect any rows, the string returned is "0E0", which evaluates to true but also to zero. Board index » Perl.
I would like to pay around with accessing our company's Informix 4gl database via an html form calling a Perl program. However, I have visited that site, explored it thoroughly, done a whole series of searches, and can't find anything about this DBD::Informix business, not even to confirm that it exists.
Does anyone here have more concrete guidance to offer? Is there a downloading step that must be done separately, or is there some magic spell with ppm that knows how to install it? Is the Informix driver a commercial product with a price, or is there something free I can evaluate? I'm using ActiveState Perl for Windows version 5. Is there a conflict between this Windows native platform and a Unix native database?
Many thanks for your patience. I know I'm a slow learner. Sure it exists ;- Read the following announcement from informix posted 10 days ago in comp. You will need the code for DBI version 1.
You should be planning to upgrade to at least version Perl 5. Jonathan Leffler Jonathan Leffler k gold badges silver badges bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Making Agile work for data science.
Stack Gives Back Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Related 0. Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled.
0コメント