Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


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

Choosing a Column Depending on Procedure Argument

Question:
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;
END PROCEDURE
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.)

Answer:
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.

 

 

Sitemap