Try the following:
SET PROCEDURE Xpt2MailMerge LOCK ON
PUT PRC00076.STP AS Xpt2MailMerge +
'Export View/Table (name="Xp%") Data for use as Mail Merge input'
SET PROCEDURE Xpt2MailMerge LOCK OFF
RETURN
--- stored procedure ---
SET QUOTES='
SET VAR Xpt076ViewName TEXT
LABEL Beg076
CHOOSE Xpt076ViewName FROM #VALUES +
FOR SYS_TABLE_NAME,(CTXT(SYS_TABLE_ID)+CHAR(44)+SYS_TABLE_NAME) +
FROM SYS_TABLES WHERE SYS_TABLE_NAME LIKE 'XP%' +
ORDER BY SYS_TABLE_NAME ASC AT CENTER CENTER CLEAR TITLE 'Select Item'
IF Xpt076ViewName = '[ESC]' THEN
CALL ApShowMsg(190)
GOTO Xit076
ENDIF
IF Xpt076ViewName = 'HELP' THEN
CALL ApShowMsg(191)
GOTO Beg076
ENDIF
CLS
SET VAR Xpt076FileName TEXT
SET VAR Xpt076RspKey TEXT
DIALOG 'Enter the file name (d:\path\filename):' Xpt076FileName Xpt076RspKey 1
IF Xpt076RspKey = '[Esc]' THEN
CALL ApShowMsg(190)
GOTO Xit076
ENDIF
SET VAR Xpt076Feedback=(CVAL('FEEDBACK'))
SET VAR Xpt076Heading=(CVAL('HEADINGS'))
SET VAR Xpt076Width=(CVAL('WIDTH'))
SET WIDTH 750
SET HEADINGS OFF
SET FEEDBACK ON
OUTPUT .Xpt076FileName
SET SELMARGIN 1
SELECT LISTOF(SYS_COLUMN_NAME)=750 FROM SYS_COLUMNS +
WHERE SYS_TABLE_ID=(INT((SSUB(.Xpt076ViewName,1))))
SET SELMARGIN 2
SET VAR Xpt076ViewName=(SSUB(.Xpt076ViewName,2))
SET NULL ' '
SET QUOTES="
UNLOAD DATA FOR &Xpt076ViewName AS CSV
SET QUOTES='
SET NULL -0-
OUTPUT SCREEN
SET FEEDBACK .Xpt076Feedback
SET WIDTH .Xpt076Width
SET HEADINGS .Xpt076Heading
LABEL Xit076
CLEAR VAR Xpt076%
-- STP: Xpt2MailMerge v1.0 03-AUG-2008 by JRB
-- Procedure export data as CSV for Mail Merge. Build header
-- independent of driving view. Fields containing delimit char must be
-- enclosed in " char. Also need to set NULL to blanks as RBase
-- includes '-0-' in empty fields.
RETURN
Note the call to ApShowMsg is another stored procedure which access an error
message or help message.
Also, in the table/view CHOOSE note how I am limiting to XP% start of name. You
probably will have to make adjustment to that code.
Also, The field name are not enclosed in quote characters.
Jim Bentley
American Celiac Society
[EMAIL PROTECTED]
tel: 1-504-737-3293
----- Original Message ----
From: Dennis McGrath <[EMAIL PROTECTED]>
To: RBASE-L Mailing List <[email protected]>
Sent: Thursday, November 13, 2008 11:09:03 AM
Subject: [RBASE-L] - RE: Programmatically Export to CSV
I just wrote this export.
This method creates a clean csv file which never fails to be read by excel.
Dennis
set var vfile = 'c:\temp.csv'
set null ' '
set eof off
out &vfile
wri
'"TransID","CloseDate","Cust","Target","StoreID","OrigTransID","Warr?","SR","Scode","Decription"'
set quotes=""""
unload data from WarrantyService +
using TransID,CloseDate,Cust,CustTarget,StoreID,+
OrigTransID,UnderWarranty,ServiceRequest,FinalSCode,FinalSCodeDesc +
as ascii +
where CloseDate between "1/1/2007" and "12/31/2007" +
and finalproblem = "sb-n"
set quotes=''''
out scr
set eof on
set null -0-
________________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Gray, Damon
Sent: Thursday, November 13, 2008 9:39 AM
To: RBASE-L Mailing List
Subject: [RBASE-L] - Programmatically Export to CSV
In 6.5++ is there a means of programmatically exporting a table to a CSV or
XLS? I see I can to it through the GUI, but would like to make that part of a
sproc.
wwwww
( @ @ )
------oOO---(_)---OOo------
Damon J. Gray
Business System Services
Anvil Corporation
(360) 937-0770
oooo0 0oooo
( ) ( )
---------\ (----) /----------
\__) (__/