Add dynamic Numbers to the strings in sql

35 Views Asked by At

My plsql procedure has a variable that holds a concatenated string of values.

var_string1 :='ABC'
var_string2 :='APPLE'
var_string3 :='BIKE'
var_string4 :='DESK'

var_reas :=var_string1||','||var_string2||','||var_string3||','||var_string4);

I need to print these to a file as 4 different columns as below along with numbering

utl_file.put_line(filename,var_id,var_name,'1)'||var_string1 ,'2)'||var_string2 ,'3)'||var_string3 ,'1)'||var_string4); 

The string var_string1 if blank then that should not be printed but the numbering has to be maintained.

utl_file.put_line(Filename,var_id,var_name,'1)'||var_string2 ,'2)'||var_string3 ,'3)'||var_string4); 

I am thinking a counter on var_reas and then a loop to add the numbers, but i am unsure how to accomplish that .

0

There are 0 best solutions below