Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help with PL/SQL code

Status
Not open for further replies.

AndreaL

Technical User
Feb 22, 2002
1
US
Can anyone help me create a procedure or
anonymous block named New_Member that will
prompt the user for First_Name, Last_Name, Street,
City, Phone, and Valid_Date.
It will insert this data into a table
called S_Member. If this data
is distinct, if it is not already in the
database it will give a message that
gives the new users member id. I have a
sequence generator named s_member_id
that will give the id. If the person is
already in the database it will give a message saying
that this user is already in the database.
Any help will be appreciated. Thanks.
Andrea
 
try this code. I have not encluded all the columns you need in your table. I only added the first and the last name. But you could just add the other information as you require;

create or replace procedure new_member
is
name_one varchar2(10);
name_two varchar2(10);
ctr number;
id_number number;

CURSOR C_ONE IS SELECT first_name,last_name FROM table_a;
begin
select '&name1' into name_one from dual;
select '&name2' into name_two from dual;
FOR C_TWO IN C_ONE LOOP
IF C_TWO.FIRST_NAME <> name_one or c_two.last_name <> name_two then
insert into table_a(first_name,last_name) values(name_one,name_two);
id_number := ctr;
dbms_output.put_line(id_number);

else
dbms_output.put_line ('name already exist');
end if;


end loop;
end;
/

hope this helps you out!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top