forked from jpscharf/ScriptMaster-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExecuteSQL.groovy
More file actions
53 lines (40 loc) · 1.12 KB
/
ExecuteSQL.groovy
File metadata and controls
53 lines (40 loc) · 1.12 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
46
47
48
49
50
51
52
53
/*
Purpose: Wrapper for the ScriptMaster fmpro.executeSQL method.
Returns: Formatted list of the results.
Name: ExecuteSQL ( theQuery ; columnDelimiter ; rowDelimiter )
Parameters: ( theQuery ) the SQL query
( columnDelimiter ) single character
( rowDelimiter ) single character
Dependencies: NONE
2011-09-01 JPS, Created.
2011-09-01 JPS, Updated to determine the query type, and return false if the user is attempting to CREATE or ALTER tables.
NOTES:
NONE
*/
//DETERMINE THE QUERY TYPE
def queryType = theQuery.split (" ")
queryType = queryType[0].toUpperCase()
switch ( queryType ) {
case "SELECT":
eolFormat = "\r\n";
break;
case "INSERT":
eolFormat = "\r";
break;
case "UPDATE":
eolFormat = "\n";
break;
case "UPDATE":
eolFormat = "\n";
break;
case "DELETE":
eolFormat = "\n";
break;
case "CREATE":
case "ALTER":
default:
//Invalid or unsuported statement provided
return false;
}
//SELECT INSERT UPDATE DELETE CREATE ALTER
fmpro.executeSql(theQuery, columnDelimiter, rowDelimiter)