Forum Discussion
I'm using Windows 11 with Core Isolation enabled; this is managed by our corporate IT, so I cannot override it. Several other forum members are also on Windows 11, and we have not encountered this issue before.
Variables of the Table Type need to be accessed in a specific way, and I am able to read and set values without issues. I suspect that the "data returned by the procedure is being inserted as a string into the table" might not be handled correctly. Additionally, characters such as diaeresis or umlaut (i.e., Unicode characters) could potentially cause issues as well.
Going forward, please include details about the AUT (e.g., Delphi or C#/.NET applications), the scripting language being used in TestComplete, and any other relevant information that could help reproduce the issue.
rraghvani
I'll share an example of how I'm using it. My application is in C# and I'm using the JavaScript language.
Example of my function that creates the table and inserts the data.
function addTableDadosPedidoComercial(Qry)
{
createVariableTemporary('varTableDadosPedidoComercialTest', 'Table');
var t = Project.Variables.VariableByName('varTableDadosPedidoComercialTest');//create colums of table temporary
t.AddColumn('nCdPedidoComercial');
t.AddColumn('nCdUsuarioResponsavel');
t.AddColumn('nCdEmpresa');
t.AddColumn('nCdModalidadeBoleto');
t.AddColumn('nCdTerceiro');
t.AddColumn('nCdTpTerceiro');
t.AddColumn('nCdTerceiroEntrega');
t.AddColumn('nCdRepresentante');
t.AddColumn('nCdProdutoCarregar');
t.AddColumn('nPreco');
t.AddColumn('nQtde');
t.AddColumn('iLimiteMinimoEmbarqueDesembarque');
t.AddColumn('iLimiteEmbarqueDesembarque');
t.AddColumn('nCdTpFaturamento');
t.AddColumn('nPercGorduraA');
t.AddColumn('nPercGorduraB');
t.AddColumn('nPercGorduraC');
t.AddColumn('nPesoMedioGorduraA');
t.AddColumn('nPesoMedioGorduraB');
t.AddColumn('nPesoMedioGorduraC');
t.AddColumn('nCdEmpresaCarga');//create rows
t.RowCount = Qry.RecordCount;""
iRow = 0;
while (!Qry.EOF)
{
t('nCdPedidoComercial',iRow) = Qry.field(0).AsString;
t('nCdUsuarioResponsavel',iRow) = Qry.field(1).AsString;
t('nCdEmpresa',iRow) = Qry.field(2).AsString;
t('nCdModalidadeBoleto',iRow) = Qry.field(3).AsString;
t('nCdTerceiro',iRow) = Qry.field(4).AsString;
t('nCdTpTerceiro',iRow) = Qry.field(5).AsString;
t('nCdTerceiroEntrega',iRow) = Qry.field(6).AsString;
t('nCdRepresentante',iRow) = Qry.field(7).AsString;
t('nCdProdutoCarregar',iRow) = Qry.field(8).AsString;
t('nPreco',iRow) = Qry.field(9).AsString;
t('nQtde',iRow) = Qry.field(10).AsString;
t('iLimiteMinimoEmbarqueDesembarque',iRow) = Qry.field(11).AsString;
t('iLimiteEmbarqueDesembarque',iRow) = Qry.field(12).AsString;
t('nCdTpFaturamento',iRow) = Qry.field(13).AsString;
t('nPercGorduraA',iRow) = Qry.field(14).AsString;
t('nPercGorduraB',iRow) = Qry.field(15).AsString;
t('nPercGorduraC',iRow) = Qry.field(16).AsString;
t('nPesoMedioGorduraA',iRow) = Qry.field(17).AsString;
t('nPesoMedioGorduraB',iRow) = Qry.field(18).AsString;
t('nPesoMedioGorduraC',iRow) = Qry.field(19).AsString;
t('nCdEmpresaCarga',iRow) = Qry.field(20).AsString;
iRow++;
Qry.Next();
}
createVariableTemporary('contTableDadosPedidoComercial', 'Integer');
Project.Variables.contTableDadosPedidoComercial = 0;
}
And I'm attaching the example return of the procedure.
My environment: Windows 11, SQL Server v22
- rraghvani15 days ago
Champion Level 3
I've created a simple example to read 6 columns from your spreadsheet, using DDT. Take note of how the values are assigned and retrieved via t.$set() and t.$get()
Output resultsfunction Test() { // Create variable, if it doesn't exist if (!Project.Variables.VariableExists("DadosPedidoComercial")) Project.Variables.AddVariable("DadosPedidoComercial", "Table"); // Get a reference to the variable var t = Project.Variables.VariableByName("DadosPedidoComercial"); // Add columns to the table t.AddColumn('nCdPedidoComercial'); t.AddColumn('nCdUsuarioResponsavel'); t.AddColumn('nCdEmpresa'); t.AddColumn('nCdModalidadeBoleto'); t.AddColumn('nPreco'); t.AddColumn('nQtde'); t.RowCount = 5; // Specify fixed size row = 0; // Use DDT to read Excel DDT.ExcelDriver("C:\\Temp\\Book1.xlsx", "Sheet1"); while (! DDT.CurrentDriver.EOF()) { DDT.CurrentDriver.Value(0) t.$set("nCdPedidoComercial", row, DDT.CurrentDriver.Value(0)); t.$set("nCdUsuarioResponsavel", row, DDT.CurrentDriver.Value(1)); t.$set("nCdEmpresa", row, DDT.CurrentDriver.Value(2)); t.$set("nCdModalidadeBoleto", row, DDT.CurrentDriver.Value(3)); t.$set("nPreco", row, DDT.CurrentDriver.Value(4)); t.$set("nQtde", row, DDT.CurrentDriver.Value(5)); row++ // Counter DDT.CurrentDriver.Next(); } DDT.CloseDriver(DDT.CurrentDriver.Name); // Output each row t.RowCount = row; // Update row count for (var i = 0; i < t.RowCount; i++) { var logMessage = "Row " + i + ": " + "Pedido=" + t.$get("nCdPedidoComercial", i) + ", " + "Usuario=" + t.$get("nCdUsuarioResponsavel", i) + ", " + "Empresa=" + t.$get("nCdEmpresa", i) + ", " + "Modalidade=" + t.$get("nCdModalidadeBoleto", i) + ", " + "Preco=" + t.$get("nPreco", i) + ", " + "Qtde=" + t.$get("nQtde", i); Log.Message(logMessage); } // Output each row and column for (var i = 0; i < t.RowCount; i++) { var rowText = "Row " + i + ": "; for (var c = 0; c < t.ColumnCount; c++) { var colName = t.ColumnName(c); rowText += colName + "=" + t.$get(colName, i) + "; "; } Log.Message(rowText); } }Also, is there any particular reasons for using a Table variable?
- Modesto15 days agoOccasional Contributor
rraghvani
This way, whether using get/set or just Log.Message, I get the data from the table back without any problem, and the field in my application is populated with this data from the table. However, when I need to debug with a breakpoint, I can no longer inspect it because TestComplete freezes/closes.
In your test, did you use a breakpoint?
Regarding the use of this type of variable, it's a standard practice here at the company, and whenever we need a large amount of data for testing, we create this variable and populate it for use. This way, we only access the database once to retrieve the data.
- rraghvani15 days ago
Champion Level 3
During debugging, I've pressed Alt+W on the line with the break point to add the variable t to the watch list. I can also inspect the t object via the inspection tool and query the various parameters, all without any issues.
The way you are assigning the value to the variable is incorrect, as t is not a function!
t('nCdPedidoComercial',iRow) = Qry.field(0).AsString;