public BigDecimal ODCITableFetch(BigDecimal nrows, ARRAY[] outSet)
			throws SQLException, ClassNotFoundException, MalformedURLException, IOException {
		Connection conn = DriverManager
				.getConnection("jdbc:default:connection:");

		sendDBMSOutput("Fetching...", conn);
		
		// retrieve stored context using the key
	    StoredCtx ctx;
	    try {
	      ctx=(StoredCtx)ContextManager.getContext(key.intValue());
	    } catch (InvalidKeyException ik ) {
	      return ERROR;
	    }

	    
		Vector<Object> v = new Vector<Object>(nrows.intValue());
	    
		StructDescriptor rowDesc = StructDescriptor.createDescriptor(
				"T"+ctx.tableName.toUpperCase()+"_ROW", conn);
		
		String userPassword = ctx.bucket + ":" + ctx.password;
		String encoding = new sun.misc.BASE64Encoder().encode(userPassword.getBytes());
		
			
		int limit = 0;
		
		while (ctx.currentIdx < ctx.ids.size() && limit++ < 500){
			
			InputStream in = null;
			
			HttpURLConnection http = (HttpURLConnection)new URL(ctx.url+ctx.bucket+"/"+ctx.ids.get(ctx.currentIdx)).openConnection();
 			http.setRequestProperty("Authorization", "Basic " + encoding);
			
		
 			in = http.getInputStream();
 			
 			JSONTokener t = new JSONTokener(in);
 			JSONObject rootJS = new JSONObject(t);
 			JsonObject root = new JsonObject(rootJS.toString());
 			//sendDBMSOutput("Processing id: " + ctx.ids.get(ctx.currentIdx) + "and looking at table "+ctx.tableName, conn);
			
 			 
 			if (ctx.model.tables.containsKey(ctx.tableName)) {
 				
 				DataTable table = ctx.model.tables.get(ctx.tableName);
 			
	 			// Process the child table yielding multiple records in v
	 			if (table.rows.size() > 2 &&table.rows.get(1).values.get(table.indexOfColumn("xpath")).toString().startsWith("#")) {
	 				//sendDBMSOutput("Processing nested table in "+ctx.ids.get(ctx.currentIdx)+"...", conn);
	 				
	 				List<Object[]> records = processChildTable(table, root, ctx.ids.get(ctx.currentIdx));
	 				
	 				for(Object[] record : records) {
	 					v.add((Object) new STRUCT(rowDesc, conn, record));
	 				}
	 				
	 			}
	            // Process the main document yielding a single record to v
	 			else {
	 				
	 				try {
	 					Object[] record = processMainTable(table, root, ctx.ids.get(ctx.currentIdx));
		 				v.add((Object) new STRUCT(rowDesc, conn, record));
		 			}
	 				catch (Exception ex) {
	 					
	 				}
	 			}
 			}
 			
 			in.close();
		
			ctx.currentIdx++;
			
		}

 		
		// create the output ARRAY using the vector
		Object out_arr[] = v.toArray();
		ArrayDescriptor ad = new ArrayDescriptor("T"+ctx.tableName.toUpperCase()+"_ROWSET", conn);
		outSet[0] = new ARRAY(ad, conn, out_arr);
		
		sendDBMSOutput("Sending rowset of: "+ad.getName(), conn);
			

		return SUCCESS;
	}