Results 1 to 9 of 9

Thread: DIV syntax...

  1. #1
    Join Date
    Aug 2008
    Posts
    464

    Unanswered: DIV syntax...

    Hi guys

    Trying to understand something that I've not seen before for using DIV in Oracle SQL.

    div (numerator,denominator,0,2)

    Regards
    Shajju

  2. #2
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    DIV is not an oracle function. What are the last two arguments in div doing?
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  3. #3
    Join Date
    Jul 2003
    Posts
    2,296
    divide? why would you do 0/2? that is funny.
    - The_Duck
    you can lead someone to something but they will never learn anything ...

  4. #4
    Join Date
    Aug 2008
    Posts
    464
    Sorry, it's

    ROUND(DIV(A,B,2,0),2)*100

    Don't understand the function of 2,0.

    Regards
    Shajju

  5. #5
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    DIV is not an oracle function, so you need to look at the source code from DIV function
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  6. #6
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Round changes nothing in this story.

    It appears that, as far as some of us know, DIV is not an Oracle (built-in) function.
    Code:
    SQL> select * from v$version;
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    
    SQL> select round(div(8, 3, 2, 0), 2) * 100 from dual;
    select round(div(8, 3, 2, 0), 2) * 100 from dual
                 *
    ERROR at line 1:
    ORA-00904: "DIV": invalid identifier
    
    
    SQL>
    Can you prove different? If so, please, do. It would be nice if you could point to documentation you read but didn't understand.

    Is DIV, perhaps, a function someone wrote (in your company? School?) and you were just told how to use it?

    What is the result of the following SELECT statement in your schema (database)? (for me, it returns "something" because I've just written the DIV function):
    Code:
    SQL> select object_name, object_type, created
      2  from user_objects
      3  where object_name = 'DIV';
    
    OBJECT_NAM OBJECT_TYP CREATED
    ---------- ---------- -------------------
    DIV        FUNCTION   25.05.2010 07:10:24
    
    SQL>

  7. #7
    Join Date
    Aug 2008
    Posts
    464
    Thanks for the info. I get the same output as yourself.

    OBJECT_NAME OBJECT_TYPE CREATED
    DIV FUNCTION 11/08/2005 8:17:01 PM

    But whether I use 2,0 or not the result is always the same though can't figure out what these numbers mean.

    Any way to understand the function?
    Last edited by shajju; 05-25-10 at 10:54.

  8. #8
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >Any way to understand the function?

    extract the function source code
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  9. #9
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    TYPE THE FOLLOWING COMMANDS AND PASTE IT IN THE FORUM


    select text
    from all_source
    where name='DIV'
    order by line;
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

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