title: How to get random foreign key in SQL Developer?
body: <p>After creating all tables in SQL Developer I need to fill them with at least 10000 entries. I had no problem with tables than had zero FK.
  How can I get random values from other tables?</p>
  
  <p>select rand() doesn't work in this statement. but max() does.</p>
  
  <pre><code>CREATE OR REPLACE PROCEDURE NAPOLNI_ARTIKEL 
  (
    ST_ARTIKLOV IN VARCHAR2 DEFAULT 10000 
  ) AS 
    naziv VARCHAR2(25);
    opis VARCHAR2(25);
    model VARCHAR2(10);
    cena FLOAT(2);
    gar INTEGER;
    ddv INTEGER;
    tip INTEGER;
  CURSOR c1 IS
    SELECT id_dobavitelj
    FROM dobavitelj;
  BEGIN
  FOR rndx IN c1 LOOP
    FOR st IN 1..ST_ARTIKLOV LOOP
      naziv := 'naziv';
      naziv := naziv ||' '|| TO_CHAR(st);
      opis := 'opis';
      opis := opis ||' '|| TO_CHAR(st);
      model := 'model';
      model := model ||' '|| TO_CHAR(st);
  
      cena := dbms_random.value(1.25,230.0);
  
      SELECT NVL(RAND(id_garancija),1)
      INTO gar
      FROM garancija;
  
      SELECT NVL(RAND(id_ddv),1)
      INTO ddv
      FROM DDV;
  
      SELECT NVL(RAND(id_tip),1)
      INTO tip
      FROM tip;
  
      INSERT INTO ARTIKEL(ID_ARTIKLA, NAZIV, OPIS, MODEL, CENA, TIP_ID_TIP, DOBAVITELJ_ID_DOBAVITELJ, GARANCIJA_ID_GARANCIJE, DDV_ID_DDV) VALUES (st, naziv, opis, model, cena, tip, rndx, gar, ddv);
    END LOOP;
  END LOOP;
  END NAPOLNI_ARTIKEL;
  </code></pre>
  
  
  
  <pre><code>   * id_artikla INTEGER NOT NULL ,
     * naziv      VARCHAR2 (25) NOT NULL ,
       opis       VARCHAR2 (25) ,
     * model      VARCHAR2 (10) NOT NULL ,
     * cena FLOAT (2) NOT NULL ,
   F * Tip_id_tip               INTEGER NOT NULL ,
   F * Dobavitelj_id_dobavitelj INTEGER NOT NULL ,
   F   Garancija_id_garancije   INTEGER ,
   F * DDV_id_ddv               INTEGER NOT NULL
  </code></pre>