These are support files to the issue described on SQL Anywhere forum at http://sqlanywhere-forum.sap.com/questions/26657/error-using-sa_dbcapi_handle-in-javascript-external-environment-with-windows
SA-17 Error using ''sa_dbcapi_handle" in JavaScript External Environment with WIndows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function test1() { | |
var logfile = 'C:/temp/tests.log'; | |
var fs = require('fs'); | |
fs.appendFileSync( logfile, "starting test1\r\n" ); | |
var sqla = require( 'sqlanywhere-xs' ); | |
var conn = sqla.createConnection(); | |
var cstr = "DSN=SQL Anywhere 17 Demo;UID=DBA;PWD=sql"; | |
conn.connect(cstr); | |
fs.appendFileSync( logfile, "Connected\r\n" ); | |
stmt = conn.prepareStatement( "SELECT * FROM Customers" ); | |
stmt.execute(); | |
var result = stmt.getResultSet(); | |
var c = 0; | |
while ( result.next() && c < 10 ) { | |
var str =result.getString(1) + " " + result.getString(3) + " " + result.getString(2); | |
fs.appendFileSync( logfile, str + "\r\n" ); | |
c += 1; | |
} | |
conn.disconnect(); | |
fs.appendFileSync( logfile, "stopping test1\r\n" ); | |
} | |
function test2() { | |
var logfile = 'C:/temp/tests.log'; | |
var fs = require('fs'); | |
fs.appendFileSync( logfile, "starting test2\r\n" ); | |
var sqla = require( 'sqlanywhere-xs' ); | |
var conn = sqla.createConnection(); | |
conn.connect(sa_dbcapi_handle); | |
fs.appendFileSync( logfile, "Connected\r\n" ); | |
stmt = conn.prepareStatement( "SELECT * FROM Customers" ); | |
stmt.execute(); | |
var result = stmt.getResultSet(); | |
var c = 0; | |
while ( result.next() && c < 10 ) { | |
var str =result.getString(1) + " " + result.getString(3) + " " + result.getString(2); | |
fs.appendFileSync( logfile, str + "\r\n" ); | |
c += 1; | |
} | |
conn.disconnect(); | |
fs.appendFileSync( logfile, "stopping test2\r\n" ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSTALL EXTERNAL OBJECT 'testscripts' | |
UPDATE | |
FROM FILE 'C:/temp/tests.js' | |
ENVIRONMENT JS; | |
CREATE OR REPLACE PROCEDURE test1() | |
EXTERNAL NAME '<file=testscripts> test1()' | |
LANGUAGE JS; | |
CREATE OR REPLACE PROCEDURE test2() | |
EXTERNAL NAME '<file=testscripts> test2()' | |
LANGUAGE JS; | |
CALL test1(); | |
CALL test2(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment