查看: 1128|回复: 2
|
PL/SQL - error problem
[复制链接]
|
|
hi, 我 是 PL/SQL 新 手 , 在 这 有 些 问 题 要 你 们 帮 我 解 决 。 我 是 用 ORACLE -SQL* PLUS 来 输 入 以 下 的 句 子 , 可 是 却 出 现 ERROR 问 题 , 所 以 想 请 教 你 们 帮 我 解 决 这 问 题 可 以 吗 ?
DECLARE
value NUMBER(6);
username VARCHAR2(30) ;
hobbies VARCHAR2(500);
address VARCHAR2(500);
CURSOR hobbies_cur IS SELECT username,hobbies FROM userinfo WHERE REGEXP_LIKE(hobbies, '(base|foot)([[:space:]]){0,}ball([^.]*)cricket','i') ;
CURSOR hobbies_music_cur IS SELECT username,hobbies FROM userinfo WHERE REGEXP_LIKE(hobbies, 'music|violin|guitar|sing(er|ing)','i') ;
CURSOR address_cur IS SELECT username, hobbies, REGEXP_SUBSTR(address, ',[^,]+',1,2) FROM userinfo ;
BEGIN
value := &choice ;
IF ( value = 1) THEN
OPEN hobbies_cur;
DBMS_OUTPUT.PUT_LINE('----------------------------------------------------------');
DBMS_OUTPUT.PUT_LINE('Searching who play either football OR baseball AND cricket');
DBMS_OUTPUT.PUT_LINE('User Name Hobbies ');
DBMS_OUTPUT.PUT_LINE('----------------------------------------------------------');
LOOP
FETCH hobbies_cur INTO username, hobbies ;
-- Exit the loop when there are no more records in the cursor
EXIT WHEN hobbies_cur%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(username || ' '|| hobbies);
END LOOP ;
CLOSE hobbies_cur;
ELSIF ( value = 2) THEN
OPEN hobbies_music_cur;
DBMS_OUTPUT.PUT_LINE('-----------------------------------------------');
DBMS_OUTPUT.PUT_LINE('Searching for users who are interested in music');
DBMS_OUTPUT.PUT_LINE('User Name Hobbies ');
DBMS_OUTPUT.PUT_LINE('-----------------------------------------------');
LOOP
FETCH hobbies_music_cur INTO username, hobbies ;
EXIT WHEN hobbies_music_cur%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(' '|| username || ' '|| hobbies);
END LOOP ;
CLOSE hobbies_music_cur;
ELSIF ( value = 3) THEN
OPEN address_cur;
DBMS_OUTPUT.PUT_LINE('------------------------------------------------------------');
DBMS_OUTPUT.PUT_LINE('Retrieve the location information for all the users in the table') ;
DBMS_OUTPUT.PUT_LINE('User Name Location Hobbies ');
DBMS_OUTPUT.PUT_LINE('------------------------------------------------------------');
LOOP
FETCH address_cur INTO username, hobbies ,address ;
EXIT WHEN address_cur%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(' '|| username || ' '|| address|| ' '||hobbies);
END LOOP ;
CLOSE address_cur;
-- If the input values is other than 1,2 and 3 then print an error message
ELSE
DBMS_OUTPUT.PUT_LINE('------------------------------------------------------------');
DBMS_OUTPUT.PUT_LINE('Invalid input. Run the script again and enter a valid choice');
DBMS_OUTPUT.PUT_LINE('------------------------------------------------------------');
END IF;
END;
/
它 出 现 的 ERROR 是
Enter value for choice: 1
old 15: value := &choice ;
new 15: value := 1 ;
CURSOR hobbies_cur IS SELECT username,hobbies FROM userinfo WHERE REGEXP_LIKE(hobbies, '(base|foot)([[:space:]]){0,}ball([^.]*)cricket','i') ;
*
ERROR at line 8:
ORA-06550: line 8, column 145:
PL/SQL: ORA-00920: invalid relational operator
ORA-06550: line 8, column 24:
PL/SQL: SQL Statement ignored
ORA-06550: line 10, column 136:
PL/SQL: ORA-00920: invalid relational operator
ORA-06550: line 10, column 30:
PL/SQL: SQL Statement ignored |
|
|
|
|
|
|
|
楼主 |
发表于 1-5-2005 05:32 PM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 3-5-2005 09:13 AM
|
显示全部楼层
可能你使用的不是10g的DATABASE, Regular Expressions到10G是才有。 |
|
|
|
|
|
|
| |
本周最热论坛帖子
|