Fernando Luna wrote:
[...]
I am running perl version 5.005_03 built for AIX Unix.

Get ready to upgrade.


I have Oracle version 8.1.7 installed and running.
I have AIX version 4.3.3.0 [...] I am able to execute queries and PL/SQL blocks using these modules with no problems. What I'd like to do is read a file that contains DDL statements and execute them through these modules.


These files contain specifically

CREATE TABLE statements
CREATE INDEX statements
CREATE PACKAGE/PACKAGE BODY statements
CREATE trigger statements
CREATE VIEW statements

In some cases, these files have more than one statement in them.
(example, creating several indexes on a table) [...]

I've searched the DBI and DBD documentation and I've not found anything that specifically addresses this.


The DBI::Shell might handle this. One issue is how are the statements separated in the source code. If you don't have an explicit separator (typically semi-colon, but I don't know whether that's what Oracle uses), then you need something (SQL::Statement?) to parse the file so that you get each separate statement into a string, which you then submit to $dbh->prepare, $sth->execute, and maybe some $sth->fetch* code.

If DBI::Shell does not handle this, then I still have a rudimentary script which I abandoned when DBI::Shell came along (circa 1997), which almost does what you need. It has a couple of fixable Informix barbarisms in it, and the statement end scanner simply looks for a semi-colon (anywhere, including inside strings and comments) so it can be fooled quite easily, but it does actually do what you need. I'll cheerfully make that code available to you if it is needed -- I never like throwing code away, and this would be an example (nearly six years later) of why you shouldn't do it.

I tried running one CREATE TABLE statement and it appears to choke on some keywords that Oracle has no trouble with, but I suspect has to do with the fact that they are not necessarily ANSI-SQL compliant.

Shouldn't be an issue - but it depends on why you think it might be


Is this something that might be covered in this book or can you
tell me if this just cannot be done with these modules?

It can be done OK - it just may not be fully pre-packaged if DBI::Shell does not handle this for you.


--
Jonathan Leffler ([EMAIL PROTECTED], [EMAIL PROTECTED]) #include <disclaimer.h>
Guardian of DBD::Informix 1.04.PC1 -- http://dbi.perl.org/




Reply via email to