Skip to content

Commit

Permalink
rowid host variables
Browse files Browse the repository at this point in the history
  • Loading branch information
ilidio-lopes committed Jul 24, 2024
1 parent 4db32ac commit 26c2199
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ host_variable_array_times: OCCURS host_variable_array_size TIMES?;
host_variable_array_size: T=dbs_integerliteral_expanded {validateIntegerRange($T.start, $T.text, 1, 32767);};

sql_host_variables: result_set_locator_variable | lob_host_variables | lob_xml_host_variables
| tableLocators_variable ;
| tableLocators_variable | rowid_host_variables;

result_set_locator_variable: dbs_level_01 entry_name host_variable_usage result_set_locator;

Expand All @@ -51,6 +51,8 @@ lob_xml_host_variables: dbs_host_var_levels entry_name host_variable_usage xml_

lob_host_variables: dbs_integer entry_name host_variable_usage (lobWithSize | lobNoSize);

rowid_host_variables: dbs_host_var_levels entry_name host_variable_usage ROWID;

dbs_host_var_levels: dbs_level_01 | T=dbs_integer {validateIntegerRange($T.text, 2, 48);};

result_set_locator: RESULT_SET_LOCATOR VARYING;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ public List<Node> visitBinary_host_variable_array(Db2SqlParser.Binary_host_varia
return createHostVariableDefinitionNode(ctx, ctx.dbs_host_var_levels(), ctx.entry_name());
}

@Override
public List<Node> visitRowid_host_variables(Db2SqlParser.Rowid_host_variablesContext ctx) {
return createHostVariableDefinitionNode(ctx, ctx.dbs_host_var_levels(), ctx.entry_name());
}

@Override
public List<Node> visitLob_xml_host_variables(Db2SqlParser.Lob_xml_host_variablesContext ctx) {
List<Node> hostVariableDefinitionNode = createHostVariableDefinitionNode(ctx, ctx.dbs_host_var_levels(), ctx.entry_name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,25 @@ public class TestSqlHostVariable {
+ " 49 {$*VAR|1} USAGE IS SQL TYPE IS XML AS CHARACTER LARGE OBJECT (10).\n"
+ " PROCEDURE DIVISION.\n"
+ " DISPLAY {$var-name1}.";

public static final String ROWID_TEXT1 =
" Identification Division.\n"
+ " Program-Id. 'TEST1'.\n"
+ " Data Division.\n"
+ " Working-Storage Section.\n"
+ " 01 {$*VAR}.\n"
+ " 02 {$*VAR1} USAGE IS SQL TYPE IS ROWID.\n"
+ " PROCEDURE DIVISION.\n";

public static final String ROWID_TEXT2 =
" Identification Division.\n"
+ " Program-Id. 'TEST1'.\n"
+ " Data Division.\n"
+ " Working-Storage Section.\n"
+ " 01 {$*VAR}.\n"
+ " 52 {$*VAR1|1} USAGE IS SQL TYPE IS ROWID.\n"
+ " PROCEDURE DIVISION.\n";

@Test
void testSupportForResultSetLocator() {
UseCaseEngine.runTest(TEXT, ImmutableList.of(), ImmutableMap.of());
Expand Down Expand Up @@ -331,6 +350,24 @@ void testLobXMLVariables_levelError() {
));
}

@Test
void testRowidVariables() {
UseCaseEngine.runTest(ROWID_TEXT1, ImmutableList.of(), ImmutableMap.of());
}

@Test
void testRowidVariables_levelError() {
UseCaseEngine.runTest(ROWID_TEXT2, ImmutableList.of(), ImmutableMap.of(
"1",
new Diagnostic(
new Range(),
"Allowed range is 2 to 48",
DiagnosticSeverity.Error,
ErrorSource.PARSING.getText()
)
));
}

@Test
void testBinaryHostVariableArray1() {
UseCaseEngine.runTest(BINARY_ARR_TEXT1, ImmutableList.of(), ImmutableMap.of());
Expand Down

0 comments on commit 26c2199

Please sign in to comment.