Skip to content

Commit 9b1b2ca

Browse files
committed
Add ability to override CCSID on runSql
Signed-off-by: worksofliam <[email protected]>
1 parent 3fd09f0 commit 9b1b2ca

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/api/IBMi.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,12 +1265,13 @@ export default class IBMi {
12651265
* @param statements
12661266
* @returns a Result set
12671267
*/
1268-
async runSQL(statements: string): Promise<Tools.DB2Row[]> {
1268+
async runSQL(statements: string, opts: {userCcsid?: number} = {}): Promise<Tools.DB2Row[]> {
12691269
const { 'QZDFMDB2.PGM': QZDFMDB2 } = this.remoteFeatures;
12701270

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

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

0 commit comments

Comments
 (0)