- Mitglied seit
- 08.03.2004
- Beiträge
- 1.574
- Reaktionen
- 0
Ich verstehe die Funktionsweise von Bind-Variablen in PL/SQL nicht. Mehr als einfache howtos zur Benutzung finde ich auch nicht im Netz. Ich würde aber gerne verstehen, wie sie genau vom PS Executor gehandhabt werden. Z.B. verstehe ich nicht, warum der folgende Code A geht, aber der Code B null in der Bind-Variablen hat.
(Fehler in B: es kann nicht NULL für own_dep.department_id gesetzt werden)
Code:
-- CODE A:
VARIABLE dept_id NUMBER
DECLARE
max_deptno own_dep.department_id% TYPE;
dept_name own_dep.department_name% TYPE := 'Edu';
BEGIN
SELECT max(department_id) INTO max_deptno FROM own_dep;
:dept_id := max_deptno+10;
END;
/
BEGIN
INSERT INTO own_dep (own_dep.department_name, own_dep.department_id, own_dep.location_id)
VALUES ('peter', :dept_id, null);
END;
Code:
-- CODE B:
VARIABLE dept_id NUMBER
DECLARE
max_deptno own_dep.department_id% TYPE;
dept_name own_dep.department_name% TYPE := 'Edu';
BEGIN
SELECT max(department_id) INTO max_deptno FROM own_dep;
:dept_id := max_deptno+10;
INSERT INTO own_dep (own_dep.department_name, own_dep.department_id, own_dep.location_id)
VALUES ('peter', :dept_id, null);
END;
(Fehler in B: es kann nicht NULL für own_dep.department_id gesetzt werden)
