Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Informix
Expertise: Beginner
Oct 16, 2000



Application Security Testing: An Integral Part of DevOps

Choosing a Column Depending on Procedure Argument

Can I specify the column I want to select from as an argument to the procedure? Something like:
create procedure show_product(language char(2), ID integer) returning char(255);

define p_prod_name CHAR (255);
select language INTO p_prod_name from productnames where prod_id = ID;

return p_prod_name;
The table productnames would then contain a column for each countrycode and, depending on the argument I pass to the procedure, I would get the name of the product in the correct language. (I am running IDS 7.3 on Linux.)

Sure, that's done all the time. Another way would be to create a stored procedure with a series of IF statements. Look at the following pseudocode:

IF passed_in = "ENGLISH" then 
   SELECT english_name from table where ID = blah

IF passed_in = "DEUTSCH" then
   SELECT german_name from table where ID = blah
DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date