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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help.

Status
Not open for further replies.

spacedancer

Programmer
Jun 20, 2002
1
US
I am trying to insert a comment in a Likes table for a focus group, and the comment is supposed to go to the specific university that the user selects from the list, but instead it inserts itself in all of the universities.

how can i specify in my insert query so that the comment goes only to the university selected from the list?

here is my query:

INSERT INTO gv_likes (f_id, u_id, l_id, l_participants, l_comment)
VALUES ('#FORM.f_id#', '#FORM.u_id#', '#VARIABLES.l_id#',
'#FORM.l_participants#', '#FORM.l_comment#')
here are some table codes to make it more understandable:

create table gv_focus_group
(
f_id VARCHAR2(35),
f_demographics VARCHAR2(100),
f_name VARCHAR2(40),
CONSTRAINT gv_focus_group_PK PRIMARY KEY (f_id)
);

create table gv_university
(
f_id VARCHAR2(35),
u_id VARCHAR2(35),
u_name VARCHAR2(100),
CONSTRAINT gv_university_PK PRIMARY KEY (u_id),
FOREIGN KEY (f_id) REFERENCES gv_focus_group(f_id) ON DELETE CASCADE
);

create table gv_likes
(
f_id VARCHAR2(35),
u_id VARCHAR2(35),
l_id VARCHAR2(35),
l_participants NUMBER(4),
l_comment VARCHAR2(300),
CONSTRAINT gv_ikes_PK PRIMARY KEY(l_id),
FOREIGN KEY (f_id) REFERENCES gv_focus_group(f_id),
FOREIGN KEY (u_id) REFERENCES gv_university(u_id) ON DELETE CASCADE
);

Thank you!
 
U CAN DO THIS ONLY IN YOUR CODE. IT'S NOT REALY AN SQL ISSUE.U NEED TO SAVE IN A VARIABLE THE NAME OF THE university AND WITH AN "IF" U CAN SOLVE YOUR PROBLEM.
:)
gOOD lUcK ! web/sql developer
 
Insert will add one row at a time.
I think you mean to update.

Don't forget to qualify the where statement in the Update to update only the one record you want, else, as it happened, all rows are updated.
AA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top