April 13, 2005
I have the database api all setup and functioning, but now I would like to do something like:

Results res = db.query("SELECT * FROM people");
Row row;
char[] name, city, state, zip;

row.bind("name", name);
row.bind("city", city);
row.bind("state", state);
row.bind("zip", zip);

while((row = res.fetchRow()) != null) {
  printf("Name = %.*s, city = %.*s, state = %.*s, zip = %.*s", name, city, state, zip);
}


----

the row.bind function is what I do not know how to develop, or if it's even possible. Can someone give me a simple example? Not of how the database api works, but simply how I would store a reference to the char array for later assigning and repeat assigning in my Row class.

Thanks!

Jeremy
April 13, 2005
Hmm... maybe something like this:

# char[] name, city, state, zip;
#
# row.bind("name", &name);
# // etc

Where Row.bind is defined as:
# public void bind(char[] label, char[]* var) { ... }

Then keep a map of variables locally, something like:
# private char[]*[char[]] boundvars;

Just a 20-seconds-of-thought suggestion.

-- Chris Sauls

Jeremy Cowgar wrote:
> I have the database api all setup and functioning, but now I would like to do something like:
> 
> Results res = db.query("SELECT * FROM people");
> Row row;
> char[] name, city, state, zip;
> 
> row.bind("name", name);
> row.bind("city", city);
> row.bind("state", state);
> row.bind("zip", zip);
> 
> while((row = res.fetchRow()) != null) {
>   printf("Name = %.*s, city = %.*s, state = %.*s, zip = %.*s", name, city, state, zip);
> }
> 
> 
> ----
> 
> the row.bind function is what I do not know how to develop, or if it's even possible. Can someone give me a simple example? Not of how the database api works, but simply how I would store a reference to the char array for later assigning and repeat assigning in my Row class.
> 
> Thanks!
> 
> Jeremy