1 /* JJT: 0.2.2 */ 2 3 package mobisnap.mobile_trx; 4 5 import java.util.*; 6 import nmp.dbms.*; 7 8 /*** 9 * Implements query statement 10 */ 11 public class ASTQueryStatement extends mobisnap.mobile_trx.SimpleNode { 12 public Vector into; 13 public Vector what; 14 public Vector from; 15 public Vector fromid; 16 public ASTSQLExpression where; 17 18 public boolean selectAll = false; 19 public boolean forUpdate = false; 20 public boolean connect = false; 21 public boolean groupBy = false; 22 public boolean orderBy = false; 23 public boolean setClause = false; 24 25 public ASTQueryStatement(int id) { 26 super(id); 27 into = new Vector(); 28 what = new Vector(); 29 from = new Vector(); 30 fromid = new Vector(); 31 } 32 33 public ASTQueryStatement( MobisnapSQL p, int i) { 34 super( p, i); 35 id = i; 36 into = new Vector(); 37 what = new Vector(); 38 from = new Vector(); 39 fromid = new Vector(); 40 } 41 42 /*** Accept the visitor. **/ 43 public Object jjtAccept(MobisnapSQLVisitor visitor, Object data) { 44 return visitor.visit(this, data); 45 } 46 47 public SQLVectorResult getResult( int msql_type) throws Exception { 48 StringBuffer buf = new StringBuffer(); 49 sourceCode( msql_type, buf); 50 return MobisnapSQL.transaction.executeQuery( buf.toString().trim()); 51 } 52 53 public void process( int msql_type) throws Exception { 54 SQLVectorResult result = getResult( msql_type); 55 if( result.rows.size() == 1) { 56 Object[] row = (Object[])result.rows.elementAt( 0); 57 if( row.length == into.size()) { 58 for( int i = 0; i < into.size(); i++) { 59 MSQLTVariable var = (MSQLTVariable)MobisnapSQL.names.getName( (String)into.elementAt(i)); 60 var.associateRsrv( null); 61 if( row[i] == null) 62 var.setValue( SQLNull.getInstance()); 63 else 64 var.setValue( row[i]); 65 } 66 } else 67 throw new mobisnap.MobisnapException( "Select into statement with mismatch size of columns"); 68 } else 69 throw new mobisnap.MobisnapException( "Select into statement returns more than one row"); 70 } 71 72 }

This page was automatically generated by Maven