-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from DSL-UMD/distributed
add stored procedure test
- Loading branch information
Showing
4 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import org.voltdb.*; | ||
|
||
// https://docs.voltdb.com/tutorial/Part5.php | ||
public class VoltDBStoredProcedureTest extends VoltProcedure { | ||
|
||
public final SQLStmt sql1 = | ||
new SQLStmt( | ||
"WITH RECURSIVE cte AS (" | ||
+ " SELECT id, parent FROM inodes d WHERE id = ?" | ||
+ " UNION ALL" | ||
+ " SELECT d.id, d.parent FROM cte" | ||
+ " JOIN inodes d ON cte.id = d.parent" | ||
+ " )" | ||
+ " SELECT id FROM cte;"); | ||
public final SQLStmt sql2 = new SQLStmt("DELETE FROM inodes WHERE id = ?;"); | ||
|
||
public long run(long id) throws VoltAbortException { | ||
voltQueueSQL(sql1, id); | ||
VoltTable[] results = voltExecuteSQL(); | ||
|
||
if (results[0].getRowCount() < 1) { | ||
return -1; | ||
} | ||
for (int i = 0; i < results[0].getRowCount(); ++i) { | ||
voltQueueSQL(sql2, results[0].fetchRow(i).getLong(0)); | ||
} | ||
voltExecuteSQL(); | ||
|
||
return 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters