CREATE OR REPLACE FUNCTION DROP_EMPS (DEPT_NAME IN DEPARTMENTS.DEPARTMENT_NAME%TYPE)
RETURN EMP_TAB AS
CURSOR C_EMPS IS
SELECT E.EMPLOYEE_ID, (E.FIRST_NAME||' '||E.LAST_NAME) EMP_NAME
FROM EMPLOYEES E
WHERE E.DEPARTMENT_ID = (SELECT DEPARTMENT_ID FROM DEPARTMENTS D WHERE D.DEPARTMENT_NAME = DEPT_NAME)
FOR UPDATE;
CURSOR C_DEPTS IS
SELECT DEPARTMENT_ID FROM DEPARTMENTS D WHERE D.DEPARTMENT_NAME = DEPT_NAME;
V_TMP_DEPT_ID DEPARTMENTS.DEPARTMENT_ID%TYPE;
EMPS EMP_TAB := EMP_TAB();
MISSING_DEPT EXCEPTION;
BEGIN
OPEN C_DEPTS;
FETCH C_DEPTS INTO V_TMP_DEPT_ID;
IF C_DEPTS%NOTFOUND THEN
RAISE MISSING_DEPT;
END IF;
CLOSE C_DEPTS;
FOR EMP IN C_EMPS LOOP
UPDATE EMPLOYEES
SET MANAGER_ID = NULL
WHERE MANAGER_ID = EMP.EMPLOYEE_ID;
DELETE FROM JOB_HISTORY
WHERE EMPLOYEE_ID = EMP.EMPLOYEE_ID;
EMPS.EXTEND;
EMPS(EMPS.LAST) := EMP_ROW(EMP.EMPLOYEE_ID, EMP.EMP_NAME);
DELETE FROM EMPLOYEES
WHERE CURRENT OF C_EMPS;
END LOOP;
RETURN EMPS;
EXCEPTION
WHEN MISSING_DEPT THEN
RAISE_APPLICATION_ERROR(-20005, 'MISSING DEPARTMENT');
END DROP_EMPS;
END PKG_EMP;
SET SERVEROUTPUT ON
DECLARE
DELETED_EMPS EMP_TAB;
V_EMP_ID NUMBER;
BEGIN
DBMS_OUTPUT.enable;
DELETED_EMPS := DROP_EMPS('IT');
FOR I IN 1..DELETED_EMPS.COUNT LOOP
DBMS_OUTPUT.put_line(DELETED_EMPS(I).EMP_ID||' '||DELETED_EMPS(I).EMP_NAME);
END LOOP;
END;
/
- намертво и неожиданно виснет, иногда позволяя в течение нескольких секунд поводить липнущим курсором мыши, замена видюшных драйверов не помогла
sudo add-apt-repository ppa:wsnipex/vaapi
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install i965-va-driver
#include <stdio.h>
#include <math.h>
#include <omp.h>
#define N 4
#define eps 0.0001
void jacobi(double a[N][N], double b[N], double x[N])
{
int i, j;
double vectorNorm;
double currentX[N];
do {
vectorNorm = 0.0;
#pragma omp parallel for private(i, j)
for(i = 0; i < N; i++) {
currentX[i] = -b[i];
for(j = 0; j < N; j++) {
if(i != j)
currentX[i] += a[i][j] * x[j];
}
currentX[i] /= -a[i][i];
}
#pragma omp parallel for
for(i = 0; i < N; i++) {
if(fabs(x[i] - currentX[i]) > vectorNorm)
vectorNorm = fabs(x[i] - currentX[i]);
x[i] = currentX[i];
}
}
while(vectorNorm > eps);
}
int main() {
int i, j;
double matrixA[N][N] = {
{2,0,0,0},
{1,2,0,0},
{3,1,2,0},
{3,2,1,3}
};
double vectorB[N] = {1,1,1,1}, vectorX[N];
jacobi(matrixA, vectorB, vectorX);
printf("Vector X:\n");
for (i = 0; i < N; i++) {
printf("%.3f ", vectorX[i]);
}
printf("\n");
return 0;
}