Error condition MSG appears correctly, but good condition msg does not appear
I did a sequence of update employe_id of the sequence. I stated a function to check for the existence of the department_id in the departments table. I stated a procedure to enter a new record in the employees table after verifying the existence of the Department in the departments table. When I get a bad department_id the particular error msg that accompanies it is displayed correctly, but, when I get a good present department_id in the departments table, data is entered, but the particular error msg that accompanies it is not displayed.
CREATE SEQUENCE employees_seq
START WITH 1000
INCREMENT BY 1;
SELECT double employees_seq.nextval;
SELECT double employees_seq.currval;
CREATE or REPLACE function valid_deptid (pi_department_id, departments.department_id%TYPE) RETURNS a BOOLEAN IS
char v_temp;
BEGIN
SELECT 'x' INTO v_temp
Ministries
WHERE department_id = pi_department_id;
RETURNS true;
EXCEPTION
WHEN no_data_found THEN
Returns false;
WHILE others THEN
Returns false;
END;
/
CREATE or REPLACE procedure new_emp (pi_first_name IN employees.first_name%TYPE,
pi_last_name IN employees.last_name%TYPE,
pi_email_id IN employees.email%TYPE,
pi_hire_date employees.hire_date%TYPE,
pi_job_id employees.job_id%TYPE DEFAULT 'SA_REP '.
pi_salary IN employees.salary%TYPE 1000 by DEFAULT,
pi_commission_pct IN employees.commission_pct%TYPE default 0,
pi_manager_id IN employees.manager_id%TYPE DEFAULT 145,
pi_department_id IN employees.department_id%TYPE by DEFAULT 30,
po_error_code OUT varchar2,
po_error_msg OUT varchar2) IS
v_temp BOOLEAN;
BEGIN
v_temp: = valid_deptid (pi_department_id);
IF v_temp THEN
INSERT INTO copy_employees(employee_id,first_name,last_name,email,hire_date,job_id,salary,commission_pct,manager_id,department_id) VALUES (employees_seq.nextval, pi_first_name, pi_last_name, pi_email_id, pi_hire_date, pi_job_id, pi_salary, pi_commission_pct, pi_manager_id, pi_department_id);
po_error_code: = '0';
po_error_msg: = "Insert complete."
ON THE OTHER
po_error_code: = "9";
po_error_msg: = ' the department_id entered is invalid, please try again. "
RAISE_APPLICATION_ERROR (-20999, po_error_msg);
END IF;
EXCEPTION
WHILE others THEN
RAISE_APPLICATION_ERROR (-20001, substr(SQLERRM,11));
END;
/
Calling program: -.
DECLARE
v_first_name employees.first_name%TYPE;
v_last_name employees.last_name%TYPE;
v_email_id employees.email%TYPE;
v_hire_date employees.hire_date%TYPE;
v_department_id employees.department_id%TYPE;
v_error_code varchar2 (10);
v_error_msg varchar2 (60);
BEGIN
new_emp (& v_first_name, & v_last_name, & v_email_id, & v_hire_date,' ', NULL, NULL, NULL, & v_department_id, v_error_code, v_error_msg);
If v_error_code = "0" THEN
dbms_output.put_line (v_error_msg);
ELSIF v_error_code = '9' THEN
dbms_output.put_line (v_error_msg);
END IF;
END;
/
When I get an invalid department_id not in the departments table: -.
Enter the value for v_first_name: "a".
Enter the value for v_last_name: 'b '.
Enter the value of v_email_id: ' [email protected] '
Enter the value for v_hire_date: sysdate
Enter the value for v_department_id: 25
10 old: new_emp (& v_first_name, & v_last_name, & v_email_id, & v_hire_date,' ', NULL, NULL, NULL, & v_department_id, v_error_code, v_error_msg);
new 10: new_emp ('a', 'b',' [email protected]', sysdate,' ', NULL, NULL, NULL, 25, v_error_code, v_error_msg);
DECLARE
*
ERROR on line 1:
ORA-20001: the department_id entered is invalid, please try again - the error msg I intend to display appears correctly
ORA-06512: at the 'SUMAN '. NEW_EMP', line 26
ORA-06512: at line 10
When I enter a valid, present department_id in the departments table: -.
Enter the value for v_first_name: "a".
Enter the value for v_last_name: 'b '.
Enter the value of v_email_id: ' [email protected] '
Enter the value for v_hire_date: sysdate
Enter the value for v_department_id: 80
10 old: new_emp (& v_first_name, & v_last_name, & v_email_id, & v_hire_date,' ', NULL, NULL, NULL, & v_department_id, v_error_code, v_error_msg);
new 10: new_emp ('a', 'b',' [email protected]', sysdate,' ', NULL, NULL, NULL, 80, v_error_code, v_error_msg);
PL/SQL procedure is completed with success - the error msg I intend to display is not displayed.
You missed to add SET SERVEROUTPUT ON before calling your program, and I will suggest to maintain the constraint for this scenario (Parent-child relationship).
Anyway, I will correct your mistakes and this is that the code will satisfy your needs. You do not need to write another function to check if the id of service entry in the department table or not. See the bottom of modified code.
CREATE OR REPLACE PROCEDURE new_emp (pi_first_name IN employees.first_name%TYPE,
pi_last_name IN employees.last_name%TYPE,
pi_email_id IN employees.email%TYPE,
pi_hire_date employees.hire_date%TYPE,
pi_job_id employees.job_id%TYPE DEFAULT 'SA_REP '.
pi_salary IN employees.salary%TYPE 1000 by DEFAULT,
pi_commission_pct IN employees.commission_pct%TYPE default 0,
pi_manager_id IN employees.manager_id%TYPE DEFAULT 145,
pi_department_id IN employees.department_id%TYPE by DEFAULT 30,
po_error_code ON the NUMBER,
po_error_msg OUT VARCHAR2)
IS
BEGIN
INSERT INTO copy_employees (employe_id,
first name,
last_name,
hire_date,
job_id,
salary,
commission_pct,
manager_id,
department_id)
SELECT employees_seq.nextval,
pi_first_name,
pi_last_name,
pi_email_id,
pi_hire_date,
pi_job_id,
pi_salary,
pi_commission_pct,
pi_manager_id,
pi_department_id
Ministries
WHERE department_id = pi_department_id;
IF (SQL % ROWCOUNT > 0) THEN
po_error_code: = 0;
po_error_msg: = "Insert complete."
ON THE OTHER
po_error_code: = 9;
po_error_msg: = ' the department_id entered is invalid, please try again. "
RAISE_APPLICATION_ERROR (-20999, po_error_msg);
END IF;
COMMIT;
END;
Performances: -.
============
-Invalid department_id not in the departments table.
SET SERVEROUTPUT ON
DECLARE
v_first_name copy_employees.first_name%TYPE: = 'a ';
v_last_name copy_employees.last_name%TYPE: = 'b ';.
v_email_id copy_employees.email%TYPE: = ' [email protected]';
v_hire_date copy_employees.hire_date%TYPE: = SYSDATE;
v_department_id copy_employees.department_id%TYPE: = 25;
v_error_code varchar2 (10);
v_error_msg varchar2 (60);
BEGIN
new_emp (v_first_name, v_last_name, v_email_id, v_hire_date,' ', NULL, NULL, NULL, v_department_id, v_error_code, v_error_msg);
DBMS_OUTPUT. Put_line (v_error_msg);
END;
-Valid, present department_id in the departments table.
DECLARE
v_first_name copy_employees.first_name%TYPE: = 'a ';
v_last_name copy_employees.last_name%TYPE: = 'b ';.
v_email_id copy_employees.email%TYPE: = ' [email protected]';
v_hire_date copy_employees.hire_date%TYPE: = SYSDATE;
v_department_id copy_employees.department_id%TYPE: = 80;
v_error_code varchar2 (10);
v_error_msg varchar2 (60);
BEGIN
new_emp (v_first_name, v_last_name, v_email_id, v_hire_date,' ', NULL, NULL, NULL, v_department_id, v_error_code, v_error_msg);
DBMS_OUTPUT. Put_line (v_error_msg);
END;
Unit tests: -.
========
SQL > SELECT * FROM departments;
DEPARTMENT_ID DNAME
------------- --------------------
DEPT1 80
SQL > SET SERVEROUTPUT ON
SQL > DECLARE
2 v_first_name copy_employees.first_name%TYPE: = 'a ';
3 v_last_name copy_employees.last_name%TYPE: = 'b ';.
4 v_email_id copy_employees.email%TYPE: = ' [email protected]';
5 v_hire_date copy_employees.hire_date%TYPE: = SYSDATE;
6 v_department_id copy_employees.department_id%TYPE: = 25;
v_error_code 7 varchar2 (10);
8 v_error_msg varchar2 (60);
BEGIN 9
10 new_emp (v_first_name, v_last_name, v_email_id, v_hire_date,' ', NULL, NULL, NULL, v_department_id, v_error_code, v_error_msg);
11 DBMS_OUTPUT. Put_line (v_error_msg);
12 END;
13.
DECLARE
*
ERROR on line 1:
ORA-20999: the department_id entered is invalid, please try again
ORA-06512: at «WMIS.» NEW_EMP', line 44
ORA-06512: at line 10
SQL > DECLARE
2 v_first_name copy_employees.first_name%TYPE: = 'a ';
3 v_last_name copy_employees.last_name%TYPE: = 'b ';.
4 v_email_id copy_employees.email%TYPE: = ' [email protected]';
5 v_hire_date copy_employees.hire_date%TYPE: = SYSDATE;
6 v_department_id copy_employees.department_id%TYPE: = 80;
v_error_code 7 varchar2 (10);
8 v_error_msg varchar2 (60);
BEGIN 9
10 new_emp (v_first_name, v_last_name, v_email_id, v_hire_date,' ', NULL, NULL, NULL, v_department_id, v_error_code, v_error_msg);
11 DBMS_OUTPUT. Put_line (v_error_msg);
12 END;
13.
Complete insert
PL/SQL procedure successfully completed.
Thank you
Ann
Tags: Database
Similar Questions
-
my internet is not works, said that the computer seems to be correctly configured but the device or resource DNS does not
Can you check this problem on Firefox 9?
-
Conditional loop does not work correctly.
Hello
If you look at my code, its all about the analysis of a dictionary. IM check the dictionary for the word 'aardvark '. It gives me wrong all the time. When "aardvark" is the first word of the table, IE my_dictionary [0] is "aardvark". I wonder why the conditional loop does not work very well. IM checking if the user string aardvark is == my_dictionary ; he should give me the true value.
Is there an error in the code? Can someone explain to me where im going wrong?
PS-> put everywhere traces gives me the right output. Except for the result of the if() function.
Best regards and many thanks in advance.
Roshan KolarHi Raymond,
Thanks for the reply. I had the problem, actually the conditional loop was perfect, the analysis was not. The reason is, a few words in the dictionary had a return of cart/jump of line/space to the index of the last after the word. It was randomly, so some words have been taken, but some were not as "vicious" == "vicious" - gives the INVALID WORD.
So I was thinking about the parser, where I removed the unwanted last tank - now the condition has worked well. Thank God I worked even after the publication of the request.
Thank you very much Raymond.
Kind regards
Roshan -
my iphone 6s is stolen I had activated find my iphone, but now the device does not appear on my icloud find my iphone please suggest what to do.
If your iPhone, iPad or iPod touch is lost or stolen - Apple supports
-
When you try to print in Firefox and when the scale to the size of the page in the page layout, the first page prints correctly, but the following pages do not scale correctly and are too large for the paper, with the parts of the text are cut off at top and right. It is not fixed by checking or unchecking the scaling / shrink to fit page width "ignore" in the print window, or by changing the scale percent.
I am running Firefox 15.0.1, on Mac OS 10.5.8.
The same problem happens in preview print and if I save the copy in a .pdf file
I tried all the fixes in the how to and others in various forums with no improvement.
This happens everytime I try to print a document from scaling upwards or downwards in Firefox.
I note the bug has been fixed and should in Firefox 21 right now, it will mean the use night http://nightly.mozilla.org/
-
My Apple Watch does not turn off. When I go to turn off the slider isn't in the article to stop, I can restart but the cursor still does not appear
Hello
It is not possible to disable Apple Watch when its on the charger and connected to the power supply - this is normal.
-
Original title: sharing printer problems!
I am trying to share a printer, so I can access it from another computer on my network, it sems to cross, but the shared icon does not appear? Why is this?
I'm on windows xp professional
Hi Pazza1995,Follow the steps listed in the articles below and check if it helps to fix the problem: -
Windows displays the device works correctly. However, the device does not appear in windows Explorer. also, I can not format disks.
What should I do next
Hello
- Are you referring to the NEC USB Floppy Driver?
- You try to format floppy disks?
- Was - this earlier work, if so, did the chnages on the computer before this problem?
If it worked, I suggest the following methods and check the status of the issue.
Method 1:
Open the hardware and devices troubleshooter.
http://Windows.Microsoft.com/en-us/Windows7/open-the-hardware-and-devices-Troubleshooter
Method 2:
Update a hardware driver that is not working properly.
http://Windows.Microsoft.com/en-us/Windows7/update-a-driver-for-hardware-that-isn ' t-work correctly
-
When I try to import multimedia an error reads "in QuickTime and or the appropriate codec does not appear to be installed."
[moved based on duplicated... messages which I deleted... MOD]
You try to make a DVD or Blu - ray (or both)?
This absurd error with 2 exports that you describe. If Yes, provide the screenshot of mediainfo John queries.
-
Tried to install adobe apps after renewal of the license but the creative cloud does not appear
Tried to install adobe apps after renewal of the license but the creative cloud does not appear, the creative cloud set up has been successful, but when I tried to open it it was all white... no application at all
Hi Karlo,.
Hope that helps!
Kind regards
Sheena
-
I own Acrobat Pro and downloaded the latest version. I also improved my 2016 from office to office, but the Acrobat option does not appear in the Office components like previously in 2013 office. How can I get that back? I often secret several worksheets in PDF format and it is tedious to print them one at a time and then combine. I used to be able to select all the worksheets I wanted and combine them in one go.
Hi steverobb,
Acrobat XI is not compatible with Office 2016 for the moment. Please wait for future updates.
Kind regards
Nicos -
I am trying to create a button print in my form, but the Action tab does not appear
I am trying to create a button print in my form, but the Action tab does not appear
I thought about it. When I tried to create a new form, I chose the "this form needs the signatures '. This option does not allow to add action buttons. If I create the form without checking the signature box, it works.
-
I try to get new version of Adobe Reader, but I get an error message that my Adobe 9.5.2 patch does not exist. I can see it in my programs, it's on the list to remove but it won't remove and it cannot be changed. It is aimed at preventing a new working version... I got lost. I have Windows XP.
Hi Vicky,
Please run this tool cleaning, Download Adobe Reader and Acrobat cleaning - Adobe Labs tool, restart your computer and download the latest version of Adobe Reader using this link Adobe - Adobe Acrobat Reader DC Distribution
Let me know if you are still having a problem.
Kind regards
Nicos
-
I'm unable to install photoshop elements13 as a result of a mistake. It shows no error code but said - this installer does not support installation on a 64-bit Windows operating system. Please download the 64-bit version of Photoshop Elements.
Download the 64-bit Installer,
Downloads available:
- Suites and programs: CC 2014 | CC | CS6 | CS5.5 | CS5 | CS4 | CS3
- Acrobat: XI, X | 9,8 | 9 standard
- First Elements: 13 | 12 | 11, 10 | 9, 8, 7 win | 8 mac | 7 mac
- Photoshop Elements: 13 | 12 | 11, 10 | 9,8,7 win | 8 mac | 7 mac
- Lightroom: 5.7| 5 | 4 | 3
- Captivate: 8 | 7 | 6 | 5
- Contribute: CS5 | CS4, CS3
Download and installation help links Adobe
Help download and installation to Prodesigntools links can be found on the most linked pages. They are essential; especially steps 1, 2 and 3. If you click on a link that does not have these listed steps, open a second window by using the link to Lightroom 3 to see these "important Instructions".
-
I have a new computer with Windows 7 Professional, Office 2007, Adobe XI. I just created a word document and tried save it in PDF format, but the PDF option does not appear in the menu dropdown. Any ideas please? Thank you.
What is "Adobe XI" - Reader or Acrobat?
But, "Save as Adobe PDF" is a function of Word, independent of this Adobe software, you have installed.
-
Installation ok on iMac OSX 10.9.5 seemed elements 13. The IMac is restarted. Tried to open items. Open but the splash screen does not open. There was only 1 menu 'Photoshop Elements' no other drop downs appeared
If you go into the applications folder, can you open Adobe organizer of 13 elements, or the Editor directly? The editor is well hidden. It is located in the support files folder in the Adobe Photoshop elements 13 folder:
Maybe you are looking for
-
HP Pavilion dv7-6151sd: cooling fan not working - 90 b (dv7-6151sd) error code
-
How to transfer apps blackBerry smartphones?
I just replaced my BB Curve with an identical phone due to hardware problems in the first. I could transfer all the contacts, messages and documents etc. by using the backup and restore the master program of office of BB, but it did not transfer my a
-
BlackBerry smartphones anyone using the 9700 on Orange in the United Kingdom?
Just buy a 9700 but find that the device will not configure e-mail without changing the phone at Orange plan. I wonder if someone managed an Orange here connection if yes what plan do you have had to put in place? Thank you
-
I just installed LR5 and extended CS6 (bought in2013) in 10 new computer window. First installed CS6 then LR5. LR5 would not export to CS6. Then times uninstalled and reinstalled LR5 first and then CS6. LR will send the file over to the CS6, but n