473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Drop by to ask for help

2
/* 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(pid,vdate,action,vaccinated) values(pat_id,vis_vdate,vis_act,vac_vacc)
;
5 DBMS_OUTPUT.PUT_LINE ('Insert attempted');
6 END;
7 /

Procedure created.

SQL> execute add_vacc('2','16=dec-1999',3,'cholera');

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','16-dec-1999',1,'cholera');
BEGIN add_vacc('2','16-dec-1999',1,'cholera'); 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','17-dec-1999',1,'cholera');
BEGIN add_vacc('2','17-dec-1999',1,'cholera'); END;

*
ERROR at line 1:
ORA-02291: integrity constraint (CGNR1.SYS_C0080698) 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','16-dec-1999','4','cholera');

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','16-dec-1999','4',cholera);
BEGIN add_vacc('2','16-dec-1999','4',cholera); 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','16-maz-1999','4','cholera');
BEGIN add_vacc('2','16-maz-1999','4','cholera'); 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.
Jul 23 '08 #1
3 1924
debasisdas
8,127 Expert 4TB
Do you have any questions ?

Why you have posted all that code here ?
Jul 23 '08 #2
nur08
2
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
Jul 24 '08 #3
amitpatel66
2,367 Expert 2GB
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.
Jul 28 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

46
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") ...
1
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
2
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...
4
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...
1
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...
2
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...
5
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);...
7
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...
4
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.
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.