Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2008
    Posts
    1

    Unanswered: Suffixing zero to numeric field in select statement

    I am just going through an exercise in migrating to a current version of Business Objects BOXI from SAP, when I came across part of a select statement which doesn't make any sense to me, being a newbie.

    It contains
    select NumericField+0, DecsriptiveField, CodeField
    from TableName
    where CodeField = '1'

    What is the use of adding a zero to a numeric field as it doesn't change the value of the field returned?
    Is it forcing the non use of an index associated with NumericField?

    Any help greatly appreciated.

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    It isn't really "suffixing" but "adding", I'd say. We'd talk about suffixing if it was, for example
    Code:
    select to_char(numeric_field) || '0' ...
    I have no idea what can be its purpose; I doubt that it has anything to do with indexes (it might have, but if it was in the WHERE clause).

  3. #3
    Join Date
    Dec 2003
    Posts
    1,074
    Maybe the original programmer thought they were getting the equivalent of

    Code:
    select nvl(NumericField, 0) as new_field
    ... which they're not.

    --=cf

  4. #4
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Who knows what made the programmer write that? It doesn't actually do anything. People write strange code sometimes. One I quite often see is:
    Code:
    v_list := 'Apple' || ',' || 'Pear' || ',' || 'Banana';
    I'm never sure whether the developer doesn't realise that is the same as:
    Code:
    v_list := 'Apple,Pear,Banana';
    or whether they do but have some odd reason for prefering the verbose syntax.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •