表中有字段status,int类型,查询该表并用DBGrid显示,想在显示时,如该
字段值为0,则显示:未更新;1则显示:更新失败;2则显示更新成功
怎么实现?

解决方案 »

  1.   

    select Case status when 0 then '未更新' when 1 then '更新失败' when 2 then '更新成功' end
    from 表
      

  2.   

    试一下,在DBGrid的onDrawColumnCell事件中加入以下代码:
      if Column.Field.FieldName ='status' then
      begin
        if Column.Field.AsInteger = 0 then
          DBGrid1.Canvas.TextRect(Rect,0,0,'未更新');
        if Column.Field.AsInteger = 1 then
          DBGrid1.Canvas.TextRect(Rect,0,0,'更新失败');
        if Column.Field.AsInteger = 1 then
          DBGrid1.Canvas.TextRect(Rect,0,0,'更新成功');
      end;
      

  3.   

    case status when 0 then '未更新' when 1 then '更新失败' when 2 then '更新成功' end as ##
      

  4.   

    select Case status when 0 then '未更新' when 1 then '更新失败' when 2 then '更新成功' end
      

  5.   

    select decode(status,0,'未更新',1,'更新失败',2,'则显示更新成功') a
    from   表
    oracle