我想删除记录类型中的列(emp_sal)具有5000+的元素,但这给我一个错误。我不知道我是否将.DELETE方法放在正确的区域。 代码:
DECLARE
TYPE rec IS RECORD (
emp_id HR.EMPLOYEES.EMPLOYEE_ID%TYPE,
emp_fname HR.EMPLOYEES.FIRST_NAME%TYPE,
emp_lname HR.EMPLOYEES.LAST_NAME%TYPE,
emp_job HR.EMPLOYEES.JOB_ID%TYPE,
emp_sal HR.EMPLOYEES.SALARY%TYPE );
TYPE rec_table IS TABLE OF rec;
rec_list rec_table := rec_table();
BEGIN
SELECT HR.EMPLOYEES.EMPLOYEE_ID,
HR.EMPLOYEES.FIRST_NAME,
HR.EMPLOYEES.LAST_NAME,
HR.EMPLOYEES.JOB_ID,
HR.EMPLOYEES.SALARY
BULK COLLECT INTO rec_list
FROM HR.EMPLOYEES;
FOR i IN rec_list.FIRST..rec_list.LAST LOOP
IF (rec_list(i).emp_sal > 5000) THEN
rec_list(i).DELETE();
END IF;
DBMS_OUTPUT.PUT_LINE('element: '||i||' '||
'emp id: '||rec_list(i).emp_id||
' full name: '||rec_list(i).emp_fname||
' '||rec_list(i).emp_lname||
' job: '||rec_list(i).emp_job||
' salary: '||rec_list(i).emp_sal);
END LOOP;
END;
输出:
ORA-06550: line 28, column 20: PLS-00302: component 'DELETE' must be declared
谢谢!
答案 0 :(得分:0)
已解决。
此操作:
FOR i IN rec_list.FIRST..rec_list.LAST LOOP
IF (rec_list(i).emp_sal > 5000) THEN
rec_list.DELETE(i);
CONTINUE;
END IF;
DBMS_OUTPUT.PUT_LINE('element: '||i||' '||
'emp id: '||rec_list(i).emp_id||
' full name: '||rec_list(i).emp_fname||
' '||rec_list(i).emp_lname||
' job: '||rec_list(i).emp_job||
' salary: '||rec_list(i).emp_sal);
END LOOP;
------------------------输出:
element: 6 emp id: 105 full name: David Austin job: IT_PROG salary: 4800
element: 7 emp id: 106 full name: Valli Pataballa job: IT_PROG salary: 4800
element: 8 emp id: 107 full name: Diana Lorentz job: IT_PROG salary: 4200
element: 16 emp id: 115 full name: Alexander Khoo job: PU_CLERK salary: 3100
element: 17 emp id: 116 full name: Shelli Baida job: PU_CLERK salary: 2900
element: 18 emp id: 117 full name: Sigal Tobias job: PU_CLERK salary: 2800
element: 19 emp id: 118 full name: Guy Himuro job: PU_CLERK salary: 2600
element: 20 emp id: 119 full name: Karen Colmenares job: PU_CLERK salary: 2500
element: 26 emp id: 125 full name: Julia Nayer job: ST_CLERK salary: 3200
谢谢!
答案 1 :(得分:0)
如果您要从集合中删除元素,则使用的是错误的
<template>
<div>
user
<div>This is Bar {{ $route.params.id }}</div>
{{personal.name}}
<router-link :to="{ name: 'personal' }">Personal Info</router-link>
<router-view></router-view>
</div>
</template>
所以在您的示例中,正确的是正确的
DELETE with no parameters removes all elements from a collection, setting COUNT to 0.
DELETE(n) removes the nth element from an associative array with a numeric key or a nested table. If the associative array has a string key, the element corresponding to the key value is deleted. If n is null, DELETE(n) does nothing.
DELETE(m,n) removes all elements in the range m..n from an associative array or nested table. If m is larger than n or if m or n is NULL, DELETE(m,n) does nothing.