List:General Discussion« Previous MessageNext Message »
From:Michael Farr Date:April 15 1999 12:50pm
Subject:Re: balance
View as plain text  
>
>Michael> double balance(UDF_INIT *initid, UDF_ARGS *args, char *is_null,
>Michael> 		     char *error)
>Michael> {
>Michael> 	float total = 0;
>Michael> 	for(int i = 1; i<=indexId; i++)
>Michael> 		total += account(i).debit;
>Michael> }
>
>Michael> If anyone can tell me how to access the data structures in MySQL
to get any
>Michael> of those things out I should be able to finish this little problem.
>
>Michael> Mike
>
>Hi!
>
>Sorry, you can't access the data structures in a UDF function.
>
>You can however solve your problem this way:
>
>Allocate a variable in your init function (you should save this in
>UDF_INIT -> ptr)
>
>For each call to the balance function, add the new value to the old
>value and return the new value.
>
>Regards,
>Monty
>

UDF_INIT->prt is a char* isn't it?  How can I store a double in a char*?  (
really hoping that isnt a stupid question )
Thread
balanceMichael Farr15 Apr
  • balanceMichael Widenius15 Apr
    • Re: balanceMichael Farr15 Apr
      • Re: balanceMichael Widenius16 Apr
        • balance solutionMichael Farr16 Apr