Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2003
    Posts
    78

    Unanswered: calling stored procedure in trigger???

    hello,
    we have a stored procedure in a database SAMPLE,
    we created a stored procedure called procx:
    (i've pasted the code below).
    we want to create a trigger that calls the stored procedure after an insert:
    that is the sql of the trigger:

    CREATE TRIGGER DRADUSR0.TRIAL AFTER INSERT ON DRADUSR0.DENEME FOR EACH ROW MODE DB2SQL CALL PROCX();

    when we try to crate it; it gives the error below:

    "[IBM][CLI Driver][DB2/6000] SQL0104N An unexpected token "(" was found following "DE DB2SQL CALL PROCX". Expected tokens may include: "JOIN <joined_table>". LINE NUMBER=1. SQLSTATE=42601"

    what can we do??? what is wrong???
    thank u all





    /**
    * JDBC Stored Procedure DRADUSR0.ProcX
    */
    import java.sql.*; // JDBC classes
    import java.io.BufferedReader;
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.ObjectOutputStream;
    import java.io.PrintWriter;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.net.URLConnection;

    public class ProcX
    {
    public static void procX ( ResultSet[] rs ) throws SQLException, Exception
    {
    // Get connection to the database
    Connection con = DriverManager.getConnection("jdbc:default:connecti on");
    PreparedStatement stmt = null;
    String sql;

    System.out.println("Start Servlet");
    URL servletURL = new URL("http://127.0.0.1/AKBANKBranchProjectWEB/servlet/com.akbank.server.test.stress.StressServlet");
    try {
    URLConnection servletConnection= servletURL.openConnection();


    /* DO POST OLMASI ICIN BU KISIM ACIK
    * DO GET ICIN KAPALI OLMASI GEREKIYOR.
    * BEGIN
    * */

    servletConnection.setDoOutput(true);
    ByteArrayOutputStream byteSteam = new ByteArrayOutputStream(512);
    PrintWriter out = new PrintWriter(byteSteam,true);
    String postData= "firstName=3&lastName=7";
    out.print(postData);
    out.flush();
    servletConnection.setRequestProperty("Content-Length",String.valueOf(byteSteam.size()));
    byteSteam.writeTo(servletConnection.getOutputStrea m());

    /* END
    * */

    BufferedReader in = new BufferedReader(new InputStreamReader(servletConnection.getInputStream ()));
    String line ;
    while ((line= in.readLine())!=null) {
    System.out.println(line);
    System.out.println("");
    }

    } catch (IOException e) {
    System.out.println(e.toString());
    }
    System.out.println("End Servlet");


    if (con != null) con.close();
    }
    }

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    Calling stored procs from trigger is proposed to be supported only from Version 8.2 (aka Stinger) ...

    Cheers
    Sathyaram
    Visit the new-look IDUG Website , register to gain access to the excellent content.

Posting Permissions

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