Creating database triggers through CFQUERY?

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Creating database triggers through CFQUERY?

    Greetings fellow CF'ers. I'm trying to create a web interface into our Oracle
    database for some of our developers to use. I intended for them to be able to
    Add a table and my app would take care of the table script along with the
    sequence and trigger needed to autoincrement the primary key of their table.

    I can create/alter tables and add sequences, but for some reason I'm having
    problems with the trigger. The trigger will be created in the database if the
    script is valid, but when I try to run an insert on that table I get an error
    saying that the trigger is invalid. I can see the trigger exists in the
    USER_TRIGGERS table, and the trigger is active.

    I've tried creating the script with and without the semicolon and forward
    slash at the end with no luck.

    Any suggestions ?

    joeDangelo Guest

  2. Similar Questions and Discussions

    1. Creation of triggers using <CFQUERY> tag is giving error
      Hi, I am creating triggers and stored procedure on ORACLE data base using <CFQUERY>. <CFQUERY DATASOURCE="CRM"> create or replace trigger...
    2. Trouble creating triggers
      Here is the code I tried: delimiter $; CREATE TRIGGER archive_addresses_ins BEFORE INSERT ON archive_addresses FOR EACH ROW BEGIN SET...
    3. Creating Database
      Hello, I'm brand new to ColdFusion, and I'm trying to go through the tutorials to learn more about it. I've installed it just fine to my Mac, OX...
    4. Database, RDS, FTP, CFquery... OH MY!
      I am new to and definitely struggling with ColdFusion MX7 (CF), Dreamweaver MX 2004 (DW), and Access on a PC running Windows XP Home SP1. I designed...
    5. database sessions persists after and </cfquery>
      Quick question for all CF gurus. I 'm trying to alter user passwords in my db. To do this I call a stored proc that issues "Alter user" SQL. I...
  3. #2

    Default Re: Creating database triggers through CFQUERY?

    An example of your code might help identify specific problems. Also, you could
    be having problems with the schema of the table that you are creating verses
    the trigger owner, and what userID is creating it, and the ownership of the
    tables referenced in the trigger, etc.

    Phil

    paross1 Guest

  4. #3

    Default Re: Creating database triggers through CFQUERY?

    I'm not permitted to paste any of our code here, but the jist of the question
    is 'Is there a syntax I should be using to create a trigger in Oracle through
    Coldfusion?' I know the trigger syntax Im using is correct for SQL+ because
    the trigger works just fine when I create it like that.

    joeDangelo Guest

  5. #4

    Default Re: Creating database triggers through CFQUERY?

    I don't think that you can use the CREATE OR REPLACE TRIGGER syntax from within
    a CFQUERY. I tried this with one of my known good triggrers, using the syntax
    below:

    <cfquery NAME="Q1" DATASOURCE="dsn">
    CREATE OR REPLACE TRIGGER xxx
    AFTER DELETE OR INSERT OR UPDATE
    ON zzz
    FOR EACH ROW
    DECLARE
    BEGIN
    trigger body
    END;
    </cfquery>

    And when I updated the table with the trigger, I got the following error:

    ERROR at line 1:
    ORA-04098: trigger 'xxx' is invalid and failed re-validation

    Once I re-compiled the trigger from SQL Plus, it worked OK. When I listed the
    contents of the trigger_body stored in user_triggers, I noticed that there were
    some "extra" garbage characters at the end of each line when I attempted to
    create the trigger via a ColdFusion CFQUERY.

    Sorry, don't know what you can use to stop that from happenning.

    Phil

    paross1 Guest

  6. #5

    Default Re: Creating database triggers through CFQUERY?

    Ah... thanks Phil. Thats what I was looking for... someone to tell me I'm not crazy.

    Did you try that in MX 7 ? We havent had a chance to upgrade to that yet...

    - J
    joeDangelo Guest

  7. #6

    Default Re: Creating database triggers through CFQUERY?

    Yup, tested with CFMX 7.

    Phil
    paross1 Guest

  8. #7

    Default Re: Creating database triggers through CFQUERY?

    It could be the line breaks.

    per.djurner.net/creating-oracle-triggers-from-coldfusion
    Unregistered Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139