Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:52:16

0001 DROP TYPE n_tbl;
0002 DROP TYPE n_obj;
0003 
0004 
0005 CREATE OR REPLACE TYPE n_obj AS OBJECT (
0006  n NUMBER
0007 );
0008 /
0009 show errors;
0010 
0011 CREATE OR REPLACE TYPE n_tbl AS TABLE OF n_obj;
0012 /
0013 show errors;
0014 
0015 CREATE OR REPLACE FUNCTION
0016 nrows (n IN NUMBER DEFAULT NULL, m IN NUMBER DEFAULT NULL)
0017 return n_tbl
0018 PIPELINED
0019 AS
0020 nrow n_obj := n_obj(0);
0021 BEGIN
0022   FOR i IN nvl(n,1) .. nvl(m,999999999)
0023   LOOP
0024     nrow.n := i;
0025     PIPE ROW(nrow);
0026   END LOOP;
0027   RETURN;
0028 END;
0029 /
0030 show errors;
0031 
0032 SELECT n FROM TABLE(nrows(1,5));
0033 
0034 CREATE OR REPLACE PROCEDURE streamtest (n_objects IN NUMBER)
0035 AS
0036 last_id NUMBER(10);
0037 n_start NUMBER(10);
0038 n_end NUMBER(10);
0039 BEGIN
0040   dbms_output.put_line('Streamtest adding ' || n_objects || ' objects');
0041   SELECT max(iov_value_id) INTO last_id FROM st_ecalpedestals;
0042 
0043   IF last_id IS NULL THEN
0044     last_id := 0;
0045   END IF;
0046 
0047   n_start := last_id + 1;
0048   n_end := n_start + n_objects - 1;
0049 
0050   dbms_output.put_line('Writing objects ' || n_start || ' through ' || n_end);
0051 
0052   INSERT INTO st_ecalpedestals (iov_value_id, time)
0053   SELECT n, n FROM TABLE(nrows(n_start, n_end));
0054 
0055   INSERT INTO st_ecalpedestals_item 
0056   (iov_value_id, pos, det_id, mean_x1, mean_x12, mean_x6, rms_x1, rms_x12, rms_x6)
0057   SELECT par_key.n, pos_key.n, dbms_random.random(), 
0058          dbms_random.value(), dbms_random.value(), dbms_random.value(),
0059          dbms_random.value(), dbms_random.value(), dbms_random.value()
0060   FROM TABLE(nrows(n_start, n_end)) par_key, TABLE(nrows(1, 61200)) pos_key;
0061 
0062   COMMIT;
0063 END;
0064 /
0065 show errors;