These are support files to the issue described on SQL Anywhere forum at http://sqlanywhere-forum.sap.com/questions/26658/problem-using-callback-form-of-connect-javascript-external-environment
Last active
February 22, 2016 03:51
-
-
Save twilkinson/00748d66bef5fff91852 to your computer and use it in GitHub Desktop.
SA-17 Problem using 'callback' form of 'connect', JavaScript External Environment
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 test1A() { | |
var logfile = '/home/twilkinson/node_demo17/testa.log'; | |
var fs = require('fs'); | |
fs.appendFileSync( logfile, "start of test1A " + process.version +"\r\n" ); | |
var sqla = require( '/opt/sqlanywhere17/node/sqlanywhere-xs' ); | |
var conn = sqla.createConnection(); | |
var cstr = "DSN=SQL Anywhere 17 Demo;UID=DBA;PWD=sql"; | |
conn.connect(cstr, function(err){ | |
if( err ) { | |
fs.appendFileSync( logfile, "ERR:" + err + "\r\n" ); | |
} else { | |
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, "Disconnected\r\n" ); | |
} | |
}); | |
fs.appendFileSync( logfile, "end of test1A\r\n" ); | |
} | |
test1A(); |
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 test1A() { | |
var logfile = 'C:/temp/tests.log'; | |
var fs = require('fs'); | |
fs.appendFileSync( logfile, "start of test1A\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, function(err){ | |
if( err ) { | |
fs.appendFileSync( logfile, "ERR:" + err + "\r\n" ); | |
} else { | |
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, "Disconnected\r\n" ); | |
} | |
}); | |
fs.appendFileSync( logfile, "end of test1A\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 'testAscript' | |
UPDATE | |
FROM FILE 'C:/temp/testA.js' | |
ENVIRONMENT JS; | |
CREATE OR REPLACE PROCEDURE test1A() | |
EXTERNAL NAME '<file=testAscript> test1A()' | |
LANGUAGE JS; | |
CALL test1A(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment