ORA-01422: exact fetch returns more than requested number of rows

ORA-01422: exact fetch returns more than requested number of rows ORA-01422: exact fetch returns more than requested number of rows Cause: The number specified in exact fetch is less than the rows returned. Solution: Rewrite the query or change number of rows requested. Example: declare v_name varchar2(255); begin select name into v_name from books where…(Continue Reading)

ORA-01403: no data found

ORA-01403: no data found ORA-01403: no data found Cause: A SELECT INTO statement was executed and no rows were returned. Solution: Set the no_data_found exception or correct the SELECT statement. Example: declare v_name varchar2(255); begin select name into v_name from books where id=00011872; dbms_output.put_line(‘The name is: ‘||v_name); end; Output: ORA-01403: no data found Correct declare…(Continue Reading)

ORA-00936: missing expression

ORA-00936: missing expression ORA-00936: missing expression Cause: A required part of a clause or expression has been omitted. Solution: Check the statement syntax and specify the missing component. Example: SELECT FROM COURSE; SELECT * FROM COURSE WHERE ; Output: ORA-00936: missing expression Correct SELECT * FROM COURSE; SELECT * FROM COURSE WHERE PRICE=10;

ORA-00918: column ambiguously defined

ORA-00918: column ambiguously defined ORA-00918: column ambiguously defined Cause: A column name used in a join exists in more than one table and is thus referenced ambiguously. Solution: Prefix references to column names that exist in multiple tables with either the table name or a table alias. Example: SELECT COURSE_ID, COURSE_ID FROM ORDERS, COURSE WHERE…(Continue Reading)

ORA-00933: SQL command not properly ended

ORA-00933: SQL command not properly ended ORA-00933: SQL command not properly ended Cause: The SQL statement ends with an inappropriate clause. Solution: Correct the syntax by removing the inappropriate clauses. Example: declare v_sql varchar2(4000):=’Insert into BOOKS (ID,NAME,PRICE) values ‘; v_string varchar2(32000); v_id number:=5; v_name varchar2(200):=’SQL Tutorial’; v_price number:=14; begin v_string:=v_sql||'(‘||v_id||’,”||v_name||”,’||v_price||’);’; DBMS_OUTPUT.PUT_LINE(v_string); execute immediate v_string; end;…(Continue Reading)