1SQL::Translator::ProducUesre:r:OCroanctlrei(b3u)ted PerlSQDLo:c:uTmreanntsaltaitoonr::Producer::Oracle(3)
2
3
4

NAME

6       SQL::Translator::Producer::Oracle - Oracle SQL producer
7

SYNOPSIS

9         use SQL::Translator;
10
11         my $t = SQL::Translator->new( parser => '...', producer => 'Oracle' );
12         print $translator->translate( $file );
13

DESCRIPTION

15       Creates an SQL DDL suitable for Oracle.
16

producer_args

18       delay_constraints
19           This option remove the primary key and other key constraints from
20           the CREATE TABLE statement and adds ALTER TABLEs at the end with
21           it.
22
23       quote_field_names
24           Controls whether quotes are being used around column names in
25           generated DDL.
26
27       quote_table_names
28           Controls whether quotes are being used around table, sequence and
29           trigger names in generated DDL.
30

NOTES

32   Autoincremental primary keys
33       This producer uses sequences and triggers to autoincrement primary key
34       columns, if necessary. SQLPlus and DBI expect a slightly different
35       syntax of CREATE TRIGGER statement. You might have noticed that this
36       producer returns a scalar containing all statements concatenated by
37       newlines or an array of single statements depending on the context
38       (scalar, array) it has been called in.
39
40       SQLPlus expects following trigger syntax:
41
42           CREATE OR REPLACE TRIGGER ai_person_id
43           BEFORE INSERT ON person
44           FOR EACH ROW WHEN (
45            new.id IS NULL OR new.id = 0
46           )
47           BEGIN
48            SELECT sq_person_id.nextval
49            INTO :new.id
50            FROM dual;
51           END;
52           /
53
54       Whereas if you want to create the same trigger using "do" in DBI, you
55       need to omit the last slash:
56
57           my $dbh = DBI->connect('dbi:Oracle:mysid', 'scott', 'tiger');
58           $dbh->do("
59               CREATE OR REPLACE TRIGGER ai_person_id
60               BEFORE INSERT ON person
61               FOR EACH ROW WHEN (
62                new.id IS NULL OR new.id = 0
63               )
64               BEGIN
65                SELECT sq_person_id.nextval
66                INTO :new.id
67                FROM dual;
68               END;
69           ");
70
71       If you call this producer in array context, we expect you want to
72       process the returned array of statements using DBI like "deploy" in
73       DBIx::Class::Schema does.
74
75       To get this working we removed the slash in those statements in version
76       0.09002 of SQL::Translator when called in array context. In scalar
77       context the slash will be still there to ensure compatibility with
78       SQLPlus.
79

CREDITS

81       Mad props to Tim Bunce for much of the logic stolen from his
82       "mysql2ora" script.
83

AUTHORS

85       Ken Youens-Clark <kclark@cpan.org>, Alexander Hartmaier
86       <abraxxa@cpan.org>, Fabien Wernli <faxmodem@cpan.org>.
87

SEE ALSO

89       SQL::Translator, DDL::Oracle, mysql2ora.
90
91
92
93perl v5.32.0                      2020-09-1S4QL::Translator::Producer::Oracle(3)
Impressum