Skip to Main Content

SQLcl: MCP Server & SQL Prompt

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

sqlcl on windows. Error trying to execute javascript.

IOcampoApr 26 2016 — edited Apr 26 2016

I'm using sqlcl trying to execute a javascript to upload files into blob field.

https://github.com/oracle/oracle-db-tools/blob/master/sqlcl/examples/blob.helper.all.js

DB connexion it's ok bet when I ran the script I receive the following error:

SQL> script load_file_to_db.js

javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "load" is not defined. (<Unknown source>#1) in <Unknown source> at line number 1

My script:

load('https://raw.githubusercontent.com/oracle/Oracle_DB_Tools/master/sqlcl/lib/helpers.js');

/* File name */

var files= helpers.exec('find . -maxdepth 1 -type f ').stdout.split('\n');

/* bind for reuse */

var binds = helpers.getBindMap();

for(f in files ) {

    /* load the blob */

  blob = helpers.getBlobFromFile(files[f]);

  /* assign the binds */

  binds.put("path",files[f]);

  binds.put("b",blob);

/* Just do it */

  var ret = util.execute("insert into k(path,blob_content,when) values(:path , :b, sysdate)",binds);

}

Comments
Post Details
Added on Apr 26 2016
1 comment
815 views