Multiple CREATE TRIGGER's in SQL file

I have an SQL file which contains multiple CREATE TRIGGER statements. I can't run it as it stands in SQLPlus Worksheet because it doesn't recognise the
end;
as the end of the create trigger statement and fails on the next CREATE line.
Is there a way I can get this file to process. I can run each statement individually, but there's a lot of them.
Any thoughts much appreciated.
Thanks in advance.

Just for clarity within your file, you may want to do the following
Create or Replace Trigger TG_One
  before insert on mytab_two
  for each row
declare
  adt_exists           EXCEPTION;
begin
end TG_One ;
Create or Replace Trigger TG_Two
  before insert on mytab_three
  for each row
declare
  adt_exists           EXCEPTION;
begin
end TG_Two ;

Similar Messages

  • Create trigger within PL/SQL

    I have a procedure that creates a trigger. When I execute the procedure I get an error: ORA-01031, however, when I copy and paste the create trigger command, it executes and will create the trigger without any problems. What is causing the 'insufficient privileges' error when it attempts to create it within a procedure?
    Here is the stream of commands SQLPlus that shows what I am getting:
    SQL> CREATE OR REPLACE PROCEDURE prc_create_trigger
    2 (Table_Name in varchar2)
    3 IS
    4 v_create_trigger VARCHAR2(4000);
    5 BEGIN
    6 v_create_trigger := 'CREATE OR REPLACE TRIGGER trg_pauls_table ';
    7 v_create_trigger := v_create_trigger || 'AFTER INSERT ON ' || table_name || ' ';
    8 v_create_trigger := v_create_trigger || 'REFERENCING NEW AS newrow OLD AS oldrow FOR EACH ROW ';
    9 v_create_trigger := v_create_trigger || 'DECLARE ';
    10 v_create_trigger := v_create_trigger || ' v_text varchar2(20);';
    11 v_create_trigger := v_create_trigger || 'BEGIN';
    12 v_create_trigger := v_create_trigger || ' v_text := ''Inserted Row'';';
    13 v_create_trigger := v_create_trigger || ' dbms_output.put_line(v_text);';
    14 v_create_trigger := v_create_trigger || 'END;';
    15
    16 DBMS_OUTPUT.put_line(v_create_trigger);
    17
    18 --
    19 execute IMMEDIATE v_create_trigger;
    20 END;
    21 /
    Procedure created.
    SQL> exec prc_create_trigger('pauls_table');
    CREATE OR REPLACE TRIGGER trg_pauls_table AFTER INSERT ON pauls_table
    REFERENCING NEW AS newrow OLD AS oldrow FOR EACH ROW DECLARE v_text
    varchar2(20);BEGIN v_text := 'Inserted Row';
    dbms_output.put_line(v_text);END;
    BEGIN prc_create_trigger('pauls_table'); END;
    ERROR at line 1:
    ORA-01031: insufficient privileges
    ORA-06512: at "BAAN.PRC_CREATE_TRIGGER", line 20
    ORA-06512: at line 1
    SQL> CREATE OR REPLACE TRIGGER trg_pauls_table AFTER INSERT ON pauls_table
    2 REFERENCING NEW AS newrow OLD AS oldrow FOR EACH ROW DECLARE v_text
    3 varchar2(20);BEGIN v_text := 'Inserted Row';
    4 dbms_output.put_line(v_text);END;
    5 /
    Trigger created.
    I am wanting to do this because I need to create this trigger dynamically when a table has been created. This trigger is simply for testing the procedure.
    Thank you for your assistance.
    Paul

    Why does the application need to drop and re-create tables in the first place? What is the purpose of this "re-org"? If it accomplishes anything useful, it's likely that there is some flaw in the application architecture/ design/ implementation that could be fixed once to remedy whatever problem this drop & rebuild option attempts to solve. If there really is a need to reorganize a table regularly, could the application at least be modified to use one of the various approaches Oracle provides for this sort of thing?
    The "re-org" process you're describing is, at best, a hack. A trigger on the TABLES_TO_BE_REORGED table that creates triggers on whatever table name was deleted from this table is, at best, a hack. Layering one hack on top of another is likely to cause lots of pain.
    For one thing, a trigger cannot commit. But DDL implicitly commits before and after the DDL is executed. So you cannot create a trigger within another trigger. You could have a trigger that creates a job that later runs and creates the new trigger, but that's adding an extra layer of asynchronisity to a problem that is already likely over-engineered. You could also declare the trigger that creates the trigger to be an autonomous transaction, but that would cause horrible problems if the re-org process ever were to encounter and exception and have to roll back.
    Justin

  • Error while executing Multiple Stored Procedure through .sql file

    Hi Guru's.
    I am new to ORACLE. I am facing problem while creating Stored Procedure through .sql file.
    I have one test.sql file with Stored Procedure is like,
    CREATE OR REPLACE PROCEDURE skeleton1
    AS
    BEGIN
         DBMS_Output.Put_Line('skeleton1');
    END skeleton1;
    CREATE OR REPLACE PROCEDURE skeleton2
    AS
    BEGIN
         DBMS_Output.Put_Line('skeleton2');
    END skeleton2;
    Now when i try to execute this test.sql file through SQL PLUS it gives me Error like this
    I am opening test.sql file from SQL PLUS,
    SQL>
    1 CREATE OR REPLACE PROCEDURE skeleton1
    2 AS
    3 BEGIN
    4 DBMS_Output.Put_Line('skeleton1');
    5 END skeleton1;
    6 /
    7 CREATE OR REPLACE PROCEDURE skeleton2
    8 AS
    9 BEGIN
    10 DBMS_Output.Put_Line('skeleton2');
    11* END skeleton2;
    SQL> /
    Warning: Procedure created with compilation errors.
    SQL> show errors;
    Errors for PROCEDURE SKELETON1:
    LINE/COL ERROR
    6/1 PLS-00103: Encountered the symbol "/"
    SQL>
    Please suggest how to create multiple CREATE PROCEDURE using single .sql script file....
    Regards,
    Shatrughan

    Hi,
    Try this
    CREATE OR REPLACE PROCEDURE skeleton1
    AS
    BEGIN
    DBMS_Output.Put_Line('skeleton1');
    END ;
    CREATE OR REPLACE PROCEDURE skeleton2
    AS
    BEGIN
    DBMS_Output.Put_Line('skeleton2');
    END;
    /Save the file and call it.
    Regards,
    Bhushan

  • Database Structure Dump into SQL file

    I would like to dump the entire structure of my database into an file that will be used later to recreate the same structure. I would like oracle to create almost like a sql file the can be run in another tablespace. I would like to create all the sql commands that would be used to create the tables and sequence generators. Is there a command in oracle that dumps the information?
    Thanks,
    eric

    No there isn't such a command
    But You can use export to export only table structure without data and You can see all CREATE statements there
    Or you can use Oracle Designer, Visio or maybe another free tool to reverse engineer tables and then generate CREATE scripts
    Or You can make Your own script or maybe search for one in internet that creates these DDL statements from data dictionary

  • System Copy Error @ CreateDB using control.sql file

    Hi Experts,
    I am doing A Homogeneous System Copy. I have installed DB and patched 10.2.0.2 as source is of the same level.
    After DB Installation, restored DB , run the control.sql file and opened it. Recovered DB using this way: "Recover Database using backup controlfile until cancel;" and opened reset logs
    Once DB is open, i continued other steps from the point Backup/Restore DB in sapinst. It said CONTROL.SQL file is missing, so i have placed the same in installation directory. In this step "CREATE DATABASE with control.sql file" it has been throwing me error:  Ora-00265 instance recovery required, cannot set ARCHIVE log mode DB altered. DB Closed. DB Dismounted and DB Closed.
    Could you please explain why it is asking for Archive logs and shutting down the DB.
    Thanks,
    Subbu

    Hi,
    well the copy guide says you have to do an OFFLINE backup.
    So sapinst expects a restored database (from offline backup) with non existing controlfiles
    and the need to do a CREATE CONTROLFILE ...
    You already did that manually. You already opened the db...
    So there is no way to run a CREATE CONTROLFILE with "SET database" (not sure
    about the RESETLOGS in this case for a second time...).
    I do not know what state your DB is in right now. If it is completely operational
    and fully recovered and can be opened and shutdown normal, try to substitute
    your control.sql with simply (copy the original content somewhere else)
    alter database mount;
    alter database open;
    Repeat the sapinst step.
    Depending on how far it put in the progress bars in the xml file, you might need
    only one of those two statements in control.sql.
    If the restored DB is not operational now, then the controlfiles might be garbled due to the
    second try top create them from sapinst. Not sure what the situation is then.
    Volker

  • Add member in Distribution List from Sql file or Sql Server

    Hi 
    I want to add member in Distribution List in MS Exchange 2010 using MS Sql Database file
    How to create connectivity between MS SQL file and MS Exchange 2010 ?
    and manage DL also add and remove member from DL?

    The answer to your question depends on the version of SQL Server and Exchange you are running.  If you have Exchange 2007 or higher, and if you have SQL Server 2010 or higher, you can load support for both in a PowerShell session.  Otherwise, you
    will need to write an application to join the two.  It may be simplest to schedule a flat-file dump from your SQL Server database, and use that to pull DL membership into Exchange - I know several third party corporations that have done this for their
    Exchange 2003 (and earlier) management add-ons.
    And before you ask, it would take too much time for me to explain how you would need to connect to and interact with the SQL Server database using PowerShell (or how to dump a flat-file from it, for that matter) for me to do it here.  I suggest you
    search the web for SQL Server PowerShell or SQL Server export
    for that information.
    Once you have the information from SQL Server, it's a simple task to run Add-DistributionGroupMember to add members and Remove-DistributionGroupMember for DL membership management.  I'll caution you, though - if you are going to do massive updates to
    a large distribution group, it would probably be faster to use DL management in AD.  The reason for this is that you can add or remove several group members at once using the AD toolset, but you can only work with individual members with the above Exchange
    commands.  And working with individual members means enumerating the entire group membership for each update - and with large groups, this takes a lot of time.

  • Creating trigger with dbms_sql causes ORA-01912

    I use the following procedure to execute statements that are stored in clobs. These statements are very long 'create trigger' statements.
    SQL> create or replace procedure executeClob(clob_stmt in clob) is
      2 
      3      n_size number := ceil(dbms_lob.getlength(clob_stmt) / 255);
      4      n_counter number;
      5     
      6      t_lines dbms_sql.varchar2s;
      7      i_cursor integer := dbms_sql.open_cursor;
      8  begin
      9  
    10      for n_counter in 1..n_size loop
    11          t_lines (n_counter) := to_char(substr(clob_stmt, 1 + 255 * (n_counter - 1), 255));
    12      end loop;
    13     
    14      dbms_sql.parse(i_cursor, t_lines, t_lines.FIRST, t_lines.LAST, false, DBMS_SQL.native);
    15      dbms_sql.close_cursor(i_cursor);
    16  end;
    17  /Every time I call this procedure, I get the following error
    ORA-01912: keyword ROW expected
    ORA-06512: in "SYS.DBMS_SYS_SQL", Line 1485
    ORA-06512: in "SYS.DBMS_SQL", Line 26
    ORA-06512: in "NTSDEV6.EXECUTECLOB", Line 14
    ORA-06512: in "NTSDEV6.CREATELOGTRIGGER", Line 150
    Has anyone an idea what the heck is going on? I can't explain that ORA-01912.
    Thanks for your help =)

    Herzal wrote:
    yes, the create-statement works fine when I paste it directly into sql*plusWhen and how did you test that? - Before putting it into the clob of after splitting clob up into strings.
    Have you tried writing out the contents of your collection before parsing it? - It sounds like a missing chr(10) after FOR EACH ROW
    Regards
    Peter

  • Order entry database sample oc_popul.sql file

    Hi Everyone,
    I just recently install oracle xe 11 and it does not come with order entry database sample. i really want to get familiar with this order entry database as it will be use in the oracle test 1z0-051.
    I already google it, and create all the necessary sql file and order entry database, however i still need to populate my order entry database.
    I was wondering if anyone can send me this one file oc_popul.sql that will populate my order entry database?
    Thanks.

    Pl post your OS details. Download the Examples zip file -
    For Win 32-bit - http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win32soft-098987.html
    For Linux 64-bit - http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-linx8664soft-100572.html
    Then follow these instructions - http://docs.oracle.com/cd/E11882_01/server.112/e10831/installation.htm#I4367
    HTH
    Srini

  • Help with creating a sql file that will capture any database table changes.

    We are in the process of creating DROP/Create tables, and using exp/imp data into the tables (the data is in flat files).
    Our client is bit curious to work with. They do the alterations to their database (change the layout, change the datatype, drops tables) without our knowing. This has created a hell lot of issues with us.
    Is there a way that we can create a sql script which can capture any table changes on the database, so that when the client trys to execute imp batch file, the sql file should first check to see if any changes are made. If made, then it should stop execution and give an error message.
    Any help/suggestions would be highly appreciable.
    Thanks,

    Just to clarify...
    1. DDL commands are like CREATE, DROP, ALTER. (These are different than DML commands - INSERT, UPDATE, DELETE).
    2. The DDL trigger is created at the database level, not on each table. You only need one DDL trigger.
    3. You can choose the DDL commands for which you want the trigger to fire (probably, you'll want CREATE, DROP, ALTER, at a minimum).
    4. The DDL trigger only fires when one of these DDL commands is run.
    Whether you have 50 tables or 50,000 tables is not significant to performance in this context.
    What's signficant is how often you'll be executing the DDL commands on which the trigger is set to fire and whether the DDL commands execute in acceptable time with the trigger in place.

  • Unload Creates a .sql file in addition to an .xls file

    Hi All, I've recently downloaded version 3.0.02 which I use to create queries for database interrogation. I tend to export to Excel regularly and I'm finding that every time I unload an .xls file a .sql file is created in tandem.
    I have no use for this and have tried many different settings in the preferences area to stop it being created but to no avail - in addition the unload seems to take as long as the original query as if the query is being rerun - can somebody tell me what I'm doing wrong? Many Thanks, Steve.
    Edited by: user4230213 on 10-Dec-2010 02:25

    Is the additional file you are seeing the Generated-<date-time>.sql file?
    This file is generated when using a Save As type that can potentially create multiple sql files. It should not be created when generating Save As Single File. When we create a single sql file during the export, a generated control file is not needed and we should not create it... even if the Save As type is separate files, type files or separate directories. However, I can see that we are generating that control file when the Save As type is separate files, type files or separate directories cases and we created just 1 export file.
    Selecting the SaveAs type as single file should get you around the problem.

  • How can I create multiple QR Codes from an Excel File?

    Hi there,
    I am currently trying to set up business cards with a QR Code on the back of each card. Therefore I have an excel spreadsheet, which contains all the data necessary for the business card like name, function, e-mail adress,... the data is then filled in automatically by using the standard function with tags for each column (e.g. table column name is filled in as <<name>> in the specific location on the business card and once executed it is matched with the data from the excel file).
    Is there anything which could help me to automate the personalization of the QR Codes?
    All the best

    For free? Not at the moment. CC does have the ability to create QR codes but only one at a time. In CS6 (perhaps earlier versions?), regular poster/advanced scripter Jongware devised a script to prepare a QR code but again, could only do one at a time.
    However, someone did build on Jongware's QR code to do this from an InDesign file that had the necessary information in tagged text boxes and would prepare QR codes accordingly. However, it would leave them in the InDesign file (e.g. not separate EPS/PDFs).
    So, a long workaround would be:
    install the script and read the thread on the adobe forums (jongware's QR code plus the additional improvement): http://forums.adobe.com/message/4787823#4787823
    data merge the current data into the indesign file using the similar structure as the fourth poster in that post had written
    once all the QR codes are written, create a PDF of the file and then use one of various methods to break up the PDF into single page files: http://colecandoo.wordpress.com/2013/07/13/breaking-up-is-hard-to-do-indesign-files-into-i ndividual-pdfs-that-is/
    It's a lot of work to generate multiple QR codes. A paid solution offered by either Meadows DPS or Woodwing (two companies I have no affiliation with whatsoever) or any other plug-in provider for that matter: http://www.adobe.com/products/indesign/indepth.displayTab3.html may be an alternative that is worth pursuing.

  • How to create multiple modules in quizzes in single file?

    Hi,
    Can someone guide me how to create a multiple module quizzes under one captivate file ( captivate 5.5 ver)
    I have a quiz.cptx file with 50 questions from different chapters A,B,C,D,E with 10 questions in each chapter.
    The scenario
    Note : min 80% score  per chapter is the passing criteria
    1. Start the quiz after login and password
    2. Start the quiz for chapter A ( 10 questions)
    3. score for chapter A should be displayed
    4. If "cpQuizInfoPointsscored"'s  value < = 40 ; ie 80 % for chapter A
             review of the failed questions in the chapter
             OR
             retake quiz for that chapter should be triggered,
       else goto chapter B
    5. Start the quiz for chapter B ( 10 questions)
    3. score for chapter B should be displayed
    5. If "cpQuizInfoPointsscored"'s  value < = 40 ; ie 80 % for chapter B
             review of the failed questions in the chapter
             OR
             retake quiz for that chapter should be triggered,
       else goto chapter C
    6. //rly with other chapters
    7. After passing all chapters the result should be printer based on the scores.
    Is there any better ideas to crack the steps 4 - 6, bcz i am not able to reset the value of "cpQuizInfoPointsscored"; which is incremented as each question is completed.

    Welcome to the forum,
    Agree totally with Rod, this can be done with advanced actions (have some examples on my blog), but it is a lot of work. And the Quizzing system variables such as cpQuizINfoPointsscored are all read only, no way to change them by advanced actions at all.
    If you want to transfer variable values from one file to another, like from the different quiz files to a main file (to take decisions over there about possible branchings), you should have a look at Michael Lund's Save & Load Data widget:
    Save & Load Data widget
    Lilybiri

  • Is it possible to open a new Worksheet without creating a new *.sql file

    Hello Community,
    Declaimer: It may be a trivial question. I just willing to make SQL Developer my default day to day tool.
    I is possible to open a new Worksheet without creating a new *.sql file. Like in an MS Word. If I just need some space to write something and than destroy the file without saying. I can quickly click < ctrl + N > and get the space.
    In SQL Developer to get a new "space"/work sheet i
    -a- < ctrl + N >
    -b- choose "SQL File"
    -c- confirm default location
    -d- choose the connection to be used (right top conner)
    This process is way to long for getting a new sheet to put write an SQL.
    Can you suggest a better way to get a workspace with current connection assigned in no time (like in MS Word)?
    Please ;)
    Yury

    There is no need to create new .sql file.
    I don't know why you need new SQL Worksheet when you can simply do the space by pressing Enter, but you can open a new one from Tools -> SQL Worksheet. There is also a toolbar button for this.

  • How do i create a new table from a *.sql file in JSP

    <html>
    <%@ page language="java" import="java.sql.*" %>
    <%@ page errorPage="ExceptionHandler.jsp" %>
    <%
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    String dbUrl = "jdbc:mysql://localhost/test?user=root";
    Connection conn = DriverManager.getConnection(dbUrl);
    Statement stmt = conn.createStatement();
    stmt.executeUpdate("\\. addresses.sql");
    %>
    how would i create a table from the addresses.sql file?

    stmt.executeUpdate("\\. addresses.sql");This, of course, will not work.
    You might even execute it the same way you do from command line with some Runtime.exec() jugglery but I would suggest you to work with my first suggestion unless someone else came up with something better.

  • How to create database from .sql file

    how to create database from .sql file..?? i put the sintax query in a sql file.. and i want to call it in java code..
    ho to do it..??

    why do you want to do this from java?
    i just don't see the point.
    find your dba and have him/her run it for you

Maybe you are looking for

  • Oracle 6i report in character mode

    we have been using oracle 6i report in Windows XP, our printer is attached to the said PC when we print character mode the print out is not in character mode but if we send the print-out in a printer attached to a PC using win98 the printout is perfe

  • Setting up multiple email accounts

    I have already an email account on iCloud and a separate email address with Demon, another ISP.  I wish to stop using this ISP and create an additional email account with my iCloud account - if that is possible?  But how?

  • How to determine "fetch size" of an application?

    Hi, all. The db is 11.2.0.3 on a linux machine. I would like to know the "fetch size" of an application, but I was not able to find any related meteris in v$statname. The application configruation is invisible to me. Do I need to do some calculations

  • Purchased music appears in iTunes on Mac but not on iPhone

    Hi all, Have recently signed up to iTunes Match but I have a silly question. All of my songs now appear in the Music App on my iPhone except for all my purchased music which appears only in iTunes on my Mac. Am I doing something wrong? cheers Jools B

  • Seeburger adapter version

    All, Can one you tell what is the latest version of Seeburger adapters and when we had reviewed Seeburger about 18 months ago, the solution for EDI 997 did not seem straightforward. Meaning unlike other EDI products, 997 had to setup and configured f