.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "SQL::Translator::Producer::Oracle 3pm" .TH SQL::Translator::Producer::Oracle 3pm 2024-01-20 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME SQL::Translator::Producer::Oracle \- Oracle SQL producer .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use SQL::Translator; \& \& my $t = SQL::Translator\->new( parser => \*(Aq...\*(Aq, producer => \*(AqOracle\*(Aq ); \& print $translator\->translate( $file ); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" Creates an SQL DDL suitable for Oracle. .SH producer_args .IX Header "producer_args" .IP delay_constraints 4 .IX Item "delay_constraints" This option remove the primary key and other key constraints from the CREATE TABLE statement and adds ALTER TABLEs at the end with it. .IP quote_field_names 4 .IX Item "quote_field_names" Controls whether quotes are being used around column names in generated DDL. .IP quote_table_names 4 .IX Item "quote_table_names" Controls whether quotes are being used around table, sequence and trigger names in generated DDL. .SH NOTES .IX Header "NOTES" .SS "Autoincremental primary keys" .IX Subsection "Autoincremental primary keys" This producer uses sequences and triggers to autoincrement primary key columns, if necessary. SQLPlus and DBI expect a slightly different syntax of CREATE TRIGGER statement. You might have noticed that this producer returns a scalar containing all statements concatenated by newlines or an array of single statements depending on the context (scalar, array) it has been called in. .PP SQLPlus expects following trigger syntax: .PP .Vb 11 \& CREATE OR REPLACE TRIGGER ai_person_id \& BEFORE INSERT ON person \& FOR EACH ROW WHEN ( \& new.id IS NULL OR new.id = 0 \& ) \& BEGIN \& SELECT sq_person_id.nextval \& INTO :new.id \& FROM dual; \& END; \& / .Ve .PP Whereas if you want to create the same trigger using "do" in DBI, you need to omit the last slash: .PP .Vb 10 \& my $dbh = DBI\->connect(\*(Aqdbi:Oracle:mysid\*(Aq, \*(Aqscott\*(Aq, \*(Aqtiger\*(Aq); \& $dbh\->do(" \& CREATE OR REPLACE TRIGGER ai_person_id \& BEFORE INSERT ON person \& FOR EACH ROW WHEN ( \& new.id IS NULL OR new.id = 0 \& ) \& BEGIN \& SELECT sq_person_id.nextval \& INTO :new.id \& FROM dual; \& END; \& "); .Ve .PP If you call this producer in array context, we expect you want to process the returned array of statements using DBI like "deploy" in DBIx::Class::Schema does. .PP To get this working we removed the slash in those statements in version 0.09002 of SQL::Translator when called in array context. In scalar context the slash will be still there to ensure compatibility with SQLPlus. .SH CREDITS .IX Header "CREDITS" Mad props to Tim Bunce for much of the logic stolen from his "mysql2ora" script. .SH AUTHORS .IX Header "AUTHORS" Ken Youens-Clark , Alexander Hartmaier , Fabien Wernli . .SH "SEE ALSO" .IX Header "SEE ALSO" SQL::Translator, DDL::Oracle, mysql2ora.