Re: [libdbi-users] Use dynamic dbi_result_bind_* functions

2008-04-17 Thread João Henrique Freitas
Yes, this functions solve my needs and the others users too.

On Thu, Apr 17, 2008 at 8:19 AM, Markus Hoenicka
[EMAIL PROTECTED] wrote:
 Markus Hoenicka writes:
char* dbi_result_fget_string_copy(dbi_result Result, const char*
fieldname);
char* dbi_result_fget_string_copy_idx(dbi_result Result, unsigned int
fieldidx);
int dbi_result_fbind_string_copy(dbi_result Result, const char*
fieldname, char** bindto);
   

  Come to think of it, the following names may be more appropriate:

  dbi_result_get_as_string_copy()
  dbi_result_get_as_string_copy_idx()
  dbi_result_bind_as_string_copy()

  dbi_result_get_as_longlong()
  dbi_result_get_as_longlong_idx()
  dbi_result_bind_as_longlong()



The dbi_result_get_string* can get all values string, integers,
datetime, all type will be return as string (char *). And the function
caller need to free the results appropriately. Ex.:

char * v;
v =  dbi_result_fget_string_copy(result, my_date);

printf(This is a date: %s, v);
- This is a date: 2008-04-17 10:38:00

v =  dbi_result_fget_string_copy(result, my_bignumber);

printf(This is a bignumber: %s, v);
- This is a date: 109456135

How we will automatically convert the types into strings formats,
inside dbi_result_fget_string*?


Meanwhile, the  dbi_result_get_as_longlong* return integers. What will
be the retur If this get a string?


  regards,
  Markus

  --
  Markus Hoenicka
  [EMAIL PROTECTED]
  (Spam-protected email: replace the quadrupeds with mhoenicka)
  http://www.mhoenicka.de




-- 
---
João Henrique Freitas - joaohf_at_gmail.com
Campinas-SP-Brasil
BSD051283
LPI 1
http://joaohf.pbwiki.com
http://www.livejournal.com/users/joaohf/
-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
libdbi-users mailing list
libdbi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-users


Re: [libdbi-users] Use dynamic dbi_result_bind_* functions

2008-04-17 Thread Markus Hoenicka
João Henrique Freitas writes:
  How we will automatically convert the types into strings formats,
  inside dbi_result_fget_string*?
  

Yes, this should happen within libdbi to make it independent of the
drivers. We should use standard C library conversion functions as far
as possible.

  
  Meanwhile, the  dbi_result_get_as_longlong* return integers. What will
  be the retur If this get a string?
  

I'd suggest to use strtoll() for the conversion. If the string happens
to be the representation of an integer which makes sense to strtoll(),
we'll return this value. If the string does not represent a number,
strtoll() returns 0 and sets errno. We should return 0 as well and
report the conversion failure by setting the libdbi error status
appropriately which you can query by calling dbi_conn_error() if
necessary.

regards,
Markus

-- 
Markus Hoenicka
[EMAIL PROTECTED]
(Spam-protected email: replace the quadrupeds with mhoenicka)
http://www.mhoenicka.de

-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
libdbi-users mailing list
libdbi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-users