I think that title of this post isn’t matching exactly with what I want to write in it. The problem is like –
You want to write about 100+ INSERT/UPDATE statements for single column (say COL7) of a TABLE (say TEMP) because that column has 100+ different values in it.
There are three possible solution for doing this –
- You manually write 100+ statements for different column values of that table. It will be like –
- INSERT INTO TEMP VALUES (‘A’,’B’,VAL1,’C’) WHERE …;
- INSERT INTO TEMP VALUES (‘A’,’B’,VAL2,’C’) WHERE …; etc.
- You write single select statement for generating 100+ INSERT statements for the 100+ different column values which will be like –
- SELECT ‘INSERT INTO TEMP VALUES(“A”, “B”, ‘||COL7||’, “C”) WHERE …;’
- Third way is of creating single procedure with single cursor with single FOR loop and it will solve the problem – the best way, I think.
I was just discussing it with a colleague and thought of posting it here.
Thank you, Boss. I still remember the things!!
This is good