Skip to content
Advertisement

please find the solution of this problem. ( in PL SQL ) ——–

I’m doing an assignment and the last question states that I call the procedure from question 2 and function from question 3 and then put them in an insert clause(question 4).

  1. Write a PL/SQL Code for an anonymous block to do the following (in package):

a) Get the doctor name for a given doctor id (read from keyboard) using a function [FunGetDoctorName].

b) Get the department name for a given department id (read from keyboard) using a procedure [ProGetepartmentName].

c) Insert the doctor name and department name (which you got from the function and

procedure) by including serial number and current date into the visitings table.

put the answer in ( Package)

this is my table codes:

My function

My procedure

here is the problem:

I keep getting errors :

SP2-0552: Bind variable “DOCID” not declared.

Advertisement

Answer

First of all, your procedure must have one in and one out parameter so that you can pass deptno and get deptname as the output.

In your pl/sql block, you can use substitution variable to take an input from keyboard as follows:

Note:

  1. Instead of fetching count from table and adding one into it for slno, you should use the sequence.
  2. In procedure and function, use exception block to handle no row found or multiple record found or any other issues gracefully.
  3. While inserting in to table, you should also use exceprion block to handle issues gracefully. (In your case it is needed because of the count(slno) + 1 logic as it can assign same number to different sessions executing simentaneously which my lead to primary key violation)
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement