Generating unique no.'s using random function

Hi,
I'm trying to generate unique values for row and column say from 0-3
and I read some where that if we use random.nextInt() we will get unique values but I'm getting repeated values.I'll appreciate if anyone can help me in this matter.Here's the code:
import java.io.*;
import java.util.*;
import java.lang.*;
public class random{
public static void main(String args[])
int b[]=new int[4];
int c[]=new int[4];
int i;
Date date;
Random random;
date=new Date();
random = new Random(date.getTime());
for(i=0;i<4;i++)
digit = random.nextInt(4);
b=digit;
for(i=0;i<4;i++)
digit = random.nextInt(4);
c[i] = digit;
for(i=0;i<4;i++)
System.out.println("column array is" + c[i]);
for(i=0;i<4;i++)
System.out.println("row array is" + b[i]);
}//end main
}//end class
Thanks
Suneetha.

here is my code for generating a random number but not a unique number. with a big enough number the possibility getting a unique is high so you may modify it to suit you need:
  private void initial_node()
    float Qxyd = -1, Qyzd = -1, Cxyd = -1, Cyzd = -1;
    long seed;
    Q_table = new float[row][col];
    seed = (long)( Math.random() * System.currentTimeMillis() * 100000000 );
    Random rand1 = new Random( seed );
    seed = (long)( Math.random() * System.currentTimeMillis() * 100000000 );
    Random rand2 = new Random( seed );
    seed = (long)( Math.random() * System.currentTimeMillis() * 100000000 );
    Random rand3 = new Random( seed );
    seed = (long)( Math.random() * System.currentTimeMillis() * 100000000 );
    Random rand4 = new Random( seed );
    for( int i = 0; i < row; i++ )
      do
        Qxyd = (float)( rand1.nextFloat() + (float)rand1.nextFloat() / 3 );
      while( Qxyd < 0.35 || Qxyd == -1 );
      Q_table[5] = Math.abs( Qxyd );
do
Qyzd = (float)( rand2.nextFloat() + (float)rand2.nextFloat() / 7 );
while( Qyzd < 0.45 || Qyzd == -1 );
Q_table[i][3] = Math.abs( Qyzd );
do
Cxyd = (float)( rand3.nextFloat() + (float)rand3.nextFloat() / 9 );
while( Cxyd > 0.15 || Cxyd == -1 );
Q_table[i][8] = Math.abs( Cxyd );
do
Cyzd = (float)( rand4.nextFloat() + (float)rand4.nextFloat() / 11 );
while( Cyzd > 0.10 || Cyzd == -1 );
Q_table[i][9] = Math.abs( Cyzd );

Similar Messages

  • Generating a 'WHERE' clause using a function

    Hi I have below requirement,
    for given function below are input parameters,
    sk_func(salary,dept_no,job,hire_date)
    which ever input is given those inputs should be there in one statement,
    For example if I give input as
    select sk_func(5000,null,null,null) from dual;
    I need output as Where salary=5000;
    if I give input as
    select sk_func(5000,null,'Programmer',null) from dual;
    I need output as Where Salary=5000 and job='Programmer';
    Hope am clear,
    In short which ever values are not null, those all should include in my where clause,
    I know how to do it, but taking into considerations, am finding the best way to do it,
    Thanks for your responses,

    Hi Karthik,
    this is the api, I have done,
    create or replace
    FUNCTION get_where_clause_for_emp_req (
       emp_id       IN   NUMBER,
       salary            IN   NUMBER,
       job         IN   VARCHAR2,
       dept IN NUMBER
       RETURN VARCHAR2
    IS
       l_where_clause   VARCHAR2 (2000);
    BEGIN
       IF (    (emp_id IS NULL)
           AND (salary IS NULL)
           AND (job IS NULL)
           AND (deptIS NULL)
       THEN
          RETURN NULL;
       ELSE
          l_where_clause := 'WHERE ';
       END IF;
       IF (emp_id IS NOT NULL)
       THEN
          l_where_clause :=
                        l_where_clause || ' emp_id =' || emp_id || '';
       END IF;
       IF ((emp_id IS NOT NULL) AND (salary IS NOT NULL))
       THEN
          l_where_clause :=
                          l_where_clause || ' AND salary= ' || salary;
       ELSIF (salary IS NOT NULL)
       THEN
          l_where_clause := l_where_clause || ' salary= ' || salary;
       END IF;
       IF (((salary IS NOT NULL) AND (dept IS NOT NULL)) OR ((emp_id IS NOT NULL) AND (salary IS NULL) AND (dept IS NOT NULL)))
       THEN
          l_where_clause := l_where_clause || ' AND dept= ' || dept;
       ELSIF (status_i IS NOT NULL)
       THEN
          l_where_clause := l_where_clause || ' dept= ' || dept;
       END IF;
    l_where_clause := l_where_clause || ' ;';
       RETURN l_where_clause;
    END;I have done for three parameters, i need to include two more input parameters for this function, so I see going forward my testing cases will increases,
    so am looking for the best solution
    Thanks
    Edited by: NSK2KSN on Jul 7, 2010 3:11 PM

  • When using TODATE function MDX query is not correctly generated

    Essbase 9.3.1.2 and OBIEE 10.1.3.4.1.
    When using TODATE function MDX query is not correctly generated.
    This leads to unexpected values not only on cumulative columns in report (generated with TODATE), but also other columns (calculated with AGO function or directly read from cube) have incorrect values.
    The problem occurs when you filter on a column that is not in the select list. If you filter on just one level of dimension, results are fine. You can filter on multiple dimensions as long as you filter on just one level of each dimension.
    If you filter on two or more levels of one dimension, than results are not correct. In some cases results for TODATE column are all zeros, in some cases it is a random value returned by Essbase (same random value for all rows of that column), and in some cases BI Server returns an error:
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. Essbase Error: Network error [10054]: Cannot Send Data (HY000).
    Here is generated MDX code:
    With
    set [Grupe proizvoda2] as '{[Grupe proizvoda].[N4]}'
    set [Grupe proizvoda4] as 'Generate([Grupe proizvoda2], Descendants([Grupe proizvoda].currentmember, [Grupe proizvoda].Generations(4), leaves))'
    set [Segmentacija2] as '{[Segmentacija].[RETAIL]}'
    set [Segmentacija4] as 'Filter(Generate({[Segmentacija2]}, Descendants([Segmentacija].currentmember, [Segmentacija].Generations(4),SELF), ALL), ([Segmentacija].CurrentMember IS [Segmentacija].[AFFLUENT]))'
    set [Vrijeme3] as '{[Vrijeme].[MJESEC_4_2009]}'
    member [Segmentacija].[SegmentacijaCustomGroup]as 'Sum([Segmentacija4])', SOLVE_ORDER = AGGREGATION_SOLVEORDER
    member [Accounts].[MS1] as '(ParallelPeriod([Vrijeme].[Gen3,Vrijeme],2,[Vrijeme].currentmember), [Accounts].[Trosak kapitala])'
    member [Accounts].[MS2] as '(ParallelPeriod([Vrijeme].[Gen3,Vrijeme],1,[Vrijeme].currentmember), [Accounts].[Trosak kapitala])'
    member [Accounts].[MS3] as 'AGGREGATE({PeriodsToDate([Vrijeme].[Gen2,Vrijeme],[Vrijeme].currentmember)}, [Accounts].[Trosak kapitala])'
    select
    { [Accounts].[Trosak kapitala],
    [Accounts].[MS1],
    [Accounts].[MS2],
    [Accounts].[MS3]
    } on columns,
    NON EMPTY {crossjoin ({[Grupe proizvoda4]},{[Vrijeme3]})} properties ANCESTOR_NAMES, GEN_NUMBER on rows
    from [NISE.NISE]
    where ([Segmentacija].[SegmentacijaCustomGroup])
    If you remove part with TODATE function, the results are fine. If you leave TODATE function, OBIEE returns an error mentioned above. If you manually modify variable SOLVE_ORDER and set value to, for example, 100 instead of AGGREGATION_SOLVEORDER, results are OK.
    In all cases when this variable was modified in generated MDX, and query manually executed on Essabse, results were OK. This variable seems to be the possible problem.

    Hi,
    Version is
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
    PL/SQL Release 10.2.0.5.0 - Production
    CORE    10.2.0.5.0      Production
    TNS for 64-bit Windows: Version 10.2.0.5.0 - Production
    NLSRTL Version 10.2.0.5.0 - Production
    Sorry, in my last post i forgot to mention that i already created a function based index but still it is not using because, there is a UNIQUE constraint on that column.
    Thanks

  • Generating Data for INSERT using a Stored Procedure, Function and Cursor

    I've written a function that I finally got to compile, but was not successful in importing and inserting the data needed to populate a table with at least 1800 rows. Here's what I needed to do:
    -- Generate a random test score ranging from 20 to 100 (already done)
    -- Generate a random final grade for the course ranging from 4 to 0 (representing A to F) (already done, but question below.
    -- Use conditional statements based on the counter to assign three courses (already done -- see SQL statements)
    -- Process no more than 95% of the students (300) for test 1.
    -- For test 2, process no more than 80% of the students who took test 1. Student cannot take test 2 unless the student takes test 1 (does this require a trigger? If so, how would I go about doing this?)
    -- Use a function or another subprocedure to process the grade using IF-ELSIF statements
    For example, I've tried the following statements:
    For procedures
    IF birth_date BETWEEN to_date('01-Jan-89 AND to_date('31-Dec-89','dd-Mon-yy') THEN
    school_grade := 6;
    AND for functions:
    IF birth_date BETWEEN to_date('01-Jan-89 AND to_date('31-Dec-89','dd-Mon-yy') THEN
    RETURN (6);
    RETURN;
    - or -
    IF birth_date BETWEEN to_date('01-Jan-89','dd-Mon-yy') AND to_date('31-Dec-89','dd-Mon-yy') THEN
    school_grade := 9
    RETURN school_grade;
    -- Read the birth_date into the main procedure so that the value returned from the subprocedure or function can populate the birth_date column.
    To give you an idea of what I've already done:
    SQL>
    SQL> CREATE OR REPLACE PROCEDURE add_tests (v_school_grade IN NUMBER) AS
    2
    3 v_counter NUMBER(3) := 0;
    4 v_num_students CONSTANT NUMBER(3) := 300;
    5 v_students_test1 NUMBER := 0;
    6 v_students_test2 NUMBER := 0;
    7 v_student_id VARCHAR2(5);
    8 v_course1 VARCHAR2(2);
    9 v_course2 VARCHAR2(2);
    10 v_course3 VARCHAR2(2);
    11 v_course4 VARCHAR2(2);
    12 v_student_grade NUMBER(1) := 0;
    13 v_test_score NUMBER(3) := 0;
    14 v_course_final_grade NUMBER(1) := 0;
    15 v_birth_date DATE;
    16
    17 FUNCTION pkg_get_grade RETURN NUMBER
    18 IS
    19
    20 v_birth_date DATE;
    21 v_school_grade NUMBER(1) :=0;
    22
    23 CURSOR grade_cur IS
    24 SELECT birth_date FROM students;
    25
    26 BEGIN
    27 OPEN grade_cur;
    28 LOOP
    29 FETCH grade_cur INTO v_birth_date;
    30
    31 EXIT WHEN grade_cur%NOTFOUND;
    32
    33 -- Assign student grade
    34
    35 -- 9th Grade
    36
    37 IF v_birth_date < TO_DATE('01-Jan-87','DD-Mon-YY') THEN
    38 v_school_grade := 9;
    39
    40 -- 8th grade
    41
    42 ELSIF v_birth_date BETWEEN
    43 TO_DATE('01-Jan-87','DD-Mon-YY') AND
    44 TO_DATE('31-Dec-87','DD-Mon-YY') THEN
    45
    46 v_school_grade := 8;
    47
    48 -- 7th grade
    49
    50 ELSIF v_birth_date BETWEEN
    51 TO_DATE('01-Jan-88','DD-Mon-YY') AND
    52 TO_DATE('31-Dec-88','DD-Mon-YY') THEN
    53
    54 v_school_grade := 7;
    55
    56 -- 6th grade
    57
    58 ELSIF v_birth_date BETWEEN
    59 TO_DATE('01-Jan-89','DD-Mon-YY') AND
    60 TO_DATE('31-Dec-89','DD-Mon-YY') THEN
    61
    62 v_school_grade := 6;
    63
    64 -- 5th grade
    65
    66 ELSIF v_birth_date > TO_DATE('31-Dec-89','DD-Mon-YY') THEN
    67
    68 v_school_grade := 5;
    69
    70 END IF; -- end if loop for student's grade
    71 END LOOP; -- end loop for grade_cur
    72 CLOSE grade_cur; -- close cursor for assigning grade
    73 RETURN v_school_grade;
    74
    75 END pkg_get_grade;
    76
    77 PROCEDURE delete_test_info AS
    78
    79 BEGIN
    80
    81 DELETE FROM student_facts;
    82
    83 END delete_test_info;
    84
    85 BEGIN
    86
    87 -- Process student for tests
    88
    89 WHILE (v_counter <= v_num_students) LOOP
    90 v_counter := v_counter + 1; -- initialize counter
    91
    92 -- Set student id
    93
    94 v_student_id := 'S'&#0124; &#0124;v_counter;
    95
    96 -- portion of students taking beginning of year tests
    97
    98 v_students_test1 := v_num_students * .95;
    99
    100
    101 -- Portion of students taking end of year tests
    102
    103 v_students_test2 := v_students_test1 * .80;
    104
    105
    106 -- Est. test scores between 20 and 100
    107
    108 v_test_score := random.rand_max(80) + 20;
    109
    110
    111 -- Est. final grade for course between 0 and 4
    112
    113 v_course_final_grade := random.rand_max(4);
    114
    115
    116 -- Process tests for courses
    117
    118 IF v_counter < ROUND(v_num_students * .20) THEN
    119 v_course1 := 'C1';
    120 v_course2 := 'C2';
    121 v_course3 := 'C3';
    122
    123 ELSIF v_counter BETWEEN ROUND(v_num_students * .20)
    124 AND ROUND(v_num_students * .40) THEN
    125
    126 v_course1 := 'C2';
    127 v_course2 := 'C1';
    128 v_course3 := 'C3';
    129
    130 ELSE IF v_counter BETWEEN ROUND(v_num_students * .40)
    131 AND ROUND(v_num_students * .60) THEN
    132
    133 v_course1 := 'C3';
    134 v_course2 := 'C1';
    135 v_course3 := 'C2';
    136
    137 ELSE IF v_counter BETWEEN (v_num_students * .60)
    138 AND ROUND(v_num_students * .80) THEN
    139
    140 v_course1 := 'C3';
    141 v_course2 := 'C1';
    142 v_course3 := 'C2';
    143
    144 ELSE
    145 v_course1 := 'C4';
    146 v_course2 := 'C2';
    147 v_course3 := 'C3';
    148
    149 END IF;
    150 END IF;
    151 END IF;
    152
    153 -- Input test information for students
    154
    155 -- Beginning of year test for Course 1
    156
    157 IF v_counter <= v_students_test1 THEN
    158 INSERT INTO studentfacts
    159 VALUES(v_student_id, v_course1, 'ACH1999',
    160 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
    161 v_student_grade, v_course_final_grade, v_test_score);
    162 ELSE
    163 INSERT INTO studentfacts
    164 VALUES(v_student_id, v_course1, 'ACH1999',
    165 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
    166 v_student_grade, v_course_final_grade, NULL);
    167 END IF;
    168
    169
    170 -- End of year test for Course 1
    171
    172 IF v_counter <= v_students_test2 THEN
    173 INSERT INTO studentfacts
    174 VALUES(v_student_id, v_course1,'ACH2000',
    175 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
    176 v_student_grade, v_course_final_grade, v_test_score);
    177 ELSE
    178 INSERT INTO studentfacts
    179 VALUES(v_student_id, v_course1, 'ACH2000',
    180 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
    181 v_student_grade, v_course_final_grade, NULL);
    182 END IF;
    183
    184
    185 -- Beginning of year test for Course 2
    186
    187 IF v_counter <= v_students_test1 THEN
    188 INSERT INTO studentfacts
    189 VALUES(v_student_id, v_course2, 'ACH1999',
    190 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
    191 v_student_grade, v_course_final_grade,
    192 v_test_score);
    193 ELSE
    194 INSERT INTO studentfacts
    195 VALUES(v_student_id, v_course2, 'ACH1999',
    196 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
    197 v_student_grade, v_course_final_grade, NULL);
    198 END IF;
    199
    200
    201 -- End of year test for Course 2
    202
    203 IF v_counter <= v_students_test2 THEN
    204 INSERT INTO studentfacts
    205 VALUES(v_student_id, v_course2,'ACH2000',
    206 TO_DATE('01-JUN-2001''DD-MON-YYYY'),
    207 v_student_grade, v_course_final_grade,
    208 v_test_score);
    209 ELSE
    210 INSERT INTO studentfacts
    211 VALUES(v_student_id, v_course2, 'ACH2000',
    212 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
    213 v_student_grade, v_course_final_grade, NULL);
    214 END IF;
    215
    216
    217 -- Beginning of year test for Course 3
    218
    219 IF v_counter <= v_students_test1 THEN
    220 INSERT INTO studentfacts
    221 VALUES(v_student_id, v_course3, 'ACH1999',
    222 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
    223 v_student_grade, v_course_final_grade,
    224 v_test_score);
    225 ELSE
    226 INSERT INTO studentfacts
    227 VALUES(v_student_id, v_course3, 'ACH1999',
    228 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
    229 v_student_grade, v_course_final_grade, NULL);
    230 END IF;
    231
    232
    233 -- End of year test for Course 3
    234
    235 IF v_counter <= v_students_test2 THEN
    236 INSERT INTO studentfacts
    237 VALUES(v_student_id, v_course3,'ACH2000',
    238 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
    239 v_student_grade, v_course_final_grade,
    240 v_test_score);
    241 ELSE
    242 INSERT INTO studentfacts
    243 VALUES(v_student_id, v_course3, 'ACH2000',
    244 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
    245 v_student_grade, v_course_final_grade, NULL);
    246 END IF;
    247
    248
    249 -- Beginning of year test for Course 4
    250
    251 IF v_counter <= v_students_test1 THEN
    252 INSERT INTO studentfacts
    253 VALUES(v_student_id, v_course4, 'ACH1999',
    254 TO_DATE('01-SEP-1999','DD-MON-Y YYY'),
    255 v_student_grade, v_course_final_grade,
    256 v_test_score);
    257 ELSE
    258 INSERT INTO studentfacts
    259 VALUES(v_student_id, v_course4, 'ACH1999',
    260 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
    261 v_student_grade, v_course_final_grade, NULL);
    262 END IF;
    263
    264
    265 -- End of year test for Course 4
    266
    267 IF v_counter <= v_students_test2 THEN
    268 INSERT INTO studentfacts
    269 VALUES(v_student_id, v_course4,'ACH2000',
    270 TO_DATE('01-JUN-2001', 'DD-MON-YYYY'),
    271 v_student_grade, v_course_final_grade, v_test_score);
    272 ELSE
    273 INSERT INTO studentfacts
    274 VALUES(v_student_id, v_course4, 'ACH2000',
    275 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
    276 v_student_grade, v_course_final_grade, NULL);
    277
    278 END IF;
    279 END LOOP;
    280 END add_tests;
    281 /
    Procedure created.
    SQL>
    SQL> show errors
    No errors.
    SQL>
    SQL> Input truncated to 9 characters
    spool off
    When I executed the main procedure, no data populated the student_table. I've tried several things, but I was not still able to populate the student_fact table (I've been at this for more than a week now, but haven't figured a way to populate the student_facts table with at least 1800 rows). Can you tell me what I need to change (if anything) whether if I need to structure things differently? I'm thinking that I missed something in calling the birth_date into the main procedure or returning the value from either a function or subprocedure. Related to the random final grade -- is there a way to sum the totals of the test scores (each student will have three), and generate a final grade from these values.
    I also compiled successfully a package containing this same information, but don't know how to execute it to see whether this approach works.
    Many thanks to anyone who can help.
    null

    ldsw,
    I am not sure if I totally understand everything that you are trying to do, but I tried to clean up your code and what is listed below is what I came up with. Please see if you can make use of any of it.
    SQL> EDIT ldsw
    CREATE OR REPLACE PACKAGE ldsw
    AS
    CURSOR grade_cur
    IS
    SELECT birth_date
    FROM students;
    PROCEDURE delete_test_info;
    FUNCTION get_grade
    (v_birth_date IN DATE)
    RETURN NUMBER;
    PRAGMA RESTRICT_REFERENCES (get_grade, WNDS, WNPS, RNDS, RNPS);
    PROCEDURE add_tests;
    END ldsw;
    CREATE OR REPLACE PACKAGE BODY ldsw
    AS
    v_student_grade NUMBER (1) := 0;
    PROCEDURE delete_test_info
    IS
    BEGIN
    DELETE FROM studentfacts;
    END delete_test_info;
    FUNCTION get_grade
    (v_birth_date IN DATE)
    RETURN NUMBER
    IS
    v_school_grade NUMBER (1) := 0;
    BEGIN
    IF v_birth_date < TO_DATE ('01-Jan-1987', 'DD-Mon-YYYY')
    THEN
    v_school_grade := 9;
    ELSIF v_birth_date BETWEEN TO_DATE ('01-Jan-1987', 'DD-Mon-YYYY') AND TO_DATE ('31-Dec-1987', 'DD-Mon-YYYY')
    THEN
    v_school_grade := 8;
    ELSIF v_birth_date BETWEEN TO_DATE ('01-Jan-1988', 'DD-Mon-YYYY') AND TO_DATE ('31-Dec-1988', 'DD-Mon-YYYY')
    THEN
    v_school_grade := 7;
    ELSIF v_birth_date BETWEEN TO_DATE ('01-Jan-1989', 'DD-Mon-YYYY') AND TO_DATE ('31-Dec-1989', 'DD-Mon-YYYY')
    THEN
    v_school_grade := 6;
    ELSIF v_birth_date > TO_DATE ('31-Dec-1989', 'DD-Mon-YYYY')
    THEN
    v_school_grade := 5;
    END IF;
    RETURN v_school_grade;
    END get_grade;
    PROCEDURE add_tests
    IS
    v_num_students CONSTANT NUMBER (3) := 300;
    v_students_test1 NUMBER := 0;
    v_students_test2 NUMBER := 0;
    v_counter NUMBER (3) := 0;
    v_student_id VARCHAR2 (5);
    v_test_score NUMBER (3) := 0;
    v_course_final_grade NUMBER (1) := 0;
    v_course1 VARCHAR2 (2) := NULL;
    v_course2 VARCHAR2 (2) := NULL;
    v_course3 VARCHAR2 (2) := NULL;
    v_course4 VARCHAR2 (2) := NULL;
    BEGIN
    ldsw.delete_test_info;
    v_students_test1 := v_num_students * .95;
    v_students_test2 := v_students_test1 * .80;
    FOR rec IN grade_cur
    LOOP
    v_counter := v_counter + 1;
    IF v_counter <= v_num_students
    THEN
    v_student_id := 'S' &#0124; &#0124; TO_CHAR (v_counter);
    v_test_score := random.rand_max (80) + 20;
    v_course_final_grade := random.rand_max (4);
    IF v_counter < ROUND (v_num_students * .20)
    THEN
    v_course1 := 'C1';
    v_course2 := 'C2';
    v_course3 := 'C3';
    ELSIF v_counter BETWEEN ROUND (v_num_students * .20) AND ROUND (v_num_students * .40)
    THEN
    v_course1 := 'C2';
    v_course2 := 'C1';
    v_course3 := 'C3';
    ELSIF v_counter BETWEEN ROUND (v_num_students * .40) AND ROUND (v_num_students * .60)
    THEN
    v_course1 := 'C3';
    v_course2 := 'C1';
    v_course3 := 'C2';
    ELSIF v_counter BETWEEN ROUND (v_num_students * .60) AND ROUND (v_num_students * .80)
    THEN
    v_course1 := 'C3';
    v_course2 := 'C1';
    v_course3 := 'C2';
    ELSE
    v_course1 := 'C4';
    v_course2 := 'C2';
    v_course3 := 'C3';
    END IF;
    SELECT ldsw.get_grade (rec.birth_date)
    INTO v_student_grade
    FROM DUAL;
    IF v_counter <= v_students_test1
    THEN
    INSERT INTO studentfacts
    VALUES (v_student_id,
    v_course1,
    'ACH1999',
    TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
    v_student_grade,
    v_course_final_grade,
    v_test_score);
    ELSE
    INSERT INTO studentfacts
    VALUES (v_student_id,
    v_course1,
    'ACH1999',
    TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
    v_student_grade,
    v_course_final_grade,
    NULL);
    END IF;
    IF v_counter <= v_students_test2
    THEN
    INSERT INTO studentfacts
    VALUES (v_student_id,
    v_course1,
    'ACH2000',
    TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
    v_student_grade,
    v_course_final_grade,
    v_test_score);
    ELSE
    INSERT INTO studentfacts
    VALUES (v_student_id,
    v_course1,
    'ACH2000',
    TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
    v_student_grade,
    v_course_final_grade,
    NULL);
    END IF;
    IF v_counter <= v_students_test1
    THEN
    INSERT INTO studentfacts
    VALUES (v_student_id,
    v_course2,
    'ACH1999',
    TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
    v_student_grade,
    v_course_final_grade,
    v_test_score);
    ELSE
    INSERT INTO studentfacts
    VALUES (v_student_id,
    v_course2,
    'ACH1999',
    TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
    v_student_grade,
    v_course_final_grade,
    NULL);
    END IF;
    IF v_counter <= v_students_test2
    THEN
    INSERT INTO studentfacts
    VALUES (v_student_id,
    v_course2,
    'ACH2000',
    TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
    v_student_grade,
    v_course_final_grade,
    v_test_score);
    ELSE
    INSERT INTO studentfacts
    VALUES (v_student_id,
    v_course2,
    'ACH2000',
    TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
    v_student_grade,
    v_course_final_grade,
    NULL);
    END IF;
    IF v_counter <= v_students_test1
    THEN
    INSERT INTO studentfacts
    VALUES (v_student_id,
    v_course3,
    'ACH1999',
    TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
    v_student_grade,
    v_course_final_grade,
    v_test_score);
    ELSE
    INSERT INTO studentfacts
    VALUES (v_student_id,
    v_course3,
    'ACH1999',
    TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
    v_student_grade,
    v_course_final_grade,
    NULL);
    END IF;
    IF v_counter <= v_students_test2
    THEN
    INSERT INTO studentfacts
    VALUES (v_student_id,
    v_course3,
    'ACH2000',
    TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
    v_student_grade,
    v_course_final_grade,
    v_test_score);
    ELSE
    INSERT INTO studentfacts
    VALUES (v_student_id,
    v_course3,
    'ACH2000',
    TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
    v_student_grade,
    v_course_final_grade,
    NULL);
    END IF;
    IF v_counter <= v_students_test1
    THEN
    INSERT INTO studentfacts
    VALUES (v_student_id,
    v_course4,
    'ACH1999',
    TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
    v_student_grade,
    v_course_final_grade,
    v_test_score);
    ELSE
    INSERT INTO studentfacts
    VALUES (v_student_id,
    v_course4,
    'ACH1999',
    TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
    v_student_grade,
    v_course_final_grade,
    NULL);
    END IF;
    IF v_counter <= v_students_test2
    THEN
    INSERT INTO studentfacts
    VALUES (v_student_id,
    v_course4,
    'ACH2000',
    TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
    v_student_grade,
    v_course_final_grade,
    v_test_score);
    ELSE
    INSERT INTO studentfacts
    VALUES (v_student_id,
    v_course4,
    'ACH2000',
    TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
    v_student_grade,
    v_course_final_grade,
    NULL);
    END IF;
    END IF;
    END LOOP;
    END add_tests;
    END ldsw;
    Save the file.
    SQL> START ldsw
    Package created.
    Package body created.
    SQL> EXECUTE ldsw.add_tests
    PL/SQL procedure successfully completed.
    SQL> SELECT * FROM student_facts;
    null

  • Distribution Type in Numbers generated by Random function

    Hello,
    I am using the built-in Random() function in TestStand for generating random numbers with seed value of 0.
    I was wondering about it's distribution. Does the built-in function use Normal or Uniform distribution?
    Thanks

    Uniform.

  • I want to use the Function Generator VI to send command signals through the NI 7344 motion controller. This will be a closed loop servo valve system. I want to be able to change from say a square wave to a sine wave on the fly. Idea's?

    I am going to run tests that require an actuator to move using various types of arbitrary waveforms such as sine or square. The NI 7344 is hooked to the UMI that is going through a driver for a servo valve. The loop is analog and it is closed. I have played with some of the examples but can't get it to work. I have used the function generator VI to generate a signal but I think I am using the wrong input VI to the motion control board. When I use what I have it moves the servo and then stops. It doesn't continually generate the signal.
    I would love to use the controls on the function generator vi to control frequency and amplitude ect. Any help or pointer would be helpful. Thank you in advance.

    Hello,
    I'm not clear on exactly how you want to use the generated data but I'm assuming they will be used as your target points.
    There's a built-in example for motion called 'One-Axis Contour Move.vi'. This example demonstrates how to provide your target points as 1-D array. All you need to do is to replace the input array with the output of the function generator. In order to have it run continuously, use a while loop. You can further program your application so that it'll change the waveform on the fly by monitoring the user interface but this might be little little tricky as you will need to reset the move and load the new generated points while keeping track of your current position.
    I hope this helps. Let me know if you have further questions regarding this
    application.
    Best regards,
    Yusuf C.
    Applications Engineering
    National Instruments

  • Elvis: Is It possible to use the Function Generator and the Oscilloscope simultaneously?

    Hi,
     We are using the NI Elvis to output a function or a sine wave at a certain frequency and using the oscilloscope on the same board/elvis to read a modified signal. Is this possible? Can we use both the Function Generator and the oscilloscope at the same time? Please help. The oscilloscope would be reading signal from an accelerometer. Thank you in advance. We have no VI as we do not know which to use and if they are possible.

    Hi,
    There is no problem using the Function Generator and Oscilloscope
    at the same time with NI ELVIS. Using the NI ELVIS soft front panels (Start
    >> Programs >> National Instruments >> NI ELVIS 3.0 >>
    NI ELVIS – see picture attached –‘NI ELVIS soft front panels.JPG’), you can choose
    to open more than one instrument at a time. We do this by opening one
    instrument, allowing it to begin, and then opening another. We can also program
    in LabVIEW using more than one instrument at a time by placing down multiple
    Express VI’s taken from the NI ELVIS pallet on the block diagram (see picture
    attached – ‘ELVIS Express VI's (LabVIEW).JPG’). One note when doing this,
    please see KB 41ODPHX1 
    for an example of how to program in parallel. If you do not wire the ‘stop’
    terminal of the express VI’s, you will get the error described.
    David L.
    Systems Engineering
    National Instruments
    Attachments:
    ELVIS Express VI's (LabVIEW).JPG ‏74 KB
    NI ELVIS soft front panels.JPG ‏56 KB

  • Generating a Generic DataSource using Function Modules

    I am attempting to create a generic DataSource using a  function module.  All of our DataSources are business content or custom generated that involve views.  At least in our company this is true.  Is there any resources available to me with examples on how to do this.  I have looked at SAP's 'simple example' and would need a ABAP/BW Guru to figure it out!  Any help would be greatfull.  Thanx.  JJ

    Hi Jerry,
       The simple example should provide you with the necessary requisite. All what you need to do is to
    create your own extract structure and assign that as type for the table parameter e_t_data.
    Now you will get the selection criteria, as well as the fields selected in the datasource from the 2 incoming tables. You need to write the necessary abap code to execute a query and populate your extract struture.
    Once important peculiarity of this function module is that it is called several times, or as many times as the MAX parameter + 1. ie, once for each row fetched. Hence you will find a persistence method of using a CURSOR with HOLD property to retain the data between the function calls.
       The help in generic datasource explains the 3 modes,
    initialize, first call and the repeat call for the
    function module. The simple function module example actually provides the necessary logic to deal with these modes and the example uses the sflight table.
    Hope that is some information that could help u begin with.
    Anoop C M

  • Generate HTML format report using  DBMS_SQLTUNE.REPORT_TUNING_TASK function

    How could i generate HTML format report using DBMS_SQLTUNE.REPORT_TUNING_TASK function in oracle 11g

    See [url http://download.oracle.com/docs/cd/E11882_01/appdev.112/e16760/d_sqltun.htm#CHDGEIHJ]documentation for DBMS_SQLTUNE.
    The TYPE parameter suggests that it would determine the format and whilst the nline documentation in the code (desc DBMS_SQLTUNE) suggests that valid values are TEXT, HTML and XML, it seems that this is not yet implemented. Whilst valid values of TEXT, HTML and XML are validated, only a TEXT report is produced.

  • I am using the function generator example

    i am using the function generator example to send sine, triangular, sawtooth waves to oscilloscope.
    I would like to send not only the symmetric but also unsymmetric amplitude of each wave.for example the upper peak of the amplitude, i could adjust as 2 volts and the lower peak as 3 volts or vice versa.how it works in function genartor example.Please note the i am using data acquisition card AT- MIO-16XE-50 for this purpose.please tell me with some example.

    To add a terminal to the connector pane, right click on vi icon and select show connector. Notice that the mouse pointer turns to a wiring tool when over the connector. Click on a small box inside the pane and then click on a front panel control or indicator to connect that box to the control/indicator. Then repeat for the next control/indicator. Do this until all the inputs (controls) and outputs (indicators) you need are defined. Normally, all inputs are on the left half and all outputs are on the right half, and Error In is connected to the bottom left box, and Error Out is connected to the bottom right box. You can change the terminal pattern by right clicking on the connector pane and pointing to pa
    ttern and then selecting a pattern. To make the graph as an output, click on the top right box then click on the waveform graph.
    As for continuous update, put the graph inside a loop where you generate your waveform and wire the output to the graph. As long as the loop is running, you will get a continuous update. The Y axis can be configured for amplitude and the X axis for time. Right click on the graph and select properties. Play with this to become familiar with all aspects.
    - tbob
    Inventor of the WORM Global

  • Odd behavior in class using Random

    Hi all, I am learning C# and built a simple Windows Form app using C# 2010 to experiment with generating random numbers. The app has two buttons and a list box. The code in the button click event is the following:
    private void button1_Click(object sender, EventArgs e)
    Random rx = new Random();
    listBox1.Items.Clear();
    for (int i = 0; i<3;i++)
    listBox1.Items.Add(rx.NextDouble());
    This behaves as expected generating 3 random numbers between 0 and 1.
    In the second button click event I have the following code which is similar tothe previous snippet, but uses a function to get the random number:
    private void button2_Click(object sender, EventArgs e)
    listBox1.Items.Clear();
    for (int i = 0; i < 3; i++)
    listBox1.Items.Add(GetRnd());
    private double GetRnd()
    Random rx = new Random();
    return rx.NextDouble();
    This also works, but I noticed that each time I clicked the button I would generally get the same 2 or 3 random number. After some research and experimentation I concluded that the random # generator was being called so quickly between each iteration that
    the same time seed was being used. To solve the problem I moved the Random rx declaration outside of the GetRnd function.
    This fixed this issue. I then wanted to see how this function would behave if I placed it in a class:
    class clsExample
    //Declarations...
    Random rx = new Random();
    private static double GetRnd()
    //Random rx = new Random();
    return rx.NextDouble();
    This does not work. The source editor places a red squiggly line under the instance name "rx" in the function's return statement. The message provided by the editor: An object reference is required for the non-static field , method or property
    'WindowsFormsApplication1.clsExample.rx'.
    This error goes away if I instantiate the Random class inside the function, as shown in the snippet above. But if I do this then the randoms numbers repeat. What am I missing? Why does this solution work in the form class and not in the class that I added?
    As always, thank you for your help! Saga
    Insanity is the prelude to discovery

    It seemed to me, from the code you posted previously, that you maybe wanted to use something static. So, rather than remove the static modifier from the method, as Stefan suggested, it might be preferable to add a static modifier to the rx field instead.
    // I changed the class name
    public class MyRandom
    //Declarations...
    private static Random rx = new Random();
    public static double GetRnd()
    return rx.NextDouble();
    Then, you'd use it like this:
    listBox1.Items.Add(MyRandom.GetRnd());
    ~~Bonnie DeWitt [C# MVP]
    http://geek-goddess-bonnie.blogspot.com

  • Fine Grained Access ERROR on INSERT when generating unique keys

    I'm using VPD/Fine Grained Access Control (FGAC) to implement security on my 9i backend. I created a security policy function that returns the predicate 'owner = USER'; - each of the tables has an additional column titled OWNER which contains the name of the logged-in user. Every time a user inserts a record, a BEFORE INSERT trigger fires (for every row) and inserts the USER name into the OWNER column. This is fairly straightforward and ensures that users can see only their rows. Using the DBMS_RLS.add_policy procedure, I attached the security policy to several tables and made it effective upon SELECT, UPDATE, INSERT, and DELETE statements.
    However, the frontend Java application (custom-made) generates unique IDs (sequences are not used) by selecting max(ID)+1 from the primary key columns of the tables. The problem is that the predicate is appended to the SELECT max(ID)+1 query to limit the max(ID) to only those rows where 'owner = USER'. Therefore, the max(ID) generated is not the largest ID for the entire table, but only the largest among the USER rows.
    So unless that USER happens to have the the largest ID in the whole table (and it has worked then), a primary-key violation error will be returned and the INSERT operation will be aborted.
    How can I allow every USER to select from AND get the absolute largest ID from the PK column without allowing that user to select records that don't belong to him? If I had developed the application, I would have made use of sequences on the back-end to generate unique primary key IDs. Unfortunately, I don't have this option and must work with the application as is.
    NOTE: the front-end Java application understands only the base table names, NOT Views created by me on the server. If the answer to this problem involves views, how can I make use of them on the backend when the front-end code does not recognize them?
    Any help is greatly appreciated!
    Michael

    first you could use default column values, not a trigger, which is more expensive.
    if your apps already assumes full access to table to get max id ( another RT ), this is bad. Current RLS can not really help if you can not change the apps because of this flaw logic ( you can store the maxid anywhere, why scanning the whole table to find it )

  • ESB problem when use merge function in master/detail relationship

    I have some problem with the merge function in database adapter.
    details:
    I have 2 tables in master/detail relationship, both have GUID column as a primary key (GUID generated by ESB).
    'car_group' table
    pk : guid
    unique : group_no, datadate, datatime
    ===============================
    guid, group_no, datadate, datatime, group_detail
    ===============================
    1, 1, 01/01/2008, 09:00, groupdetail01
    2, 1, 01/01/2008, 10:00, groupdetail02
    'car_group_detail' table
    pk : guid
    fk : car_group_guid link to car_group.guid
    ==================
    guid, car_group_guid, detail
    ==================
    1, 1, detail01
    2, 1, detail02
    3, 2, detail03
    4, 2, detail04
    I used a file adapter as a input, here is an example text file
    M, 1, 01/01/2008, 09:00, groupdetail01
    D, detail01
    D, detail02
    M, 1, 01/01/2008, 10:00, groupdetail02
    D, detail03
    D, detail04
    Because I used merge function so I need to specify the columns that will be a condition for the insert/update,
    but I have generate GUID as a primary key in the tables, I can't used it, so in toplink I map my unique key as a primary key.
    The insert operation work fine but when update is required (for example, try to change 'group_detail' column of the master table in text file),
    an SQLException thrown, the log file shown the adapter try to update the GUID column of master table but the constraint not allowed.
    And yes, cause of GUID generate everytime so ESB try to update this column also, but I don't want to do like that, I need something
    like when update operation required, just ignored the GUID column.
    I try to mark read-only to the GUID column in Toplink mapping file but still have the same problem, it still generate UPDATE statement
    with the GUID column, and also I try to let the database trigger to generate GUID instead of ESB function, but it not works in master/detail
    relationship (I think the Toplink manage the relationship, is it right ?)
    Please advise, thanks for advance.

    somebody please help, thanks !!!

  • Generate 3 digits floating point random number

    hai....How I want to generate 3 digits floating point random number??..plz help me...
    Thanks..

    Hi gdah,
    use some common math functions to get a randopm number in the range from 1 to 5 (but not including 5, see help for "random number"!)... Then format to a string (if needed) or set properties of numeric indicator...
    Hey Mike, your first version looked quite different
    Message Edited by GerdW on 05-05-2008 09:39 AM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    RND_1-5_3Digits.png ‏1 KB

  • FR Studio 11.1.1.3 : You're not authorized to use this function...

    Hi,
    we have FR Studio (client, v. 11.1.1.3.0238 and Report Server v. 11.1.1.3.0.0301) distributed on Citrix terminal server (windows 2003 32-bit) and on latest 2 prod servers we have this error "You're not authorized to use this function. Contact your administrator." appearing.
    On QA server FR Studio works fine, we had an issue there when we forgot to set ports
    8295-8299 to "listening mode" = they were not defined on FR server's FR_servp.properties config files.
    This is also fixed on Prod FR servers and we have double checked firewalls are open.
    After adding them to QA FR servers we had no issues with FR Studio on QA, but on PROD the issue still exists.
    We have also checked that this shouldn' have anything to do with authentication.
    Odd thing is that we get at least partially same sort of error messages on both working and non-working FRClient.log files.
    On FRClient.log there are for example following records:
    08-04 09:26:11 ERROR ConfigResourceBundle     Could not find fr_configcache.properties file
    08-04 09:26:11 ERROR SerializableResourceBundle     Could not get registry instance
    08-04 09:26:11 ERROR SerializableResourceBundle     java.io.FileNotFoundException: C:\Apps\Hyperion\common\config\9.5.0.0\reg.properties (The system cannot find the file specified)
    com.hyperion.hit.registry.exceptions.RegistryException: java.io.FileNotFoundException: C:\Apps\Hyperion\common\config\9.5.0.0\reg.properties (The system cannot find the file specified)
         at com.hyperion.hit.registry.RegistryUtils.createNewConnection(RegistryUtils.java:158)
         at com.hyperion.hit.registry.RegistryConnection.getInstance(RegistryConnection.java:155)
         at com.hyperion.hit.registry.Registry.getInstance(Registry.java:309).....
    Caused by: java.io.FileNotFoundException: C:\Apps\Hyperion\common\config\9.5.0.0\reg.properties (The system cannot find the file specified)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(FileInputStream.java:106)
         at com.hyperion.hit.registry.RegistryUtils.createNewConnection(RegistryUtils.java:151)
         ... 15 more
    08-04 09:26:11 ERROR HRResourceBundleFactory     Could not locate registry
    08-04 09:26:11 ERROR HRResourceBundleFactory     5500
    com.hyperion.reporting.util.HyperionReportException: Server not yet configured. Please configure the server.
         at com.hyperion.reporting.config.ConfigResourceBundle.<init>(Unknown Source)
         at com.hyperion.reporting.config.ConfigResourceBundle.getInstance(Unknown Source)
         at com.hyperion.reporting.config.HRResourceBundleFactory.getConfigBundle(Unknown Source)...
    That propably gives already an idea what FR Studio is logging.
    Does anyone have idea about this .properties file for frconfig cache?
    Should that be defined somehow during system configuration as we don't find that from any of our environments?
    Just for additional info:
    We have used following packages and installed HFM Admin Client, FR Studio and EPMA File Generator GUI.
    •     02. installer - V17382-01.zip
    •     03. foundation 1 of 4 - V17397-01.zip
    •     03. foundation 2 of 4 - V17369-01.zip
    •     04. architect - V17398-01.zip
    •     08. financial reporting - V17378-01.zip
    •     11. financial management - V17365-01.zip
    Patches:
    + hfm_11113_50-p9976978_111130_WINNT.zip
    + financial reporting_11113_20-p9657652_11113_WINNT.zip
    During the installation we selected:
    Foundation \
    Performance Management Architect\Performance Management Architect File Generator
    Financial Management\
    Financial Management Client
    Financial ManagementADM Driver
    Financial Reporting\
    Financial Reporting Studio Client
    I noticed that apparently no configuration was run neither in QA or in PROD, not sure though if FR Studio even requires that? HFM Admin Client does work on all environments Citrix servers.
    But in Dev and LAB where FR Studio is working fine - FRClient logs absolutely no recods at all and there we did run configuration to tell which SQL db is on background.
    Not sure though whether that config run has any significance for FR Studio.
    Sorry for extremely long story, but just in case if anybody has faced similar issues and whether there could be something with Windows server settings I should go and check?
    Btw... even adding this fr_configcache.properties manually (to try to highlight FR server name and port) it seems FR Client can't find the file.
    Br, MJK

    Denis,
    Thank you for the prompt reply.
    >
    Denis Konovalov wrote:
    > if those reports were saved with security - you're not goingt o be able to open them with Xi3.1 Deski.
    Forgive me for my mundane question but what does saving with security mean?
    Thanks

Maybe you are looking for

  • Why is it so hard to change my plan and upgrade my phone?

    My droid 2 has not been working properly for the last month (send button for text broke) so I thought I would upgrade my phone to the droid 4 and go with a new plan ( 2 years is way up)....Wow, I'm getting treated like crap...I have been with verizon

  • Is there any way to get songs from your iPod nano into your iTunes library?

    My iTunes library has been totally cleared but my iPod nano is full. I'd really like the music back in my iTunes library, so is there a way to get the music from my iPod into iTunes?

  • How to Pan and Scan and keep a mask stationary?

    I am trying to pan and scan a clip that has mask.  But I do not want the mask to follow the pan and scan.  Can this be done? I am using CS5 on Win7

  • WLAN disconnect after 20 minutes of streaming with AirTunes

    Hi, I'm using the AirTunes-Feature to stream my music form my computer to my amplifier. I'm working with a Lenovo (IBM) Thinkpad T61 with Windows XP SP2. The streaming works well for about 20 minutes. After that my WLAN network-interface disconnects

  • Step to Send IDOC to Webmethod

    I have a Scenario to Send IDOC from SAP R/3 to Webmethods. Could you plz tell me the Steps to configure the IDOc and then send it to the Webmethods for further Processing. if we have any documentation, then plz forward me. Any Links which i can refer