Read TABLE and write in TXT file

Hi,
I want to read the values from a table in ASA9 and want them in TXT file format delimted by tab.I use PB10.

(I can use SELECT n OUTPUT stt in ISQL and do the same, but it seems I cannot write TXT file using Stored Proc.)

Any idea ?
Thanks
M
mahalakshmi_sAsked:
Who is Participating?
 
buasuwanCommented:
Hi,
   
   The simplest way to export your data to text file is creating a datawindow object, call retrieve() and then saveas().  And here is the codes.


datastore   lds_obj

lds_obj = create datastore
lds_obj.dataobject = "d_your_datawindow_object"  // SELECT n OUTPUT stt
lds_obj.SetTransObject(sqlca)

lds_obj.Retrieve()
lds_obj.SaveAs("your_text_file.txt", Text!, false)


Hope this help,

Buasuwan
0
 
sandeep_patelCommented:
Hi,

It depends on whether you want to write a programme in powerbuilder or just want to export data of any table from back end.

1) For powerbuilder...solution given by Buasuwan

2) to export data from back end...see help for Unload table command

UNLOAD [ FROM ] TABLE [ owner. ]table-name TO filename
[ unload-option . . . ]
unload-option :
APPEND{ON | OFF}
| DELIMITED BY string
| ESCAPE CHARACTER character
| ESCAPES {ON | OFF}
| FORMAT {ASCII | BCP}
| HEXADECIMAL {ON | OFF}
| ORDER {ON | OFF}
| QUOTES {ON | OFF}
filename : { string | variable }

Regards,
Sandeep
0
 
mahalakshmi_sAuthor Commented:
Sandeep,
This UNLOAD is not working inside StoredProc ,only from ISQL :-((((((
will work onBuasuwan's option now.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.