If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Sybase > Dynamic SELECT OUTPUT to text file ?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-19-11, 04:13
mberggren mberggren is offline
Registered User
 
Join Date: Oct 2007
Posts: 29
Dynamic SELECT OUTPUT to text file ?

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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On