[sr-dev] duplicate db_res_t
Henning Westerholt
henning.westerholt at 1und1.de
Fri Aug 6 16:44:25 CEST 2010
On Friday 06 August 2010, Chandrakant Solanki wrote:
> I have developed one custom function in module, and also create one custom
> structure to store database recordset.
>
> What I would like to do is...
>
> 1] I have structure say struct record and it has variable
> struct record {
> int id;
> char name;
> db_res_t *res;
> };
> 2] Execute one query and store result into "db_res" variable of db_res_t
> datatype; 3] Now I would like to preserve 'n in future i will use this
> recordset.. so how can i store this "db_res" variable into structure
> variable.
>
> I have tried using below syntax...
>
> struct record rec[2];
>
> db_res = get_record( "pass_any_query" );
> rec[0].res = db_res;
>
> But when I used this rec[0].res in future it gives garbage value.
>
> Any Idea...???
Hi Chandrakant,
i'm not 100% sure what you want to achive. You want to execute one query, and
then execute another query on the existing result set to fill it with more
values? This is somewhat already available with the "fetch result"
functionality.
But if you want to store just some arbitrary results from an result set in an
own structure i'd suggest that you not hold any pointer to the internal result
set for this purposes. They will be freed after the query, for example if you
call free_result on it. Better would be to copy the data that you need from
the result set to an own structure which you can then control.
Cheers,
Henning
More information about the sr-dev
mailing list