database - PL/SQL: IF ELSE statement and working with an invalid string from user input -


i taking in user input database. when user enters invalid name not in database trying error message saying input not in database. cant figure out belongs after v_employee_name. great. thanks!!

accept p_1 prompt 'please enter employee name'  declare v_employee_name    varchar2(40) :='&p_1'; (declared cursors)  begin    if v_employee_name (???????)       dbms_output.put_line('the employee not in database' || upper(v_employee_name));    else        ........... 

you cannot expect database validate user's input if magic. because databases aren't magic. need write query. know, shocking.

accept p_1 prompt 'please enter employee name'  declare   v_employee_id   employees.emp_id%type; (declared cursors)  begin    begin      select emp_id v_employee_id      employees      employee_name = upper('&p_1');      --      ....   exception      when no_data_found           raise_application_error(-20000, 'the employee not in database' || upper(v_employee_name));    end;      .... 

incidentally, if you're going capitalize name in output should capitalize when doing validation, case matters when testing equality.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -