1 24 25 package com.mckoi.database.interpret; 26 27 import java.util.ArrayList ; 28 import java.util.List ; 29 import java.math.BigDecimal ; 30 import com.mckoi.database.*; 31 32 38 39 public class Set extends Statement { 40 41 44 String type; 45 46 49 String var_name; 50 51 55 Expression exp; 56 57 60 String value; 61 62 63 64 66 public void prepare() throws DatabaseException { 67 type = (String ) cmd.getObject("type"); 68 var_name = (String ) cmd.getObject("var_name"); 69 exp = (Expression) cmd.getObject("exp"); 70 value = (String ) cmd.getObject("value"); 71 } 72 73 public Table evaluate() throws DatabaseException { 74 75 DatabaseQueryContext context = new DatabaseQueryContext(database); 76 77 String com = type.toLowerCase(); 78 79 if (com.equals("varset")) { 80 database.setVar(var_name, exp); 81 } 82 else if (com.equals("isolationset")) { 83 value = value.toLowerCase(); 84 database.setTransactionIsolation(value); 85 } 86 else if (com.equals("autocommit")) { 87 value = value.toLowerCase(); 88 if (value.equals("on") || 89 value.equals("1")) { 90 database.setAutoCommit(true); 91 } 92 else if (value.equals("off") || 93 value.equals("0")) { 94 database.setAutoCommit(false); 95 } 96 else { 97 throw new DatabaseException("Unrecognised value for SET AUTO COMMIT"); 98 } 99 } 100 else if (com.equals("schema")) { 101 105 database.setDefaultSchema(value); 107 108 } 109 else { 110 throw new DatabaseException("Unrecognised set command."); 111 } 112 113 return FunctionTable.resultTable(context, 0); 114 115 } 116 117 118 } 119 | Popular Tags |