[plsql] Support more than simple names for order by and select into.

This commit is contained in:
Andreas Dangel
2019-02-13 20:32:46 +01:00
parent 4814ece9ac
commit f43e261243
4 changed files with 33 additions and 5 deletions

View File

@ -1189,9 +1189,9 @@ ASTOrderByClause OrderByClause() :
void OrderByEntry() #void :
{}
{
( LOOKAHEAD(2) ColumnAlias() | LOOKAHEAD(2) SqlExpression() )
( LOOKAHEAD(ID() ".") SqlExpression() | LOOKAHEAD(2) ColumnAlias() | SqlExpression() )
[ <ASC> | <DESC> ]
[ LOOKAHEAD(2) <NULLS> "FIRST" | LOOKAHEAD(2) <NULLS> "LAST" ]
[ <NULLS> ( "FIRST" | "LAST" ) ]
}
/**
@ -1675,10 +1675,14 @@ ASTIntoClause IntoClause() :
}
ASTVariableName VariableName() :
{ ASTID id; }
{ ASTID id; StringBuilder name = new StringBuilder(); }
{
id = ID() {jjtThis.setImage(id.getImage());}
{ return jjtThis; }
id = ID() { name.append(id.getImage()); }
[ "." id = ID() { name.append('.').append(id.getImage()); } ]
{
jjtThis.setImage(name.toString());
return jjtThis;
}
}
ASTBulkCollectIntoClause BulkCollectIntoClause() :

View File

@ -61,4 +61,11 @@ public class SelectIntoStatementTest extends AbstractPLSQLParserTst {
StandardCharsets.UTF_8);
ASTInput input = parsePLSQL(code);
}
@Test
public void testParsingIntoRecordField() throws Exception {
String code = IOUtils.toString(this.getClass().getResourceAsStream("SelectIntoStatementRecordField.pls"),
StandardCharsets.UTF_8);
ASTInput input = parsePLSQL(code);
}
}

View File

@ -56,5 +56,9 @@ SELECT department_id "Dept", hire_date "Date", last_name "Name",
WHERE hire_date < '01-SEP-2003'
ORDER BY "Dept", "Date", "Name";
SELECT listagg(e.email,',') within group (order by e.email )INTO
v_task_resp
FROM sso_auth_employees e;
END;
/

View File

@ -0,0 +1,13 @@
--
-- BSD-style license; for more info see http://pmd.sourceforge.net/license.html
--
BEGIN
SELECT the_id
INTO my_record.the_id
FROM my_table
WHERE the_id = '1';
END;
/