MySQL Forums
Forum List  »  Stored Procedures

How to declare column name as a parmeter?
Posted by: Eva Hansen
Date: November 24, 2005 03:22AM

The code is as seen below. The error is that the column name in the update statement is a parameter and I cant solve how the parameter should be declared.
Is there anybody who has a solution of this problem?

CREATE PROCEDURE `sp_update_spss`()
BEGIN
declare id_trial_count ,query_name_ans_count, n,p integer;
declare var_version_no char (3);
declare var_project_no char(4);
declare var_id_no char(10);
declare var_trial_no integer;
declare var_query_name char(64);'The declared name of the column
declare var_query_ans integer;



declare get_id_trial cursor for select id_no,trial_no from login
where id_mysqlstored is null and id_finish=1;

declare get_query_name_ans cursor for select query_name, query_ans from query_internet where id_no=
var_id_no and trial_no= var_trial_no;

declare get_table cursor for select id_no,trial_no,query_ans,query_name from query_internet where query_name=var_query_name;

select count(*) into id_trial_count from login where id_mysqlstored is null and id_finish=1;

select id_no,trial_no,query_ans,query_name from query_internet where query_name=var_query_name;

set n=1;

open get_id_trial ;

repeat
fetch get_id_trial into var_id_no,var_trial_no;
select count(*) into query_name_ans_count from query_internet where id_no=
var_id_no and trial_no= var_trial_no;
open get_query_name_ans;
set p=1;
repeat
fetch get_query_name_ans into var_query_name,var_query_ans;

update query_spss_v01 set var_query_ans where id_no=var_id_no and trial_no=var_trial_no;
set p=p+1;
until n>query_name_ans_count end repeat;
close get_query_name_ans;
set n=n+1;
until n>id_trial_count end repeat;
close get_id_trial;

END$$

Options: ReplyQuote


Subject
Views
Written By
Posted
How to declare column name as a parmeter?
4469
November 24, 2005 03:22AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.