Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2003
    Posts
    26

    Unanswered: FROM emp SAMPLE (mynumber)

    Hello,
    why does the following code work NOT with the line:
    SAMPLE (mynumber )




    Code:
    CREATE OR REPLACE
    PROCEDURE mysample
    IS
    
    mynumber NUMBER := 20;
    
    
    BEGIN
    
    DBMS_OUTPUT.PUT_LINE('mynumber:  '||mynumber);
    
    FOR r_samp IN (
    	SELECT SAL 
    	FROM EMP  
    	--SAMPLE ( 20 )
    	SAMPLE ( mynumber )
    )
    LOOP
    
    DBMS_OUTPUT.PUT_LINE('sal:  '||r_samp.SAL);
    
    
    END LOOP;
    
    DBMS_OUTPUT.PUT_LINE('mynumber:  '||mynumber);
    
    END  mysample;

  2. #2
    Join Date
    Jan 2004
    Posts
    492
    Disregard - I'm an idiot and it won't let me delete this.
    Last edited by ss659; 10-17-04 at 13:24.
    Oracle OCPI (Certified Practicing Idiot)

  3. #3
    Join Date
    Aug 2003
    Posts
    26
    SAMPLE ( NUMBER ) is a builtin function, which is a sort of random test, e.g.

    SELECT * FROM MYTABLE SAMPLE (10);
    would select about 10 percent of all rows of the table MYTABLE.

    The range of SAMPLE is ( 0.000001 to 100 ). What I like to do, is to describe the percentage with a variable ( here MYNUMBER) rather then hardcode it like SAMPLE(20)

Posting Permissions

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