From 5f6dcedf4a83c71503893fb912e26de7efc39d7f Mon Sep 17 00:00:00 2001 From: radwanromy Date: Sun, 24 Oct 2021 05:14:35 +0600 Subject: [PATCH 01/95] PLSQL 12 Message --- DECODE.sql | 9 +++++++++ PLSQL 12 Message.sql | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 DECODE.sql create mode 100644 PLSQL 12 Message.sql diff --git a/DECODE.sql b/DECODE.sql new file mode 100644 index 0000000..a592126 --- /dev/null +++ b/DECODE.sql @@ -0,0 +1,9 @@ +/* Formatted on 21-Oct-21 5:11:34 AM (QP5 v5.287) */ +SELECT * + FROM HR.EMPLOYEES + WHERE department_id = + DECODE ( :PDEPT, + 'ALL', department_id, + 'TEN', 10, + 'NINTY', 90, + 20); \ No newline at end of file diff --git a/PLSQL 12 Message.sql b/PLSQL 12 Message.sql new file mode 100644 index 0000000..ee354ae --- /dev/null +++ b/PLSQL 12 Message.sql @@ -0,0 +1,17 @@ +DECLARE + v_sal NUMBER(7,2) := 60000; + v_comm NUMBER(7,2) := v_sal * 0.20; + v_message VARCHAR2(255) := ' eligible for commission'; +BEGIN + DECLARE + v_sal NUMBER(7,2) := 50000; + v_comm NUMBER(7,2) := 0; + v_total_comp NUMBER(7,2) := v_sal + v_comm; + BEGIN + v_message := 'CLERK not'||v_message; + v_comm := v_sal * 0.30; + + END; + v_message := 'SALESMAN'||v_message; + +END; From 82bb708748fb7f3d8443216e2d3023c19ad17e95 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Sun, 24 Oct 2021 22:25:11 +0600 Subject: [PATCH 02/95] PLSQL Cursor --- New 3.sql | 12 ++++++++++++ PLSQL CURSOR 13.sql | 12 ++++++++++++ PLSQL Update Salary By Cursor.sql | 13 +++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 New 3.sql create mode 100644 PLSQL CURSOR 13.sql create mode 100644 PLSQL Update Salary By Cursor.sql diff --git a/New 3.sql b/New 3.sql new file mode 100644 index 0000000..b61cd94 --- /dev/null +++ b/New 3.sql @@ -0,0 +1,12 @@ +DECLARE + CURSOR emp_cursor IS + SELECT employee_id, last_name, department_name + FROM employees,departments + WHERE employees.department_id = + departments.department_id + AND employees.department_id = 80 + FOR UPDATE OF salary NOWAIT; +BEGIN + OPEN emp_cursor ; + CLOSE emp_cursor; +END; diff --git a/PLSQL CURSOR 13.sql b/PLSQL CURSOR 13.sql new file mode 100644 index 0000000..63fcef1 --- /dev/null +++ b/PLSQL CURSOR 13.sql @@ -0,0 +1,12 @@ +DECLARE + CURSOR emp_cursor + (p_deptno NUMBER, p_job VARCHAR2) IS + SELECT employee_id, last_name + FROM employees + WHERE department_id = p_deptno + AND job_id = p_job; +BEGIN + OPEN emp_cursor (80, 'SA_REP'); + CLOSE emp_cursor; + OPEN emp_cursor (60, 'IT_PROG'); +END; diff --git a/PLSQL Update Salary By Cursor.sql b/PLSQL Update Salary By Cursor.sql new file mode 100644 index 0000000..d9c7adc --- /dev/null +++ b/PLSQL Update Salary By Cursor.sql @@ -0,0 +1,13 @@ +/* Formatted on 24/Oct/21 10:12:46 PM (QP5 v5.287) */ +DECLARE + CURSOR emp_cursor(n_department_id NUMBER) + IS + SELECT employee_id, last_name, department_name + FROM employees, departments + WHERE employees.department_id = departments.department_id + AND employees.department_id = n_department_id + FOR UPDATE OF salary NOWAIT; +BEGIN + OPEN emp_cursor(90); + CLOSE emp_cursor; +END; \ No newline at end of file From f80ed210c39360098abd83ddeb86cdb9469c90c9 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Sun, 24 Oct 2021 22:34:39 +0600 Subject: [PATCH 03/95] PLSQL Cursor Where Current of and update for query --- ... Where Current of And Update For Query.sql | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 PLSQL Where Current of And Update For Query.sql diff --git a/PLSQL Where Current of And Update For Query.sql b/PLSQL Where Current of And Update For Query.sql new file mode 100644 index 0000000..463fd27 --- /dev/null +++ b/PLSQL Where Current of And Update For Query.sql @@ -0,0 +1,23 @@ +/* Formatted on 24/Oct/21 10:32:49 PM (QP5 v5.287) */ +DECLARE + CURSOR sal_cursor + IS + SELECT e.department_id, + employee_id, + last_name, + salary + FROM employees e, departments d + WHERE d.department_id = e.department_id AND d.department_id = 60 + FOR UPDATE OF salary NOWAIT; +BEGIN + FOR emp_record IN sal_cursor + LOOP + IF emp_record.salary < 5000 + THEN + UPDATE employees + SET salary = emp_record.salary * 1.10 + WHERE CURRENT OF sal_cursor; + END IF; + END LOOP; +END; +/ \ No newline at end of file From f0054227535b7e2769682c7fc228a9f52a37e54c Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 00:18:41 +0600 Subject: [PATCH 04/95] PLSQL Bio --- PLSQL Bio.sql | 23 +++++++++++++++++++++++ PLSQL Inner Outter Loop.sql | 16 ++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 PLSQL Bio.sql create mode 100644 PLSQL Inner Outter Loop.sql diff --git a/PLSQL Bio.sql b/PLSQL Bio.sql new file mode 100644 index 0000000..8ee3527 --- /dev/null +++ b/PLSQL Bio.sql @@ -0,0 +1,23 @@ +DECLARE + name varchar2(20); + company varchar2(30); + introduction clob; + choice char(1); + hiredate varchar2(20); + details clob; +BEGIN + name := 'A. S. M. Radwan'; + company := 'ERA Infotech Limited'; + introduction := ' Hello! I''m A. S. M. Radwan from Infotech.'; + hiredate := '10th June 1998'; + details := 'You have not put your details yet.'; + choice := 'y'; + IF choice = 'y' THEN + dbms_output.put_line(name); + dbms_output.put_line(company); + dbms_output.put_line(introduction); + dbms_output.put_line(hiredate); + dbms_output.put_line(details); + END IF; +END; +/ \ No newline at end of file diff --git a/PLSQL Inner Outter Loop.sql b/PLSQL Inner Outter Loop.sql new file mode 100644 index 0000000..5d4a4cc --- /dev/null +++ b/PLSQL Inner Outter Loop.sql @@ -0,0 +1,16 @@ +/* Formatted on 24-Oct-21 11:49:38 PM (QP5 v5.287) */ +DECLARE + i NUMBER (1); + j NUMBER (1); +BEGIN + <> + FOR i IN 1 .. 3 + LOOP + <> + FOR j IN 1 .. 3 + LOOP + DBMS_OUTPUT.put_line ('i is: ' || i || ' and j is: ' || j); + END LOOP inner_loop; + END LOOP outer_loop; +END; +/ \ No newline at end of file From 31dc40dff9f701470307dec1a2e56df43fe3e020 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 00:24:35 +0600 Subject: [PATCH 05/95] PLSQL Function --- PLSQL Functions.sql | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 PLSQL Functions.sql diff --git a/PLSQL Functions.sql b/PLSQL Functions.sql new file mode 100644 index 0000000..4e77e73 --- /dev/null +++ b/PLSQL Functions.sql @@ -0,0 +1,23 @@ +DECLARE + a number; + b number; + c number; +FUNCTION findMax(x IN number, y IN number) +RETURN number +IS + z number; +BEGIN + IF x > y THEN + z:= x; + ELSE + Z:= y; + END IF; + RETURN z; +END; +BEGIN + a:= 23; + b:= 45; + c := findMax(a, b); + dbms_output.put_line(' Maximum of (23,45): ' || c); +END; +/ \ No newline at end of file From 92c5217d086b83e092cd7798ace3822b923fd192 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 00:51:38 +0600 Subject: [PATCH 06/95] PLSQL Cursor 02 --- PLSQL CURSOR 02.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 PLSQL CURSOR 02.sql diff --git a/PLSQL CURSOR 02.sql b/PLSQL CURSOR 02.sql new file mode 100644 index 0000000..e6496ac --- /dev/null +++ b/PLSQL CURSOR 02.sql @@ -0,0 +1,13 @@ + DECLARE + v_empno employees.employee_id%TYPE; + v_ename employees.last_name%TYPE; + CURSOR emp_cursor IS + SELECT employee_id, last_name + FROM employees; + BEGIN + OPEN emp_cursor; + FOR i IN 1..10 LOOP + FETCH emp_cursor INTO v_empno, v_ename; + DBMS_OUTPUT.PUT_LINE (TO_CHAR(v_empno)||' '|| v_ename); + END LOOP; + END ; \ No newline at end of file From 3438d89a9541ad687fec6fb00970a2db4d3eb755 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 02:37:43 +0600 Subject: [PATCH 07/95] PL SQL Create and Replace --- PLSQL create and replace.prc | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 PLSQL create and replace.prc diff --git a/PLSQL create and replace.prc b/PLSQL create and replace.prc new file mode 100644 index 0000000..ae7e53f --- /dev/null +++ b/PLSQL create and replace.prc @@ -0,0 +1,9 @@ +CREATE OR REPLACE PROCEDURE raise_salary + (p_id IN employees.employee_id%TYPE) +IS +BEGIN + UPDATE employees + SET salary = salary * 1.10 + WHERE employee_id = p_id; +END raise_salary; +/ From 4410a3a2ad6f30a3daa6aa7535a0f6028bf5647a Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 02:42:15 +0600 Subject: [PATCH 08/95] PL SQL QUERY_EMP --- PL SQL QUERY_EMP.prc | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 PL SQL QUERY_EMP.prc diff --git a/PL SQL QUERY_EMP.prc b/PL SQL QUERY_EMP.prc new file mode 100644 index 0000000..8583178 --- /dev/null +++ b/PL SQL QUERY_EMP.prc @@ -0,0 +1,13 @@ +CREATE OR REPLACE PROCEDURE query_emp + (p_id IN employees.employee_id%TYPE, + p_name OUT employees.last_name%TYPE, + p_salary OUT employees.salary%TYPE, + p_comm OUT employees.commission_pct%TYPE) +IS +BEGIN + SELECT last_name, salary, commission_pct + INTO p_name, p_salary, p_comm + FROM employees + WHERE employee_id = p_id; +END query_emp; +/ From d39158fdb0aebd4bff73cc6cf97d3eef34df8220 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 02:53:59 +0600 Subject: [PATCH 09/95] PL SQL ADD --- PLSQL ADD_DEPT.prc | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 PLSQL ADD_DEPT.prc diff --git a/PLSQL ADD_DEPT.prc b/PLSQL ADD_DEPT.prc new file mode 100644 index 0000000..01ebc08 --- /dev/null +++ b/PLSQL ADD_DEPT.prc @@ -0,0 +1,12 @@ +CREATE OR REPLACE PROCEDURE add_dept + (p_name IN departments.department_name%TYPE + DEFAULT 'unknown', + p_loc IN departments.location_id%TYPE + DEFAULT 1700) +IS +BEGIN + INSERT INTO departments(department_id, + department_name, location_id) + VALUES (departments_seq.NEXTVAL, p_name, p_loc); +END add_dept; +/ From 219ae520c1501dc0ac9e01c4526ba10e89b59dcb Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 02:57:20 +0600 Subject: [PATCH 10/95] PL SQL ADD DEPT --- PL SQL HR.ADD_DEPT.prc | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 PL SQL HR.ADD_DEPT.prc diff --git a/PL SQL HR.ADD_DEPT.prc b/PL SQL HR.ADD_DEPT.prc new file mode 100644 index 0000000..a6bcfdb --- /dev/null +++ b/PL SQL HR.ADD_DEPT.prc @@ -0,0 +1,9 @@ +BEGIN + add_dept; + add_dept ('TRAINING', 2500); + add_dept ( p_loc => 2400, p_name =>'EDUCATION'); + add_dept ( p_loc => 1200) ; +END; +/ +SELECT department_id, department_name, location_id +FROM departments; From cc6f849c26a3c86888890c20d20c7e8d6c04089d Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 03:02:26 +0600 Subject: [PATCH 11/95] PLSQL Leave EMP --- PLSQL LEAVE_EMP2.prc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 PLSQL LEAVE_EMP2.prc diff --git a/PLSQL LEAVE_EMP2.prc b/PLSQL LEAVE_EMP2.prc new file mode 100644 index 0000000..7eaad8c --- /dev/null +++ b/PLSQL LEAVE_EMP2.prc @@ -0,0 +1,15 @@ +CREATE OR REPLACE PROCEDURE leave_emp2 + (p_id IN employees.employee_id%TYPE) +IS + PROCEDURE log_exec + IS + BEGIN + INSERT INTO log_table (user_id, log_date) + VALUES (USER, SYSDATE); + END log_exec; +BEGIN + DELETE FROM employees + WHERE employee_id = p_id; + log_exec; +END leave_emp2; +/ From 504399516bf6089bb272d40ece48ace7cee03134 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 03:07:31 +0600 Subject: [PATCH 12/95] PLSQL_PROCESS_EMPS --- PLSQL_PROCESS_EMPS.prc | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 PLSQL_PROCESS_EMPS.prc diff --git a/PLSQL_PROCESS_EMPS.prc b/PLSQL_PROCESS_EMPS.prc new file mode 100644 index 0000000..e7fbd8a --- /dev/null +++ b/PLSQL_PROCESS_EMPS.prc @@ -0,0 +1,13 @@ +CREATE OR REPLACE PROCEDURE process_emps +IS + CURSOR emp_cursor IS + SELECT employee_id + FROM employees; +BEGIN + FOR emp_rec IN emp_cursor + LOOP + raise_salary(emp_rec.employee_id); + END LOOP; + COMMIT; +END process_emps; +/ From 80931dd5195bd058185c5ad7ecf75757b0786277 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 03:24:21 +0600 Subject: [PATCH 13/95] PLSQL_Function_Get --- PLSQL GET_SAL.fnc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 PLSQL GET_SAL.fnc diff --git a/PLSQL GET_SAL.fnc b/PLSQL GET_SAL.fnc new file mode 100644 index 0000000..d8a1d65 --- /dev/null +++ b/PLSQL GET_SAL.fnc @@ -0,0 +1,14 @@ +/* Formatted on 25/Oct/21 3:14:41 AM (QP5 v5.287) */ +CREATE OR REPLACE FUNCTION get_sal (p_id IN employees.employee_id%TYPE) + RETURN NUMBER +IS + v_salary employees.salary%TYPE := 0; +BEGIN + SELECT salary + INTO v_salary + FROM employees + WHERE employee_id = p_id; + + RETURN v_salary; +END get_sal; +/ \ No newline at end of file From 307e028813fc6697233eb742282658659de151da Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 03:29:25 +0600 Subject: [PATCH 14/95] PLSQL_Function_TAX --- PLSQL CREATE OR REPLACE FUNCTION TAX.fnc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 PLSQL CREATE OR REPLACE FUNCTION TAX.fnc diff --git a/PLSQL CREATE OR REPLACE FUNCTION TAX.fnc b/PLSQL CREATE OR REPLACE FUNCTION TAX.fnc new file mode 100644 index 0000000..309b16a --- /dev/null +++ b/PLSQL CREATE OR REPLACE FUNCTION TAX.fnc @@ -0,0 +1,15 @@ +/* Formatted on 25-Oct-21 3:27:30 AM (QP5 v5.287) */ +CREATE OR REPLACE FUNCTION tax (p_value IN NUMBER) + RETURN NUMBER +IS +BEGIN + RETURN (p_value * 0.08); +END tax; +/ + +SELECT employee_id, + last_name, + salary, + tax (salary) + FROM employees + WHERE department_id = 100; \ No newline at end of file From abddab4426c4cbf5c0053d21fbd2b4744060d3b7 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 03:35:25 +0600 Subject: [PATCH 15/95] PLSQL_DML_CALL --- PLSQL_DML_CALL_SQL.fnc | 10 ++++++++++ PLSQL_PROCESS_EMPS.prc | 16 +++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 PLSQL_DML_CALL_SQL.fnc diff --git a/PLSQL_DML_CALL_SQL.fnc b/PLSQL_DML_CALL_SQL.fnc new file mode 100644 index 0000000..1323dc2 --- /dev/null +++ b/PLSQL_DML_CALL_SQL.fnc @@ -0,0 +1,10 @@ +CREATE OR REPLACE FUNCTION dml_call_sql (p_sal NUMBER) + RETURN NUMBER IS +BEGIN + INSERT INTO employees(employee_id, last_name, email, + hire_date, job_id, salary) + VALUES(1, 'employee 1', 'emp1@company.com', + SYSDATE, 'SA_MAN', 1000); + RETURN (p_sal + 100); +END; +/ diff --git a/PLSQL_PROCESS_EMPS.prc b/PLSQL_PROCESS_EMPS.prc index e7fbd8a..1dfebdd 100644 --- a/PLSQL_PROCESS_EMPS.prc +++ b/PLSQL_PROCESS_EMPS.prc @@ -1,13 +1,15 @@ +/* Formatted on 25/Oct/21 3:12:25 AM (QP5 v5.287) */ CREATE OR REPLACE PROCEDURE process_emps IS - CURSOR emp_cursor IS - SELECT employee_id - FROM employees; + CURSOR emp_cursor + IS + SELECT employee_id FROM employees; BEGIN - FOR emp_rec IN emp_cursor + FOR emp_rec IN emp_cursor LOOP - raise_salary(emp_rec.employee_id); - END LOOP; + raise_salary (emp_rec.employee_id); + END LOOP; + COMMIT; END process_emps; -/ +/ \ No newline at end of file From e45c99fe88b376346f131f40af97661df0200cb7 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 03:38:18 +0600 Subject: [PATCH 16/95] PLSQL_DML_CALL_UPDATE --- PLSQL_DML_CALL_SQL.fnc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/PLSQL_DML_CALL_SQL.fnc b/PLSQL_DML_CALL_SQL.fnc index 1323dc2..a864a33 100644 --- a/PLSQL_DML_CALL_SQL.fnc +++ b/PLSQL_DML_CALL_SQL.fnc @@ -6,5 +6,9 @@ BEGIN VALUES(1, 'employee 1', 'emp1@company.com', SYSDATE, 'SA_MAN', 1000); RETURN (p_sal + 100); + +UPDATE employees SET salary = dml_call_sql(2000) + WHERE employee_id = 170; END; / + From 510d7c7ce2c855cbb01e6813832c2ee0c1b5817b Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 03:44:36 +0600 Subject: [PATCH 17/95] PLSQL_DROP PRocedure --- PLSQL QUERY_EMPLOYEE.prc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 PLSQL QUERY_EMPLOYEE.prc diff --git a/PLSQL QUERY_EMPLOYEE.prc b/PLSQL QUERY_EMPLOYEE.prc new file mode 100644 index 0000000..f8be61f --- /dev/null +++ b/PLSQL QUERY_EMPLOYEE.prc @@ -0,0 +1,16 @@ +CREATE PROCEDURE query_employee +(p_id IN employees.employee_id%TYPE, + p_name OUT employees.last_name%TYPE, + p_salary OUT employees.salary%TYPE, + p_comm OUT + employees.commission_pct%TYPE) +AUTHID CURRENT_USER +IS +BEGIN + SELECT last_name, salary, + commission_pct + INTO p_name, p_salary, p_comm + FROM employees + WHERE employee_id=p_id; +END query_employee; +/ From 625c5bdd14a2f82733031c8126b764dd1a7f3ab8 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 03:50:44 +0600 Subject: [PATCH 18/95] PLSQL_On_Procedure --- PLSQL CREATE OR REPLACE FUNCTION TAX.fnc | 1 - PLSQL DESCRIBE.prc | 3 +++ PLSQL PROCEDURE QUERY EMP.prc | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 PLSQL DESCRIBE.prc create mode 100644 PLSQL PROCEDURE QUERY EMP.prc diff --git a/PLSQL CREATE OR REPLACE FUNCTION TAX.fnc b/PLSQL CREATE OR REPLACE FUNCTION TAX.fnc index 309b16a..7245fd9 100644 --- a/PLSQL CREATE OR REPLACE FUNCTION TAX.fnc +++ b/PLSQL CREATE OR REPLACE FUNCTION TAX.fnc @@ -6,7 +6,6 @@ BEGIN RETURN (p_value * 0.08); END tax; / - SELECT employee_id, last_name, salary, diff --git a/PLSQL DESCRIBE.prc b/PLSQL DESCRIBE.prc new file mode 100644 index 0000000..e690ef3 --- /dev/null +++ b/PLSQL DESCRIBE.prc @@ -0,0 +1,3 @@ +DESCRIBE query_employee +DESCRIBE add_dept +DESCRIBE tax diff --git a/PLSQL PROCEDURE QUERY EMP.prc b/PLSQL PROCEDURE QUERY EMP.prc new file mode 100644 index 0000000..3f3dfcd --- /dev/null +++ b/PLSQL PROCEDURE QUERY EMP.prc @@ -0,0 +1,4 @@ +SELECT * +FROM user_source +WHERE name = 'QUERY_EMPLOYEE' +ORDER BY line; From 9d37500564034d7b30f0bf96e3454ee1dfed8e03 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 04:06:42 +0600 Subject: [PATCH 19/95] PLSQL_PACKAGE --- PLSQL Package.prc | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 PLSQL Package.prc diff --git a/PLSQL Package.prc b/PLSQL Package.prc new file mode 100644 index 0000000..3298b43 --- /dev/null +++ b/PLSQL Package.prc @@ -0,0 +1,8 @@ +/* Formatted on 25-Oct-21 4:06:12 AM (QP5 v5.287) */ +CREATE OR REPLACE PACKAGE comm_package +IS + g_comm NUMBER := 0.10; --initialized to 0.10 + + PROCEDURE reset_comm (p_comm IN NUMBER); +END comm_package; +/ \ No newline at end of file From 6e04889addd81ad56a967a5f7422983525f677a8 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 04:08:58 +0600 Subject: [PATCH 20/95] PLSQL_COMM_PACKAGE --- PLSQL_COMM_PACKAGE.pkb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 PLSQL_COMM_PACKAGE.pkb diff --git a/PLSQL_COMM_PACKAGE.pkb b/PLSQL_COMM_PACKAGE.pkb new file mode 100644 index 0000000..48f7f55 --- /dev/null +++ b/PLSQL_COMM_PACKAGE.pkb @@ -0,0 +1,15 @@ +CREATE OR REPLACE PACKAGE BODY comm_package +IS + FUNCTION validate_comm (p_comm IN NUMBER) + RETURN BOOLEAN + IS + v_max_comm NUMBER; + BEGIN + SELECT MAX(commission_pct) + INTO v_max_comm + FROM employees; + IF p_comm > v_max_comm THEN RETURN(FALSE); + ELSE RETURN(TRUE); + END IF; + END validate_comm; +End; From 61d2dd17c825488d54aadf0f2fdc338dfa1f4678 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 04:11:45 +0600 Subject: [PATCH 21/95] PLSQL_RESET_COMM --- PLSQP_RESET_COMM.prc | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 PLSQP_RESET_COMM.prc diff --git a/PLSQP_RESET_COMM.prc b/PLSQP_RESET_COMM.prc new file mode 100644 index 0000000..fee9903 --- /dev/null +++ b/PLSQP_RESET_COMM.prc @@ -0,0 +1,10 @@ + PROCEDURE reset_comm (p_comm IN NUMBER) + IS + BEGIN + IF validate_comm(p_comm) + THEN g_comm:=p_comm; --reset global variable + ELSE + RAISE_APPLICATION_ERROR(-20210,'Invalid commission'); + END IF; + END reset_comm; + / From bbf93473cbd796f7e917acb7645dfa59c73b3ef2 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 04:13:30 +0600 Subject: [PATCH 22/95] PLSQL_COMM_PACKAGE --- PLSQL_COMM_PACKAGE_.pkb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 PLSQL_COMM_PACKAGE_.pkb diff --git a/PLSQL_COMM_PACKAGE_.pkb b/PLSQL_COMM_PACKAGE_.pkb new file mode 100644 index 0000000..c8fab83 --- /dev/null +++ b/PLSQL_COMM_PACKAGE_.pkb @@ -0,0 +1,14 @@ +/* Formatted on 25-Oct-21 4:12:33 AM (QP5 v5.287) */ +CREATE OR REPLACE PACKAGE BODY comm_package +IS + PROCEDURE reset_comm (p_comm IN NUMBER) + IS + BEGIN + IF validate_comm (p_comm) + THEN + g_comm := p_comm; + ELSE + RAISE_APPLICATION_ERROR (-20210, 'Invalid commission'); + END IF; + END reset_comm; +END comm_package; \ No newline at end of file From fd6db653ba03c235067dfd34af232009023613af Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 04:35:28 +0600 Subject: [PATCH 23/95] PL SQL DBMS EXECUTION --- PLSQL DBMS OUTPUT EXECUTION.pkb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 PLSQL DBMS OUTPUT EXECUTION.pkb diff --git a/PLSQL DBMS OUTPUT EXECUTION.pkb b/PLSQL DBMS OUTPUT EXECUTION.pkb new file mode 100644 index 0000000..123fa37 --- /dev/null +++ b/PLSQL DBMS OUTPUT EXECUTION.pkb @@ -0,0 +1,9 @@ +CREATE OR REPLACE PACKAGE global_consts IS + mile_2_kilo CONSTANT NUMBER := 1.6093; + kilo_2_mile CONSTANT NUMBER := 0.6214; + yard_2_meter CONSTANT NUMBER := 0.9144; + meter_2_yard CONSTANT NUMBER := 1.0936; +END global_consts; +/ + +EXECUTE DBMS_OUTPUT.PUT_LINE('20 miles = '||20* global_consts.mile_2_kilo||' km') From 0b4f695916932a9596c7c198b142ffb95cdf9ad8 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 04:39:04 +0600 Subject: [PATCH 24/95] PLSQL METER TO YARD --- PLSQL_METER_TO_YARD.prc | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 PLSQL_METER_TO_YARD.prc diff --git a/PLSQL_METER_TO_YARD.prc b/PLSQL_METER_TO_YARD.prc new file mode 100644 index 0000000..9923681 --- /dev/null +++ b/PLSQL_METER_TO_YARD.prc @@ -0,0 +1,12 @@ +/* Formatted on 25-Oct-21 4:38:12 AM (QP5 v5.287) */ +CREATE OR REPLACE PROCEDURE meter_to_yard (p_meter IN NUMBER, + p_yard OUT NUMBER) +IS +BEGIN + p_yard := p_meter * global_consts.meter_2_yard; +END meter_to_yard; +/ + +VARIABLE yard NUMBER +EXECUTE meter_to_yard (1, :yard) +PRINT yard \ No newline at end of file From deeb8d9624d8cb20a3ab851d4ba7bfecfee6bb10 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 04:47:49 +0600 Subject: [PATCH 25/95] PLSQL_OVER_PACK --- PLSQL_OVER_PACK.pks | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 PLSQL_OVER_PACK.pks diff --git a/PLSQL_OVER_PACK.pks b/PLSQL_OVER_PACK.pks new file mode 100644 index 0000000..65bef3d --- /dev/null +++ b/PLSQL_OVER_PACK.pks @@ -0,0 +1,13 @@ +/* Formatted on 25-Oct-21 4:47:21 AM (QP5 v5.287) */ +CREATE OR REPLACE PACKAGE over_pack +IS + PROCEDURE add_dept ( + p_deptno IN departments.department_id%TYPE, + p_name IN departments.department_name%TYPE DEFAULT 'unknown', + p_loc IN departments.location_id%TYPE DEFAULT 0); + + PROCEDURE add_dept ( + p_name IN departments.department_name%TYPE DEFAULT 'unknown', + p_loc IN departments.location_id%TYPE DEFAULT 0); +END over_pack; +/ \ No newline at end of file From fc9890d69e6db5888110457e0261a8e0e54abb9d Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 04:49:58 +0600 Subject: [PATCH 26/95] PLSQL_UPDATED_OVER_PACK --- PLSQL_UPDATED_OVER_PACK.pkb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 PLSQL_UPDATED_OVER_PACK.pkb diff --git a/PLSQL_UPDATED_OVER_PACK.pkb b/PLSQL_UPDATED_OVER_PACK.pkb new file mode 100644 index 0000000..32f0b1f --- /dev/null +++ b/PLSQL_UPDATED_OVER_PACK.pkb @@ -0,0 +1,23 @@ +/* Formatted on 25-Oct-21 4:49:06 AM (QP5 v5.287) */ +CREATE OR REPLACE PACKAGE BODY over_pack +IS + PROCEDURE add_dept ( + p_deptno IN departments.department_id%TYPE, + p_name IN departments.department_name%TYPE DEFAULT 'unknown', + p_loc IN departments.location_id%TYPE DEFAULT 0) + IS + BEGIN + INSERT INTO departments (department_id, department_name, location_id) + VALUES (p_deptno, p_name, p_loc); + END add_dept; + + PROCEDURE add_dept ( + p_name IN departments.department_name%TYPE DEFAULT 'unknown', + p_loc IN departments.location_id%TYPE DEFAULT 0) + IS + BEGIN + INSERT INTO departments (department_id, department_name, location_id) + VALUES (departments_seq.NEXTVAL, p_name, p_loc); + END add_dept; +END over_pack; +/ \ No newline at end of file From cdca248dc8a0ffec42ee116368b81c2c0eba963e Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 04:56:43 +0600 Subject: [PATCH 27/95] PLSQL_UPDATED_TAXES_PACK --- PLSQL TAXES PACK.pkb | 5 +++++ PLSQL_UPDATED_TAXES_PACK.pkb | 10 ++++++++++ 2 files changed, 15 insertions(+) create mode 100644 PLSQL TAXES PACK.pkb create mode 100644 PLSQL_UPDATED_TAXES_PACK.pkb diff --git a/PLSQL TAXES PACK.pkb b/PLSQL TAXES PACK.pkb new file mode 100644 index 0000000..7f8aa04 --- /dev/null +++ b/PLSQL TAXES PACK.pkb @@ -0,0 +1,5 @@ +CREATE OR REPLACE PACKAGE taxes_pack +IS + FUNCTION tax (p_value IN NUMBER) RETURN NUMBER; +END taxes_pack; +/ diff --git a/PLSQL_UPDATED_TAXES_PACK.pkb b/PLSQL_UPDATED_TAXES_PACK.pkb new file mode 100644 index 0000000..2720cf6 --- /dev/null +++ b/PLSQL_UPDATED_TAXES_PACK.pkb @@ -0,0 +1,10 @@ +CREATE OR REPLACE PACKAGE BODY taxes_pack +IS + FUNCTION tax (p_value IN NUMBER) RETURN NUMBER + IS + v_rate NUMBER := 0.08; + BEGIN + RETURN (p_value * v_rate); + END tax; +END taxes_pack; +/ From 6a0c43e9d4db83f59b3b01e37eb9940f63b8fa3d Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 05:02:19 +0600 Subject: [PATCH 28/95] PLSQL_PACK CUR --- PLSQL PACK CUR.pkb | 9 +++++++++ PLSQL UPDATED PACK_CUR.pkb | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 PLSQL PACK CUR.pkb create mode 100644 PLSQL UPDATED PACK_CUR.pkb diff --git a/PLSQL PACK CUR.pkb b/PLSQL PACK CUR.pkb new file mode 100644 index 0000000..21974f4 --- /dev/null +++ b/PLSQL PACK CUR.pkb @@ -0,0 +1,9 @@ + CREATE OR REPLACE PACKAGE pack_cur +IS + CURSOR c1 IS SELECT employee_id + FROM employees + ORDER BY employee_id DESC; + PROCEDURE proc1_3rows; + PROCEDURE proc4_6rows; + END pack_cur; +/ diff --git a/PLSQL UPDATED PACK_CUR.pkb b/PLSQL UPDATED PACK_CUR.pkb new file mode 100644 index 0000000..755a0d4 --- /dev/null +++ b/PLSQL UPDATED PACK_CUR.pkb @@ -0,0 +1,32 @@ +/* Formatted on 25-Oct-21 5:01:11 AM (QP5 v5.287) */ +CREATE OR REPLACE PACKAGE BODY pack_cur +IS + v_empno NUMBER; + + PROCEDURE proc1_3rows + IS + BEGIN + OPEN c1; + + LOOP + FETCH c1 INTO v_empno; + + DBMS_OUTPUT.PUT_LINE ('Id :' || (v_empno)); + EXIT WHEN c1%ROWCOUNT >= 3; + END LOOP; + END proc1_3rows; + + PROCEDURE proc4_6rows + IS + BEGIN + LOOP + FETCH c1 INTO v_empno; + + DBMS_OUTPUT.PUT_LINE ('Id :' || (v_empno)); + EXIT WHEN c1%ROWCOUNT >= 6; + END LOOP; + + CLOSE c1; + END proc4_6rows; +END pack_cur; +/ \ No newline at end of file From f549911c38ce5a4c173212181303f1f7a32a36ac Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 05:05:01 +0600 Subject: [PATCH 29/95] PLSQL_EMP_PACK --- PLSQL_EMP_PACK.pks | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 PLSQL_EMP_PACK.pks diff --git a/PLSQL_EMP_PACK.pks b/PLSQL_EMP_PACK.pks new file mode 100644 index 0000000..85c6101 --- /dev/null +++ b/PLSQL_EMP_PACK.pks @@ -0,0 +1,7 @@ +CREATE OR REPLACE PACKAGE emp_package IS + TYPE emp_table_type IS TABLE OF employees%ROWTYPE + INDEX BY BINARY_INTEGER; + PROCEDURE read_emp_table + (p_emp_table OUT emp_table_type); +END emp_package; +/ From 6e217d9edc241908a1ffa194dbe4909d33e8440c Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 05:06:38 +0600 Subject: [PATCH 30/95] PLSQL_EMP_PACKAGE --- PLSQL_EMP_PACKAGE.pkb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 PLSQL_EMP_PACKAGE.pkb diff --git a/PLSQL_EMP_PACKAGE.pkb b/PLSQL_EMP_PACKAGE.pkb new file mode 100644 index 0000000..f71a2d4 --- /dev/null +++ b/PLSQL_EMP_PACKAGE.pkb @@ -0,0 +1,12 @@ +CREATE OR REPLACE PACKAGE BODY emp_package IS + PROCEDURE read_emp_table (p_emp_table OUT emp_table_type) IS + i BINARY_INTEGER := 0; + BEGIN + FOR emp_record IN (SELECT * FROM employees) + LOOP + p_emp_table(i) := emp_record; + i:= i+1; + END LOOP; + END read_emp_table; +END emp_package; +/ From d392cc4e3036382053347995cb25b50a0bf4105b Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 05:20:25 +0600 Subject: [PATCH 31/95] PLSQL_DELETE_ALL_ROWS --- COMM_PACKAGE.pkb | 11 +++++++++++ FORWARD_PACK.pkb | 18 ++++++++++++++++++ PLSQL_DELETE_ALL_ROWS.prc | 12 ++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 COMM_PACKAGE.pkb create mode 100644 FORWARD_PACK.pkb create mode 100644 PLSQL_DELETE_ALL_ROWS.prc diff --git a/COMM_PACKAGE.pkb b/COMM_PACKAGE.pkb new file mode 100644 index 0000000..ff4f91e --- /dev/null +++ b/COMM_PACKAGE.pkb @@ -0,0 +1,11 @@ +CREATE OR REPLACE PACKAGE BODY comm_package IS + FUNCTION validate_comm (p_comm IN NUMBER) RETURN BOOLEAN + IS v_max_comm NUMBER; + BEGIN -- validates commission to be less than maximum + -- commission in the table + END validate_comm; + PROCEDURE reset_comm (p_comm IN NUMBER) + IS BEGIN -- calls validate_comm with specified value + END reset_comm; +END comm_package; +/ diff --git a/FORWARD_PACK.pkb b/FORWARD_PACK.pkb new file mode 100644 index 0000000..bd5d2de --- /dev/null +++ b/FORWARD_PACK.pkb @@ -0,0 +1,18 @@ +/* Formatted on 25-Oct-21 4:53:03 AM (QP5 v5.287) */ +CREATE OR REPLACE PACKAGE BODY forward_pack +IS + PROCEDURE award_bonus(1000) + IS + BEGIN + calc_rating(5); --illegal reference + + END; + + PROCEDURE calc_rating(5) + IS + BEGIN + ... + END; + +END forward_pack; +/ \ No newline at end of file diff --git a/PLSQL_DELETE_ALL_ROWS.prc b/PLSQL_DELETE_ALL_ROWS.prc new file mode 100644 index 0000000..3006e4d --- /dev/null +++ b/PLSQL_DELETE_ALL_ROWS.prc @@ -0,0 +1,12 @@ +CREATE OR REPLACE PROCEDURE delete_all_rows + (p_tab_name IN VARCHAR2, p_rows_del OUT NUMBER) + IS + cursor_name INTEGER; + BEGIN + cursor_name := DBMS_SQL.OPEN_CURSOR; + DBMS_SQL.PARSE(cursor_name, 'DELETE FROM '||p_tab_name, + DBMS_SQL.NATIVE ); + p_rows_del := DBMS_SQL.EXECUTE (cursor_name); + DBMS_SQL.CLOSE_CURSOR(cursor_name); +END; +/ From 992d31ea4bbab97f3b32733a49f30a0be3174234 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 05:23:40 +0600 Subject: [PATCH 32/95] PLSQL_DELETE_ALL_ROW --- PLSQL DELETE _.prc | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 PLSQL DELETE _.prc diff --git a/PLSQL DELETE _.prc b/PLSQL DELETE _.prc new file mode 100644 index 0000000..4251958 --- /dev/null +++ b/PLSQL DELETE _.prc @@ -0,0 +1,3 @@ +VARIABLE deleted NUMBER +EXECUTE delete_all_rows('employees', :deleted) +PRINT deleted From 48a96233d5aaae400d61f9e6f56c158f13a4a83f Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 05:25:53 +0600 Subject: [PATCH 33/95] PLSQL_DEL_ROWS --- PLSQL_DEL_ROWS.prc | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 PLSQL_DEL_ROWS.prc diff --git a/PLSQL_DEL_ROWS.prc b/PLSQL_DEL_ROWS.prc new file mode 100644 index 0000000..dad7f8f --- /dev/null +++ b/PLSQL_DEL_ROWS.prc @@ -0,0 +1,9 @@ +CREATE PROCEDURE del_rows + (p_table_name IN VARCHAR2, + p_rows_deld OUT NUMBER) +IS +BEGIN + EXECUTE IMMEDIATE 'delete from '||p_table_name; + p_rows_deld := SQL%ROWCOUNT; +END; +/ From 78a556169220cbef513b40c7b0ea23fd22e4d133 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 05:27:18 +0600 Subject: [PATCH 34/95] PLSQL_DEL --- PLSQL DEL NUMBER.prc | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 PLSQL DEL NUMBER.prc diff --git a/PLSQL DEL NUMBER.prc b/PLSQL DEL NUMBER.prc new file mode 100644 index 0000000..3e5c2c7 --- /dev/null +++ b/PLSQL DEL NUMBER.prc @@ -0,0 +1,3 @@ +VARIABLE deleted NUMBER +EXECUTE del_rows('test_employees',:deleted) +PRINT deleted From a294ef43c245f1a0fd884a7a438aed9db6b9eb10 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 05:30:03 +0600 Subject: [PATCH 35/95] PLSQL_COMMIT_JOB_NUMBER --- PLSQL COMMIT JOB NUMBER.prc | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 PLSQL COMMIT JOB NUMBER.prc diff --git a/PLSQL COMMIT JOB NUMBER.prc b/PLSQL COMMIT JOB NUMBER.prc new file mode 100644 index 0000000..279cd7c --- /dev/null +++ b/PLSQL COMMIT JOB NUMBER.prc @@ -0,0 +1,12 @@ +VARIABLE jobno NUMBER +BEGIN + DBMS_JOB.SUBMIT ( + job => :jobno, + what => 'OVER_PACK.ADD_DEPT(''EDUCATION'',2710);', + next_date => TRUNC(SYSDATE + 1), + interval => 'TRUNC(SYSDATE + 1)' + ); + COMMIT; +END; +/ +PRINT jobno From fc526af8d6200deca15d525382e6af7f782b439a Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 22:43:06 +0600 Subject: [PATCH 36/95] PLSQL_BFILE --- PLSQL BFILE.prc | 15 +++++++++++++++ PLSQL_LOAD_EMP_BFILE.prc | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 PLSQL BFILE.prc create mode 100644 PLSQL_LOAD_EMP_BFILE.prc diff --git a/PLSQL BFILE.prc b/PLSQL BFILE.prc new file mode 100644 index 0000000..da40291 --- /dev/null +++ b/PLSQL BFILE.prc @@ -0,0 +1,15 @@ +/* Formatted on 25/Oct/21 10:34:56 PM (QP5 v5.287) */ +CREATE OR REPLACE PROCEDURE load_emp_bfile +(p_file_loc IN VARCHAR2) +IS + v_file BFILE; v_filename VARCHAR2(16); + v_file_exists BOOLEAN; + CURSOR emp_cursor IS +BEGIN + FOR emp_record IN emp_cursor LOOP + v_filename := emp_record.first_name || '.bmp'; + v_file := BFILENAME (p_file_loc, v_filename); + v_file_exists := (DBMS_LOB.FILEEXISTS(v_file) = 1); + IF v_file_exists THEN + DBMS_LOB.FILEOPEN (v_file); +END; \ No newline at end of file diff --git a/PLSQL_LOAD_EMP_BFILE.prc b/PLSQL_LOAD_EMP_BFILE.prc new file mode 100644 index 0000000..e90ef42 --- /dev/null +++ b/PLSQL_LOAD_EMP_BFILE.prc @@ -0,0 +1,32 @@ +/* Formatted on 25/Oct/21 10:42:18 PM (QP5 v5.287) */ +CREATE OR REPLACE PROCEDURE load_emp_bfile (p_file_loc IN VARCHAR2) +IS + v_file BFILE; + v_filename VARCHAR2 (16); + + CURSOR emp_cursor + IS + SELECT first_name + FROM employees + WHERE department_id = 60 + FOR UPDATE; +BEGIN + FOR emp_record IN emp_cursor + LOOP + v_filename := emp_record.first_name || '.bmp'; + v_file := BFILENAME (p_file_loc, v_filename); + DBMS_LOB.FILEOPEN (v_file); + + UPDATE employees + SET emp_video = v_file + WHERE CURRENT OF emp_cursor; + + DBMS_OUTPUT.PUT_LINE ( + 'LOADED FILE: ' + || v_filename + || ' SIZE: ' + || DBMS_LOB.GETLENGTH (v_file)); + DBMS_LOB.FILECLOSE (v_file); + END LOOP; +END load_emp_bfile; +/ \ No newline at end of file From 32277d205976db0837e0c49d2e4d2f391da742ea Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 22:46:21 +0600 Subject: [PATCH 37/95] PLSQL_BFILE 2 --- PLSQL BFILE 02.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 PLSQL BFILE 02.sql diff --git a/PLSQL BFILE 02.sql b/PLSQL BFILE 02.sql new file mode 100644 index 0000000..8c47241 --- /dev/null +++ b/PLSQL BFILE 02.sql @@ -0,0 +1,15 @@ +/* Formatted on 25/Oct/21 10:45:43 PM (QP5 v5.287) */ +CREATE OR REPLACE PROCEDURE load_emp_bfile (p_file_loc IN VARCHAR2) +IS + v_file BFILE; + v_filename VARCHAR2 (16); + v_file_exists BOOLEAN; + + CURSOR emp_cursor IS +BEGIN + FOR emp_record IN emp_cursor LOOP + v_filename := emp_record.first_name || '.bmp'; + v_file := BFILENAME (p_file_loc, v_filename); + v_file_exists := (DBMS_LOB.FILEEXISTS(v_file) = 1); + IF v_file_exists THEN + DBMS_LOB.FILEOPEN (v_file); \ No newline at end of file From 39c35bb700df6dae2705d8de24dc4c10126aad3a Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 25 Oct 2021 23:23:40 +0600 Subject: [PATCH 38/95] PLSQL_GETLEANTH --- PLSQL_GETLEANTH.sql | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 PLSQL_GETLEANTH.sql diff --git a/PLSQL_GETLEANTH.sql b/PLSQL_GETLEANTH.sql new file mode 100644 index 0000000..e367d4d --- /dev/null +++ b/PLSQL_GETLEANTH.sql @@ -0,0 +1,31 @@ +/* Formatted on 25/Oct/21 11:22:37 PM (QP5 v5.287) */ +DECLARE + lobloc CLOB; -- serves as the LOB locator + text VARCHAR2 (32767) := 'Resigned: 5 August 2000'; + amount NUMBER; -- amount to be written + offset INTEGER; -- where to start writing +BEGIN + SELECT resume + INTO lobloc + FROM employees + WHERE employee_id = 405 + FOR UPDATE; + + offset := DBMS_LOB.GETLENGTH (lobloc) + 2; + amount := LENGTH (text); + DBMS_LOB.WRITE (lobloc, + amount, + offset, + text); + text := ' Resigned: 30 September 2000'; + + SELECT resume + INTO lobloc + FROM employees + WHERE employee_id = 170 + FOR UPDATE; + + amount := LENGTH (text); + DBMS_LOB.WRITEAPPEND (lobloc, amount, text); + COMMIT; +END; \ No newline at end of file From 925bac23c8165a05aaec41ca8c762ab476ff7262 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 26 Oct 2021 02:34:30 +0600 Subject: [PATCH 39/95] PLSQL_BLOB_CLOB_ALTER --- PLSQL BLOB CLOB ALTER.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 PLSQL BLOB CLOB ALTER.sql diff --git a/PLSQL BLOB CLOB ALTER.sql b/PLSQL BLOB CLOB ALTER.sql new file mode 100644 index 0000000..b28d1bd --- /dev/null +++ b/PLSQL BLOB CLOB ALTER.sql @@ -0,0 +1,3 @@ +ALTER TABLE employees ADD + (resume CLOB, + picture BLOB); From a3da58ab3b282d73f6c189afba22606815c197eb Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 26 Oct 2021 03:05:29 +0600 Subject: [PATCH 40/95] PLSQL BLOB CLOB INSERT --- PLSQL BLOB CLOB INSERT.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 PLSQL BLOB CLOB INSERT.sql diff --git a/PLSQL BLOB CLOB INSERT.sql b/PLSQL BLOB CLOB INSERT.sql new file mode 100644 index 0000000..6c9eddc --- /dev/null +++ b/PLSQL BLOB CLOB INSERT.sql @@ -0,0 +1,2 @@ +INSERT INTO employees (employee_id, first_name,last_name, email, hire_date, job_id, salary, resume, picture) +VALUES (405, 'Marvin', 'Ellis', 'MELLIS', SYSDATE, 'AD_ASST', 4000, EMPTY_CLOB(),NULL); From 284b9e39a60b6be9b116f155544203db45c80b63 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 26 Oct 2021 03:06:04 +0600 Subject: [PATCH 41/95] PLSQL BLOB CLOB UPDATE --- PLSQL BLOB CLOB UPDATE.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 PLSQL BLOB CLOB UPDATE.sql diff --git a/PLSQL BLOB CLOB UPDATE.sql b/PLSQL BLOB CLOB UPDATE.sql new file mode 100644 index 0000000..ce97d04 --- /dev/null +++ b/PLSQL BLOB CLOB UPDATE.sql @@ -0,0 +1,4 @@ +UPDATE employees +SET resume = 'Date of Birth: 8 February 1951', + picture = EMPTY_BLOB() +WHERE employee_id = 405; From 561a0d7eb303117c9021ba3ea48edf76542d4e61 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 26 Oct 2021 03:08:49 +0600 Subject: [PATCH 42/95] PLSQL CLOB DML --- PLSQL CLOB DML.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 PLSQL CLOB DML.sql diff --git a/PLSQL CLOB DML.sql b/PLSQL CLOB DML.sql new file mode 100644 index 0000000..6a0e31b --- /dev/null +++ b/PLSQL CLOB DML.sql @@ -0,0 +1,3 @@ +SELECT employee_id, last_name , resume -- CLOB +FROM employees +WHERE employee_id IN (405, 170); From cd32f41316b60f349497a62fb960fe90c509b6ad Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 26 Oct 2021 03:10:20 +0600 Subject: [PATCH 43/95] PLSQL DBMS LOB SUBSTR INSTR --- PLSQL DBMS LOB SUBSTR INSTR.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 PLSQL DBMS LOB SUBSTR INSTR.sql diff --git a/PLSQL DBMS LOB SUBSTR INSTR.sql b/PLSQL DBMS LOB SUBSTR INSTR.sql new file mode 100644 index 0000000..1325ee2 --- /dev/null +++ b/PLSQL DBMS LOB SUBSTR INSTR.sql @@ -0,0 +1,4 @@ +SELECT DBMS_LOB.SUBSTR (resume, 5, 18), + DBMS_LOB.INSTR (resume,' = ') +FROM employees +WHERE employee_id IN (170, 405); From de461067f203f85e05b43507139f3836009c5e10 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 26 Oct 2021 03:12:22 +0600 Subject: [PATCH 44/95] PLSQL DBMS RESUME --- PLSQL DBMSOutput Resume.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 PLSQL DBMSOutput Resume.txt diff --git a/PLSQL DBMSOutput Resume.txt b/PLSQL DBMSOutput Resume.txt new file mode 100644 index 0000000..fcbca38 --- /dev/null +++ b/PLSQL DBMSOutput Resume.txt @@ -0,0 +1,6 @@ +text is: +text is: +text is: +text is: +text is: +Radwan From a29544bce349494255fa33303bc346be405a3e47 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 26 Oct 2021 03:16:01 +0600 Subject: [PATCH 45/95] PLSQL ISTEMPLOBOPEN --- PLSQL ISTEMPLOBOPEN.prc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 PLSQL ISTEMPLOBOPEN.prc diff --git a/PLSQL ISTEMPLOBOPEN.prc b/PLSQL ISTEMPLOBOPEN.prc new file mode 100644 index 0000000..331ae5a --- /dev/null +++ b/PLSQL ISTEMPLOBOPEN.prc @@ -0,0 +1,15 @@ +/* Formatted on 26-Oct-21 3:15:06 AM (QP5 v5.287) */ +CREATE OR REPLACE PROCEDURE IsTempLOBOpen (p_lob_loc IN OUT BLOB, + p_retval OUT INTEGER) +IS +BEGIN + -- create a temporary LOB + DBMS_LOB.CREATETEMPORARY (p_lob_loc, TRUE); + -- see if the LOB is open: returns 1 if open + p_retval := DBMS_LOB.ISOPEN (p_lob_loc); + DBMS_OUTPUT.PUT_LINE ( + 'The file returned a value ....' || p_retval); + -- free the temporary LOB + DBMS_LOB.FREETEMPORARY (p_lob_loc); +END; +/ \ No newline at end of file From 4a416f017bd5fde59651f061553a0491a3e77871 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Wed, 27 Oct 2021 12:23:05 +0600 Subject: [PATCH 46/95] PLSQL_Exception_Handling --- PLSQL Exception Handling.sql | 58 ++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 PLSQL Exception Handling.sql diff --git a/PLSQL Exception Handling.sql b/PLSQL Exception Handling.sql new file mode 100644 index 0000000..efd2cd8 --- /dev/null +++ b/PLSQL Exception Handling.sql @@ -0,0 +1,58 @@ +/* Formatted on 27/Oct/21 12:21:41 PM (QP5 v5.287) */ +DECLARE + v_variable VARCHAR2 (100); + v_eid employees.employee_id%TYPE; + v_dptid departments.department_id%TYPE := 90; +BEGIN + SELECT e.last_name, e.department_id, e.employee_id + INTO v_variable, v_dptid, v_eid + FROM employees e, departments d + WHERE d.department_id = e.department_id + AND e.department_id = v_dptid + AND e.employee_id = v_eid; + + DBMS_OUTPUT.put_line ( + 'Empolyee ID: ' + || v_eid + || ' And The Name Of The Employee Is: ' + || v_variable + || ' Department ID Is: ' + || v_dptid); +EXCEPTION + WHEN TOO_MANY_ROWS + THEN + v_eid := 101; + DBMS_OUTPUT.put_line ( + 'Too many rows found that why we take on specific employee id'); + DBMS_OUTPUT.put_line ( + 'Empolyee ID: ' + || v_eid + || ' And The Name Of The Employee Is: ' + || v_variable + || ' Department ID Is: ' + || v_dptid); + WHEN NO_DATA_FOUND + THEN + v_eid := 101; + v_dptid := 90; + + SELECT e.last_name, e.department_id, e.employee_id + INTO v_variable, v_dptid, v_eid + FROM employees e, departments d + WHERE d.department_id = e.department_id + AND e.department_id = v_dptid + AND e.employee_id = v_eid; + + DBMS_OUTPUT.put_line ('No citizen detail found'); + DBMS_OUTPUT.put_line ( + 'Empolyee ID: ' + || v_eid + || ' And The Name Of The Employee Is: ' + || v_variable + || ' Department ID Is: ' + || v_dptid); + WHEN OTHERS + THEN + DBMS_OUTPUT.put_line ('Empolyee ID: ' || v_eid || ' ' || v_variable); +END; +/ \ No newline at end of file From a17459c251c3a8a18383c4a79f78c5b195679929 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Wed, 27 Oct 2021 16:49:01 +0600 Subject: [PATCH 47/95] PLSQL_EMAIL_VALIDATION --- PLSQL_EMAIL_VALIDATION.fnc | 30 ++++++++++++++++++++++ XX_CHECK_EMAIL.fnc | 52 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 PLSQL_EMAIL_VALIDATION.fnc create mode 100644 XX_CHECK_EMAIL.fnc diff --git a/PLSQL_EMAIL_VALIDATION.fnc b/PLSQL_EMAIL_VALIDATION.fnc new file mode 100644 index 0000000..fa79e97 --- /dev/null +++ b/PLSQL_EMAIL_VALIDATION.fnc @@ -0,0 +1,30 @@ +/* Formatted on 27/Oct/21 4:40:15 PM (QP5 v5.287) */ +CREATE OR REPLACE FUNCTION email_validation (email_address IN VARCHAR2) + RETURN VARCHAR2 +IS + at_the_rate NUMBER; + dot_symbol NUMBER; + l_str_length NUMBER; +BEGIN + -- domain := INSTR (email_address, 'com'or '.in'or'.bd'or '.gov'or '.org'); + at_the_rate := INSTR (email_address, '@'); + dot_symbol := INSTR (email_address, '.'); + l_str_length := LENGTH (email_address); + + IF ( ( (dot_symbol = 0) + OR (at_the_rate = 0) + OR (dot_symbol = at_the_rate + 1) + OR (at_the_rate = 1) + OR (at_the_rate = l_str_length) + OR (dot_symbol = l_str_length))) + THEN + RETURN 'Invalid email addresses'; + END IF; + + IF INSTR (SUBSTR (email_address, at_the_rate), '.') = 0 + THEN + RETURN 'Invalid email addresses'; + END IF; + + RETURN 'Valid email addresses'; +END email_validation; \ No newline at end of file diff --git a/XX_CHECK_EMAIL.fnc b/XX_CHECK_EMAIL.fnc new file mode 100644 index 0000000..320eb58 --- /dev/null +++ b/XX_CHECK_EMAIL.fnc @@ -0,0 +1,52 @@ +Create or replace + +FUNCTION xx_check_email(l_user_name IN VARCHAR2) + +RETURN VARCHAR2 IS + +l_dot_pos NUMBER; + +l_at_pos NUMBER; + +l_str_length NUMBER; + +BEGIN + + +l_dot_pos := instr(l_user_name + +,’.’); + +l_at_pos := instr(l_user_name + +,’@’); + +l_str_length := length(l_user_name); + +IF ((l_dot_pos = 0) OR (l_at_pos = 0) OR (l_dot_pos = l_at_pos + 1) OR + +(l_at_pos = 1) OR (l_at_pos = l_str_length) OR + +(l_dot_pos = l_str_length)) + +THEN + +RETURN ‘FAILURE’; + +END IF; + +IF instr(substr(l_user_name + +,l_at_pos) + +,’.’) = 0 + +THEN + +RETURN ‘FAILURE’; + +END IF; + +RETURN ‘SUCCESS’; + +end xx_check_email; \ No newline at end of file From c61bea021d9416d61126f5e6e443a76ff3e79532 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Wed, 27 Oct 2021 18:02:57 +0600 Subject: [PATCH 48/95] PLSQL_EMAIL_VALIDATION_UPDATED --- PLSQL_EMAIL_VALIDATION.fnc | 40 +++++++++++++++++------- PLSQL_EMAIL_VALIDATION_UPDATED.fnc | 50 ++++++++++++++++++++++++++++++ Test.fnc | 1 + 3 files changed, 80 insertions(+), 11 deletions(-) create mode 100644 PLSQL_EMAIL_VALIDATION_UPDATED.fnc create mode 100644 Test.fnc diff --git a/PLSQL_EMAIL_VALIDATION.fnc b/PLSQL_EMAIL_VALIDATION.fnc index fa79e97..bc39aef 100644 --- a/PLSQL_EMAIL_VALIDATION.fnc +++ b/PLSQL_EMAIL_VALIDATION.fnc @@ -1,30 +1,48 @@ -/* Formatted on 27/Oct/21 4:40:15 PM (QP5 v5.287) */ +/* Formatted on 27/Oct/21 5:22:57 PM (QP5 v5.287) */ CREATE OR REPLACE FUNCTION email_validation (email_address IN VARCHAR2) RETURN VARCHAR2 IS - at_the_rate NUMBER; - dot_symbol NUMBER; - l_str_length NUMBER; + at_the_rate NUMBER; + dot_symbol NUMBER; + c_at_the_rate NUMBER; + c_dot_symbol NUMBER; + string_length NUMBER; BEGIN -- domain := INSTR (email_address, 'com'or '.in'or'.bd'or '.gov'or '.org'); at_the_rate := INSTR (email_address, '@'); dot_symbol := INSTR (email_address, '.'); - l_str_length := LENGTH (email_address); + string_length := LENGTH (email_address); + c_at_the_rate := Count(email_address, '@'); + c_dot_symbol := Count(email_address, '@'); + IF ( ( (dot_symbol = 0) OR (at_the_rate = 0) OR (dot_symbol = at_the_rate + 1) OR (at_the_rate = 1) - OR (at_the_rate = l_str_length) - OR (dot_symbol = l_str_length))) + OR (at_the_rate = string_length) + OR (dot_symbol = string_length) + OR (COUNT(INSTR (email_address, '@')) > 1))) THEN RETURN 'Invalid email addresses'; END IF; - IF INSTR (SUBSTR (email_address, at_the_rate), '.') = 0 - THEN - RETURN 'Invalid email addresses'; - END IF; + /* + IF INSTR (SUBSTR (email_address, at_the_rate), '.') = 0 + THEN + RETURN 'Invalid email addresses'; + END IF; + + IF TO_NUMBER (INSTR (email_address, at_the_rate)) >1 + THEN + RETURN 'Invalid email addresses'; + END IF; + IF TO_NUMBER (INSTR (email_address, dot_symbol)) >1 + THEN + RETURN 'Invalid email addresses'; + END IF; */ + + RETURN 'Valid email addresses'; END email_validation; \ No newline at end of file diff --git a/PLSQL_EMAIL_VALIDATION_UPDATED.fnc b/PLSQL_EMAIL_VALIDATION_UPDATED.fnc new file mode 100644 index 0000000..61bda2d --- /dev/null +++ b/PLSQL_EMAIL_VALIDATION_UPDATED.fnc @@ -0,0 +1,50 @@ +/* Formatted on 27/Oct/21 5:22:57 PM (QP5 v5.287) */ +CREATE OR REPLACE FUNCTION email_validation (email_address IN VARCHAR2) + RETURN VARCHAR2 +IS + at_the_rate NUMBER; + dot_symbol NUMBER; + c_at_the_rate NUMBER; + c_dot_symbol NUMBER; + string_length NUMBER; +BEGIN + -- domain := INSTR (email_address, 'com'or '.in'or'.bd'or '.gov'or '.org'); + at_the_rate := INSTR (email_address, '@'); + dot_symbol := INSTR (email_address, '.'); + string_length := LENGTH (email_address); + c_at_the_rate := ROUND(LENGTH(email_address)-LENGTH(REplace(email_address, '@'))); + c_dot_symbol := ROUND(LENGTH(email_address)-LENGTH(REplace(email_address, '.'))); + -- after_at_the_rate := c_at_the_rate+1; + + + IF ( ( (dot_symbol = 0) + OR (at_the_rate = 0) + OR (dot_symbol = at_the_rate + 1) + OR (at_the_rate = 1) + OR (c_at_the_rate> 1) + OR (c_dot_symbol=c_at_the_rate+1) + OR (at_the_rate = string_length) + OR (dot_symbol = string_length))) + THEN + RETURN 'Invalid email addresses'; + END IF; + + /* + IF INSTR (SUBSTR (email_address, at_the_rate), '.') = 0 + THEN + RETURN 'Invalid email addresses'; + END IF; + + IF TO_NUMBER (INSTR (email_address, at_the_rate)) >1 + THEN + RETURN 'Invalid email addresses'; + END IF; + IF TO_NUMBER (INSTR (email_address, dot_symbol)) >1 + THEN + RETURN 'Invalid email addresses'; + END IF; */ + + + + RETURN 'Valid email addresses'; +END email_validation; \ No newline at end of file diff --git a/Test.fnc b/Test.fnc new file mode 100644 index 0000000..49dd5da --- /dev/null +++ b/Test.fnc @@ -0,0 +1 @@ +Select email_validation('radwanromy@@gmail.com') from dual; \ No newline at end of file From ce7b11f8a849462ebfb0aaabf120745f7b9a5907 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Thu, 28 Oct 2021 12:10:44 +0600 Subject: [PATCH 49/95] FUCNTION_EMAIL_VALIDATION --- FUNCTION_EMAIL_VALIDATION.fnc | 75 +++++++++++++++++++++++++++++++++++ Test_Email_Validation.fnc | 1 + 2 files changed, 76 insertions(+) create mode 100644 FUNCTION_EMAIL_VALIDATION.fnc create mode 100644 Test_Email_Validation.fnc diff --git a/FUNCTION_EMAIL_VALIDATION.fnc b/FUNCTION_EMAIL_VALIDATION.fnc new file mode 100644 index 0000000..da60ae2 --- /dev/null +++ b/FUNCTION_EMAIL_VALIDATION.fnc @@ -0,0 +1,75 @@ +/* Formatted on 28/Oct/21 11:51:07 AM (QP5 v5.287) */ +CREATE OR REPLACE FUNCTION email_validation (email_address IN VARCHAR2) + RETURN VARCHAR2 +IS + at_the_rate NUMBER; + dot_symbol NUMBER; + c_at_the_rate NUMBER; + c_dot_symbol NUMBER; + string_length NUMBER; + before_dot NUMBER; + temp NUMBER; + after_dot NUMBER; + undefine_symbol NUMBER; +BEGIN + -- domain := INSTR (email_address, 'com'or '.in'or'.bd'or '.gov'or '.org'); + at_the_rate := INSTR (email_address, '@'); + dot_symbol := INSTR (email_address, '.'); + string_length := LENGTH (email_address); + c_at_the_rate := + ROUND (LENGTH (email_address) - LENGTH (REPLACE (email_address, '@'))); + c_dot_symbol := + ROUND (LENGTH (email_address) - LENGTH (REPLACE (email_address, '.'))); + -- after_at_the_rate := at_the_rate+1; + before_dot := INSTR (email_address, '.'); + after_dot := INSTR (email_address, '.'); + temp := dot_symbol; + DBMS_OUTPUT.put_line ('TEMP' || ' : ' || temp); + undefine_symbol := + INSTR (email_address, '!') + || INSTR (email_address, '/') + || INSTR (email_address, '#') + || INSTR (email_address, '%') + || INSTR (email_address, '$') + || INSTR (email_address, '^') + || INSTR (email_address, '&') + || INSTR (email_address, '*') + || INSTR (email_address, '(') + || INSTR (email_address, '(') + || INSTR (email_address, '-') + || INSTR (email_address, '+') + || INSTR (email_address, '=') + || INSTR (email_address, '`') + || INSTR (email_address, '~') + || INSTR (email_address, '?') + || INSTR (email_address, '{') + || INSTR (email_address, '}') + || INSTR (email_address, '[') + || INSTR (email_address, ']') + || INSTR (email_address, '\') + || INSTR (email_address, '|') + || INSTR (email_address, '"') + || INSTR (email_address, ':') + || INSTR (email_address, ';') + || INSTR (email_address, ']') + || INSTR (email_address, '[') + || INSTR (email_address, '?') + || INSTR (email_address, '>') + || INSTR (email_address, '<') + || INSTR (email_address, ',') + || INSTR (email_address, '..') + || INSTR (email_address, '.@') + || INSTR (email_address, '@.'); + DBMS_OUTPUT.put_line (before_dot || ' AND ' || after_dot); + IF ( ( (dot_symbol = 0) + OR (at_the_rate = 0) + OR (undefine_symbol >= 1) + OR (at_the_rate = 1) + OR (c_at_the_rate > 1) + OR (at_the_rate = string_length) + OR (dot_symbol = string_length))) + THEN + RETURN 'Invalid email addresses'; + END IF; + RETURN 'Valid email addresses'; +END email_validation; \ No newline at end of file diff --git a/Test_Email_Validation.fnc b/Test_Email_Validation.fnc new file mode 100644 index 0000000..35c57dc --- /dev/null +++ b/Test_Email_Validation.fnc @@ -0,0 +1 @@ +Select email_validation('ra.dwan_romy@gmail.bd.in') from dual; \ No newline at end of file From b3a070db7b5e70dd9c7f2e552dc49580eab1d771 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 2 Nov 2021 17:49:26 +0600 Subject: [PATCH 50/95] DPK_RADWAN Package Create --- DPK_RADWAN Package Create.pks | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 DPK_RADWAN Package Create.pks diff --git a/DPK_RADWAN Package Create.pks b/DPK_RADWAN Package Create.pks new file mode 100644 index 0000000..648d861 --- /dev/null +++ b/DPK_RADWAN Package Create.pks @@ -0,0 +1,5 @@ +/* Formatted on 02-Nov-21 4:43:58 PM (QP5 v5.287) */ +CREATE OR REPLACE PACKAGE dpk_radwan +AS + PROCEDURE p_email_validation (email_address IN VARCHAR2); +END dpk_radwan; From 3ee3f8c1963e582fc49282c63568dbfc65346a0e Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 2 Nov 2021 17:50:55 +0600 Subject: [PATCH 51/95] Package Test Execute --- Package Test Execute.pks | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Package Test Execute.pks diff --git a/Package Test Execute.pks b/Package Test Execute.pks new file mode 100644 index 0000000..5a1ec04 --- /dev/null +++ b/Package Test Execute.pks @@ -0,0 +1,2 @@ +--EXECUTE p_email_validation( 'radwanromy@gmail.com'); + EXECUTE dpk_radwan.p_email_validation('radwanromy@gmail.com'); From 3f97e81c2a172a294c327f6c3cdbf461e659ea99 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 2 Nov 2021 17:51:52 +0600 Subject: [PATCH 52/95] DPK_RADWAN PROCEDURE.pkb --- DPK_RADWAN PROCEDURE.pkb | 79 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 DPK_RADWAN PROCEDURE.pkb diff --git a/DPK_RADWAN PROCEDURE.pkb b/DPK_RADWAN PROCEDURE.pkb new file mode 100644 index 0000000..e46b8d7 --- /dev/null +++ b/DPK_RADWAN PROCEDURE.pkb @@ -0,0 +1,79 @@ +CREATE OR REPLACE PACKAGE BODY dpk_radwan +AS + PROCEDURE p_email_validation (email_address IN VARCHAR2) IS + at_the_rate NUMBER; + dot_symbol NUMBER; + c_at_the_rate NUMBER; + c_dot_symbol NUMBER; + string_length NUMBER; + before_dot NUMBER; + temp NUMBER; + after_dot NUMBER; + undefine_symbol NUMBER; + BEGIN -- domain := INSTR (email_address, 'com'or '.in'or'.bd'or '.gov'or '.org'); + + at_the_rate := INSTR (email_address, '@'); + dot_symbol := INSTR (email_address, '.'); + string_length := LENGTH (email_address); + c_at_the_rate := + ROUND (LENGTH (email_address) - LENGTH (REPLACE (email_address, '@'))); + c_dot_symbol := + ROUND (LENGTH (email_address) - LENGTH (REPLACE (email_address, '.'))); + -- after_at_the_rate := at_the_rate+1; + before_dot := INSTR (email_address, '.'); + after_dot := INSTR (email_address, '.'); + temp := dot_symbol; + --DBMS_OUTPUT.put_line ('TEMP' || ' : ' || temp); + undefine_symbol := + INSTR (email_address, '!') + || INSTR (email_address, '/') + || INSTR (email_address, '#') + || INSTR (email_address, '%') + || INSTR (email_address, '$') + || INSTR (email_address, '^') + || INSTR (email_address, '&') + || INSTR (email_address, '*') + || INSTR (email_address, '(') + || INSTR (email_address, '(') + || INSTR (email_address, '-') + || INSTR (email_address, '+') + || INSTR (email_address, '=') + || INSTR (email_address, '`') + || INSTR (email_address, '~') + || INSTR (email_address, '?') + || INSTR (email_address, '{') + || INSTR (email_address, '}') + || INSTR (email_address, '[') + || INSTR (email_address, ']') + || INSTR (email_address, '\') + || INSTR (email_address, '|') + || INSTR (email_address, '"') + || INSTR (email_address, ':') + || INSTR (email_address, ';') + || INSTR (email_address, ']') + || INSTR (email_address, '[') + || INSTR (email_address, '?') + || INSTR (email_address, '>') + || INSTR (email_address, '<') + || INSTR (email_address, ',') + || INSTR (email_address, '..') + || INSTR (email_address, '.@') + || INSTR (email_address, '@.'); + -- DBMS_OUTPUT.put_line (before_dot || ' AND ' || after_dot); + IF ( ( (dot_symbol = 0) + OR (at_the_rate = 0) + OR (undefine_symbol >= 1) + OR (at_the_rate = 1) + OR (c_at_the_rate > 1) + OR (at_the_rate = string_length) + OR (dot_symbol = string_length))) + THEN + DBMS_OUTPUT.put_line ('Invalid email addresses'); + END IF; + DBMS_OUTPUT.put_line ('Valid email addresses'); + EXCEPTION + WHEN OTHERS + THEN + DBMS_OUTPUT.put_line ('Can not able to say valid or invalid'); + END p_email_validation; +END dpk_radwan; \ No newline at end of file From 4439e153e2b44ce1d10d66c4d62154de6de37398 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Wed, 3 Nov 2021 12:18:47 +0600 Subject: [PATCH 53/95] DML_EMP_VALUES --- DML_EMP_VALUES.trg | 90 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 DML_EMP_VALUES.trg diff --git a/DML_EMP_VALUES.trg b/DML_EMP_VALUES.trg new file mode 100644 index 0000000..f2fdc32 --- /dev/null +++ b/DML_EMP_VALUES.trg @@ -0,0 +1,90 @@ +/* Formatted on 03-Nov-21 11:55:31 AM (QP5 v5.287) */ +CREATE OR REPLACE TRIGGER dml_emp_values + AFTER DELETE OR INSERT OR UPDATE + ON employee + FOR EACH ROW + ENABLE +DECLARE + idn NUMBER (6, 0); + user_name VARCHAR2 (25); + timestampn VARCHAR2 (25); + old_last_name VARCHAR2 (25); + new_last_name VARCHAR2 (25); + old_title VARCHAR2 (10); + new_title VARCHAR2 (10); + old_salary VARCHAR2 (10); + new_salary VARCHAR2 (10); +BEGIN + SELECT USER, TO_CHAR (SYSDATE, 'DD/MON/YYYY HH24:MI:SS') + INTO user_name, timestampn + FROM DUAL; + + IF INSERTING + THEN + INSERT INTO t_emp_table (user_name, + timestampn, + idn, + old_last_name, + new_last_name, + old_title, + new_title, + old_salary, + new_salary, + operation) + VALUES (USER, + SYSDATE, + :NEW.employee_id, + :NEW.last_name, + :NEW.last_name, + :NEW.job_id, + :NEW.last_name, + :NEW.salary, + :NEW.salary, + 'Insert'); + ELSIF DELETING + THEN + INSERT INTO t_emp_table (user_name, + timestampn, + idn, + old_last_name, + new_last_name, + old_title, + new_title, + old_salary, + new_salary, + operation) + VALUES (USER, + SYSDATE, + :OLD.employee_id, + :OLD.last_name, + :OLD.last_name, + :OLD.job_id, + :OLD.last_name, + :OLD.salary, + :OLD.salary, + 'Delete'); + ELSIF UPDATING + THEN + INSERT INTO t_emp_table (user_name, + timestampn, + idn, + old_last_name, + new_last_name, + old_title, + new_title, + old_salary, + new_salary, + operation) + VALUES (USER, + SYSDATE, + :OLD.employee_id, + :OLD.last_name, + :NEW.last_name, + :OLD.job_id, + :NEW.last_name, + :OLD.salary, + :NEW.salary, + 'Insert'); + END IF; +END; +/ \ No newline at end of file From 9e1002ebd3df32ba43a3a4087139df5c79a71104 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Wed, 3 Nov 2021 12:19:51 +0600 Subject: [PATCH 54/95] Trigger_Temp_Table --- Trigger_Temp_Table.trg | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Trigger_Temp_Table.trg diff --git a/Trigger_Temp_Table.trg b/Trigger_Temp_Table.trg new file mode 100644 index 0000000..517ace1 --- /dev/null +++ b/Trigger_Temp_Table.trg @@ -0,0 +1,13 @@ +CREATE TABLE t_emp_table( +user_name varchar(255) NOT NULL, + timestampn varchar(255) NOT NULL, + idn int NOT NULL, + old_last_name varchar(255) NOT NULL, + new_last_name varchar(255) NOT NULL, + old_title varchar(255) NOT NULL, + new_title varchar(255) NOT NULL, + old_salary varchar(255) NOT NULL, + new_salary varchar(255) NOT NULL, + operation varchar(255) NOT NULL, + PRIMARY KEY (IDN) +); \ No newline at end of file From 056a9206dda4b23268cc36423db0afc043e81618 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Wed, 3 Nov 2021 12:21:35 +0600 Subject: [PATCH 55/95] Trigger Test Insert --- Trigger Test Insert.trg | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Trigger Test Insert.trg diff --git a/Trigger Test Insert.trg b/Trigger Test Insert.trg new file mode 100644 index 0000000..97ad2a0 --- /dev/null +++ b/Trigger Test Insert.trg @@ -0,0 +1,4 @@ +/* Formatted on 03-Nov-21 12:04:34 PM (QP5 v5.287) */ +INSERT INTO employee (employee_id,last_name,job_id,salary) + VALUES (013, 'FAS' , 'IT', 4000 + ); From 09ba9b1f8e01d8ee441cbf0cfe0b31439f25e81d Mon Sep 17 00:00:00 2001 From: radwanromy Date: Wed, 3 Nov 2021 12:42:00 +0600 Subject: [PATCH 56/95] Trigger Store Test --- Trigger Store Test.trg | 1 + 1 file changed, 1 insertion(+) create mode 100644 Trigger Store Test.trg diff --git a/Trigger Store Test.trg b/Trigger Store Test.trg new file mode 100644 index 0000000..84f32c3 --- /dev/null +++ b/Trigger Store Test.trg @@ -0,0 +1 @@ +select * from t_emp_table; \ No newline at end of file From aff5667d429f9ceae6cd43cecedb011996944f65 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Wed, 3 Nov 2021 12:44:27 +0600 Subject: [PATCH 57/95] Trigger Table Check --- Create For Trigger Operation On Table.trg | 5 +++++ Trigger Table Check.trg | 1 + 2 files changed, 6 insertions(+) create mode 100644 Create For Trigger Operation On Table.trg create mode 100644 Trigger Table Check.trg diff --git a/Create For Trigger Operation On Table.trg b/Create For Trigger Operation On Table.trg new file mode 100644 index 0000000..5985bf4 --- /dev/null +++ b/Create For Trigger Operation On Table.trg @@ -0,0 +1,5 @@ + +CREATE TABLE employee( +employee_id int NOT NULL,last_name varchar(255) NOT NULL, job_id varchar(255) NOT NULL,salary varchar(255) NOT NULL, + PRIMARY KEY (employee_id) +); \ No newline at end of file diff --git a/Trigger Table Check.trg b/Trigger Table Check.trg new file mode 100644 index 0000000..5a6b369 --- /dev/null +++ b/Trigger Table Check.trg @@ -0,0 +1 @@ +Select * from employee; \ No newline at end of file From d73e25439340271b1a3d871f2c1419c54f65c715 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Wed, 3 Nov 2021 12:44:58 +0600 Subject: [PATCH 58/95] Drop Trigger --- Drop Trigger.trg | 1 + 1 file changed, 1 insertion(+) create mode 100644 Drop Trigger.trg diff --git a/Drop Trigger.trg b/Drop Trigger.trg new file mode 100644 index 0000000..30016fb --- /dev/null +++ b/Drop Trigger.trg @@ -0,0 +1 @@ +DROP TRIGGER dml_emp_values; \ No newline at end of file From 39fa6b24d1cfd76374fd7d53fe7bffb30e46d1fe Mon Sep 17 00:00:00 2001 From: radwanromy Date: Wed, 3 Nov 2021 12:45:43 +0600 Subject: [PATCH 59/95] Trigger Delete Check --- Trigger Delete Check.trg | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Trigger Delete Check.trg diff --git a/Trigger Delete Check.trg b/Trigger Delete Check.trg new file mode 100644 index 0000000..5391481 --- /dev/null +++ b/Trigger Delete Check.trg @@ -0,0 +1,3 @@ +/* Formatted on 03-Nov-21 12:25:35 PM (QP5 v5.287) */ +DELETE FROM employee + WHERE employee_id = 12; \ No newline at end of file From 0d15161a46ca32069910a7ede47e9ced4b608532 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Wed, 3 Nov 2021 12:46:19 +0600 Subject: [PATCH 60/95] Trigger Insert Check --- Trigger Insert Check.trg | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Trigger Insert Check.trg diff --git a/Trigger Insert Check.trg b/Trigger Insert Check.trg new file mode 100644 index 0000000..8c30e80 --- /dev/null +++ b/Trigger Insert Check.trg @@ -0,0 +1,3 @@ +UPDATE employee +SET last_name = 'Ansu', job_id= 'Player' +WHERE employee_id = 11; \ No newline at end of file From f4ce7b9a96a2d20da706d951281d11f99cca9330 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 9 Nov 2021 13:18:58 +0600 Subject: [PATCH 61/95] Package Procedure To Perform In Trigger --- Package Procedure to perform in trigger.sql | 48 +++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Package Procedure to perform in trigger.sql diff --git a/Package Procedure to perform in trigger.sql b/Package Procedure to perform in trigger.sql new file mode 100644 index 0000000..27b8367 --- /dev/null +++ b/Package Procedure to perform in trigger.sql @@ -0,0 +1,48 @@ +/* Formatted on 09-Nov-21 1:15:34 PM (QP5 v5.287) */ +CREATE OR REPLACE PACKAGE BODY e_tpp +AS + PROCEDURE addEmployee (e_id employee.employee_id%TYPE, + e_name employee.last_name%TYPE, + e_job employee.job_id%TYPE, + e_sal employee.salary%TYPE) + IS + BEGIN + INSERT INTO employee (employee_id, + last_name, + job_id, + salary) + VALUES (e_id, + e_name, + e_job, + e_sal); + END addEmployee; + + PROCEDURE delEmployee (e_id employee.employee_id%TYPE) + IS + BEGIN + DELETE FROM employee + WHERE employee_id = c_id; + END delEmployee; + + PROCEDURE listCustomer + IS + CURSOR c_customers + IS + SELECT name FROM customers; + + TYPE c_list IS TABLE OF customers.Name%TYPE; + + name_list c_list := c_list (); + counter INTEGER := 0; + BEGIN + FOR n IN c_customers + LOOP + counter := counter + 1; + name_list.EXTEND; + name_list (counter) := n.name; + DBMS_OUTPUT.put_line ( + 'Customer(' || counter || ')' || name_list (counter)); + END LOOP; + END listCustomer; +END e_tpp; +/ \ No newline at end of file From f563de1e5761a9b68e6a37a9c45f65671f58c671 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 9 Nov 2021 13:21:22 +0600 Subject: [PATCH 62/95] Package Procedure To Perform In Trigger 02 --- Package Procedure to perform in trigger.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Package Procedure to perform in trigger.sql b/Package Procedure to perform in trigger.sql index 27b8367..c961ad2 100644 --- a/Package Procedure to perform in trigger.sql +++ b/Package Procedure to perform in trigger.sql @@ -24,18 +24,18 @@ AS WHERE employee_id = c_id; END delEmployee; - PROCEDURE listCustomer + PROCEDURE listEmployee IS - CURSOR c_customers + CURSOR e_employees IS - SELECT name FROM customers; + SELECT name FROM employee; - TYPE c_list IS TABLE OF customers.Name%TYPE; + TYPE e_list IS TABLE OF employee.last_name%TYPE; name_list c_list := c_list (); counter INTEGER := 0; BEGIN - FOR n IN c_customers + FOR n IN e_employees LOOP counter := counter + 1; name_list.EXTEND; From d635b748e3b4c2998fbb478cbb8dde00812ab447 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 9 Nov 2021 14:46:30 +0600 Subject: [PATCH 63/95] Package Procedure To Perform In Trigger 03 --- E_TPP package and procedures creating.pks | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 E_TPP package and procedures creating.pks diff --git a/E_TPP package and procedures creating.pks b/E_TPP package and procedures creating.pks new file mode 100644 index 0000000..53fda44 --- /dev/null +++ b/E_TPP package and procedures creating.pks @@ -0,0 +1,10 @@ +CREATE OR REPLACE PACKAGE e_tpp +AS + + PROCEDURE delEmployee (e_id employee.employee_id%TYPE); + PROCEDURE listEmployee; + PROCEDURE addEmployee (e_id employee.employee_id%TYPE, + e_name employee.last_name%TYPE, + e_job employee.job_id%TYPE, + e_sal employee.salary%TYPE); +END e_tpp; From 1d126bcc72ceb1098dc8d380f4d88395b99f6ce5 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 9 Nov 2021 14:47:38 +0600 Subject: [PATCH 64/95] Package Procedure To Perform In Trigger 04 --- ...tion of e_tpp add employee by package to perfrom trigger.pks | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Execution of e_tpp add employee by package to perfrom trigger.pks diff --git a/Execution of e_tpp add employee by package to perfrom trigger.pks b/Execution of e_tpp add employee by package to perfrom trigger.pks new file mode 100644 index 0000000..44aea4a --- /dev/null +++ b/Execution of e_tpp add employee by package to perfrom trigger.pks @@ -0,0 +1,2 @@ +--EXECUTE p_email_validation( 'radwanromy@gmail.com'); + EXECUTE e_tpp.addEmployee(033,'Radwan','CEO',5000); From def7c0a41981e94ead9f434243fc2bc358bbc8ec Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 9 Nov 2021 15:18:22 +0600 Subject: [PATCH 65/95] Add Del Up Package Procedure To Perform In Trigger --- ...ackage Procedure to perform in trigger.sql | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 UP DEL ADD Package Procedure to perform in trigger.sql diff --git a/UP DEL ADD Package Procedure to perform in trigger.sql b/UP DEL ADD Package Procedure to perform in trigger.sql new file mode 100644 index 0000000..c7e3a99 --- /dev/null +++ b/UP DEL ADD Package Procedure to perform in trigger.sql @@ -0,0 +1,61 @@ +/* Formatted on 09-Nov-21 3:13:14 PM (QP5 v5.287) */ +CREATE OR REPLACE PACKAGE BODY e_tpp +AS + PROCEDURE addEmployee (e_id employee.employee_id%TYPE, + e_name employee.last_name%TYPE, + e_job employee.job_id%TYPE, + e_sal employee.salary%TYPE) + IS + BEGIN + INSERT INTO employee (employee_id, + last_name, + job_id, + salary) + VALUES (e_id, + e_name, + e_job, + e_sal); + END addEmployee; + + PROCEDURE delEmployee (e_id employee.employee_id%TYPE) + IS + BEGIN + DELETE FROM employee + WHERE employee_id = e_id; + END delEmployee; + + PROCEDURE upEmployee (e_id employee.employee_id%TYPE, + e_name employee.last_name%TYPE, + e_job employee.job_id%TYPE, + e_sal employee.salary%TYPE) + IS + BEGIN + UPDATE employee + SET last_name = e_name, job_id = e_job, salary = e_sal + WHERE employee_id = e_id; + END upEmployee; +/* PROCEDURE listEmployee + IS + CURSOR e_employees + IS + SELECT last_name FROM employee; + + TYPE e_list IS TABLE OF employee.last_name%TYPE; + + name_list e_list := e_list (); + counter INTEGER := 0; + BEGIN + FOR n IN e_employees + LOOP + counter := counter + 1; + name_list.EXTEND; + name_list (counter) := n.last_name; + DBMS_OUTPUT.put_line ( + 'Customer(' || counter || ')' || name_list (counter)); + END LOOP; + END listEmployee; */ + + + +END e_tpp; +/ \ No newline at end of file From cbb58b5024734d50a60f749486eda22e77c58c5f Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 9 Nov 2021 15:19:04 +0600 Subject: [PATCH 66/95] Add Del Up Package Procedure To Perform In Trigger 02 --- ... procedures creating with UP date Procedure.pks | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 E_TPP package and procedures creating with UP date Procedure.pks diff --git a/E_TPP package and procedures creating with UP date Procedure.pks b/E_TPP package and procedures creating with UP date Procedure.pks new file mode 100644 index 0000000..17c08a6 --- /dev/null +++ b/E_TPP package and procedures creating with UP date Procedure.pks @@ -0,0 +1,14 @@ +CREATE OR REPLACE PACKAGE e_tpp +AS + + PROCEDURE delEmployee (e_id employee.employee_id%TYPE); + + PROCEDURE addEmployee (e_id employee.employee_id%TYPE, + e_name employee.last_name%TYPE, + e_job employee.job_id%TYPE, + e_sal employee.salary%TYPE); + PROCEDURE upEmployee (e_id employee.employee_id%TYPE, + e_name employee.last_name%TYPE, + e_job employee.job_id%TYPE, + e_sal employee.salary%TYPE); +END e_tpp; From 1f48a1fe39fd04b03d80d945b11492ca96c9e6a0 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 9 Nov 2021 15:27:10 +0600 Subject: [PATCH 67/95] Add Del Up Package Procedure To Perform In Trigger updated --- ...rocedure to perform in trigger updated.sql | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Package Procedure to perform in trigger updated.sql diff --git a/Package Procedure to perform in trigger updated.sql b/Package Procedure to perform in trigger updated.sql new file mode 100644 index 0000000..c961ad2 --- /dev/null +++ b/Package Procedure to perform in trigger updated.sql @@ -0,0 +1,48 @@ +/* Formatted on 09-Nov-21 1:15:34 PM (QP5 v5.287) */ +CREATE OR REPLACE PACKAGE BODY e_tpp +AS + PROCEDURE addEmployee (e_id employee.employee_id%TYPE, + e_name employee.last_name%TYPE, + e_job employee.job_id%TYPE, + e_sal employee.salary%TYPE) + IS + BEGIN + INSERT INTO employee (employee_id, + last_name, + job_id, + salary) + VALUES (e_id, + e_name, + e_job, + e_sal); + END addEmployee; + + PROCEDURE delEmployee (e_id employee.employee_id%TYPE) + IS + BEGIN + DELETE FROM employee + WHERE employee_id = c_id; + END delEmployee; + + PROCEDURE listEmployee + IS + CURSOR e_employees + IS + SELECT name FROM employee; + + TYPE e_list IS TABLE OF employee.last_name%TYPE; + + name_list c_list := c_list (); + counter INTEGER := 0; + BEGIN + FOR n IN e_employees + LOOP + counter := counter + 1; + name_list.EXTEND; + name_list (counter) := n.name; + DBMS_OUTPUT.put_line ( + 'Customer(' || counter || ')' || name_list (counter)); + END LOOP; + END listCustomer; +END e_tpp; +/ \ No newline at end of file From 36c978c2a413aec1e87417d14cec97b9c26b7ac1 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 9 Nov 2021 15:29:50 +0600 Subject: [PATCH 68/95] Add Del Up Package Procedure To Perform In Trigger updated with delete sell --- deleting using package procedure and store with trigger.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 deleting using package procedure and store with trigger.sql diff --git a/deleting using package procedure and store with trigger.sql b/deleting using package procedure and store with trigger.sql new file mode 100644 index 0000000..5f79e34 --- /dev/null +++ b/deleting using package procedure and store with trigger.sql @@ -0,0 +1 @@ +EXECUTE e_tpp.delEmployee(44); \ No newline at end of file From 084215109da0590c0dc7a5d80c2e7526b6f3927f Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 9 Nov 2021 17:00:48 +0600 Subject: [PATCH 69/95] TPP --- tpp01.pks | 14 +++++++ tpp02.sql | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tpp03.trg | 24 ++++++++++++ 3 files changed, 150 insertions(+) create mode 100644 tpp01.pks create mode 100644 tpp02.sql create mode 100644 tpp03.trg diff --git a/tpp01.pks b/tpp01.pks new file mode 100644 index 0000000..17c08a6 --- /dev/null +++ b/tpp01.pks @@ -0,0 +1,14 @@ +CREATE OR REPLACE PACKAGE e_tpp +AS + + PROCEDURE delEmployee (e_id employee.employee_id%TYPE); + + PROCEDURE addEmployee (e_id employee.employee_id%TYPE, + e_name employee.last_name%TYPE, + e_job employee.job_id%TYPE, + e_sal employee.salary%TYPE); + PROCEDURE upEmployee (e_id employee.employee_id%TYPE, + e_name employee.last_name%TYPE, + e_job employee.job_id%TYPE, + e_sal employee.salary%TYPE); +END e_tpp; diff --git a/tpp02.sql b/tpp02.sql new file mode 100644 index 0000000..7f8159a --- /dev/null +++ b/tpp02.sql @@ -0,0 +1,112 @@ +/* Formatted on 09-Nov-21 1:15:34 PM (QP5 v5.287) */ +CREATE OR REPLACE PACKAGE BODY e_tpp + +AS + + PROCEDURE addEmployee (e_id employee.employee_id%TYPE, + e_name employee.last_name%TYPE, + e_job employee.job_id%TYPE, + e_sal employee.salary%TYPE) + IS + BEGIN + INSERT INTO employee (employee_id, + last_name, + job_id, + salary) + VALUES (e_id, + e_name, + e_job, + e_sal); + END addEmployee; + + PROCEDURE delEmployee (e_id employee.employee_id%TYPE) + IS + BEGIN + DELETE FROM employee + WHERE employee_id = c_id; + END delEmployee; + + idn NUMBER (6, 0); + user_name VARCHAR2 (25); + timestampn VARCHAR2 (25); + old_last_name VARCHAR2 (25); + new_last_name VARCHAR2 (25); + old_title VARCHAR2 (10); + new_title VARCHAR2 (10); + old_salary VARCHAR2 (10); + new_salary VARCHAR2 (10); +BEGIN + SELECT USER, TO_CHAR (SYSDATE, 'DD/MON/YYYY HH24:MI:SS') + INTO user_name, timestampn + FROM DUAL; + + IF INSERTING + THEN + INSERT INTO t_emp_table (user_name, + timestampn, + idn, + old_last_name, + new_last_name, + old_title, + new_title, + old_salary, + new_salary, + operation) + VALUES (USER, + SYSDATE, + :NEW.employee_id, + :NEW.last_name, + :NEW.last_name, + :NEW.job_id, + :NEW.last_name, + :NEW.salary, + :NEW.salary, + 'Insert'); + ELSIF DELETING + THEN + INSERT INTO t_emp_table (user_name, + timestampn, + idn, + old_last_name, + new_last_name, + old_title, + new_title, + old_salary, + new_salary, + operation) + VALUES (USER, + SYSDATE, + :OLD.employee_id, + :OLD.last_name, + :OLD.last_name, + :OLD.job_id, + :OLD.last_name, + :OLD.salary, + :OLD.salary, + 'Delete'); + ELSIF UPDATING + THEN + INSERT INTO t_emp_table (user_name, + timestampn, + idn, + old_last_name, + new_last_name, + old_title, + new_title, + old_salary, + new_salary, + operation) + VALUES (USER, + SYSDATE, + :OLD.employee_id, + :OLD.last_name, + :NEW.last_name, + :OLD.job_id, + :NEW.last_name, + :OLD.salary, + :NEW.salary, + 'Insert'); + END IF; + +END e_tpp; +/ \ No newline at end of file diff --git a/tpp03.trg b/tpp03.trg new file mode 100644 index 0000000..da2d1e7 --- /dev/null +++ b/tpp03.trg @@ -0,0 +1,24 @@ +/* Formatted on 03-Nov-21 11:55:31 AM (QP5 v5.287) */ +CREATE OR REPLACE TRIGGER dml_emp_values + AFTER DELETE OR INSERT OR UPDATE + ON employee + FOR EACH ROW + ENABLE + +BEGIN + SELECT USER, TO_CHAR (SYSDATE, 'DD/MON/YYYY HH24:MI:SS') + INTO user_name, timestampn + FROM DUAL; + + IF INSERTING + THEN + Execute PAckage E_tpp PROCEDURE delEmployee (); + + ELSIF DELETING + THEN + ELSIF UPDATING + THEN + + END IF; +END; +/ \ No newline at end of file From 4d43b6b2c23ec52c22da9478ee0d8cb1b58c346b Mon Sep 17 00:00:00 2001 From: radwanromy Date: Wed, 10 Nov 2021 11:47:08 +0600 Subject: [PATCH 70/95] TPP 001 --- New 1.sql | 1 + tpp01.pks | 17 +++++-- tpp02.sql | 80 +++++++++++++++++------------- tpp03.trg | 9 ++-- triggerPP01.sql | 126 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 190 insertions(+), 43 deletions(-) create mode 100644 New 1.sql create mode 100644 triggerPP01.sql diff --git a/New 1.sql b/New 1.sql new file mode 100644 index 0000000..70b5fc6 --- /dev/null +++ b/New 1.sql @@ -0,0 +1 @@ +drop package e_tpp; diff --git a/tpp01.pks b/tpp01.pks index 17c08a6..db1cc4a 100644 --- a/tpp01.pks +++ b/tpp01.pks @@ -1,14 +1,21 @@ +/* Formatted on 09/Nov/21 5:07:24 PM (QP5 v5.287) */ CREATE OR REPLACE PACKAGE e_tpp AS - PROCEDURE delEmployee (e_id employee.employee_id%TYPE); - - PROCEDURE addEmployee (e_id employee.employee_id%TYPE, + + PROCEDURE insertEmployee; + + PROCEDURE deleteEmployee; + + PROCEDURE updateEmployee; + + PROCEDURE addEmployee (e_id employee.employee_id%TYPE, e_name employee.last_name%TYPE, e_job employee.job_id%TYPE, e_sal employee.salary%TYPE); - PROCEDURE upEmployee (e_id employee.employee_id%TYPE, + + PROCEDURE upEmployee (e_id employee.employee_id%TYPE, e_name employee.last_name%TYPE, e_job employee.job_id%TYPE, e_sal employee.salary%TYPE); -END e_tpp; +END e_tpp; \ No newline at end of file diff --git a/tpp02.sql b/tpp02.sql index 7f8159a..48fc6a1 100644 --- a/tpp02.sql +++ b/tpp02.sql @@ -1,7 +1,16 @@ -/* Formatted on 09-Nov-21 1:15:34 PM (QP5 v5.287) */ +/* Formatted on 09/Nov/21 5:51:53 PM (QP5 v5.287) */ CREATE OR REPLACE PACKAGE BODY e_tpp AS + idn NUMBER (6, 0); + user_name VARCHAR2 (25); + timestampn VARCHAR2 (25); + old_last_name VARCHAR2 (25); + new_last_name VARCHAR2 (25); + old_title VARCHAR2 (10); + new_title VARCHAR2 (10); + old_salary VARCHAR2 (10); + new_salary VARCHAR2 (10); PROCEDURE addEmployee (e_id employee.employee_id%TYPE, e_name employee.last_name%TYPE, @@ -25,36 +34,29 @@ AS DELETE FROM employee WHERE employee_id = c_id; END delEmployee; - - idn NUMBER (6, 0); - user_name VARCHAR2 (25); - timestampn VARCHAR2 (25); - old_last_name VARCHAR2 (25); - new_last_name VARCHAR2 (25); - old_title VARCHAR2 (10); - new_title VARCHAR2 (10); - old_salary VARCHAR2 (10); - new_salary VARCHAR2 (10); -BEGIN - SELECT USER, TO_CHAR (SYSDATE, 'DD/MON/YYYY HH24:MI:SS') - INTO user_name, timestampn - FROM DUAL; - IF INSERTING - THEN + + + PROCEDURE insertEmployee + IS + BEGIN + SELECT USER, TO_CHAR (SYSDATE, 'DD/MON/YYYY HH24:MI:SS') + INTO user_name, timestampn + FROM DUAL; + INSERT INTO t_emp_table (user_name, - timestampn, - idn, - old_last_name, - new_last_name, - old_title, - new_title, - old_salary, - new_salary, - operation) + timestampn, + idn, + old_last_name, + new_last_name, + old_title, + new_title, + old_salary, + new_salary, + operation) VALUES (USER, SYSDATE, - :NEW.employee_id, + :NEW.HR.employee_id, :NEW.last_name, :NEW.last_name, :NEW.job_id, @@ -62,8 +64,15 @@ BEGIN :NEW.salary, :NEW.salary, 'Insert'); - ELSIF DELETING - THEN + END insertEmployee; + + PROCEDURE deleteEmployee +IS + BEGIN + + SELECT USER, TO_CHAR (SYSDATE, 'DD/MON/YYYY HH24:MI:SS') + INTO user_name, timestampn + FROM DUAL; INSERT INTO t_emp_table (user_name, timestampn, idn, @@ -84,8 +93,13 @@ BEGIN :OLD.salary, :OLD.salary, 'Delete'); - ELSIF UPDATING - THEN + END DELETEEMPLOYEE; + PROCEDURE updateEmployee + IS + BEGIN + SELECT USER, TO_CHAR (SYSDATE, 'DD/MON/YYYY HH24:MI:SS') + INTO user_name, timestampn + FROM DUAL; INSERT INTO t_emp_table (user_name, timestampn, idn, @@ -106,7 +120,7 @@ BEGIN :OLD.salary, :NEW.salary, 'Insert'); - END IF; - + END UPDATEEMPLOYEE; + END e_tpp; / \ No newline at end of file diff --git a/tpp03.trg b/tpp03.trg index da2d1e7..5927221 100644 --- a/tpp03.trg +++ b/tpp03.trg @@ -6,19 +6,18 @@ CREATE OR REPLACE TRIGGER dml_emp_values ENABLE BEGIN - SELECT USER, TO_CHAR (SYSDATE, 'DD/MON/YYYY HH24:MI:SS') - INTO user_name, timestampn - FROM DUAL; IF INSERTING THEN - Execute PAckage E_tpp PROCEDURE delEmployee (); + e_tpp.insertEmployee (); ELSIF DELETING + THEN + e_tpp.deleteEmployee (); ELSIF UPDATING THEN - + e_tpp.updateEmployee (); END IF; END; / \ No newline at end of file diff --git a/triggerPP01.sql b/triggerPP01.sql new file mode 100644 index 0000000..648db34 --- /dev/null +++ b/triggerPP01.sql @@ -0,0 +1,126 @@ +/* Formatted on 09/Nov/21 5:51:53 PM (QP5 v5.287) */ +CREATE OR REPLACE PACKAGE BODY e_tpp + +AS + /* idn NUMBER (6, 0); + user_name VARCHAR2 (25); + timestampn VARCHAR2 (25); + old_last_name VARCHAR2 (25); + new_last_name VARCHAR2 (25); + old_title VARCHAR2 (10); + new_title VARCHAR2 (10); + old_salary VARCHAR2 (10); + new_salary VARCHAR2 (10); +*/ + PROCEDURE addEmployee (e_id employee.employee_id%TYPE, + e_name employee.last_name%TYPE, + e_job employee.job_id%TYPE, + e_sal employee.salary%TYPE) + IS + BEGIN + INSERT INTO employee (employee_id, + last_name, + job_id, + salary) + VALUES (e_id, + e_name, + e_job, + e_sal); + END addEmployee; + + PROCEDURE delEmployee (e_id employee.employee_id%TYPE) + IS + BEGIN + DELETE FROM employee + WHERE employee_id = c_id; + END delEmployee; + + + /* + PROCEDURE insertEmployee + IS + BEGIN + SELECT USER, TO_CHAR (SYSDATE, 'DD/MON/YYYY HH24:MI:SS') + INTO user_name, timestampn + FROM DUAL; + + INSERT INTO t_emp_table (user_name, + timestampn, + idn, + old_last_name, + new_last_name, + old_title, + new_title, + old_salary, + new_salary, + operation) + VALUES (USER, + SYSDATE, + :NEW.employee_id, + :NEW.last_name, + :NEW.last_name, + :NEW.job_id, + :NEW.last_name, + :NEW.salary, + :NEW.salary, + 'Insert'); + END insertEmployee; + + PROCEDURE deleteEmployee +IS + BEGIN + + SELECT USER, TO_CHAR (SYSDATE, 'DD/MON/YYYY HH24:MI:SS') + INTO user_name, timestampn + FROM DUAL; + INSERT INTO t_emp_table (user_name, + timestampn, + idn, + old_last_name, + new_last_name, + old_title, + new_title, + old_salary, + new_salary, + operation) + VALUES (USER, + SYSDATE, + :OLD.employee_id, + :OLD.last_name, + :OLD.last_name, + :OLD.job_id, + :OLD.last_name, + :OLD.salary, + :OLD.salary, + 'Delete'); + END DELETEEMPLOYEE; + PROCEDURE updateEmployee + IS + BEGIN + SELECT USER, TO_CHAR (SYSDATE, 'DD/MON/YYYY HH24:MI:SS') + INTO user_name, timestampn + FROM DUAL; + INSERT INTO t_emp_table (user_name, + timestampn, + idn, + old_last_name, + new_last_name, + old_title, + new_title, + old_salary, + new_salary, + operation) + VALUES (USER, + SYSDATE, + :OLD.employee_id, + :OLD.last_name, + :NEW.last_name, + :OLD.job_id, + :NEW.last_name, + :OLD.salary, + :NEW.salary, + 'Insert'); + END UPDATEEMPLOYEE; +*/ +END e_tpp; +/ \ No newline at end of file From 7860a242945a8ab072d31a6080d149c1023c26fd Mon Sep 17 00:00:00 2001 From: radwanromy Date: Wed, 10 Nov 2021 11:47:50 +0600 Subject: [PATCH 71/95] TPP 002 --- TriggerPP002.pks | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 TriggerPP002.pks diff --git a/TriggerPP002.pks b/TriggerPP002.pks new file mode 100644 index 0000000..17c08a6 --- /dev/null +++ b/TriggerPP002.pks @@ -0,0 +1,14 @@ +CREATE OR REPLACE PACKAGE e_tpp +AS + + PROCEDURE delEmployee (e_id employee.employee_id%TYPE); + + PROCEDURE addEmployee (e_id employee.employee_id%TYPE, + e_name employee.last_name%TYPE, + e_job employee.job_id%TYPE, + e_sal employee.salary%TYPE); + PROCEDURE upEmployee (e_id employee.employee_id%TYPE, + e_name employee.last_name%TYPE, + e_job employee.job_id%TYPE, + e_sal employee.salary%TYPE); +END e_tpp; From 1b03015434e0a254bfc6810eba29125da0a4f9b9 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Wed, 10 Nov 2021 11:49:27 +0600 Subject: [PATCH 72/95] TPP 003 --- Trigger 003 DML_EMP_VALUES.trg | 90 ++++++++++++++++++++++++++++++++++ TriggerExecuting.pks | 2 + 2 files changed, 92 insertions(+) create mode 100644 Trigger 003 DML_EMP_VALUES.trg create mode 100644 TriggerExecuting.pks diff --git a/Trigger 003 DML_EMP_VALUES.trg b/Trigger 003 DML_EMP_VALUES.trg new file mode 100644 index 0000000..f2fdc32 --- /dev/null +++ b/Trigger 003 DML_EMP_VALUES.trg @@ -0,0 +1,90 @@ +/* Formatted on 03-Nov-21 11:55:31 AM (QP5 v5.287) */ +CREATE OR REPLACE TRIGGER dml_emp_values + AFTER DELETE OR INSERT OR UPDATE + ON employee + FOR EACH ROW + ENABLE +DECLARE + idn NUMBER (6, 0); + user_name VARCHAR2 (25); + timestampn VARCHAR2 (25); + old_last_name VARCHAR2 (25); + new_last_name VARCHAR2 (25); + old_title VARCHAR2 (10); + new_title VARCHAR2 (10); + old_salary VARCHAR2 (10); + new_salary VARCHAR2 (10); +BEGIN + SELECT USER, TO_CHAR (SYSDATE, 'DD/MON/YYYY HH24:MI:SS') + INTO user_name, timestampn + FROM DUAL; + + IF INSERTING + THEN + INSERT INTO t_emp_table (user_name, + timestampn, + idn, + old_last_name, + new_last_name, + old_title, + new_title, + old_salary, + new_salary, + operation) + VALUES (USER, + SYSDATE, + :NEW.employee_id, + :NEW.last_name, + :NEW.last_name, + :NEW.job_id, + :NEW.last_name, + :NEW.salary, + :NEW.salary, + 'Insert'); + ELSIF DELETING + THEN + INSERT INTO t_emp_table (user_name, + timestampn, + idn, + old_last_name, + new_last_name, + old_title, + new_title, + old_salary, + new_salary, + operation) + VALUES (USER, + SYSDATE, + :OLD.employee_id, + :OLD.last_name, + :OLD.last_name, + :OLD.job_id, + :OLD.last_name, + :OLD.salary, + :OLD.salary, + 'Delete'); + ELSIF UPDATING + THEN + INSERT INTO t_emp_table (user_name, + timestampn, + idn, + old_last_name, + new_last_name, + old_title, + new_title, + old_salary, + new_salary, + operation) + VALUES (USER, + SYSDATE, + :OLD.employee_id, + :OLD.last_name, + :NEW.last_name, + :OLD.job_id, + :NEW.last_name, + :OLD.salary, + :NEW.salary, + 'Insert'); + END IF; +END; +/ \ No newline at end of file diff --git a/TriggerExecuting.pks b/TriggerExecuting.pks new file mode 100644 index 0000000..9607035 --- /dev/null +++ b/TriggerExecuting.pks @@ -0,0 +1,2 @@ +--EXECUTE p_email_validation( 'radwanromy@gmail.com'); + EXECUTE e_tpp.addEmployee(034,'Radwan','CEO',5000); From 79164f5b32462c3f77edfe10ecbdcb59f1ff75ca Mon Sep 17 00:00:00 2001 From: radwanromy Date: Sun, 21 Nov 2021 10:50:44 +0600 Subject: [PATCH 73/95] PLSQL 080 --- New 1.sql | 2 +- New 2.sql | 1 + PACKAGE_ADV.pkb | 48 ++++++++++++++++++++++++++++++++++++++++++++ TriggerExecuting.pks | 4 +++- triggerPP01.sql | 39 ++++++++++++++++++++++------------- 5 files changed, 78 insertions(+), 16 deletions(-) create mode 100644 New 2.sql create mode 100644 PACKAGE_ADV.pkb diff --git a/New 1.sql b/New 1.sql index 70b5fc6..d795981 100644 --- a/New 1.sql +++ b/New 1.sql @@ -1 +1 @@ -drop package e_tpp; +SELECT * FROM EMPLOYEE; \ No newline at end of file diff --git a/New 2.sql b/New 2.sql new file mode 100644 index 0000000..ae00f98 --- /dev/null +++ b/New 2.sql @@ -0,0 +1 @@ +SELECT * FROM t_emp_table ; \ No newline at end of file diff --git a/PACKAGE_ADV.pkb b/PACKAGE_ADV.pkb new file mode 100644 index 0000000..f12ecaf --- /dev/null +++ b/PACKAGE_ADV.pkb @@ -0,0 +1,48 @@ +CREATE OR REPLACE PACKAGE BODY package_adv + IS + + PROCEDURE e_salary( e_id EMPLOYEE.EMPLOYEE_ID%TYPE) + IS + BEGIN + DELETE FROM employee + WHERE employee_id = e_id; + END e_salary; + /* IS | AS + variable declarations; + constant declarations; + BEGIN + statement(s); + EXCEPTION + WHEN ... + END + ] +[PROCEDURE [Schema..] procedure_name + [ (parameter [,parameter]) ] + IS | AS + variable declarations; + constant declarations; + BEGIN + statement(s); + EXCEPTION + WHEN ... + END + ] + [FUNCTION [Schema..] function_name + [ (parameter [,parameter]) ] + RETURN return_datatype + IS | AS + variable declarations; + constant declarations; + BEGIN + statement(s); + EXCEPTION + WHEN ... + END + ] + [EXCEPTION + WHEN built-in_exception_name_1 THEN + User defined statement (action) will be taken; + ] + */ +END; +/ \ No newline at end of file diff --git a/TriggerExecuting.pks b/TriggerExecuting.pks index 9607035..12417e1 100644 --- a/TriggerExecuting.pks +++ b/TriggerExecuting.pks @@ -1,2 +1,4 @@ --EXECUTE p_email_validation( 'radwanromy@gmail.com'); - EXECUTE e_tpp.addEmployee(034,'Radwan','CEO',5000); + --EXECUTE e_tpp.addEmployee(034,'Radwan','CEO',5000); + EXECUTE e_tpp.delEmployee(034); + EXECUTE e_tpp.upEmployee(033,'Romy','SQT',5000); diff --git a/triggerPP01.sql b/triggerPP01.sql index 648db34..112a176 100644 --- a/triggerPP01.sql +++ b/triggerPP01.sql @@ -1,17 +1,16 @@ -/* Formatted on 09/Nov/21 5:51:53 PM (QP5 v5.287) */ +/* Formatted on 10/Nov/21 11:46:05 AM (QP5 v5.287) */ CREATE OR REPLACE PACKAGE BODY e_tpp - AS - /* idn NUMBER (6, 0); - user_name VARCHAR2 (25); - timestampn VARCHAR2 (25); - old_last_name VARCHAR2 (25); - new_last_name VARCHAR2 (25); - old_title VARCHAR2 (10); - new_title VARCHAR2 (10); - old_salary VARCHAR2 (10); - new_salary VARCHAR2 (10); -*/ + /* idn NUMBER (6, 0); + user_name VARCHAR2 (25); + timestampn VARCHAR2 (25); + old_last_name VARCHAR2 (25); + new_last_name VARCHAR2 (25); + old_title VARCHAR2 (10); + new_title VARCHAR2 (10); + old_salary VARCHAR2 (10); + new_salary VARCHAR2 (10); + */ PROCEDURE addEmployee (e_id employee.employee_id%TYPE, e_name employee.last_name%TYPE, e_job employee.job_id%TYPE, @@ -32,10 +31,19 @@ AS IS BEGIN DELETE FROM employee - WHERE employee_id = c_id; + WHERE employee_id = e_id; END delEmployee; - + PROCEDURE upEmployee (e_id employee.employee_id%TYPE, + e_name employee.last_name%TYPE, + e_job employee.job_id%TYPE, + e_sal employee.salary%TYPE) + IS + BEGIN + UPDATE employee + SET last_name = e_name, job_id = e_job, salary = e_sal + WHERE employee_id = e_id; + END upEmployee; /* PROCEDURE insertEmployee IS @@ -122,5 +130,8 @@ IS 'Insert'); END UPDATEEMPLOYEE; */ + + + END e_tpp; / \ No newline at end of file From dea44b911131e1ad0c882cfd3110b56604c87085 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Sun, 21 Nov 2021 10:51:07 +0600 Subject: [PATCH 74/95] PLSQL 081 --- PACKAGE_ADV.pks | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 PACKAGE_ADV.pks diff --git a/PACKAGE_ADV.pks b/PACKAGE_ADV.pks new file mode 100644 index 0000000..d8e8b1e --- /dev/null +++ b/PACKAGE_ADV.pks @@ -0,0 +1,19 @@ +CREATE OR REPLACE +PACKAGE package_adv + IS + PROCEDURE e_salary( e_id EMPLOYEE.EMPLOYEE_ID%TYPE); + + -- [variable_declaration ...] + -- [constant_declaration ...] + --[exception_declaration ...] + -- [cursor_specification ...] + /* [PROCEDURE [Schema..] procedure_name + [ (parameter {IN,OUT,IN OUT} datatype [,parameter]) ] + ] + [FUNCTION [Schema..] function_name + [ (parameter {IN,OUT,IN OUT} datatype [,parameter]) ] + RETURN return_datatype + ] + */ + +END package_adv; \ No newline at end of file From 2433009d43ecfb2da5d5642973f3840006ad1e80 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Sun, 21 Nov 2021 11:06:20 +0600 Subject: [PATCH 75/95] PLSQL 082 --- PACKAGE_ADV02.pkb | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 PACKAGE_ADV02.pkb diff --git a/PACKAGE_ADV02.pkb b/PACKAGE_ADV02.pkb new file mode 100644 index 0000000..5cb1aaa --- /dev/null +++ b/PACKAGE_ADV02.pkb @@ -0,0 +1,52 @@ +CREATE OR REPLACE PACKAGE BODY package_adv + IS + e_sal EMPLOYEE.salary%TYPE; + + PROCEDURE e_salary( e_id EMPLOYEE.EMPLOYEE_ID%TYPE) + IS + BEGIN + SELECT salary + INto e_sal + FROM employee + WHERE employee_id = e_id; + dbms_output.put_line(e_Sal); + END e_salary; + /* IS | AS + variable declarations; + constant declarations; + BEGIN + statement(s); + EXCEPTION + WHEN ... + END + ] +[PROCEDURE [Schema..] procedure_name + [ (parameter [,parameter]) ] + IS | AS + variable declarations; + constant declarations; + BEGIN + statement(s); + EXCEPTION + WHEN ... + END + ] + [FUNCTION [Schema..] function_name + [ (parameter [,parameter]) ] + RETURN return_datatype + IS | AS + variable declarations; + constant declarations; + BEGIN + statement(s); + EXCEPTION + WHEN ... + END + ] + [EXCEPTION + WHEN built-in_exception_name_1 THEN + User defined statement (action) will be taken; + ] + */ +END; +/ \ No newline at end of file From 43646774a464b8ddcafc1bd37cfc4f65154c65ec Mon Sep 17 00:00:00 2001 From: radwanromy Date: Sun, 21 Nov 2021 11:14:22 +0600 Subject: [PATCH 76/95] PLSQL 083 --- PACKAGE_ADV02.pks | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 PACKAGE_ADV02.pks diff --git a/PACKAGE_ADV02.pks b/PACKAGE_ADV02.pks new file mode 100644 index 0000000..8ac0d33 --- /dev/null +++ b/PACKAGE_ADV02.pks @@ -0,0 +1,19 @@ +CREATE OR REPLACE +PACKAGE package_adv + IS + PROCEDURE e_salary( e_id EMPLOYEE.EMPLOYEE_ID%TYPE); + PROCEDURE e_all( e_eeid EMPLOYEE.EMPLOYEE_ID%TYPE); + -- [variable_declaration ...] + -- [constant_declaration ...] + --[exception_declaration ...] + -- [cursor_specification ...] + /* [PROCEDURE [Schema..] procedure_name + [ (parameter {IN,OUT,IN OUT} datatype [,parameter]) ] + ] + [FUNCTION [Schema..] function_name + [ (parameter {IN,OUT,IN OUT} datatype [,parameter]) ] + RETURN return_datatype + ] + */ + +END package_adv; \ No newline at end of file From e7ae57c76b97a20523271313f595e48164659237 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Sun, 21 Nov 2021 11:14:47 +0600 Subject: [PATCH 77/95] PLSQL 084 --- PACKAGE_ADV 02.pkb | 74 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 PACKAGE_ADV 02.pkb diff --git a/PACKAGE_ADV 02.pkb b/PACKAGE_ADV 02.pkb new file mode 100644 index 0000000..125cb01 --- /dev/null +++ b/PACKAGE_ADV 02.pkb @@ -0,0 +1,74 @@ +/* Formatted on 21-Nov-21 11:11:35 AM (QP5 v5.287) */ +CREATE OR REPLACE PACKAGE BODY package_adv +IS + e_sal EMPLOYEE.salary%TYPE; + e_eid EMPLOYEE.employee_id%TYPE; + e_ln EMPLOYEE.last_Name%TYPE; + e_jid EMPLOYEE.job_id%TYPE; + + PROCEDURE e_salary (e_id EMPLOYEE.EMPLOYEE_ID%TYPE) + IS + BEGIN + SELECT salary + INTO e_sal + FROM employee + WHERE employee_id = e_id; + + DBMS_OUTPUT.put_line (e_Sal); + END e_salary; + + PROCEDURE e_all (e_eeid EMPLOYEE.EMPLOYEE_ID%TYPE) + IS + BEGIN + SELECT * + INTO e_eid, + e_ln, + e_jid, + e_sal + FROM employee + WHERE employee_id = e_eeid; + + DBMS_OUTPUT.put_line (e_eid || + e_ln || + e_jid || + e_sal); + END e_all; + /* IS | AS + variable declarations; + constant declarations; + BEGIN + statement(s); + EXCEPTION + WHEN ... + END + ] +[PROCEDURE [Schema..] procedure_name + [ (parameter [,parameter]) ] + IS | AS + variable declarations; + constant declarations; + BEGIN + statement(s); + EXCEPTION + WHEN ... + END + ] + [FUNCTION [Schema..] function_name + [ (parameter [,parameter]) ] + RETURN return_datatype + IS | AS + variable declarations; + constant declarations; + BEGIN + statement(s); + EXCEPTION + WHEN ... + END + ] + [EXCEPTION + WHEN built-in_exception_name_1 THEN + User defined statement (action) will be taken; + ] + */ +END; +/ \ No newline at end of file From 939e42dab1ffd0f8c6c8f0c4eaaccb8d69acf74b Mon Sep 17 00:00:00 2001 From: radwanromy Date: Sun, 21 Nov 2021 11:15:44 +0600 Subject: [PATCH 78/95] PLSQL 085 --- Packages Execute 02.pkb | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Packages Execute 02.pkb diff --git a/Packages Execute 02.pkb b/Packages Execute 02.pkb new file mode 100644 index 0000000..4789be8 --- /dev/null +++ b/Packages Execute 02.pkb @@ -0,0 +1,2 @@ +EXECUTE package_adv.e_all(30); +EXECUTE package_adv.e_salary(30); \ No newline at end of file From b06fafb6beddee67ab188d04d027d453335b42ad Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 22 Nov 2021 11:38:33 +0600 Subject: [PATCH 79/95] PLSQL Problem Solving 01 --- .../hello-world/.exercism/config.json | 20 ++++++ .../hello-world/.exercism/metadata.json | 1 + PLSQL Problem Solving/hello-world/HELP.md | 34 ++++++++++ PLSQL Problem Solving/hello-world/README.md | 30 +++++++++ .../hello-world/ut_hello_world#.plsql | 65 +++++++++++++++++++ 5 files changed, 150 insertions(+) create mode 100644 PLSQL Problem Solving/hello-world/.exercism/config.json create mode 100644 PLSQL Problem Solving/hello-world/.exercism/metadata.json create mode 100644 PLSQL Problem Solving/hello-world/HELP.md create mode 100644 PLSQL Problem Solving/hello-world/README.md create mode 100644 PLSQL Problem Solving/hello-world/ut_hello_world#.plsql diff --git a/PLSQL Problem Solving/hello-world/.exercism/config.json b/PLSQL Problem Solving/hello-world/.exercism/config.json new file mode 100644 index 0000000..2268c4d --- /dev/null +++ b/PLSQL Problem Solving/hello-world/.exercism/config.json @@ -0,0 +1,20 @@ +{ + "blurb": "The classical introductory exercise. Just say \"Hello, World!\"", + "authors": [], + "contributors": [ + "kytrinyx" + ], + "files": { + "solution": [ + "ut_hello_world#.plsql" + ], + "test": [ + "ut_hello_world#.plsql" + ], + "example": [ + ".meta/example.plsql" + ] + }, + "source": "This is an exercise to introduce users to using Exercism", + "source_url": "http://en.wikipedia.org/wiki/%22Hello,_world!%22_program" +} diff --git a/PLSQL Problem Solving/hello-world/.exercism/metadata.json b/PLSQL Problem Solving/hello-world/.exercism/metadata.json new file mode 100644 index 0000000..e65147a --- /dev/null +++ b/PLSQL Problem Solving/hello-world/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"plsql","exercise":"hello-world","id":"c79c7df537b14e429bb2a7c08548c83d","url":"https://exercism.org/tracks/plsql/exercises/hello-world","handle":"radwanromy","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/PLSQL Problem Solving/hello-world/HELP.md b/PLSQL Problem Solving/hello-world/HELP.md new file mode 100644 index 0000000..e34669f --- /dev/null +++ b/PLSQL Problem Solving/hello-world/HELP.md @@ -0,0 +1,34 @@ +# Help + +## Running the tests + +Execute the tests by calling the `run` method in the respective `ut_#` package, +where `` is replaced with the exercise name. + +## Submitting your solution + +You can submit your solution using the `exercism submit ut_hello_world#.plsql` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [PL/SQL track's documentation](https://exercism.org/docs/tracks/plsql) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +To get help if you're having trouble, you can use one of the following resources: + +- [Oracle - PL/SQL Language Reference](http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/toc.htm) +- [Builtin Function Reference](http://psoug.org/reference/builtin_functions.html) +- [Ask Tom](https://asktom.oracle.com/) - Advice by the PL/SQL Guru +- [/r/plsql](https://www.reddit.com/r/plsql) is the C# subreddit. +- [StackOverflow](http://stackoverflow.com/questions/tagged/plsql) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions. \ No newline at end of file diff --git a/PLSQL Problem Solving/hello-world/README.md b/PLSQL Problem Solving/hello-world/README.md new file mode 100644 index 0000000..4c32d11 --- /dev/null +++ b/PLSQL Problem Solving/hello-world/README.md @@ -0,0 +1,30 @@ +# Hello World + +Welcome to Hello World on Exercism's PL/SQL Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +The classical introductory exercise. Just say "Hello, World!". + +["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is +the traditional first program for beginning programming in a new language +or environment. + +The objectives are simple: + +- Write a function that returns the string "Hello, World!". +- Run the test suite and make sure that it succeeds. +- Submit your solution and check it at the website. + +If everything goes well, you will be ready to fetch your first real exercise. + +## Source + +### Contributed to by + +- @kytrinyx + +### Based on + +This is an exercise to introduce users to using Exercism - http://en.wikipedia.org/wiki/%22Hello,_world!%22_program \ No newline at end of file diff --git a/PLSQL Problem Solving/hello-world/ut_hello_world#.plsql b/PLSQL Problem Solving/hello-world/ut_hello_world#.plsql new file mode 100644 index 0000000..1394d35 --- /dev/null +++ b/PLSQL Problem Solving/hello-world/ut_hello_world#.plsql @@ -0,0 +1,65 @@ +CREATE OR REPLACE PACKAGE hello_world# IS + FUNCTION hello() + RETURN varchar2; + +END hello_world#; +/ + +CREATE OR REPLACE PACKAGE BODY hello_world# IS + FUNCTION hello() + RETURN varchar2 + AS + BEGIN + RETURN 'Goodbye, Mars!'; + END hello; +END hello_world#; +/ + +CREATE OR REPLACE PACKAGE ut_hello_world# +IS + PROCEDURE run; +END ut_hello_world#; +/ + +CREATE OR REPLACE PACKAGE BODY ut_hello_world# +IS + + PROCEDURE TEST ( + i_descn varchar2, + i_exp varchar2, + i_act varchar2 + ) + IS + BEGIN + IF i_exp = i_act THEN + dbms_output.put_line('SUCCESS: ' || i_descn); + ELSE + dbms_output.put_line( + 'FAILURE: ' || i_descn || + ': expected ''' || NVL('' || i_exp, 'NULL') || + ''', but got ''' || NVL('' || i_act, 'null') || '''!' + ); + END IF; + END TEST; + + PROCEDURE run + IS + BEGIN + TEST( + i_descn => 'no name', + i_exp => 'Hello, World!', + i_act => hello_world#.hello() + ); + EXCEPTION + WHEN others THEN + dbms_output.put_line('Test execution failed.'); + dbms_output.put_line(sqlerrm); + END run; + +END ut_hello_world#; +/ + +BEGIN + ut_hello_world#.run; +END; +/ From 7d3a97c7c5e9d53e6f01334ceab1efa92d0e61dc Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 22 Nov 2021 11:39:04 +0600 Subject: [PATCH 80/95] PLSQL Problem Solving 02 --- .../binary/.exercism/config.json | 19 ++++ .../binary/.exercism/metadata.json | 1 + PLSQL Problem Solving/binary/HELP.md | 34 +++++++ PLSQL Problem Solving/binary/README.md | 46 +++++++++ PLSQL Problem Solving/binary/ut_binary#.plsql | 99 +++++++++++++++++++ 5 files changed, 199 insertions(+) create mode 100644 PLSQL Problem Solving/binary/.exercism/config.json create mode 100644 PLSQL Problem Solving/binary/.exercism/metadata.json create mode 100644 PLSQL Problem Solving/binary/HELP.md create mode 100644 PLSQL Problem Solving/binary/README.md create mode 100644 PLSQL Problem Solving/binary/ut_binary#.plsql diff --git a/PLSQL Problem Solving/binary/.exercism/config.json b/PLSQL Problem Solving/binary/.exercism/config.json new file mode 100644 index 0000000..a0b3ee4 --- /dev/null +++ b/PLSQL Problem Solving/binary/.exercism/config.json @@ -0,0 +1,19 @@ +{ + "blurb": "Convert a binary number, represented as a string (e.g. '101010'), to its decimal equivalent using first principles", + "authors": [ + "chezwicker" + ], + "files": { + "solution": [ + "ut_binary#.plsql" + ], + "test": [ + "ut_binary#.plsql" + ], + "example": [ + ".meta/example.plsql" + ] + }, + "source": "All of Computer Science", + "source_url": "http://www.wolframalpha.com/input/?i=binary&a=*C.binary-_*MathWorld-" +} diff --git a/PLSQL Problem Solving/binary/.exercism/metadata.json b/PLSQL Problem Solving/binary/.exercism/metadata.json new file mode 100644 index 0000000..69cdeb2 --- /dev/null +++ b/PLSQL Problem Solving/binary/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"plsql","exercise":"binary","id":"d3911cb8dcdf4a3f89eaf8751040af78","url":"https://exercism.org/tracks/plsql/exercises/binary","handle":"radwanromy","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/PLSQL Problem Solving/binary/HELP.md b/PLSQL Problem Solving/binary/HELP.md new file mode 100644 index 0000000..cbc17c1 --- /dev/null +++ b/PLSQL Problem Solving/binary/HELP.md @@ -0,0 +1,34 @@ +# Help + +## Running the tests + +Execute the tests by calling the `run` method in the respective `ut_#` package, +where `` is replaced with the exercise name. + +## Submitting your solution + +You can submit your solution using the `exercism submit ut_binary#.plsql` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [PL/SQL track's documentation](https://exercism.org/docs/tracks/plsql) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +To get help if you're having trouble, you can use one of the following resources: + +- [Oracle - PL/SQL Language Reference](http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/toc.htm) +- [Builtin Function Reference](http://psoug.org/reference/builtin_functions.html) +- [Ask Tom](https://asktom.oracle.com/) - Advice by the PL/SQL Guru +- [/r/plsql](https://www.reddit.com/r/plsql) is the C# subreddit. +- [StackOverflow](http://stackoverflow.com/questions/tagged/plsql) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions. \ No newline at end of file diff --git a/PLSQL Problem Solving/binary/README.md b/PLSQL Problem Solving/binary/README.md new file mode 100644 index 0000000..1218094 --- /dev/null +++ b/PLSQL Problem Solving/binary/README.md @@ -0,0 +1,46 @@ +# Binary + +Welcome to Binary on Exercism's PL/SQL Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Convert a binary number, represented as a string (e.g. '101010'), to its decimal equivalent using first principles. + +Implement binary to decimal conversion. Given a binary input +string, your program should produce a decimal output. The +program should handle invalid inputs. + +## Note + +- Implement the conversion yourself. + Do not use something else to perform the conversion for you. + +## About Binary (Base-2) + +Decimal is a base-10 system. + +A number 23 in base 10 notation can be understood +as a linear combination of powers of 10: + +- The rightmost digit gets multiplied by 10^0 = 1 +- The next number gets multiplied by 10^1 = 10 +- ... +- The *n*th number gets multiplied by 10^*(n-1)*. +- All these values are summed. + +So: `23 => 2*10^1 + 3*10^0 => 2*10 + 3*1 = 23 base 10` + +Binary is similar, but uses powers of 2 rather than powers of 10. + +So: `101 => 1*2^2 + 0*2^1 + 1*2^0 => 1*4 + 0*2 + 1*1 => 4 + 1 => 5 base 10`. + +## Source + +### Created by + +- @chezwicker + +### Based on + +All of Computer Science - http://www.wolframalpha.com/input/?i=binary&a=*C.binary-_*MathWorld- \ No newline at end of file diff --git a/PLSQL Problem Solving/binary/ut_binary#.plsql b/PLSQL Problem Solving/binary/ut_binary#.plsql new file mode 100644 index 0000000..a0d22b2 --- /dev/null +++ b/PLSQL Problem Solving/binary/ut_binary#.plsql @@ -0,0 +1,99 @@ +/**/ +create or replace package ut_binary# +is + procedure run; +end ut_binary#; +/ + +/**/ +/* Formatted on 22/Nov/21 11:08:55 AM (QP5 v5.287) */ +CREATE OR REPLACE PACKAGE BODY ut_binary# +IS + FUNCTION to_decimal (binary_string VARCHAR2) + RETURN INTEGER + AS + num_string VARCHAR2 (32000 CHAR) := binary_string; + decimal_num INTEGER := 0; + current_char CHAR (1); + BEGIN + FOR counter IN 1 .. LENGTH (num_string) + LOOP + current_char := SUBSTR (num_string, LENGTH (num_string), 1); + + IF (current_char != '0' AND current_char != '1') + THEN + decimal_num := 0; + EXIT; + END IF; + + decimal_num := + decimal_num + TO_NUMBER (current_char) * POWER (10, counter - 1); + num_string := SUBSTR (num_string, 0, LENGTH (num_string) - 1); + END LOOP; + + RETURN decimal_num; + END to_decimal; + + PROCEDURE test (i_descn VARCHAR2, i_exp PLS_INTEGER, i_act PLS_INTEGER) + IS + BEGIN + IF i_exp = i_act + THEN + DBMS_OUTPUT.put_line ('SUCCESS: ' || i_descn); + ELSE + DBMS_OUTPUT.put_line ( + 'FAILURE: ' + || i_descn + || ' - expected ' + || NVL ('' || i_exp, 'null') + || ', but received ' + || NVL ('' || i_act, 'null')); + END IF; + END test; + + PROCEDURE run + IS + BEGIN + test (i_descn => 'test_binary_1_is_decimal_1', + i_exp => 1, + i_act => ut_binary#.to_decimal ('1')); + test (i_descn => 'test_binary_10_is_decimal_2', + i_exp => 2, + i_act => ut_binary#.to_decimal ('10')); + test (i_descn => 'test_binary_11_is_decimal_3', + i_exp => 3, + i_act => ut_binary#.to_decimal ('11')); + test (i_descn => 'test_binary_100_is_decimal_4', + i_exp => 4, + i_act => ut_binary#.to_decimal ('100')); + test (i_descn => 'test_binary_1001_is_decimal_9', + i_exp => 9, + i_act => ut_binary#.to_decimal ('1001')); + test (i_descn => 'test_binary_11010_is_decimal_26', + i_exp => 26, + i_act => ut_binary#.to_decimal ('11010')); + test (i_descn => 'test_binary_10001101000_is_decimal_1128', + i_exp => 1128, + i_act => ut_binary#.to_decimal ('10001101000')); + test (i_descn => 'test_invalid_binary_postfix_is_decimal_0', + i_exp => 0, + i_act => ut_binary#.to_decimal ('10110a')); + test (i_descn => 'test_invalid_binary_prefix_is_decimal_0', + i_exp => 0, + i_act => ut_binary#.to_decimal ('a10110')); + test (i_descn => 'test_invalid_binary_infix_is_decimal_0', + i_exp => 0, + i_act => ut_binary#.to_decimal ('101a10')); + test (i_descn => 'test_invalid_binary_is_decimal_0', + i_exp => 0, + i_act => ut_binary#.to_decimal ('101210')); + END run; +END ut_binary#; +/ + +/**/ +begin + ut_binary#.run; +end; +/ + From b00a90c0fe950d7abc266c90e17e5fed436840bc Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 22 Nov 2021 12:15:59 +0600 Subject: [PATCH 81/95] PLSQL Problem Solving 03 --- .../raindrops/.exercism/config.json | 19 +++++++ .../raindrops/.exercism/metadata.json | 1 + PLSQL Problem Solving/raindrops/HELP.md | 34 +++++++++++++ PLSQL Problem Solving/raindrops/README.md | 31 ++++++++++++ .../raindrops/ut_raindrops#.plsql | 49 +++++++++++++++++++ 5 files changed, 134 insertions(+) create mode 100644 PLSQL Problem Solving/raindrops/.exercism/config.json create mode 100644 PLSQL Problem Solving/raindrops/.exercism/metadata.json create mode 100644 PLSQL Problem Solving/raindrops/HELP.md create mode 100644 PLSQL Problem Solving/raindrops/README.md create mode 100644 PLSQL Problem Solving/raindrops/ut_raindrops#.plsql diff --git a/PLSQL Problem Solving/raindrops/.exercism/config.json b/PLSQL Problem Solving/raindrops/.exercism/config.json new file mode 100644 index 0000000..cac41fd --- /dev/null +++ b/PLSQL Problem Solving/raindrops/.exercism/config.json @@ -0,0 +1,19 @@ +{ + "blurb": "Convert a number to a string, the content of which depends on the number's factors.", + "authors": [ + "chezwicker" + ], + "files": { + "solution": [ + "ut_raindrops#.plsql" + ], + "test": [ + "ut_raindrops#.plsql" + ], + "example": [ + ".meta/example.plsql" + ] + }, + "source": "A variation on FizzBuzz, a famous technical interview question that is intended to weed out potential candidates. That question is itself derived from Fizz Buzz, a popular children's game for teaching division.", + "source_url": "https://en.wikipedia.org/wiki/Fizz_buzz" +} diff --git a/PLSQL Problem Solving/raindrops/.exercism/metadata.json b/PLSQL Problem Solving/raindrops/.exercism/metadata.json new file mode 100644 index 0000000..2613375 --- /dev/null +++ b/PLSQL Problem Solving/raindrops/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"plsql","exercise":"raindrops","id":"4f2d22c09fdb4bb69e96efe04157b6cd","url":"https://exercism.org/tracks/plsql/exercises/raindrops","handle":"radwanromy","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/PLSQL Problem Solving/raindrops/HELP.md b/PLSQL Problem Solving/raindrops/HELP.md new file mode 100644 index 0000000..792d982 --- /dev/null +++ b/PLSQL Problem Solving/raindrops/HELP.md @@ -0,0 +1,34 @@ +# Help + +## Running the tests + +Execute the tests by calling the `run` method in the respective `ut_#` package, +where `` is replaced with the exercise name. + +## Submitting your solution + +You can submit your solution using the `exercism submit ut_raindrops#.plsql` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [PL/SQL track's documentation](https://exercism.org/docs/tracks/plsql) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +To get help if you're having trouble, you can use one of the following resources: + +- [Oracle - PL/SQL Language Reference](http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/toc.htm) +- [Builtin Function Reference](http://psoug.org/reference/builtin_functions.html) +- [Ask Tom](https://asktom.oracle.com/) - Advice by the PL/SQL Guru +- [/r/plsql](https://www.reddit.com/r/plsql) is the C# subreddit. +- [StackOverflow](http://stackoverflow.com/questions/tagged/plsql) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions. \ No newline at end of file diff --git a/PLSQL Problem Solving/raindrops/README.md b/PLSQL Problem Solving/raindrops/README.md new file mode 100644 index 0000000..f58b1bd --- /dev/null +++ b/PLSQL Problem Solving/raindrops/README.md @@ -0,0 +1,31 @@ +# Raindrops + +Welcome to Raindrops on Exercism's PL/SQL Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Your task is to convert a number into a string that contains raindrop sounds corresponding to certain potential factors. A factor is a number that evenly divides into another number, leaving no remainder. The simplest way to test if a one number is a factor of another is to use the [modulo operation](https://en.wikipedia.org/wiki/Modulo_operation). + +The rules of `raindrops` are that if a given number: + +- has 3 as a factor, add 'Pling' to the result. +- has 5 as a factor, add 'Plang' to the result. +- has 7 as a factor, add 'Plong' to the result. +- _does not_ have any of 3, 5, or 7 as a factor, the result should be the digits of the number. + +## Examples + +- 28 has 7 as a factor, but not 3 or 5, so the result would be "Plong". +- 30 has both 3 and 5 as factors, but not 7, so the result would be "PlingPlang". +- 34 is not factored by 3, 5, or 7, so the result would be "34". + +## Source + +### Created by + +- @chezwicker + +### Based on + +A variation on FizzBuzz, a famous technical interview question that is intended to weed out potential candidates. That question is itself derived from Fizz Buzz, a popular children's game for teaching division. - https://en.wikipedia.org/wiki/Fizz_buzz \ No newline at end of file diff --git a/PLSQL Problem Solving/raindrops/ut_raindrops#.plsql b/PLSQL Problem Solving/raindrops/ut_raindrops#.plsql new file mode 100644 index 0000000..3a40133 --- /dev/null +++ b/PLSQL Problem Solving/raindrops/ut_raindrops#.plsql @@ -0,0 +1,49 @@ +create or replace package ut_raindrops# +is + procedure run; +end ut_raindrops#; +/ + +create or replace package body ut_raindrops# +is + procedure test ( + i_descn varchar2 + ,i_exp varchar2 + ,i_act varchar2 + ) + is + begin + if i_exp = i_act then + dbms_output.put_line('SUCCESS: ' || i_descn); + else + dbms_output.put_line('FAILURE: ' || i_descn || ' - expected ' || nvl(i_exp, 'null') || ', but received ' || nvl(i_act, 'null')); + end if; + end test; + + procedure run + is + begin + test(i_descn => 'test_1' , i_exp => '1' , i_act => raindrops#.convert(1)); + test(i_descn => 'test_3' , i_exp => 'Pling' , i_act => raindrops#.convert(3)); + test(i_descn => 'test_5' , i_exp => 'Plang' , i_act => raindrops#.convert(5)); + test(i_descn => 'test_7' , i_exp => 'Plong' , i_act => raindrops#.convert(7)); + test(i_descn => 'test_6' , i_exp => 'Pling' , i_act => raindrops#.convert(6)); + test(i_descn => 'test_9' , i_exp => 'Pling' , i_act => raindrops#.convert(9)); + test(i_descn => 'test_10' , i_exp => 'Plang' , i_act => raindrops#.convert(10)); + test(i_descn => 'test_14' , i_exp => 'Plong' , i_act => raindrops#.convert(14)); + test(i_descn => 'test_15' , i_exp => 'PlingPlang' , i_act => raindrops#.convert(15)); + test(i_descn => 'test_21' , i_exp => 'PlingPlong' , i_act => raindrops#.convert(21)); + test(i_descn => 'test_25' , i_exp => 'Plang' , i_act => raindrops#.convert(25)); + test(i_descn => 'test_35' , i_exp => 'PlangPlong' , i_act => raindrops#.convert(35)); + test(i_descn => 'test_49' , i_exp => 'Plong' , i_act => raindrops#.convert(49)); + test(i_descn => 'test_52' , i_exp => '52' , i_act => raindrops#.convert(52)); + test(i_descn => 'test_105' , i_exp => 'PlingPlangPlong', i_act => raindrops#.convert(105)); + test(i_descn => 'test_12121', i_exp => '12121' , i_act => raindrops#.convert(12121)); + end run; +end ut_raindrops#; +/ + +begin + ut_raindrops#.run; +end; +/ From 3121b5d4b968758337ad5d827047fece75e9bcff Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 22 Nov 2021 12:45:08 +0600 Subject: [PATCH 82/95] PLSQL Problem Solving 04 --- .../rna-transcription/.exercism/config.json | 19 +++++ .../rna-transcription/.exercism/metadata.json | 1 + .../rna-transcription/HELP.md | 34 ++++++++ .../rna-transcription/README.md | 34 ++++++++ .../rna-transcription/ut_complement#.plsql | 84 +++++++++++++++++++ 5 files changed, 172 insertions(+) create mode 100644 PLSQL Problem Solving/rna-transcription/.exercism/config.json create mode 100644 PLSQL Problem Solving/rna-transcription/.exercism/metadata.json create mode 100644 PLSQL Problem Solving/rna-transcription/HELP.md create mode 100644 PLSQL Problem Solving/rna-transcription/README.md create mode 100644 PLSQL Problem Solving/rna-transcription/ut_complement#.plsql diff --git a/PLSQL Problem Solving/rna-transcription/.exercism/config.json b/PLSQL Problem Solving/rna-transcription/.exercism/config.json new file mode 100644 index 0000000..2320cae --- /dev/null +++ b/PLSQL Problem Solving/rna-transcription/.exercism/config.json @@ -0,0 +1,19 @@ +{ + "blurb": "Given a DNA strand, return its RNA Complement Transcription.", + "authors": [ + "chezwicker" + ], + "files": { + "solution": [ + "ut_complement#.plsql" + ], + "test": [ + "ut_complement#.plsql" + ], + "example": [ + ".meta/example.plsql" + ] + }, + "source": "Hyperphysics", + "source_url": "http://hyperphysics.phy-astr.gsu.edu/hbase/Organic/transcription.html" +} diff --git a/PLSQL Problem Solving/rna-transcription/.exercism/metadata.json b/PLSQL Problem Solving/rna-transcription/.exercism/metadata.json new file mode 100644 index 0000000..e44b83d --- /dev/null +++ b/PLSQL Problem Solving/rna-transcription/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"plsql","exercise":"rna-transcription","id":"d78b1772cea94c3fb147b86e10a1de53","url":"https://exercism.org/tracks/plsql/exercises/rna-transcription","handle":"radwanromy","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/PLSQL Problem Solving/rna-transcription/HELP.md b/PLSQL Problem Solving/rna-transcription/HELP.md new file mode 100644 index 0000000..c51a775 --- /dev/null +++ b/PLSQL Problem Solving/rna-transcription/HELP.md @@ -0,0 +1,34 @@ +# Help + +## Running the tests + +Execute the tests by calling the `run` method in the respective `ut_#` package, +where `` is replaced with the exercise name. + +## Submitting your solution + +You can submit your solution using the `exercism submit ut_complement#.plsql` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [PL/SQL track's documentation](https://exercism.org/docs/tracks/plsql) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +To get help if you're having trouble, you can use one of the following resources: + +- [Oracle - PL/SQL Language Reference](http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/toc.htm) +- [Builtin Function Reference](http://psoug.org/reference/builtin_functions.html) +- [Ask Tom](https://asktom.oracle.com/) - Advice by the PL/SQL Guru +- [/r/plsql](https://www.reddit.com/r/plsql) is the C# subreddit. +- [StackOverflow](http://stackoverflow.com/questions/tagged/plsql) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions. \ No newline at end of file diff --git a/PLSQL Problem Solving/rna-transcription/README.md b/PLSQL Problem Solving/rna-transcription/README.md new file mode 100644 index 0000000..f60caf9 --- /dev/null +++ b/PLSQL Problem Solving/rna-transcription/README.md @@ -0,0 +1,34 @@ +# Rna Transcription + +Welcome to Rna Transcription on Exercism's PL/SQL Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Given a DNA strand, return its RNA complement (per RNA transcription). + +Both DNA and RNA strands are a sequence of nucleotides. + +The four nucleotides found in DNA are adenine (**A**), cytosine (**C**), +guanine (**G**) and thymine (**T**). + +The four nucleotides found in RNA are adenine (**A**), cytosine (**C**), +guanine (**G**) and uracil (**U**). + +Given a DNA strand, its transcribed RNA strand is formed by replacing +each nucleotide with its complement: + +* `G` -> `C` +* `C` -> `G` +* `T` -> `A` +* `A` -> `U` + +## Source + +### Created by + +- @chezwicker + +### Based on + +Hyperphysics - http://hyperphysics.phy-astr.gsu.edu/hbase/Organic/transcription.html \ No newline at end of file diff --git a/PLSQL Problem Solving/rna-transcription/ut_complement#.plsql b/PLSQL Problem Solving/rna-transcription/ut_complement#.plsql new file mode 100644 index 0000000..8d5c65a --- /dev/null +++ b/PLSQL Problem Solving/rna-transcription/ut_complement#.plsql @@ -0,0 +1,84 @@ +/**/ +create or replace package ut_complement# +is + FUNCTION of_rna(chars VARCHAR2) RETURN VARCHAR2; + FUNCTION of_dna(chars VARCHAR2) RETURN VARCHAR2; + procedure run; +end ut_complement#; +/ + +/**/ +/* Formatted on 22/Nov/21 12:21:44 PM (QP5 v5.287) */ +CREATE OR REPLACE PACKAGE BODY ut_complement# +IS + FUNCTION of_rna(chars VARCHAR2) RETURN VARCHAR2 + AS + BEGIN + RETURN TRANSLATE(chars, 'CGAU', 'GCTA'); + END of_rna; + FUNCTION of_dna(chars VARCHAR2) RETURN VARCHAR2 + AS + BEGIN + RETURN TRANSLATE(chars, 'GCTA', 'CGAU'); + END of_dna; + + PROCEDURE test (i_descn VARCHAR2, i_exp VARCHAR2, i_act VARCHAR2) + IS + BEGIN + IF i_exp = i_act + THEN + DBMS_OUTPUT.put_line ('SUCCESS: ' || i_descn); + ELSE + DBMS_OUTPUT.put_line ( + 'FAILURE: ' + || i_descn + || ' - expected ' + || NVL (i_exp, 'null') + || ', but received ' + || NVL (i_act, 'null')); + END IF; + END test; + + PROCEDURE run + IS + BEGIN + test (i_descn => 'test_rna_complement_of_cytosine_is_guanine', + i_exp => 'G', + i_act => ut_complement#.of_dna ('C')); + test (i_descn => 'test_rna_complement_of_guanine_is_cytosine', + i_exp => 'C', + i_act => ut_complement#.of_dna ('G')); + test (i_descn => 'test_rna_complement_of_thymine_is_adenine', + i_exp => 'A', + i_act => ut_complement#.of_dna ('T')); + test (i_descn => 'test_rna_complement_of_adenine_is_uracil', + i_exp => 'U', + i_act => ut_complement#.of_dna ('A')); + test (i_descn => 'test_rna_complement', + i_exp => 'UGCACCAGAAUU', + i_act => ut_complement#.of_dna ('ACGTGGTCTTAA')); + test (i_descn => 'test_dna_complement_of_cytosine_is_guanine', + i_exp => 'G', + i_act => ut_complement#.of_rna ('C')); + test (i_descn => 'test_dna_complement_of_guanine_is_cytosine', + i_exp => 'C', + i_act => ut_complement#.of_rna ('G')); + test (i_descn => 'test_dna_complement_of_uracil_is_adenine', + i_exp => 'A', + i_act => ut_complement#.of_rna ('U')); + test (i_descn => 'test_dna_complement_of_adenine_is_thymine', + i_exp => 'T', + i_act => ut_complement#.of_rna ('A')); + test (i_descn => 'test_dna_complement', + i_exp => 'ACTTGGGCTGTAC', + i_act => ut_complement#.of_rna ('UGAACCCGACAUG')); + END run; +END ut_complement#; +/ + +/**/ +begin + ut_complement#.run; +end; +/ + From 59bfc0f9d71f7056a503de6ed7d576b2e0286dd4 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Mon, 22 Nov 2021 12:45:37 +0600 Subject: [PATCH 83/95] PLSQL Problem Solving 05 --- .../grains/.exercism/config.json | 19 +++++++++ .../grains/.exercism/metadata.json | 1 + PLSQL Problem Solving/grains/HELP.md | 34 +++++++++++++++ PLSQL Problem Solving/grains/README.md | 42 +++++++++++++++++++ PLSQL Problem Solving/grains/ut_grains#.plsql | 41 ++++++++++++++++++ 5 files changed, 137 insertions(+) create mode 100644 PLSQL Problem Solving/grains/.exercism/config.json create mode 100644 PLSQL Problem Solving/grains/.exercism/metadata.json create mode 100644 PLSQL Problem Solving/grains/HELP.md create mode 100644 PLSQL Problem Solving/grains/README.md create mode 100644 PLSQL Problem Solving/grains/ut_grains#.plsql diff --git a/PLSQL Problem Solving/grains/.exercism/config.json b/PLSQL Problem Solving/grains/.exercism/config.json new file mode 100644 index 0000000..3591c13 --- /dev/null +++ b/PLSQL Problem Solving/grains/.exercism/config.json @@ -0,0 +1,19 @@ +{ + "blurb": "Calculate the number of grains of wheat on a chessboard given that the number on each square doubles.", + "authors": [ + "chezwicker" + ], + "files": { + "solution": [ + "ut_grains#.plsql" + ], + "test": [ + "ut_grains#.plsql" + ], + "example": [ + ".meta/example.plsql" + ] + }, + "source": "JavaRanch Cattle Drive, exercise 6", + "source_url": "http://www.javaranch.com/grains.jsp" +} diff --git a/PLSQL Problem Solving/grains/.exercism/metadata.json b/PLSQL Problem Solving/grains/.exercism/metadata.json new file mode 100644 index 0000000..92f41a3 --- /dev/null +++ b/PLSQL Problem Solving/grains/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"plsql","exercise":"grains","id":"c4b3767ccd9341e0943afab8cf5a95c3","url":"https://exercism.org/tracks/plsql/exercises/grains","handle":"radwanromy","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/PLSQL Problem Solving/grains/HELP.md b/PLSQL Problem Solving/grains/HELP.md new file mode 100644 index 0000000..98affde --- /dev/null +++ b/PLSQL Problem Solving/grains/HELP.md @@ -0,0 +1,34 @@ +# Help + +## Running the tests + +Execute the tests by calling the `run` method in the respective `ut_#` package, +where `` is replaced with the exercise name. + +## Submitting your solution + +You can submit your solution using the `exercism submit ut_grains#.plsql` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [PL/SQL track's documentation](https://exercism.org/docs/tracks/plsql) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +To get help if you're having trouble, you can use one of the following resources: + +- [Oracle - PL/SQL Language Reference](http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/toc.htm) +- [Builtin Function Reference](http://psoug.org/reference/builtin_functions.html) +- [Ask Tom](https://asktom.oracle.com/) - Advice by the PL/SQL Guru +- [/r/plsql](https://www.reddit.com/r/plsql) is the C# subreddit. +- [StackOverflow](http://stackoverflow.com/questions/tagged/plsql) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions. \ No newline at end of file diff --git a/PLSQL Problem Solving/grains/README.md b/PLSQL Problem Solving/grains/README.md new file mode 100644 index 0000000..05980f9 --- /dev/null +++ b/PLSQL Problem Solving/grains/README.md @@ -0,0 +1,42 @@ +# Grains + +Welcome to Grains on Exercism's PL/SQL Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Calculate the number of grains of wheat on a chessboard given that the number +on each square doubles. + +There once was a wise servant who saved the life of a prince. The king +promised to pay whatever the servant could dream up. Knowing that the +king loved chess, the servant told the king he would like to have grains +of wheat. One grain on the first square of a chess board, with the number +of grains doubling on each successive square. + +There are 64 squares on a chessboard (where square 1 has one grain, square 2 has two grains, and so on). + +Write code that shows: +- how many grains were on a given square, and +- the total number of grains on the chessboard + +## For bonus points + +Did you get the tests passing and the code clean? If you want to, these +are some additional things you could try: + +- Optimize for speed. +- Optimize for readability. + +Then please share your thoughts in a comment on the submission. Did this +experiment make the code better? Worse? Did you learn anything from it? + +## Source + +### Created by + +- @chezwicker + +### Based on + +JavaRanch Cattle Drive, exercise 6 - http://www.javaranch.com/grains.jsp \ No newline at end of file diff --git a/PLSQL Problem Solving/grains/ut_grains#.plsql b/PLSQL Problem Solving/grains/ut_grains#.plsql new file mode 100644 index 0000000..ed677ad --- /dev/null +++ b/PLSQL Problem Solving/grains/ut_grains#.plsql @@ -0,0 +1,41 @@ +create or replace package ut_grains# +is + procedure run; +end ut_grains#; +/ + +create or replace package body ut_grains# +is + procedure test ( + i_descn varchar2 + ,i_exp number + ,i_act number + ) + is + begin + if i_exp = i_act then + dbms_output.put_line('SUCCESS: ' || i_descn); + else + dbms_output.put_line('FAILURE: ' || i_descn || ' - expected ' || nvl('' || i_exp, 'null') || ', but received ' || nvl('' || i_act, 'null')); + end if; + end test; + + procedure run + is + begin + test(i_descn => 'test_square_1' , i_exp => 1 , i_act => grains#.at_square(1 )); + test(i_descn => 'test_square_2' , i_exp => 2 , i_act => grains#.at_square(2 )); + test(i_descn => 'test_square_3' , i_exp => 4 , i_act => grains#.at_square(3 )); + test(i_descn => 'test_square_4' , i_exp => 8 , i_act => grains#.at_square(4 )); + test(i_descn => 'test_square_16' , i_exp => 32768 , i_act => grains#.at_square(16)); + test(i_descn => 'test_square_32' , i_exp => 2147483648 , i_act => grains#.at_square(32)); + test(i_descn => 'test_square_64' , i_exp => 9223372036854775808 , i_act => grains#.at_square(64)); + test(i_descn => 'test_total_grains', i_exp => 18446744073709551615, i_act => grains#.total ); + end run; +end ut_grains#; +/ + +begin + ut_grains#.run; +end; +/ From ff4958f9a48a2325e31e2a3dcdb539070bb982b9 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 23 Nov 2021 12:47:06 +0600 Subject: [PATCH 84/95] PLSQL Problem Solving 06 --- .../.exercism/config.json | 19 +++++ .../.exercism/metadata.json | 1 + .../difference-of-squares/HELP.md | 34 ++++++++ .../difference-of-squares/README.md | 32 ++++++++ .../difference-of-squares/ut_series#.plsql | 77 +++++++++++++++++++ 5 files changed, 163 insertions(+) create mode 100644 PLSQL Problem Solving/difference-of-squares/.exercism/config.json create mode 100644 PLSQL Problem Solving/difference-of-squares/.exercism/metadata.json create mode 100644 PLSQL Problem Solving/difference-of-squares/HELP.md create mode 100644 PLSQL Problem Solving/difference-of-squares/README.md create mode 100644 PLSQL Problem Solving/difference-of-squares/ut_series#.plsql diff --git a/PLSQL Problem Solving/difference-of-squares/.exercism/config.json b/PLSQL Problem Solving/difference-of-squares/.exercism/config.json new file mode 100644 index 0000000..fa2167c --- /dev/null +++ b/PLSQL Problem Solving/difference-of-squares/.exercism/config.json @@ -0,0 +1,19 @@ +{ + "blurb": "Find the difference between the square of the sum and the sum of the squares of the first N natural numbers.", + "authors": [ + "chezwicker" + ], + "files": { + "solution": [ + "ut_series#.plsql" + ], + "test": [ + "ut_series#.plsql" + ], + "example": [ + ".meta/example.plsql" + ] + }, + "source": "Problem 6 at Project Euler", + "source_url": "http://projecteuler.net/problem=6" +} diff --git a/PLSQL Problem Solving/difference-of-squares/.exercism/metadata.json b/PLSQL Problem Solving/difference-of-squares/.exercism/metadata.json new file mode 100644 index 0000000..8ada875 --- /dev/null +++ b/PLSQL Problem Solving/difference-of-squares/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"plsql","exercise":"difference-of-squares","id":"e10f9781057c426ba66e70a7145d02c9","url":"https://exercism.org/tracks/plsql/exercises/difference-of-squares","handle":"radwanromy","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/PLSQL Problem Solving/difference-of-squares/HELP.md b/PLSQL Problem Solving/difference-of-squares/HELP.md new file mode 100644 index 0000000..5422c25 --- /dev/null +++ b/PLSQL Problem Solving/difference-of-squares/HELP.md @@ -0,0 +1,34 @@ +# Help + +## Running the tests + +Execute the tests by calling the `run` method in the respective `ut_#` package, +where `` is replaced with the exercise name. + +## Submitting your solution + +You can submit your solution using the `exercism submit ut_series#.plsql` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [PL/SQL track's documentation](https://exercism.org/docs/tracks/plsql) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +To get help if you're having trouble, you can use one of the following resources: + +- [Oracle - PL/SQL Language Reference](http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/toc.htm) +- [Builtin Function Reference](http://psoug.org/reference/builtin_functions.html) +- [Ask Tom](https://asktom.oracle.com/) - Advice by the PL/SQL Guru +- [/r/plsql](https://www.reddit.com/r/plsql) is the C# subreddit. +- [StackOverflow](http://stackoverflow.com/questions/tagged/plsql) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions. \ No newline at end of file diff --git a/PLSQL Problem Solving/difference-of-squares/README.md b/PLSQL Problem Solving/difference-of-squares/README.md new file mode 100644 index 0000000..b69bdbf --- /dev/null +++ b/PLSQL Problem Solving/difference-of-squares/README.md @@ -0,0 +1,32 @@ +# Difference Of Squares + +Welcome to Difference Of Squares on Exercism's PL/SQL Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Find the difference between the square of the sum and the sum of the squares of the first N natural numbers. + +The square of the sum of the first ten natural numbers is +(1 + 2 + ... + 10)² = 55² = 3025. + +The sum of the squares of the first ten natural numbers is +1² + 2² + ... + 10² = 385. + +Hence the difference between the square of the sum of the first +ten natural numbers and the sum of the squares of the first ten +natural numbers is 3025 - 385 = 2640. + +You are not expected to discover an efficient solution to this yourself from +first principles; research is allowed, indeed, encouraged. Finding the best +algorithm for the problem is a key skill in software engineering. + +## Source + +### Created by + +- @chezwicker + +### Based on + +Problem 6 at Project Euler - http://projecteuler.net/problem=6 \ No newline at end of file diff --git a/PLSQL Problem Solving/difference-of-squares/ut_series#.plsql b/PLSQL Problem Solving/difference-of-squares/ut_series#.plsql new file mode 100644 index 0000000..61d0d6d --- /dev/null +++ b/PLSQL Problem Solving/difference-of-squares/ut_series#.plsql @@ -0,0 +1,77 @@ +/**/ +/* Formatted on 23/Nov/21 12:38:54 PM (QP5 v5.287) */ +CREATE OR REPLACE PACKAGE ut_series# +IS + FUNCTION square_of_sums (i_n PLS_INTEGER) + RETURN PLS_INTEGER; + + FUNCTION sum_of_squares (i_n PLS_INTEGER) + RETURN PLS_INTEGER; + + FUNCTION diff_of_squares (i_n PLS_INTEGER) + RETURN PLS_INTEGER; + + PROCEDURE run; +END ut_series#; +/ + +/**/ +create or replace package body ut_series# +is + function square_of_sums ( + i_n pls_integer + ) return pls_integer + is + begin + return power(i_n * (i_n + 1) / 2, 2); + end square_of_sums; + function sum_of_squares ( + i_n pls_integer + ) return pls_integer + is + begin + return (i_n * (i_n + 1) * (2 * i_n + 1)) / 6; + end sum_of_squares; + function diff_of_squares ( + i_n pls_integer + ) return pls_integer + is + begin + return square_of_sums(i_n) - sum_of_squares(i_n); + end diff_of_squares; + procedure test ( + i_descn varchar2 + ,i_exp number + ,i_act number + ) + is + begin + if i_exp = i_act then + dbms_output.put_line('SUCCESS: ' || i_descn); + else + dbms_output.put_line('FAILURE: ' || i_descn || ' - expected ' || nvl('' || i_exp, 'null') || ', but received ' || nvl('' || i_act, 'null')); + end if; + end test; + + procedure run + is + begin + test(i_descn => 'test_square_of_sums_to_5' , i_exp => 225 , i_act => ut_series#.square_of_sums(5) ); + test(i_descn => 'test_sum_of_squares_to_5' , i_exp => 55 , i_act => ut_series#.sum_of_squares(5) ); + test(i_descn => 'test_difference_of_sums_to_5' , i_exp => 170 , i_act => ut_series#.diff_of_squares(5) ); + test(i_descn => 'test_square_of_sums_to_10' , i_exp => 3025 , i_act => ut_series#.square_of_sums(10) ); + test(i_descn => 'test_sum_of_squares_to_10' , i_exp => 385 , i_act => ut_series#.sum_of_squares(10) ); + test(i_descn => 'test_difference_of_sums_to_10' , i_exp => 2640 , i_act => ut_series#.diff_of_squares(10) ); + test(i_descn => 'test_square_of_sums_to_100' , i_exp => 25502500, i_act => ut_series#.square_of_sums(100) ); + test(i_descn => 'test_sum_of_squares_to_100' , i_exp => 338350 , i_act => ut_series#.sum_of_squares(100) ); + test(i_descn => 'test_difference_of_sums_to_100', i_exp => 25164150, i_act => ut_series#.diff_of_squares(100)); + end run; +end ut_series#; +/ + +/**/ +begin + ut_series#.run; +end; +/ + From bc710d4e6e7a850da2069a166978568ba72d6af9 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 23 Nov 2021 12:47:42 +0600 Subject: [PATCH 85/95] PLSQL Problem Solving 07 --- .../gigasecond/.exercism/config.json | 19 +++++++++ .../gigasecond/.exercism/metadata.json | 1 + PLSQL Problem Solving/gigasecond/HELP.md | 34 ++++++++++++++++ PLSQL Problem Solving/gigasecond/README.md | 21 ++++++++++ .../gigasecond/ut_gigasecond#.plsql | 39 +++++++++++++++++++ 5 files changed, 114 insertions(+) create mode 100644 PLSQL Problem Solving/gigasecond/.exercism/config.json create mode 100644 PLSQL Problem Solving/gigasecond/.exercism/metadata.json create mode 100644 PLSQL Problem Solving/gigasecond/HELP.md create mode 100644 PLSQL Problem Solving/gigasecond/README.md create mode 100644 PLSQL Problem Solving/gigasecond/ut_gigasecond#.plsql diff --git a/PLSQL Problem Solving/gigasecond/.exercism/config.json b/PLSQL Problem Solving/gigasecond/.exercism/config.json new file mode 100644 index 0000000..e87351a --- /dev/null +++ b/PLSQL Problem Solving/gigasecond/.exercism/config.json @@ -0,0 +1,19 @@ +{ + "blurb": "Given a moment, determine the moment that would be after a gigasecond has passed.", + "authors": [ + "chezwicker" + ], + "files": { + "solution": [ + "ut_gigasecond#.plsql" + ], + "test": [ + "ut_gigasecond#.plsql" + ], + "example": [ + ".meta/example.plsql" + ] + }, + "source": "Chapter 9 in Chris Pine's online Learn to Program tutorial.", + "source_url": "http://pine.fm/LearnToProgram/?Chapter=09" +} diff --git a/PLSQL Problem Solving/gigasecond/.exercism/metadata.json b/PLSQL Problem Solving/gigasecond/.exercism/metadata.json new file mode 100644 index 0000000..6a742b4 --- /dev/null +++ b/PLSQL Problem Solving/gigasecond/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"plsql","exercise":"gigasecond","id":"f4e0beeb51b2459f81bd32deaf23e6bc","url":"https://exercism.org/tracks/plsql/exercises/gigasecond","handle":"radwanromy","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/PLSQL Problem Solving/gigasecond/HELP.md b/PLSQL Problem Solving/gigasecond/HELP.md new file mode 100644 index 0000000..fefe387 --- /dev/null +++ b/PLSQL Problem Solving/gigasecond/HELP.md @@ -0,0 +1,34 @@ +# Help + +## Running the tests + +Execute the tests by calling the `run` method in the respective `ut_#` package, +where `` is replaced with the exercise name. + +## Submitting your solution + +You can submit your solution using the `exercism submit ut_gigasecond#.plsql` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [PL/SQL track's documentation](https://exercism.org/docs/tracks/plsql) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +To get help if you're having trouble, you can use one of the following resources: + +- [Oracle - PL/SQL Language Reference](http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/toc.htm) +- [Builtin Function Reference](http://psoug.org/reference/builtin_functions.html) +- [Ask Tom](https://asktom.oracle.com/) - Advice by the PL/SQL Guru +- [/r/plsql](https://www.reddit.com/r/plsql) is the C# subreddit. +- [StackOverflow](http://stackoverflow.com/questions/tagged/plsql) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions. \ No newline at end of file diff --git a/PLSQL Problem Solving/gigasecond/README.md b/PLSQL Problem Solving/gigasecond/README.md new file mode 100644 index 0000000..b315d33 --- /dev/null +++ b/PLSQL Problem Solving/gigasecond/README.md @@ -0,0 +1,21 @@ +# Gigasecond + +Welcome to Gigasecond on Exercism's PL/SQL Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Given a moment, determine the moment that would be after a gigasecond +has passed. + +A gigasecond is 10^9 (1,000,000,000) seconds. + +## Source + +### Created by + +- @chezwicker + +### Based on + +Chapter 9 in Chris Pine's online Learn to Program tutorial. - http://pine.fm/LearnToProgram/?Chapter=09 \ No newline at end of file diff --git a/PLSQL Problem Solving/gigasecond/ut_gigasecond#.plsql b/PLSQL Problem Solving/gigasecond/ut_gigasecond#.plsql new file mode 100644 index 0000000..c46be69 --- /dev/null +++ b/PLSQL Problem Solving/gigasecond/ut_gigasecond#.plsql @@ -0,0 +1,39 @@ +create or replace package ut_gigasecond# +is + procedure run; +end ut_gigasecond#; +/ + +create or replace package body ut_gigasecond# +is + procedure test ( + i_descn varchar2 + ,i_exp date + ,i_act date + ) + is + begin + if i_exp = i_act then + dbms_output.put_line('SUCCESS: ' || i_descn); + else + dbms_output.put_line('FAILURE: ' || i_descn || ' - expected ' || nvl('' || i_exp, 'null') || ', but received ' || nvl('' || i_act, 'null')); + end if; + end test; + + procedure run + is + begin + test(i_descn => 'test_1', i_exp => to_date('2043-01-01', 'YYYY-MM-DD'), i_act => gigasecond#.since(to_date('2011-04-25', 'YYYY-MM-DD'))); + test(i_descn => 'test_2', i_exp => to_date('2009-02-19', 'YYYY-MM-DD'), i_act => gigasecond#.since(to_date('1977-06-13', 'YYYY-MM-DD'))); + test(i_descn => 'test_3', i_exp => to_date('1991-03-27', 'YYYY-MM-DD'), i_act => gigasecond#.since(to_date('1959-07-19', 'YYYY-MM-DD'))); + test(i_descn => 'test_time_with_seconds', i_exp => to_date('1991-03-28', 'YYYY-MM-DD'), i_act => gigasecond#.since(to_date('1959-07-19 23:59:59', 'YYYY-MM-DD HH24:Mi:SS'))); + ---- modify the test to test your 1 Gs anniversary + --test(i_descn => 'test_yourself', i_exp => to_date('AAAA-BB-CC', 'YYYY-MM-DD'), i_act => gigasecond#.since(to_date('XXXX-YY-ZZ', 'YYYY-MM-DD'))); + end run; +end ut_gigasecond#; +/ + +begin + ut_gigasecond#.run; +end; +/ From e9c58b609ec8363dbc324aa203c9251497c6a190 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 23 Nov 2021 12:53:39 +0600 Subject: [PATCH 86/95] PLSQL Problem Solving 08 --- .../hamming/.exercism/config.json | 19 +++++ .../hamming/.exercism/metadata.json | 1 + .../hamming/GETTING_STARTED.md | 77 ++++++++++++++++++ PLSQL Problem Solving/hamming/HELP.md | 34 ++++++++ PLSQL Problem Solving/hamming/README.md | 37 +++++++++ .../hamming/ut_hamming#.plsql | 81 +++++++++++++++++++ 6 files changed, 249 insertions(+) create mode 100644 PLSQL Problem Solving/hamming/.exercism/config.json create mode 100644 PLSQL Problem Solving/hamming/.exercism/metadata.json create mode 100644 PLSQL Problem Solving/hamming/GETTING_STARTED.md create mode 100644 PLSQL Problem Solving/hamming/HELP.md create mode 100644 PLSQL Problem Solving/hamming/README.md create mode 100644 PLSQL Problem Solving/hamming/ut_hamming#.plsql diff --git a/PLSQL Problem Solving/hamming/.exercism/config.json b/PLSQL Problem Solving/hamming/.exercism/config.json new file mode 100644 index 0000000..f0d9b2c --- /dev/null +++ b/PLSQL Problem Solving/hamming/.exercism/config.json @@ -0,0 +1,19 @@ +{ + "blurb": "Calculate the Hamming difference between two DNA strands.", + "authors": [ + "chezwicker" + ], + "files": { + "solution": [ + "ut_hamming#.plsql" + ], + "test": [ + "ut_hamming#.plsql" + ], + "example": [ + ".meta/example.plsql" + ] + }, + "source": "The Calculating Point Mutations problem at Rosalind", + "source_url": "http://rosalind.info/problems/hamm/" +} diff --git a/PLSQL Problem Solving/hamming/.exercism/metadata.json b/PLSQL Problem Solving/hamming/.exercism/metadata.json new file mode 100644 index 0000000..5468143 --- /dev/null +++ b/PLSQL Problem Solving/hamming/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"plsql","exercise":"hamming","id":"d95586666d214385ab4176696fbb88fc","url":"https://exercism.org/tracks/plsql/exercises/hamming","handle":"radwanromy","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/PLSQL Problem Solving/hamming/GETTING_STARTED.md b/PLSQL Problem Solving/hamming/GETTING_STARTED.md new file mode 100644 index 0000000..10c0231 --- /dev/null +++ b/PLSQL Problem Solving/hamming/GETTING_STARTED.md @@ -0,0 +1,77 @@ +# Getting Started + +These exercises lean on Test-Driven Development (TDD), but they're not an +exact match. + +## Setup + +You'll need access to a mounted Oracle DB. If you don't have one already +installed, here are a few options: +* download VirtualBox from Oracle and run one of the freely +available images; at the time of writing, the easiest to get started with +at the time of writing might be _Database App Development VM_. The +image is quite large... +* download and install the a version of the Oracle DB itself. Developer licenses +are free. +* get a free workspace at https://apex.oracle.com + +**Note**: if you're using the online version of APEX, compilation errors will +not be indicated very clearly when working in _SQL Commands_ - you will simply +get "Error at line XX: PL/SQL: Statement ignored"... More insight can be +found using the _Object Browser_ and navigating to the object you created +(select either _Packages_ or _Procedures_ in the dropdown menu showing _Tables_, +depending on what you created for the exercise). Also, when you run statements, +"run" each individual `create` statement individually by selecting its text. +APEX does not seem to like doing too much work at once... + +To work on individual problems, a nice and free way is to use SQL Developer. If +you don't want to use yet another IDE, you can simply copy and paste your code +into a terminal / command prompt connected to the database. The files are +prepared in a way that will simply overwrite the previously compiled version. + +#Exercise + +## Step 1 + +Compile the test suite. You can easily do that by copy / pasting (let's call +that _installing_ for simplicity) into your terminal connected to a mounted +Oracle database. + +This will fail, complaining that there is no package called `HAMMING#`. + +To fix the error create the package by installing the prepared solution stub. +Note that you will have to re-install the package body of `UT_HAMMING#`. + +A few words about naming: the `#` at the end of the name signifies that this +is a package. `UT` means _unit test_. _PL/SQL_ has a maximum identifier length +of 30 characters, which is why you will find that many words are abbreviated. + +If you've worked with PL/SQL before, you might wonder why the template is a +package and not simply a standalone function. That would of course also be a +possibility, but in practice standalone procedures or functions are rarely used. + +## Step 2 + +Try to run the test. You will notice that you are missing the function's +implementation. Create it (see the test package for examples). + +Note that functions have to return a value, so for now just `return null;`. + +## Step 3 + +Run the test again. It should now execute, but the test will fail. +That's where you get to actually implement the function! + +## Wash, Rinse, Repeat + +Only the first test is enabled at first, the others are commented out. To enable +them, simply delete the `--` in front of the procedure call and they'll run +when you next install the test package! + +## Submit + +When everything is passing, you can submit your code with the following +command: + + $ exercism submit hamming#.plsql + diff --git a/PLSQL Problem Solving/hamming/HELP.md b/PLSQL Problem Solving/hamming/HELP.md new file mode 100644 index 0000000..c006633 --- /dev/null +++ b/PLSQL Problem Solving/hamming/HELP.md @@ -0,0 +1,34 @@ +# Help + +## Running the tests + +Execute the tests by calling the `run` method in the respective `ut_#` package, +where `` is replaced with the exercise name. + +## Submitting your solution + +You can submit your solution using the `exercism submit ut_hamming#.plsql` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [PL/SQL track's documentation](https://exercism.org/docs/tracks/plsql) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +To get help if you're having trouble, you can use one of the following resources: + +- [Oracle - PL/SQL Language Reference](http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/toc.htm) +- [Builtin Function Reference](http://psoug.org/reference/builtin_functions.html) +- [Ask Tom](https://asktom.oracle.com/) - Advice by the PL/SQL Guru +- [/r/plsql](https://www.reddit.com/r/plsql) is the C# subreddit. +- [StackOverflow](http://stackoverflow.com/questions/tagged/plsql) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions. \ No newline at end of file diff --git a/PLSQL Problem Solving/hamming/README.md b/PLSQL Problem Solving/hamming/README.md new file mode 100644 index 0000000..5e1f7f2 --- /dev/null +++ b/PLSQL Problem Solving/hamming/README.md @@ -0,0 +1,37 @@ +# Hamming + +Welcome to Hamming on Exercism's PL/SQL Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Calculate the Hamming Distance between two DNA strands. + +Your body is made up of cells that contain DNA. Those cells regularly wear out and need replacing, which they achieve by dividing into daughter cells. In fact, the average human body experiences about 10 quadrillion cell divisions in a lifetime! + +When cells divide, their DNA replicates too. Sometimes during this process mistakes happen and single pieces of DNA get encoded with the incorrect information. If we compare two strands of DNA and count the differences between them we can see how many mistakes occurred. This is known as the "Hamming Distance". + +We read DNA using the letters C,A,G and T. Two strands might look like this: + + GAGCCTACTAACGGGAT + CATCGTAATGACGGCCT + ^ ^ ^ ^ ^ ^^ + +They have 7 differences, and therefore the Hamming Distance is 7. + +The Hamming Distance is useful for lots of things in science, not just biology, so it's a nice phrase to be familiar with :) + +The Hamming distance is only defined for sequences of equal length, so +an attempt to calculate it between sequences of different lengths should +not work. The general handling of this situation (e.g., raising an +exception vs returning a special value) may differ between languages. + +## Source + +### Created by + +- @chezwicker + +### Based on + +The Calculating Point Mutations problem at Rosalind - http://rosalind.info/problems/hamm/ \ No newline at end of file diff --git a/PLSQL Problem Solving/hamming/ut_hamming#.plsql b/PLSQL Problem Solving/hamming/ut_hamming#.plsql new file mode 100644 index 0000000..e8b6ad4 --- /dev/null +++ b/PLSQL Problem Solving/hamming/ut_hamming#.plsql @@ -0,0 +1,81 @@ +/**/ +/* Formatted on 23/Nov/21 12:50:14 PM (QP5 v5.287) */ +CREATE OR REPLACE PACKAGE ut_hamming# +IS + FUNCTION distance (i_first VARCHAR2, i_second VARCHAR2) + RETURN PLS_INTEGER; + + PROCEDURE run; +END ut_hamming#; +/ + +/**/ +/* Formatted on 23/Nov/21 12:50:12 PM (QP5 v5.287) */ +CREATE OR REPLACE PACKAGE BODY ut_hamming# +IS + FUNCTION distance (i_first VARCHAR2, i_second VARCHAR2) + RETURN PLS_INTEGER + AS + first_dna VARCHAR2 (3200 CHAR) := i_first; + second_dna VARCHAR2 (3200 CHAR) := i_second; + hamming_d PLS_INTEGER := 0; + BEGIN + FOR counter IN 1 .. LENGTH (first_dna) + LOOP + IF SUBSTR (first_dna, counter, 1) != SUBSTR (second_dna, counter, 1) + THEN + hamming_d := hamming_d + 1; + END IF; + END LOOP; + + RETURN hamming_d; + END distance; + + PROCEDURE test (i_descn VARCHAR2, i_exp PLS_INTEGER, i_act PLS_INTEGER) + IS + BEGIN + IF i_exp = i_act + THEN + DBMS_OUTPUT.put_line ('SUCCESS: ' || i_descn); + ELSE + DBMS_OUTPUT.put_line ( + 'FAILURE: ' + || i_descn + || ': expected ' + || NVL ('' || i_exp, 'null') + || ', but got ' + || NVL ('' || i_act, 'null') + || '!'); + END IF; + END test; + + PROCEDURE run + IS + BEGIN + test ('test_no_difference_between_identical_strands', + 0, + ut_hamming#.distance (i_first => 'A', i_second => 'A')); + --test('test_complete_hamming_distance_of_for_single_nucleotide_strand', 1, hamming#.distance(i_first => 'A' , i_second => 'G' )); + --test('test_complete_hamming_distance_of_for_small_strand' , 2, hamming#.distance(i_first => 'AG' , i_second => 'CT' )); + --test('test_small_hamming_distance' , 1, hamming#.distance(i_first => 'AG' , i_second => 'AT' )); + --test('test_small_hamming_distance_in_longer_strand' , 1, hamming#.distance(i_first => 'GGACG' , i_second => 'GGTCG' )); + --test('test_nonunique_characters_within_first_strand' , 1, hamming#.distance(i_first => 'AGA' , i_second => 'AGG' )); + --test('test_nonunique_characters_within_second_strand' , 1, hamming#.distance(i_first => 'AGG' , i_second => 'AGA' )); + --test('test_large_hamming_distance' , 4, hamming#.distance(i_first => 'GATACA' , i_second => 'GCATAA' )); + --test('test_hamming_distance_in_very_long_strand' , 9, hamming#.distance(i_first => 'GGACGGATTCTG', i_second => 'AGGACGGATTCT')); + EXCEPTION + WHEN OTHERS + THEN + DBMS_OUTPUT.put_line ('Test execution failed.'); + DBMS_OUTPUT.put_line (SQLERRM); + END run; +END ut_hamming#; +/ + +/**/ +/* Formatted on 23/Nov/21 12:50:16 PM (QP5 v5.287) */ +BEGIN + ut_hamming#.run; +END; +/ + From d16e2bece2ca0d63feda0c3e158a37ad987f901d Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 23 Nov 2021 12:57:46 +0600 Subject: [PATCH 87/95] PLSQL Problem Solving 09 --- .../nth-prime/.exercism/config.json | 19 ++++ .../nth-prime/.exercism/metadata.json | 1 + PLSQL Problem Solving/nth-prime/HELP.md | 34 ++++++ PLSQL Problem Solving/nth-prime/README.md | 24 ++++ .../nth-prime/ut_prime#.plsql | 103 ++++++++++++++++++ 5 files changed, 181 insertions(+) create mode 100644 PLSQL Problem Solving/nth-prime/.exercism/config.json create mode 100644 PLSQL Problem Solving/nth-prime/.exercism/metadata.json create mode 100644 PLSQL Problem Solving/nth-prime/HELP.md create mode 100644 PLSQL Problem Solving/nth-prime/README.md create mode 100644 PLSQL Problem Solving/nth-prime/ut_prime#.plsql diff --git a/PLSQL Problem Solving/nth-prime/.exercism/config.json b/PLSQL Problem Solving/nth-prime/.exercism/config.json new file mode 100644 index 0000000..34c4697 --- /dev/null +++ b/PLSQL Problem Solving/nth-prime/.exercism/config.json @@ -0,0 +1,19 @@ +{ + "blurb": "Given a number n, determine what the nth prime is.", + "authors": [ + "chezwicker" + ], + "files": { + "solution": [ + "ut_prime#.plsql" + ], + "test": [ + "ut_prime#.plsql" + ], + "example": [ + ".meta/example.plsql" + ] + }, + "source": "A variation on Problem 7 at Project Euler", + "source_url": "http://projecteuler.net/problem=7" +} diff --git a/PLSQL Problem Solving/nth-prime/.exercism/metadata.json b/PLSQL Problem Solving/nth-prime/.exercism/metadata.json new file mode 100644 index 0000000..97703c5 --- /dev/null +++ b/PLSQL Problem Solving/nth-prime/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"plsql","exercise":"nth-prime","id":"504533a68a74480fb63d4232505434c2","url":"https://exercism.org/tracks/plsql/exercises/nth-prime","handle":"radwanromy","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/PLSQL Problem Solving/nth-prime/HELP.md b/PLSQL Problem Solving/nth-prime/HELP.md new file mode 100644 index 0000000..4813953 --- /dev/null +++ b/PLSQL Problem Solving/nth-prime/HELP.md @@ -0,0 +1,34 @@ +# Help + +## Running the tests + +Execute the tests by calling the `run` method in the respective `ut_#` package, +where `` is replaced with the exercise name. + +## Submitting your solution + +You can submit your solution using the `exercism submit ut_prime#.plsql` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [PL/SQL track's documentation](https://exercism.org/docs/tracks/plsql) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +To get help if you're having trouble, you can use one of the following resources: + +- [Oracle - PL/SQL Language Reference](http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/toc.htm) +- [Builtin Function Reference](http://psoug.org/reference/builtin_functions.html) +- [Ask Tom](https://asktom.oracle.com/) - Advice by the PL/SQL Guru +- [/r/plsql](https://www.reddit.com/r/plsql) is the C# subreddit. +- [StackOverflow](http://stackoverflow.com/questions/tagged/plsql) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions. \ No newline at end of file diff --git a/PLSQL Problem Solving/nth-prime/README.md b/PLSQL Problem Solving/nth-prime/README.md new file mode 100644 index 0000000..719d843 --- /dev/null +++ b/PLSQL Problem Solving/nth-prime/README.md @@ -0,0 +1,24 @@ +# Nth Prime + +Welcome to Nth Prime on Exercism's PL/SQL Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Given a number n, determine what the nth prime is. + +By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that +the 6th prime is 13. + +If your language provides methods in the standard library to deal with prime +numbers, pretend they don't exist and implement them yourself. + +## Source + +### Created by + +- @chezwicker + +### Based on + +A variation on Problem 7 at Project Euler - http://projecteuler.net/problem=7 \ No newline at end of file diff --git a/PLSQL Problem Solving/nth-prime/ut_prime#.plsql b/PLSQL Problem Solving/nth-prime/ut_prime#.plsql new file mode 100644 index 0000000..69d179d --- /dev/null +++ b/PLSQL Problem Solving/nth-prime/ut_prime#.plsql @@ -0,0 +1,103 @@ +/**/ +/* Formatted on 23/Nov/21 12:54:20 PM (QP5 v5.287) */ +CREATE OR REPLACE PACKAGE ut_prime# +IS + FUNCTION f_prime (i_num PLS_INTEGER) + RETURN BOOLEAN; + + FUNCTION nth (i_num_prime PLS_INTEGER) + RETURN PLS_INTEGER; + + PROCEDURE run; +END ut_prime#; +/ + +/**/ +/* Formatted on 23/Nov/21 12:54:36 PM (QP5 v5.287) */ +CREATE OR REPLACE PACKAGE BODY ut_prime# +IS + FUNCTION f_prime (i_num PLS_INTEGER) + RETURN BOOLEAN + IS + l_prime BOOLEAN := TRUE; + BEGIN + FOR i IN 2 .. ROUND (SQRT (i_num)) + LOOP + IF MOD (i_num, i) = 0 + THEN + l_prime := FALSE; + EXIT; + END IF; + END LOOP; + + RETURN l_prime; + END f_prime; + + FUNCTION nth (i_num_prime PLS_INTEGER) + RETURN PLS_INTEGER + IS + i_count PLS_INTEGER := 1; + i_cur PLS_INTEGER := 2; + BEGIN + WHILE i_count < i_num_prime + LOOP + i_cur := i_cur + 1; + + IF f_prime (i_cur) + THEN + i_count := i_count + 1; + END IF; + END LOOP; + + RETURN i_cur; + END nth; + + PROCEDURE test (i_descn VARCHAR2, i_exp NUMBER, i_act NUMBER) + IS + BEGIN + IF i_exp = i_act + THEN + DBMS_OUTPUT.put_line ('SUCCESS: ' || i_descn); + ELSE + DBMS_OUTPUT.put_line ( + 'FAILURE: ' + || i_descn + || ' - expected ' + || NVL ('' || i_exp, 'null') + || ', but received ' + || NVL ('' || i_act, 'null')); + END IF; + END test; + + PROCEDURE run + IS + l_act NUMBER; + BEGIN + test (i_descn => 'test_first', i_exp => 2, i_act => ut_prime#.nth (1)); + test (i_descn => 'test_second', i_exp => 3, i_act => ut_prime#.nth (2)); + test (i_descn => 'test_sixth', i_exp => 13, i_act => ut_prime#.nth (6)); + test (i_descn => 'test_big_prime', + i_exp => 104743, + i_act => ut_prime#.nth (10001)); + + BEGIN + l_act := ut_prime#.nth (0); + DBMS_OUTPUT.put_line ( + 'FAILURE: test_weird_case - expected invalid_argument_error to be raised, but received ' + || NVL ('' || l_act, 'null')); + EXCEPTION + WHEN ut_prime#.invalid_argument_error + THEN + DBMS_OUTPUT.put_line ('SUCCESS: test_weird_case'); + END; + END run; +END ut_prime#; +/ + +/**/ +/* Formatted on 23/Nov/21 12:54:37 PM (QP5 v5.287) */ +BEGIN + ut_prime#.run; +END; +/ + From 2d069be5e8497e8dc750f938c725f4b5b2c5c857 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 23 Nov 2021 13:00:51 +0600 Subject: [PATCH 88/95] PLSQL Problem Solving 10 --- .../leap/.exercism/config.json | 19 +++++++++ .../leap/.exercism/metadata.json | 1 + PLSQL Problem Solving/leap/HELP.md | 34 ++++++++++++++++ PLSQL Problem Solving/leap/README.md | 39 +++++++++++++++++++ PLSQL Problem Solving/leap/ut_leap#.plsql | 38 ++++++++++++++++++ 5 files changed, 131 insertions(+) create mode 100644 PLSQL Problem Solving/leap/.exercism/config.json create mode 100644 PLSQL Problem Solving/leap/.exercism/metadata.json create mode 100644 PLSQL Problem Solving/leap/HELP.md create mode 100644 PLSQL Problem Solving/leap/README.md create mode 100644 PLSQL Problem Solving/leap/ut_leap#.plsql diff --git a/PLSQL Problem Solving/leap/.exercism/config.json b/PLSQL Problem Solving/leap/.exercism/config.json new file mode 100644 index 0000000..4b4394d --- /dev/null +++ b/PLSQL Problem Solving/leap/.exercism/config.json @@ -0,0 +1,19 @@ +{ + "blurb": "Given a year, report if it is a leap year.", + "authors": [ + "chezwicker" + ], + "files": { + "solution": [ + "ut_leap#.plsql" + ], + "test": [ + "ut_leap#.plsql" + ], + "example": [ + ".meta/example.plsql" + ] + }, + "source": "JavaRanch Cattle Drive, exercise 3", + "source_url": "http://www.javaranch.com/leap.jsp" +} diff --git a/PLSQL Problem Solving/leap/.exercism/metadata.json b/PLSQL Problem Solving/leap/.exercism/metadata.json new file mode 100644 index 0000000..0b8440e --- /dev/null +++ b/PLSQL Problem Solving/leap/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"plsql","exercise":"leap","id":"ab747eb58b424df0acc31cd206b3c128","url":"https://exercism.org/tracks/plsql/exercises/leap","handle":"radwanromy","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/PLSQL Problem Solving/leap/HELP.md b/PLSQL Problem Solving/leap/HELP.md new file mode 100644 index 0000000..abc7c72 --- /dev/null +++ b/PLSQL Problem Solving/leap/HELP.md @@ -0,0 +1,34 @@ +# Help + +## Running the tests + +Execute the tests by calling the `run` method in the respective `ut_#` package, +where `` is replaced with the exercise name. + +## Submitting your solution + +You can submit your solution using the `exercism submit ut_leap#.plsql` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [PL/SQL track's documentation](https://exercism.org/docs/tracks/plsql) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +To get help if you're having trouble, you can use one of the following resources: + +- [Oracle - PL/SQL Language Reference](http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/toc.htm) +- [Builtin Function Reference](http://psoug.org/reference/builtin_functions.html) +- [Ask Tom](https://asktom.oracle.com/) - Advice by the PL/SQL Guru +- [/r/plsql](https://www.reddit.com/r/plsql) is the C# subreddit. +- [StackOverflow](http://stackoverflow.com/questions/tagged/plsql) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions. \ No newline at end of file diff --git a/PLSQL Problem Solving/leap/README.md b/PLSQL Problem Solving/leap/README.md new file mode 100644 index 0000000..0b593eb --- /dev/null +++ b/PLSQL Problem Solving/leap/README.md @@ -0,0 +1,39 @@ +# Leap + +Welcome to Leap on Exercism's PL/SQL Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Given a year, report if it is a leap year. + +The tricky thing here is that a leap year in the Gregorian calendar occurs: + +```text +on every year that is evenly divisible by 4 + except every year that is evenly divisible by 100 + unless the year is also evenly divisible by 400 +``` + +For example, 1997 is not a leap year, but 1996 is. 1900 is not a leap +year, but 2000 is. + +## Notes + +Though our exercise adopts some very simple rules, there is more to +learn! + +For a delightful, four minute explanation of the whole leap year +phenomenon, go watch [this youtube video][video]. + +[video]: http://www.youtube.com/watch?v=xX96xng7sAE + +## Source + +### Created by + +- @chezwicker + +### Based on + +JavaRanch Cattle Drive, exercise 3 - http://www.javaranch.com/leap.jsp \ No newline at end of file diff --git a/PLSQL Problem Solving/leap/ut_leap#.plsql b/PLSQL Problem Solving/leap/ut_leap#.plsql new file mode 100644 index 0000000..292782b --- /dev/null +++ b/PLSQL Problem Solving/leap/ut_leap#.plsql @@ -0,0 +1,38 @@ +create or replace package ut_year# +is + procedure run; +end ut_year#; +/ + +create or replace package body ut_year# +is + procedure test ( + i_descn varchar2 + ,i_exp varchar2 + ,i_act varchar2 + ) + is + begin + if i_exp = i_act then + dbms_output.put_line('SUCCESS: ' || i_descn); + else + dbms_output.put_line('FAILURE: ' || i_descn || ' - expected ' || nvl(i_exp, 'null') || ', but received ' || nvl(i_act, 'null')); + end if; + end test; + + procedure run + is + begin + test(i_descn => 'test_leap_year' , i_exp => 'Yes, 1996 is a leap year' , i_act => year#.is_leap(1996)); + test(i_descn => 'test_non_leap_year' , i_exp => 'No, 1997 is not a leap year', i_act => year#.is_leap(1997)); + test(i_descn => 'test_non_leap_even_year', i_exp => 'No, 1998 is not a leap year', i_act => year#.is_leap(1998)); + test(i_descn => 'test_century' , i_exp => 'No, 1900 is not a leap year', i_act => year#.is_leap(1900)); + test(i_descn => 'test_fourth_century' , i_exp => 'Yes, 2400 is a leap year' , i_act => year#.is_leap(2400)); + end run; +end ut_year#; +/ + +begin + ut_year#.run; +end; +/ From 0e361fbd4e1bcfd3ae7d619d705c3949d6c07179 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 23 Nov 2021 13:05:38 +0600 Subject: [PATCH 89/95] PLSQL Problem Solving 11 --- .../roman-numerals/.exercism/config.json | 19 ++++++ .../roman-numerals/.exercism/metadata.json | 1 + PLSQL Problem Solving/roman-numerals/HELP.md | 34 +++++++++++ .../roman-numerals/README.md | 58 +++++++++++++++++++ .../roman-numerals/ut_numeral#.plsql | 51 ++++++++++++++++ 5 files changed, 163 insertions(+) create mode 100644 PLSQL Problem Solving/roman-numerals/.exercism/config.json create mode 100644 PLSQL Problem Solving/roman-numerals/.exercism/metadata.json create mode 100644 PLSQL Problem Solving/roman-numerals/HELP.md create mode 100644 PLSQL Problem Solving/roman-numerals/README.md create mode 100644 PLSQL Problem Solving/roman-numerals/ut_numeral#.plsql diff --git a/PLSQL Problem Solving/roman-numerals/.exercism/config.json b/PLSQL Problem Solving/roman-numerals/.exercism/config.json new file mode 100644 index 0000000..ac39bfb --- /dev/null +++ b/PLSQL Problem Solving/roman-numerals/.exercism/config.json @@ -0,0 +1,19 @@ +{ + "blurb": "Write a function to convert from normal numbers to Roman Numerals.", + "authors": [ + "chezwicker" + ], + "files": { + "solution": [ + "ut_numeral#.plsql" + ], + "test": [ + "ut_numeral#.plsql" + ], + "example": [ + ".meta/example.plsql" + ] + }, + "source": "The Roman Numeral Kata", + "source_url": "http://codingdojo.org/cgi-bin/index.pl?KataRomanNumerals" +} diff --git a/PLSQL Problem Solving/roman-numerals/.exercism/metadata.json b/PLSQL Problem Solving/roman-numerals/.exercism/metadata.json new file mode 100644 index 0000000..1bc00c0 --- /dev/null +++ b/PLSQL Problem Solving/roman-numerals/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"plsql","exercise":"roman-numerals","id":"86fa443992e3474e8599761e687f7d56","url":"https://exercism.org/tracks/plsql/exercises/roman-numerals","handle":"radwanromy","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/PLSQL Problem Solving/roman-numerals/HELP.md b/PLSQL Problem Solving/roman-numerals/HELP.md new file mode 100644 index 0000000..00275ea --- /dev/null +++ b/PLSQL Problem Solving/roman-numerals/HELP.md @@ -0,0 +1,34 @@ +# Help + +## Running the tests + +Execute the tests by calling the `run` method in the respective `ut_#` package, +where `` is replaced with the exercise name. + +## Submitting your solution + +You can submit your solution using the `exercism submit ut_numeral#.plsql` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [PL/SQL track's documentation](https://exercism.org/docs/tracks/plsql) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +To get help if you're having trouble, you can use one of the following resources: + +- [Oracle - PL/SQL Language Reference](http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/toc.htm) +- [Builtin Function Reference](http://psoug.org/reference/builtin_functions.html) +- [Ask Tom](https://asktom.oracle.com/) - Advice by the PL/SQL Guru +- [/r/plsql](https://www.reddit.com/r/plsql) is the C# subreddit. +- [StackOverflow](http://stackoverflow.com/questions/tagged/plsql) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions. \ No newline at end of file diff --git a/PLSQL Problem Solving/roman-numerals/README.md b/PLSQL Problem Solving/roman-numerals/README.md new file mode 100644 index 0000000..4ee83a0 --- /dev/null +++ b/PLSQL Problem Solving/roman-numerals/README.md @@ -0,0 +1,58 @@ +# Roman Numerals + +Welcome to Roman Numerals on Exercism's PL/SQL Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Write a function to convert from normal numbers to Roman Numerals. + +The Romans were a clever bunch. They conquered most of Europe and ruled +it for hundreds of years. They invented concrete and straight roads and +even bikinis. One thing they never discovered though was the number +zero. This made writing and dating extensive histories of their exploits +slightly more challenging, but the system of numbers they came up with +is still in use today. For example the BBC uses Roman numerals to date +their programmes. + +The Romans wrote numbers using letters - I, V, X, L, C, D, M. (notice +these letters have lots of straight lines and are hence easy to hack +into stone tablets). + +```text + 1 => I +10 => X + 7 => VII +``` + +There is no need to be able to convert numbers larger than about 3000. +(The Romans themselves didn't tend to go any higher) + +Wikipedia says: Modern Roman numerals ... are written by expressing each +digit separately starting with the left most digit and skipping any +digit with a value of zero. + +To see this in practice, consider the example of 1990. + +In Roman numerals 1990 is MCMXC: + +1000=M +900=CM +90=XC + +2008 is written as MMVIII: + +2000=MM +8=VIII + +See also: http://www.novaroma.org/via_romana/numbers.html + +## Source + +### Created by + +- @chezwicker + +### Based on + +The Roman Numeral Kata - http://codingdojo.org/cgi-bin/index.pl?KataRomanNumerals \ No newline at end of file diff --git a/PLSQL Problem Solving/roman-numerals/ut_numeral#.plsql b/PLSQL Problem Solving/roman-numerals/ut_numeral#.plsql new file mode 100644 index 0000000..5d2c0ae --- /dev/null +++ b/PLSQL Problem Solving/roman-numerals/ut_numeral#.plsql @@ -0,0 +1,51 @@ +create or replace package ut_numeral# +is + procedure run; +end ut_numeral#; +/ + +create or replace package body ut_numeral# +is + procedure test ( + i_descn varchar2 + ,i_exp varchar2 + ,i_act varchar2 + ) + is + begin + if i_exp = i_act then + dbms_output.put_line('SUCCESS: ' || i_descn); + else + dbms_output.put_line('FAILURE: ' || i_descn || ' - expected ' || nvl('' || i_exp, 'null') || ', but received ' || nvl('' || i_act, 'null')); + end if; + end test; + + procedure run + is + begin + test(i_descn => 'test_1', i_exp => 'I', i_act => numeral#.to_roman(1 )); + test(i_descn => 'test_2', i_exp => 'II', i_act => numeral#.to_roman(2 )); + test(i_descn => 'test_3', i_exp => 'III', i_act => numeral#.to_roman(3 )); + test(i_descn => 'test_4', i_exp => 'IV', i_act => numeral#.to_roman(4 )); + test(i_descn => 'test_5', i_exp => 'V', i_act => numeral#.to_roman(5 )); + test(i_descn => 'test_6', i_exp => 'VI', i_act => numeral#.to_roman(6 )); + test(i_descn => 'test_9', i_exp => 'IX', i_act => numeral#.to_roman(9 )); + test(i_descn => 'test_27', i_exp => 'XXVII', i_act => numeral#.to_roman(27 )); + test(i_descn => 'test_48', i_exp => 'XLVIII', i_act => numeral#.to_roman(48 )); + test(i_descn => 'test_59', i_exp => 'LIX', i_act => numeral#.to_roman(59 )); + test(i_descn => 'test_93', i_exp => 'XCIII', i_act => numeral#.to_roman(93 )); + test(i_descn => 'test_141', i_exp => 'CXLI', i_act => numeral#.to_roman(141 )); + test(i_descn => 'test_163', i_exp => 'CLXIII', i_act => numeral#.to_roman(163 )); + test(i_descn => 'test_402', i_exp => 'CDII', i_act => numeral#.to_roman(402 )); + test(i_descn => 'test_575', i_exp => 'DLXXV', i_act => numeral#.to_roman(575 )); + test(i_descn => 'test_911', i_exp => 'CMXI', i_act => numeral#.to_roman(911 )); + test(i_descn => 'test_1024', i_exp => 'MXXIV', i_act => numeral#.to_roman(1024)); + test(i_descn => 'test_3000', i_exp => 'MMM', i_act => numeral#.to_roman(3000)); + end run; +end ut_numeral#; +/ + +begin + ut_numeral#.run; +end; +/ From 5ad47ff8ec6b6a27e47200a2fe306f781e198014 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 4 Jan 2022 15:51:04 +0600 Subject: [PATCH 90/95] SYS_CONTEXT --- SYS_CONTEXT.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 SYS_CONTEXT.sql diff --git a/SYS_CONTEXT.sql b/SYS_CONTEXT.sql new file mode 100644 index 0000000..ec6337d --- /dev/null +++ b/SYS_CONTEXT.sql @@ -0,0 +1 @@ +SELECT SYS_CONTEXT('USERENV','Host') FROM dual; \ No newline at end of file From 76bcfaca7d9b5f404fb988d2e03af0ad432c8c92 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 4 Jan 2022 15:53:28 +0600 Subject: [PATCH 91/95] Login Function Create --- LOG_IN.fnc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 LOG_IN.fnc diff --git a/LOG_IN.fnc b/LOG_IN.fnc new file mode 100644 index 0000000..c0c4bd8 --- /dev/null +++ b/LOG_IN.fnc @@ -0,0 +1,22 @@ +/* Formatted on 04/Jan/22 12:36:03 PM (QP5 v5.287) */ +CREATE OR REPLACE FUNCTION log_in (x IN VARCHAR2, y IN VARCHAR2) + RETURN VARCHAR2 +AS + check_count NUMBER; +BEGIN + SELECT COUNT (*) + INTO check_count + FROM employees + WHERE first_name = x AND last_name = y; + + IF check_count = 0 + THEN + RETURN 'Wrong username or password!'; + ELSIF check_count = 1 + THEN + RETURN 'Login successful!'; + ELSE + RETURN 'Too many matches, this should never happen!'; + END IF; +END; +/ \ No newline at end of file From ffd48863a81aba45088f99a34fac5b7d24c02be4 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 4 Jan 2022 15:54:55 +0600 Subject: [PATCH 92/95] Login Check Using Function --- login check using function.fnc | 1 + 1 file changed, 1 insertion(+) create mode 100644 login check using function.fnc diff --git a/login check using function.fnc b/login check using function.fnc new file mode 100644 index 0000000..f21b944 --- /dev/null +++ b/login check using function.fnc @@ -0,0 +1 @@ +select log_in('David', 'Austin') from employees; \ No newline at end of file From bfdb23cb5db5c470068b048be8449837b45a7279 Mon Sep 17 00:00:00 2001 From: radwanromy Date: Tue, 4 Jan 2022 15:56:27 +0600 Subject: [PATCH 93/95] Login Check Using Procedure --- LOG_INN.prc | 21 +++++++++++++++++++++ login check using Procedure.prc | 1 + 2 files changed, 22 insertions(+) create mode 100644 LOG_INN.prc create mode 100644 login check using Procedure.prc diff --git a/LOG_INN.prc b/LOG_INN.prc new file mode 100644 index 0000000..b1774ae --- /dev/null +++ b/LOG_INN.prc @@ -0,0 +1,21 @@ +CREATE OR REPLACE procedure log_inn (x IN VARCHAR2, y IN VARCHAR2) + +AS + check_count NUMBER; +BEGIN + SELECT COUNT (*) + INTO check_count + FROM employees + WHERE first_name = x AND last_name = y; + + IF check_count = 0 + THEN + dbms_output.put_line( 'Wrong username or password!'); + ELSIF check_count = 1 + THEN +dbms_output.put_line( 'Login successful!'); + ELSE + dbms_output.put_line( 'Too many matches, this should never happen!'); + END IF; +END; +/ \ No newline at end of file diff --git a/login check using Procedure.prc b/login check using Procedure.prc new file mode 100644 index 0000000..1b8fe6a --- /dev/null +++ b/login check using Procedure.prc @@ -0,0 +1 @@ +EXECUTE log_inn('David', 'Austin'); \ No newline at end of file From b17530855960aaaca9af678923e218ea73fe33ca Mon Sep 17 00:00:00 2001 From: "A . S . M . RADWAN" <50805604+radwanromy@users.noreply.github.com> Date: Thu, 6 Jan 2022 11:13:25 +0600 Subject: [PATCH 94/95] Create SECURITY.md --- SECURITY.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..034e848 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,21 @@ +# Security Policy + +## Supported Versions + +Use this section to tell people about which versions of your project are +currently being supported with security updates. + +| Version | Supported | +| ------- | ------------------ | +| 5.1.x | :white_check_mark: | +| 5.0.x | :x: | +| 4.0.x | :white_check_mark: | +| < 4.0 | :x: | + +## Reporting a Vulnerability + +Use this section to tell people how to report a vulnerability. + +Tell them where to go, how often they can expect to get an update on a +reported vulnerability, what to expect if the vulnerability is accepted or +declined, etc. From 9c8d8ff50c3cba93253fc62ddc85eaf341719511 Mon Sep 17 00:00:00 2001 From: "A . S . M . RADWAN" <50805604+radwanromy@users.noreply.github.com> Date: Thu, 6 Jan 2022 11:14:50 +0600 Subject: [PATCH 95/95] Work Flow --- .github/workflows/veracode-analysis.yml | 51 +++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/veracode-analysis.yml diff --git a/.github/workflows/veracode-analysis.yml b/.github/workflows/veracode-analysis.yml new file mode 100644 index 0000000..1dd5dd2 --- /dev/null +++ b/.github/workflows/veracode-analysis.yml @@ -0,0 +1,51 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# This workflow will initiate a Veracode Static Analysis Pipeline scan, return a results.json and convert to SARIF for upload as a code scanning alert + +name: Veracode Static Analysis Pipeline Scan + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master ] + schedule: + - cron: '34 4 * * 1' + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a job to build and submit pipeline scan, you will need to customize the build process accordingly and make sure the artifact you build is used as the file input to the pipeline scan file parameter + build-and-pipeline-scan: + # The type of runner that the job will run on + runs-on: ubuntu-latest + steps: + + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it and copies all sources into ZIP file for submitting for analysis. Replace this section with your applications build steps + - uses: actions/checkout@v2 + with: + repository: '' + + - run: zip -r veracode-scan-target.zip ./ + + # download the Veracode Static Analysis Pipeline scan jar + - run: curl --silent --show-error --fail -O https://downloads.veracode.com/securityscan/pipeline-scan-LATEST.zip + - run: unzip -o pipeline-scan-LATEST.zip + + - uses: actions/setup-java@v1 + with: + java-version: 1.8 + - run: java -jar pipeline-scan.jar --veracode_api_id "${{secrets.VERACODE_API_ID}}" --veracode_api_key "${{secrets.VERACODE_API_KEY}}" --fail_on_severity="Very High, High" --file veracode-scan-target.zip + continue-on-error: true + - name: Convert pipeline scan output to SARIF format + id: convert + uses: veracode/veracode-pipeline-scan-results-to-sarif@ff08ae5b45d5384cb4679932f184c013d34da9be + with: + pipeline-results-json: results.json + - uses: github/codeql-action/upload-sarif@v1 + with: + # Path to SARIF file relative to the root of the repository + sarif_file: veracode-results.sarif