Michael_Coxson_5769

API - Better way to perform an SQL query?

Discussion created by Michael_Coxson_5769 on Feb 23, 2017
Latest reply on Feb 23, 2017 by Michael_Coxson_5769
Is there a better way to perform an SQL query than modifying a preexisting VARA object and previewing its use?  While this is serviceable, it seems a bit round-around and I would prefer not to have to manipulate objects on the fly just to get a database search performed.

Example:
OpenObject openVar = new OpenObject(new UC4ObjectName("TEST.VSQLI.TESTVAR")); conn.sendRequestAndWait(openVar); Variable searchVars = (Variable) openVar.getUC4Object(); DynamicSQLVariableIntern sqlVar = searchVars.sqlIntern(); sqlVar.setStatementOracle("select OH_NAME from OH H, OVW V where H.OH_OTYPE like 'VARA' and H.OH_IDNR = V.OVW_OH_IDNR and (cast(V.OVW_Value1 as varchar(50)) = '" + object + "' or cast(V.OVW_Value2 as varchar(50)) = '" + object + "' or cast(V.OVW_Value3 as varchar(50)) = '" + object + "' or cast(V.OVW_Value4 as varchar(50)) = '" + object + "' or cast(V.OVW_Value5 as varchar(50)) = '" + object + "')"); conn.sendRequestAndWait(new SaveObject(searchVars)); PreviewVariable varPrev = new PreviewVariable(searchVars); conn.sendRequestAndWait(varPrev); if (varPrev.size() != 0) {      System.out.println("\t" + varPrev.getRow(0)[0]); } conn.sendRequestAndWait(new CloseObject(searchVars));

Outcomes