/* Note: default for serveroutput is OFF.
Therefore no 'Insert attempted' as I did not switch it on by
set serveroutput on; */
SQL> CREATE OR REPLACE PROCEDURE add_vacc (pat_id in char, vis_vdate in date, vis_act in number, vac
_vacc in char)
2 AS
3 BEGIN
4 insert into vaccinations(pi d,vdate,action, vaccinated) values(pat_id,v is_vdate,vis_ac t,vac_vacc)
;
5 DBMS_OUTPUT.PUT _LINE ('Insert attempted');
6 END;
7 /
Procedure created.
SQL> execute add_vacc('2','1 6=dec-1999',3,'choler a');
PL/SQL procedure successfully completed.
SQL> select * from vaccinations
2 where pid = '2' and action = 3;
PID VDATE ACTION VACCINATED
------ --------- ---------- --------------------
2 06-AUG-91 3 polio
2 16-DEC-99 3 cholera
SQL> commit;
Commit complete.
/* Commit saves current state of database */
SQL> execute add_vacc('2','1 6-dec-1999',1,'choler a');
BEGIN add_vacc('2','1 6-dec-1999',1,'choler a'); END;
*
ERROR at line 1:
ORA-00001: unique constraint (CGNR1.PKVAC) violated
ORA-06512: at "CGNR1.ADD_VACC ", line 4
ORA-06512: at line 1
/* violates primary key constraint for vaccination */
SQL> execute add_vacc('2','1 7-dec-1999',1,'choler a');
BEGIN add_vacc('2','1 7-dec-1999',1,'choler a'); END;
*
ERROR at line 1:
ORA-02291: integrity constraint (CGNR1.SYS_C008 0698) violated - parent key not found
ORA-06512: at "CGNR1.ADD_VACC ", line 4
ORA-06512: at line 1
/* foreign key violation */
SQL> execute add_vacc('2','1 6-dec-1999','4','chol era');
PL/SQL procedure successfully completed.
/* Note: action entered as char with quotes but type cast to number */
SQL> select * from vaccinations
2 where pid = '2' and action = 4;
PID VDATE ACTION VACCINATED
------ --------- ---------- --------------------
2 16-DEC-99 4 cholera
SQL> execute add_vacc('2','1 6-dec-1999','4',chole ra);
BEGIN add_vacc('2','1 6-dec-1999','4',chole ra); END;
*
ERROR at line 1:
ORA-06550: line 1, column 38:
PLS-00201: identifier 'CHOLERA' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
/* cholera not in quotes is taken as (undeclared) variable, not as value */
SQL> execute add_vacc('2','1 6-maz-1999','4','chol era');
BEGIN add_vacc('2','1 6-maz-1999','4','chol era'); END;
*
ERROR at line 1:
ORA-01843: not a valid month
ORA-06512: at line 1
/* month is maz, should presumably be mar or may */
SQL>
1. transaction commands (commit/rollback);
2. a business rule that no more than two vaccinations are allowed per day
3. a business rule that the vaccination date must be no earlier than 1st January 2003
4. an exception handler that catches any error and displays the error code.
3 1942
Do you have any questions ?
Why you have posted all that code here ?
Do you have any questions ?
Why you have posted all that code here ?
I need to know the step how to used the business rules in this code please help
I am new to oracle
I need to know the step how to used the business rules in this code please help
I am new to oracle
if y ou are looking for any PLSQL standards then you can refer some documents for this purpose.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Kingdom |
last post by:
In my data base I have a list of componet types e.g. type A - I have 8 off
- type B I have 12 off etc.
I'm using
Set objRS = objDC.Execute("Select DISTINCT Component_Type FROM
Parts_Table")
to populate a drop down but would like to use several drop downs
restricting the contents of each drop down to the records pertaining to one
|
by: Sabrina |
last post by:
Hi everybody,
I need some help in SQL Server. I am looking for a command that will "Drop
all user table" in a
user database.
Can anyone help me?
Thank you very much
Sabrina
|
by: ehm |
last post by:
I am working on creating an editable grid (for use in adding,
deleting, and editing rows back to an Oracle database). I have a JSP
that posts back to a servlet, which in turns posts to a WebLogic SFSB
and, from there, to the database.
On the front end, all cells appear as text fields. However, for
certain cells, when the user clicks on the cell, the text field turns
into a drop-down field (i.e. Select object), defaulting to the value...
|
by: Dave |
last post by:
I need to add the ability to drag from a Windows Form and drop into a
non dotNet application. For example, having a generated image in my
app that I wish to drag out into explorer as a friendly way to save
it.
I have tried creating the object that I place into the DoDragDrop() by
inheriting the COM interfaces IDropSource and IDataObject with no
luck. If anyone can help I am very much open to suggestions.
Thanks in advance!
|
by: Torre Quinn |
last post by:
Does anyone have any good sites or resources dealing with adding drag and
drop functionality to a set of controls on a form? I'd like to try to get
several examples of varied applications of drag and drop being used on
different types of controls.
My current task is this. I have a treeview control and a data grid control.
The data grid has two fields, 'value' and 'name'. I want to be able to drag
nodes from the tree view and drop them...
| |
by: Yoshitha |
last post by:
hi
I have 2 drop down lists in my application.1st list ontains itmes like
java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the
items like 50,60,70,80,90,100.
i will select any skill in 1st drop down list then i'll select % of this
skill in the 2nd list box , based on the percentage i've selected in the 2nd
list box it has to display
2 sets of drop down list boxes at run time one for selecting skill and
|
by: Vigneshwar Pilli via DotNetMonster.com |
last post by:
string connectionString1 = "server=(local); user=sa;password=sa;
database=sonic";
System.Data.SqlClient.SqlConnection dbConnection1 = new
System.Data.SqlClient.SqlConnection(connectionString1);
System.Data.SqlClient.SqlCommand dbCommand1 = new
System.Data.SqlClient.SqlCommand();
|
by: callawayglfr |
last post by:
I am building a database in access where I have a drop down box that
relates to a text box, that part I have working but when someone
selects information from the first drop down I need it to limit the
second drop down to just the related information. Explaining this is
obviously challeging. So I'll try to draw a picture:
(drop down 1) Select number --- once selected description is populated
in text box
(drop down 2) based on first...
|
by: pagelogix |
last post by:
I'm looking for a way to drop multple tables at the same time from my
access database. Any ideas?
Thanks.
|
by: ashok893 |
last post by:
I'm using two drop down list in a form. I have generated the first drop down list from MySQL database with the help of PHP. When i select an option from first drop down list, i have to generate second drop down list options by the selected value of first drop down list from MySQL database.
For example, the first drop down list contains Animals, Birds... If i select the Animal option, the second drop down list should show like Lion,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |