oracle - how to incorporate dynamic column name in sql query -


i have table, has columns, week1,week2, week3 , on.

i have stored procedure, , based on number input, want select column.

example, if input 4 want make query,

select *  table_name  week4=<something> 

is there way other using dynamic query? because dynamic thing small part of huge query.

the comments normalization right, if have no choice, can use "or" clauses:

declare @inputvalue int; set @int = 1;  select *   <table>  (week1 = <something> , @inputvalue = 1)     or (week2 = <something> , @inputvalue = 2)     or (week3 = <something> , @inputvalue = 3)     or (week4 = <something> , @inputvalue = 4) 

this slow if tables of size, won't using indexes. wouldn't suggest doing unless you're absolutely unable change table structure.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -