Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 11-17-2004, 01:15 PM   #1
Member (6 bit)
 
buddhad's Avatar
 
Join Date: Mar 2002
Posts: 45
MySQL Stored Procedure

Hello All,

I am trying to create a stored procedure in MySQL that takes as input, among other values, a parameter that gives a column name to select. I can't seem to get this to work and am not even sure if it is possible. So my question would be, is this possible and if so how? I am posting some code to show what I have tried so far.


create procedure myProc (col_name varchar(100), ...)
begin
select col_name from table where ....;
end

create procedure myProc(col_name varchar(100),...)
begin
set @s = "select " + col_name + " from table where ...";
prepare testStmt from @s;
execute testStmt using ...;
deallocate testStmt;
end


Thanks in advance

AG
buddhad is offline   Reply With Quote
Old 12-01-2004, 08:39 PM   #2
Member (7 bit)
 
Join Date: Nov 2003
Location: LA
Posts: 101
Send a message via AIM to HNPFL
MySql Version ?

Depending on the version of MySql that your server is running will depend on weather or not you can even run a stored procedure. The newest version does.
HNPFL is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:11 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2