Skip to content

Commit

Permalink
Add ability to override CCSID on runSql
Browse files Browse the repository at this point in the history
Signed-off-by: worksofliam <[email protected]>
  • Loading branch information
worksofliam committed Apr 10, 2024
1 parent 3fd09f0 commit 9b1b2ca
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/api/IBMi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1265,12 +1265,13 @@ export default class IBMi {
* @param statements
* @returns a Result set
*/
async runSQL(statements: string): Promise<Tools.DB2Row[]> {
async runSQL(statements: string, opts: {userCcsid?: number} = {}): Promise<Tools.DB2Row[]> {
const { 'QZDFMDB2.PGM': QZDFMDB2 } = this.remoteFeatures;

if (QZDFMDB2) {
const ccsidDetail = this.getEncoding();
const possibleChangeCommand = (ccsidDetail.fallback && !ccsidDetail.invalid ? `@CHGJOB CCSID(${ccsidDetail.ccsid});\n` : '');
const useCcsid = opts.userCcsid || (ccsidDetail.fallback && !ccsidDetail.invalid ? ccsidDetail.ccsid : undefined);
const possibleChangeCommand = (useCcsid ? `@CHGJOB CCSID(${useCcsid});\n` : '');

const output = await this.sendCommand({
command: `LC_ALL=EN_US.UTF-8 system "call QSYS/QZDFMDB2 PARM('-d' '-i' '-t')"`,
Expand Down

0 comments on commit 9b1b2ca

Please sign in to comment.