-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathtestPlpgsql_label.java
More file actions
45 lines (40 loc) · 1.84 KB
/
Copy pathtestPlpgsql_label.java
File metadata and controls
45 lines (40 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package test.postgresql;
/*
* Date: 13-12-4
*/
import gudusoft.gsqlparser.EDbVendor;
import gudusoft.gsqlparser.TGSqlParser;
import gudusoft.gsqlparser.stmt.postgresql.TPostgresqlCreateFunction;
import junit.framework.TestCase;
public class testPlpgsql_label extends TestCase {
public void test1(){
TGSqlParser sqlparser = new TGSqlParser(EDbVendor.dbvpostgresql);
sqlparser.sqltext = "CREATE FUNCTION somefunc() RETURNS integer AS $$\n" +
"<< outerblock >>\n" +
"DECLARE\n" +
" quantity integer := 30;\n" +
"BEGIN\n" +
" RAISE NOTICE 'Quantity here is %', quantity; -- Prints 30\n" +
" quantity := 50;\n" +
" --\n" +
" -- Create a subblock\n" +
" --\n" +
" DECLARE\n" +
" quantity integer := 80;\n" +
" BEGIN\n" +
" RAISE NOTICE 'Quantity here is %', quantity; -- Prints 80\n" +
" RAISE NOTICE 'Outer quantity here is %', outerblock.quantity; -- Prints 50\n" +
" END;\n" +
"\n" +
" RAISE NOTICE 'Quantity here is %', quantity; -- Prints 50\n" +
"\n" +
" RETURN quantity;\n" +
"END;\n" +
"$$ LANGUAGE plpgsql;";
assertTrue(sqlparser.parse() == 0);
TPostgresqlCreateFunction createFunction = (TPostgresqlCreateFunction)sqlparser.sqlstatements.get(0);
assertTrue(createFunction.getBodyStatements().size()==5);
// System.out.println(createFunction.getOuterLabelName().toString());
assertTrue(createFunction.getOuterLabelName().toString().equalsIgnoreCase("outerblock"));
}
}