Whenever I try to use the columns from a callable stored procedure
(returns a SimpleResultSet), I get a "Column $COLUMN_NAME not found"
error (where $ColumnName is a column defined in the stored
procedure). I *know* that column name is valid for the
SimpleResultSet, and the query works if I just use a SELECT * instead
of naming columns. In the H2 web GUI, the displayed column name
matches the column name I am using.
How can I fix this or find a work-around? I *must* use regexes and
capturing group to extract my info (scraping from webpages), and I
don't want to hardcode the analysis of returned groups into my stored
procedure.
Sample procedure code (gets all capturing groups from a string and a
regex):
public static ResultSet getRegexMatchedGroups(String source, String
regex) throws SQLException {
SimpleResultSet brs = new SimpleResultSet();
brs.addColumn("Match_Number", Types.INTEGER, 10, 0);
brs.addColumn("Group_Number", Types.INTEGER, 10, 0);
brs.addColumn("Captured_Group",Types.VARCHAR, 65536, 0);
Pattern p = Pattern.compile(regex, Pattern.MULTILINE |
Pattern.DOTALL);
Matcher m = p.matcher(source);
final int groupCount = m.groupCount();
Integer[] groupNumber = new Integer[groupCount]; //Saves on
object overhead by re-using objs
for(int i=0; i<groupCount; i++){
groupNumber[i]=new Integer(i+1);
}
int matchNumber = 0;
Object[] row = new Object[3];
while(m.find()){
row[0]=new Integer(matchNumber);
for(int i=0; i<groupCount; i++){
row[1]=groupNumber[i];
row[2]=m.group(i+1);
brs.addRow(java.util.Arrays.copyOf(row, 3));
}
matchNumber++;
}
return brs;
}
** SAMPLE SQL (for the above as stored procedure with alias
regex_groups **
** WORKS: **
FROM regex_groups('<entry><key>Cheese</key><value>Delicious</value></
entry><entry><key>Blood Sausage</key><value>Disgusting</value></
entry>', '<key>([^<]*)</key><value>([^<]*)</value>') AS basicmetadata
SELECT *;
** DOES NOT WORK **
FROM regex_groups('<entry><key>Cheese</key><value>Delicious</value></
entry><entry><key>Blood Sausage</key><value>Disgusting</value></
entry>', '<key>([^<]*)</key><value>([^<]*)</value>') AS basicmetadata
SELECT Group_Number;
** ERROR CODE: **
"Column GROUP_NUMBER not found; SQL statement:" -- followed by the
statement above, and error code 42122-114 42S22/42122
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en
-~----------~----~----~----~------~----~------~--~---