LONG			ret,
			band,
			number_of_bands;
SE_BIN_FUNCTION_TYPE	bin_function_type;
SE_RASBANDINFO	*rasbandinfo;
CHAR			bandname[24];
SE_STREAM		stream;
CHAR			**columns,
			name_value[] = "ESRI_SDERASTERDATASET";
SHORT	  		name_ind = SE_IS_NOT_NULL_VALUE,
			raster_ind = SE_IS_NOT_NULL_VALUE,
			num_columns = 1;
SE_RASTERATTR	raster_attrib, raster_attrib2;
SE_QUERYINFO 	queryinfo;
CHAR  		**tables, 
		    	whereclause[32],
		    	raster_column[] = "RASTER";

/* Initialize SE_RASTERATTR structure */

ret = SE_rasterattr_create(&raster_attrib,FALSE);
check_error (NULL, NULL, ret, "SE_rasterattr_create");

ret = SE_stream_create(connection,&stream);
check_error (connection, NULL, ret, "SE_stream_create");

/* Create the queryinfo structure */

ret = SE_queryinfo_create (&queryinfo);
check_error (connection, NULL, ret, "SE_stream_create");

/* Add the raster table to the query info structure */

tables = (CHAR **)malloc(sizeof(CHAR*));
tables[0] = malloc((strlen(table) +1) * sizeof(CHAR));
strcpy(tables[0],table);

ret = SE_queryinfo_set_tables(queryinfo,
					1,
					(const CHAR **)tables,NULL); 
check_error (connection, NULL, ret,
			   "SE_queryinfo_set_table");

free(tables);

/* Add the raster table's columns to the query info structure */

columns = (CHAR **)malloc(sizeof(CHAR*));
columns[0] = malloc((strlen(raster_column) +1) * sizeof(CHAR));

strcpy(columns[0],raster_column);

ret = SE_queryinfo_set_columns (queryinfo,
1,
(const CHAR **)columns);
check_error (connection, NULL, ret,
             "SE_queryinfo_set_columns");

sprintf(whereclause,"objectid = %d",row_id);

ret = SE_queryinfo_set_where_clause(queryinfo,whereclause);
check_error (NULL, NULL, ret,
             "SE_queryinfo_set_where_clause");

/* Add the queryinfo structure to the stream */

ret = SE_stream_query_with_info (stream, queryinfo);
check_error (NULL, stream, ret,
             "SE_stream_query_with_info");

/* Free the queryinfo. */

SE_queryinfo_free(queryinfo);

/* Bind the output of the stream the raster column */

ret = SE_stream_bind_output_column (stream,
                                    1,
                                    raster_attrib,
                                    &raster_ind); 
check_error (NULL, stream, ret,
             "SE_stream_bind_output_column"); 

/* Execute the query */

ret = SE_stream_execute (stream);
check_error (NULL, stream, ret, "SE_stream_execute");

while (SE_SUCCESS == ret) {

/* Fetch each record of the business table */

        ret = SE_stream_fetch (stream);

    if (SE_FINISHED != ret) {	
	check_error (NULL, stream, ret, "SE_stream_fetch");

	if(raster_ind==SE_IS_NOT_NULL_VALUE) {			
	  ret = SE_rasterattr_get_rasterband_info_list (           
                                         raster_attrib, 
                                         &rasbandinfo, 
                                         &number_of_bands);
	  check_error (NULL, NULL, ret,  
                     "SE_rasterattr_get_rasterband_info_list");
	}
          }
  }

  SE_queryinfo_free(queryinfo);

  for(band=0; band<number_of_bands; band++) {	
	
   bin_function_type = SE_BIN_FUNCTION_AUTO;

 /* Set the bin function to automatic complete with bin table */

          ret = SE_rasbandinfo_set_bin_function (rasbandinfo[band],
                                         bin_function_type,
                                         0,
                                         NULL);
  check_error (NULL, NULL, ret, 
                 "SE_rasbandinfo_set_bin_function");
}
      }

/* Bind the raster attribute column */

ret = SE_rasterattr_create (&raster_attrib2,TRUE);
check_error (connection, stream, ret, "SE_rasterattr_create");

ret = SE_rasterattr_set_rasterband_info_list(raster_attrib2,
                                             rasbandinfo, 
                                             number_of_bands);
check_error (connection, stream, ret,  
             "SE_rasterattr_set_rasterband_info_list");

SE_rasterattr_free(raster_attrib);

ret = SE_stream_close(stream,FALSE);
check_error (NULL, NULL, ret, "SE_stream_free");
	
/* Set the stream update */
	
ret = SE_stream_update_row (stream, table, &row_id, 
                            num_columns, (const CHAR **)columns);
check_error (NULL, stream, ret, "SE_stream_update_row");

/* Bind the RASTER column */

	ret = SE_stream_bind_input_column(stream,1,(void *) 
                                        raster_attrib2,
                                        &raster_ind);
check_error (NULL, stream, ret, "SE_stream_bind_input_column");

ret = SE_stream_execute(stream);
check_error (NULL, stream, ret, "SE_stream_execute");
	

/********/
/* Done */
/********/

SE_rasterattr_free(raster_attrib2);
SE_stream_free(stream);
free(columns);