All files / output cl_sql_statement.clas.mjs

59.72% Statements 86/144
45% Branches 9/20
22.22% Functions 6/27
59.72% Lines 86/144

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 1441x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x             1x                           1x           1x 2x 2x 2x 2x 2x     2x 2x 2x 1x           1x 10x 10x 10x 10x 10x 10x 10x 10x 10x     10x         10x 10x 10x     10x         10x 10x 1x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x     6x         6x 6x 6x 6x 6x                   6x 6x 1x 1x 1x
const {cx_root} = await import("./cx_root.clas.mjs");
// cl_sql_statement.clas.abap
class cl_sql_statement {
  static STATIC_SUPER = undefined;
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'CL_SQL_STATEMENT';
  static IMPLEMENTED_INTERFACES = [];
  static ATTRIBUTES = {"MV_CONNECTION": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "visibility": "I", "is_constant": " ", "is_class": " "}};
  static METHODS = {"CONSTRUCTOR": {"visibility": "U", "parameters": {"CON_REF": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "CL_SQL_CONNECTION", RTTIName: "\\CLASS=CL_SQL_CONNECTION"});}, "is_optional": " ", "parm_kind": "I", "type_name": "ObjectReferenceType"}}},
  "EXECUTE_UPDATE": {"visibility": "U", "parameters": {"ROWS_UPDATED": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "is_optional": " ", "parm_kind": "R", "type_name": "IntegerType"}, "STATEMENT": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " ", "parm_kind": "I", "type_name": "StringType"}}},
  "SET_PARAM_TABLE": {"visibility": "U", "parameters": {"TABLE_REF": {"type": () => {return new abap.types.DataReference(new abap.types.Character(4));}, "is_optional": " ", "parm_kind": "I", "type_name": "DataReference"}, "LOB_FIELDS": {"type": () => {return abap.types.TableFactory.construct(new abap.types.Character(30, {"qualifiedName":"adbc_name","ddicName":"CHAR30","description":""}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[]}, "adbc_column_tab");}, "is_optional": " ", "parm_kind": "I", "type_name": "TableType"}}},
  "SET_PARAM": {"visibility": "U", "parameters": {"DATA_REF": {"type": () => {return new abap.types.DataReference(new abap.types.Character(4));}, "is_optional": " ", "parm_kind": "I", "type_name": "DataReference"}, "POS": {"type": () => {return new abap.types.Integer({qualifiedName: "INT2"});}, "is_optional": " ", "parm_kind": "I", "type_name": "IntegerType"}, "IND_REF": {"type": () => {return new abap.types.DataReference(new abap.types.Integer({qualifiedName: "INT2"}));}, "is_optional": " ", "parm_kind": "I", "type_name": "DataReference"}, "INOUT": {"type": () => {return new abap.types.Character(4);}, "is_optional": " ", "parm_kind": "I", "type_name": "AnyType"}, "IS_LOB": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"FLAG","ddicName":"FLAG","description":"FLAG"});}, "is_optional": " ", "parm_kind": "I", "type_name": "CharacterType"}}},
  "EXECUTE_PROCEDURE": {"visibility": "U", "parameters": {"ROWS_PROCESSED": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "is_optional": " ", "parm_kind": "R", "type_name": "IntegerType"}, "PROC_NAME": {"type": () => {return new abap.types.Character();}, "is_optional": " ", "parm_kind": "I", "type_name": "CGenericType"}}},
  "EXECUTE_QUERY": {"visibility": "U", "parameters": {"RESULT_SET": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "CL_SQL_RESULT_SET", RTTIName: "\\CLASS=CL_SQL_RESULT_SET"});}, "is_optional": " ", "parm_kind": "R", "type_name": "ObjectReferenceType"}, "STATEMENT": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " ", "parm_kind": "I", "type_name": "StringType"}, "HOLD_CURSOR": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});}, "is_optional": " ", "parm_kind": "I", "type_name": "CharacterType"}}},
  "EXECUTE_DDL": {"visibility": "U", "parameters": {"STATEMENT": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " ", "parm_kind": "I", "type_name": "StringType"}}}};
  #mv_connection;
  constructor() {
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
      "execute_update": this.execute_update.bind(this),
      "set_param_table": this.set_param_table.bind(this),
      "set_param": this.set_param.bind(this),
      "execute_procedure": this.execute_procedure.bind(this),
      "execute_query": this.execute_query.bind(this),
      "execute_ddl": this.execute_ddl.bind(this),
    };
    this.#mv_connection = new abap.types.String({qualifiedName: "STRING"});
    this.FRIENDS_ACCESS_INSTANCE["mv_connection"] = this.#mv_connection;
  }
  async set_param_table(INPUT) {
    let table_ref = INPUT?.table_ref;
    if (table_ref === undefined) { table_ref = new abap.types.DataReference(new abap.types.Character(4)).set(INPUT.table_ref); }
    let lob_fields = abap.types.TableFactory.construct(new abap.types.Character(30, {"qualifiedName":"adbc_name","ddicName":"CHAR30","description":""}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[]}, "adbc_column_tab");
    if (INPUT && INPUT.lob_fields) {lob_fields.set(INPUT.lob_fields);}
    abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(13, 'not supported')));
  }
  async set_param(INPUT) {
    let data_ref = INPUT?.data_ref;
    if (data_ref === undefined) { data_ref = new abap.types.DataReference(new abap.types.Character(4)).set(INPUT.data_ref); }
    let pos = new abap.types.Integer({qualifiedName: "INT2"});
    if (INPUT && INPUT.pos) {pos.set(INPUT.pos);}
    if (INPUT === undefined || INPUT.pos === undefined) {pos = abap.IntegerFactory.get(0);}
    let ind_ref = new abap.types.DataReference(new abap.types.Integer({qualifiedName: "INT2"}));
    if (INPUT && INPUT.ind_ref) {ind_ref.set(INPUT.ind_ref);}
    let inout = INPUT?.inout || new abap.types.Character(4);
    let is_lob = new abap.types.Character(1, {"qualifiedName":"FLAG","ddicName":"FLAG","description":"FLAG"});
    if (INPUT && INPUT.is_lob) {is_lob.set(INPUT.is_lob);}
    if (INPUT === undefined || INPUT.is_lob === undefined) {is_lob = abap.builtin.space;}
    abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(13, 'not supported')));
  }
  async execute_procedure(INPUT) {
    let rows_processed = new abap.types.Integer({qualifiedName: "I"});
    let proc_name = INPUT?.proc_name;
    abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(13, 'not supported')));
    return rows_processed;
  }
  async constructor_(INPUT) {
    let con_ref = new abap.types.ABAPObject({qualifiedName: "CL_SQL_CONNECTION", RTTIName: "\\CLASS=CL_SQL_CONNECTION"});
    if (INPUT && INPUT.con_ref) {con_ref.set(INPUT.con_ref);}
    if (abap.compare.initial(con_ref)) {
      this.#mv_connection.set(abap.CharacterFactory.get(7, 'DEFAULT'));
    } else {
      this.#mv_connection.set((await con_ref.get().get_con_name()));
    }
    abap.statements.assert(abap.compare.initial(this.#mv_connection) === false);
    return this;
  }
  async execute_ddl(INPUT) {
    let statement = INPUT?.statement;
    if (statement?.getQualifiedName === undefined || statement.getQualifiedName() !== "STRING") { statement = undefined; }
    if (statement === undefined) { statement = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.statement); }
    abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(13, 'not supported')));
  }
  async execute_update(INPUT) {
    let rows_updated = new abap.types.Integer({qualifiedName: "I"});
    let statement = INPUT?.statement;
    if (statement?.getQualifiedName === undefined || statement.getQualifiedName() !== "STRING") { statement = undefined; }
    if (statement === undefined) { statement = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.statement); }
    let lv_sql_message = new abap.types.String({qualifiedName: "STRING"});
    let connection = new abap.types.String({qualifiedName: "STRING"});
    abap.statements.assert(abap.compare.initial(statement) === false);
    connection.set(this.#mv_connection);
    if (abap.context.databaseConnections[connection.get()] === undefined) {
      lv_sql_message.set(abap.CharacterFactory.get(19, 'not connected to db'));
    }
    if (abap.compare.initial(lv_sql_message) === false) {
      const unique1447 = await (new abap.Classes['CX_SQL_EXCEPTION']()).constructor_();
      unique1447.EXTRA_CX = {"INTERNAL_FILENAME": "cl_sql_statement.clas.abap","INTERNAL_LINE": 98};
      throw unique1447;
    }
    try {
        await abap.context.databaseConnections[connection.get()].execute(statement.get());
    } catch(e) {
        lv_sql_message.set(e + "");
    }
    if (abap.compare.initial(lv_sql_message) === false) {
      const unique1448 = await (new abap.Classes['CX_SQL_EXCEPTION']()).constructor_();
      unique1448.EXTRA_CX = {"INTERNAL_FILENAME": "cl_sql_statement.clas.abap","INTERNAL_LINE": 107};
      throw unique1448;
    }
    return rows_updated;
  }
  async execute_query(INPUT) {
    let result_set = new abap.types.ABAPObject({qualifiedName: "CL_SQL_RESULT_SET", RTTIName: "\\CLASS=CL_SQL_RESULT_SET"});
    let statement = INPUT?.statement;
    if (statement?.getQualifiedName === undefined || statement.getQualifiedName() !== "STRING") { statement = undefined; }
    if (statement === undefined) { statement = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.statement); }
    let hold_cursor = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
    if (INPUT && INPUT.hold_cursor) {hold_cursor.set(INPUT.hold_cursor);}
    let lx_osql = new abap.types.ABAPObject({qualifiedName: "CX_SY_DYNAMIC_OSQL_SEMANTICS", RTTIName: "\\CLASS=CX_SY_DYNAMIC_OSQL_SEMANTICS"});
    let lv_sql_message = new abap.types.String({qualifiedName: "STRING"});
    let connection = new abap.types.String({qualifiedName: "STRING"});
    connection.set(this.#mv_connection);
    abap.statements.assert(abap.compare.initial(statement) === false);
    abap.statements.assert(abap.compare.initial(this.#mv_connection) === false);
    if (abap.context.databaseConnections[connection.get()] === undefined) {
      lv_sql_message.set(abap.CharacterFactory.get(19, 'not connected to db'));
    }
    if (abap.compare.initial(lv_sql_message) === false) {
      const unique1449 = await (new abap.Classes['CX_SQL_EXCEPTION']()).constructor_({sql_message: lv_sql_message});
      unique1449.EXTRA_CX = {"INTERNAL_FILENAME": "cl_sql_statement.clas.abap","INTERNAL_LINE": 127};
      throw unique1449;
    }
    result_set.set(await (new abap.Classes['CL_SQL_RESULT_SET']()).constructor_());
    try {
        const res = await abap.context.databaseConnections[connection.get()].select({select: statement.get()});
        result_set.get().mv_magic = res.rows;
    } catch (e) {
      if ((abap.Classes['CX_SY_DYNAMIC_OSQL_SEMANTICS'] && e instanceof abap.Classes['CX_SY_DYNAMIC_OSQL_SEMANTICS'])) {
        lx_osql.set(e);
        const unique1450 = await (new abap.Classes['CX_SQL_EXCEPTION']()).constructor_({sql_message: lx_osql.get().sqlmsg});
        unique1450.EXTRA_CX = {"INTERNAL_FILENAME": "cl_sql_statement.clas.abap","INTERNAL_LINE": 137};
        throw unique1450;
      } else {
        throw e;
      }
    }
    return result_set;
  }
}
abap.Classes['CL_SQL_STATEMENT'] = cl_sql_statement;
export {cl_sql_statement};