Posts

Showing posts from February, 2022

How to set apex public account's password limit life time.

Image
------------------Check User Status--------------------------------- select * from apex_release; select username      , account_status   from dba_users  where username in (        'ANONYMOUS'      , 'APEX_210200'      , 'APEX_LISTENER'      , 'APEX_PUBLIC_USER'      , 'APEX_REST_PUBLIC_USER'      , 'APEX_INSTANCE_ADMIN_USER'      , 'ORDS_PUBLIC_USER'      , 'ORDS_METADATA'      , 'PDBADMIN'      , 'SYS'      , 'XDB'  )  order by username; NOTE: Be sure that the new passwords for APEX accounts are the same passwords you set at the time of installing ORDS, otherwise, you will get an error. ------------------------Reason for being apex password expired/account locked---------------------- what is a profile? A profile is a set of limits on database resources and password access to the data...

How to print even numbers and odd numbers by PL/SQL

Image
 Even and Odd Numbers -------------------------------------------- Even numbers are divisible by 2 without remainders. They end in 0, 2, 4, 6, or 8.  Odd numbers are not evenly divisible by 2 and end in 1, 3, 5, 7, or 9. set serveroutput on; declare v_input number := 10; v_counter number := 1; v_odd_number clob; v_even_number clob; begin while (v_counter <= v_input) loop if (mod(v_counter, 2) = 0) then v_even_number := v_even_number||','||v_counter; else v_odd_number := v_odd_number||','||v_counter; end if; v_counter := v_counter+1; end loop; dbms_output.put_line('Even Numbers = '||trim(leading ',' from v_even_number)); dbms_output.put_line('Odd Numbers = '||trim(leading ',' from v_odd_number)); end; Result: Even Numbers = 2,4,6,8,10 Odd Numbers = 1,3,5,7,9

How to print prime numbers by PL/Sql

Image
 Prime Number -------------------------------------------- A prime number is a positive integer that has no positive integer divisors other than 1 and itself.   set serveroutput on; declare v_input number := 200; v_counter number := 2; v_flag boolean; v_result clob; begin while (v_counter <= v_input) loop v_flag := true; for i in 2..v_counter-1 loop if (mod(v_counter, i) = 0) then v_flag := false; exit; end if; end loop; if (v_flag = true) then v_result := v_result||','||v_counter; end if; v_counter := v_counter+1; end loop; dbms_output.put_line('Prime Numbers = '||trim( leading ',' from v_result)); end; Result:Prime Numbers = 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199

How to print factors of a particular number by PL/SQL

Image
 Factors of a particular number ------------------------------------------ A factor is a number that divides into another number exactly and without leaving a remainder.  set serveroutput on; declare v_input number := 125; v_counter number := 1; v_result clob; begin while (v_counter <= v_input) loop if (mod(v_input, v_counter) = 0) then v_result := v_result||','||v_counter; end if; v_counter := v_counter + 1; end loop; dbms_output.put_line(v_input||' Factor = '||trim(leading ',' from v_result)); end; Result: 125 Factors = 1,5,25,125

How to print Factorial by PL/SQL

Image
  Factorial -------------------------------------------- Factorial, in mathematics, the product of all positive integers less than or equal to a given positive  integer and denoted by that integer and an exclamation point.  Thus, factorial seven is written 7!, meaning 1 × 2 × 3 × 4 × 5 × 6 × 7. ----------------------Start Codes---------------- set serveroutput on; declare v_factorial number := 30; v_fact_products number := 1; v_counter number := 1; v_result clob; begin while (v_counter <= v_factorial) loop v_fact_products := v_fact_products*v_counter; v_result := v_result||'X'||(v_factorial-v_counter+1); v_counter := v_counter + 1; end loop; dbms_output.put_line(v_factorial||'!='||trim(leading 'X' from v_result)||'='||v_fact_products); end; Result: 30!=30X29X28X27X26X25X24X23X22X21X20X19X18X17X16X15X14X13X12X11X10X9X8X7X6X5X4X3X2X1=265252859812191058636308480000000

How to print Fibonacci Series by PL/SQL

Image
Fibonacci Series ---------------------------------------------------------------- * The Fibonacci numbers are the numbers in the following integer  Sequence: 0 1 1 2 3 5 8 13 21 * The first two numbers in the fibonacci sequence are 0 and 1. and each subsequence nubmer  is the sum  of the previous two. -----------------------Start Codes---------------------------- set serveroutput on; declare first_no number := 0; second_no number := 1; series_lng number := 50; febo_sum number := 0; counter number := 1; begin dbms_output.put(first_no); dbms_output.put(','||second_no); series_lng := series_lng-2; while (counter <= series_lng) loop  febo_sum := first_no + second_no;  dbms_output.put(','||febo_sum);  first_no  := second_no;  second_no := febo_sum;  counter := counter + 1; end loop; dbms_output.new_line; end; Result: 0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,83...