Updating table in dbi perl
Those drivers are compiled together with the C client libraries of the respective database engines. | |---| XYZ Driver |---| XYZ Engine | | Perl | | | `--------------' `-------------' | script| |A| |D| .--------------. | using |--|P|--|B|---|Oracle Driver |---|Oracle Engine| | DBI | |I| |I| `--------------' `-------------' | API | | |... Then use the second one to insert a few people in the table. In case of SQLite, of course all the database engine gets embedded in the perl application. Finally use the last example to extract some data from the database and print it out. Note that this may be an expression and not simply the text used for the default value in the original CREATE TABLE statement.
CHAR_OCTET_LENGTH: The maximum length in bytes of a character or binary data type column.
The Perl scripts use DBI, which in turn uses the appropriate Database Driver (e.g. In case of SQLite, the only thing we really need is the path to the database file. In this case we can do this with a single command: is followed by the actual values that go in place of the the place-holders. This is by far the most interesting part of the database access. For this we can use several methods: The method will return the values of the next row in the result set as a list, that we can assign to an array. In the hash the keys will be the names of the fields in the database.
DBD:: Oracle for Oracle, DBD:: Pg for Postgre SQL and DBD:: SQLite to access SQLite). `-' We load DBI but we do not explicitly load the database driver. The DSN (Data Source Name) (in the $dsn variable) is very straight forward. As you can see we did not have to put the place-holders in any kind of quotes nor did we have to somehow convert the values. As the SELECT statement can return a lot of rows and a lot of values in each row we cannot use a simple call to the method of the statement handle passing to it values that should be placed instead of the place-holders. The order of the elements is as the order of the fields in the query. As different databases might return these names of the fields in different cases we configured our database handler to make sure they - the names of the fields - will always converted to lower case. Use the first one to set up the database and create a table.
Note that do() returns 0E0 which == 0, but is still true.
Also note that when using this method, the order of the bound vars are often swapped in the insert since the key or keys are last in the update sql.