Percent Format Problem

(3 posts) (2 voices)

Tags:

No tags yet.

  1. Steve44, Member

    I have two decimal columns in a query and I'm formatting them with the 2 colstyle commands shown below. The first column displays correctly, but the second column is blank and a series of error messages appear (one for each row returned) as follows:

    Warning: sprintf(): Too few arguments in /var/www/mydbr/lib/utils.php on line 2139

    Can you tell me why this seemingly identical syntax is causing this error? If I remove the second colstyle command the warnings do not appear, but the second column is not formatted as percent.

    SELECT 'dbr.colstyle', 'FF%', '%.2f %'; SELECT 'dbr.colstyle', 'R%', '%.2f %';

  2. myDBR Team, Key Master

    Most likely the first column is a number and second one is a string. To format a string with % concatenation, use '%s %%'.

    --
    myDBR Team

  3. Steve44, Member

    Wow! This was complicated. Your solution worked - the second column was a string. But it wasn't really a string. Both columns were decimal(10,4). But I UNIONed a second query to display an adjustment line and we were showing a string value in the second column in the second query. So apparently MySQL converted the second column in the first query to a string so that the two tables would be compatible. I've moved the string value in the second query to a different string column and now my original colstyle command works.

    Thanks again.


Reply

You must log in to post.