Informix

 View Only
  • 1.  SMART TRIGGERS IFX14.10

    Posted Wed November 11, 2020 10:50 AM
    Hi,

    Anybody have already try using Javascript with Smart Triggers ?
    Sample ?

    Regards

    ------------------------------
    Garcia Benjamin
    ------------------------------

    #Informix


  • 2.  RE: SMART TRIGGERS IFX14.10

    Posted Tue November 17, 2020 09:34 AM
    So it may or may not be helpful, but a couple years ago I tested this out to wire up Javascript (NodeJS) with JDBC to utilize the Smart Trigger API there.  

    You do need java and the JDBC driver but it worked.

    var java = require("java");
    java.asyncOptions = {
      syncSuffix: ""
    };
    
    java.classpath.push("ifxjdbc.jar");
    
    var smartTrigger = java.newInstanceSync("com.informix.smartTrigger.IfxSmartTrigger", "jdbc:informix-sqli://localhost:20290/sysadmin:USER=informix;PASSWORD=informix");
    
    smartTrigger.timeout(10);
    
    smartTrigger.open();
    smartTrigger.addTrigger("pushtest", "informix", "ewdb", "SELECT * FROM pushtest", "smart-trigger");
    smartTrigger.tableRegistration();
    
    var foo = smartTrigger.readFromSmartBlobObject();
    console.log(foo);
    ​

    $ cat package.json
    {
      "name": "jdbc-nodejs",
      "version": "1.0.0",
      "description": "",
      "main": "app.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "author": "Brian Hughes",
      "license": "Apache-2.0",
      "dependencies": {
        "java": "^0.8.0"
      }
    }
    ​


    ------------------------------
    Brian Hughes
    ------------------------------