Hi,
I´m trying to make my SQL statement more dynamic and efficient. For every unique row creating I need to create a new SQL statement for just that particular row.
In my table I have a unique autoincrement number
ObNum
The total rows
ObNum could vairy a lot from day to day. So for every time a new unique row is added I have to change the code of my SQL.
SQL example:
Code:
SELECT my_table.ObNum,
my_table.column1, // 2
my_table.column2, // 3
my_table.column3, // 4
FROM my_table
WHERE date = today() - 1 AND ObNum = 1;
OUTPUT TO c:\export\ dep_01.txt delimited by '\x09'
As you see in my WHERE statement my ObNum is 1 and the OUTPUT TO is dep_01.txt.
Next row...
Example:
Code:
SELECT my_table.ObNum,
my_table.column1, // 2
my_table.column2, // 3
my_table.column3, // 4
FROM my_table
WHERE date = today() - 1 AND ObNum = 2;
OUTPUT TO c:\export\ dep_02.txt delimited by '\x09'
As you see in my WHERE statement my ObNum is 2 and the OUTPUT TO is dep_02.txt.
Result in c:\export\ becomes
dep_01.txt
dep_02.txt
I think a need create two VARIABLES, one for ObNum and one for dep_. Combined with a LOOP I guess but not really sure ?
// Regards