DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: STEP function in oracle?

  1. #1
    Join Date
    Mar 2001
    Location
    Reading, U.K
    Posts
    598
    is STEP function in oracle?
    Cheers!
    OraKid.

  2. #2
    Join Date
    Jul 2001
    Posts
    334
    Did you read or test in Oracle?

  3. #3
    Join Date
    Jun 2001
    Location
    NJ
    Posts
    118
    HI Balaji,
    TO my knowledge, there is no built-in function named "Step" in Oracle. I would lprefer you to download the Orcle documentation from Oracle site or buy a fundemental Oracle book.

    Thanks,

    GD_1976.

  4. #4
    Join Date
    Mar 2001
    Location
    Reading, U.K
    Posts
    598
    hi,
    my requirement is the FOR LOOP should increment by 5 values.
    (eg) FOR i IN 1..100 LOOP

    ...stmt

    END LOOP;

    now i use MOD function to get the 5th row

    i want a simple function
    thanx guys
    Cheers!
    OraKid.

  5. #5
    Join Date
    Nov 2000
    Location
    Baltimore, MD USA
    Posts
    1,339
    First, I would do as everyone suggested and figure out how to get to the documentation.

    The easiest way is to simply make a free account on Oracle Technology Network. This would then allow you to get to this link:

    http://otn.oracle.com/docs/products/..._struc.htm#685

    There, you would find the following:

    Some languages provide a STEP clause, which lets you specify a different increment (5 instead of 1 for example). PL/SQL has no such structure, but you can easily build one. Inside the FOR loop, simply multiply each reference to the loop counter by the new increment. In the following example, you assign today's date to elements 5, 10, and 15 of an index-by table:

    DECLARE
    TYPE DateList IS TABLE OF DATE INDEX BY BINARY_INTEGER;
    dates DateList;
    k CONSTANT INTEGER := 5; -- set new increment
    BEGIN
    FOR j IN 1..3 LOOP
    dates(j*k) := SYSDATE; -- multiply loop counter by increment
    END LOOP;
    ...
    END;
    Unfortunately, there is no STEP function in PL/SQL - spiffy, eh?

    HTH,

    - Chris
    Christopher R. Long
    ChrisRLong@HotMail.Com
    But that's just my opinion. I could be wrong

Posting Permissions

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


Click Here to Expand Forum to Full Width