Quick Search:
 CODE Oracle PL/SQL Code Library
 JOBS Find Or Post Oracle Jobs
 FORUM Oracle Discussion & Chat
 Oracle PL/SQL: Generate Fibonaci series Jump to: Select a Location PSOUG Home Page Oracle Code Library mySQL Code Library PHP Code Library JavaScript Code Library Oracle Terms & Definitions Oracle Error Codes PSOUG Community Blogs Oracle Jobs Board PSOUG Forum Oracle User Group Directory Free Oracle Magazines Online Learning Center PSOUG Presentations Advanced Code Search News and Events Sponsors Page Submit Code Contact Us

Snippet Name: Generate Fibonaci series

Description: For math users: produce the numbers of the Fibonaci series.

Comment: (none)

Language: PL/SQL
Highlight Mode: PLSQL

```CREATE OR REPLACE PROCEDURE fib AS

fib_var VARCHAR2(1000);
i INTEGER;
fib_num NUMBER;
fib_num1 NUMBER;
fib_num2 NUMBER;
start_var NUMBER;
count_var NUMBER;

BEGIN

/*
select 50 - to_number(to_char(sysdate, 'DD'))
into start_var
from dual;
*/

start_var := 9;

count_var := 11;

DELETE FROM jwc_fib;

fib_num1 := 1;
fib_num2 := 2;
fib_var := TO_CHAR(fib_num1)||to_char(fib_num2);

FOR i IN 1.. 25

LOOP

fib_num := fib_num1+fib_num2;

fib_var := fib_var || TO_CHAR(fib_num);
fib_num1 := fib_num2;
fib_num2 := fib_num;

END LOOP;

INSERT INTO jwc_fib field1
--values (substr(fib_var,start_var,count_var));
VALUES (fib_var);    -- this will output 25 iterations of the fibonaci series

COMMIT;

--could have the fib_nums (instead of the start and count vars) as input based on month, day, etc.

END fib;```

SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.