I found my mistake already while I read the SQL Grammar.
Next is the result generated by the query have a header I don't want.
How can I customize the header of the output file? For example
_____A_____B_____C_____D
___1| This result is queried at time xxxxxxx (xxxxxxx is current time
that query executed)
___2| (this line is a result from query)
___3| (this line is a result from query)
.
.
.
.
___n| (this line is a result from query)
Thank you for your help.
Phamorn Hongsawat
On Tuesday, August 5, 2014 9:14:00 AM UTC+7, Phamorn Hongsawat wrote:
>
> I try with this query
>
> SELECT 'icetea--NagLogApplicationError--' || SPOOLER_ID ||
> '--critical--JOB ' || Job_NAME || ' status ERROR at time ' || END_TIME ||
> '--ROC' FROM SCHEDULER_HISTORY WHERE JOB_NAME = 'SMS_Test' AND ERROR =
> 'TRUE'
>
> the result is satisfied but when I try to use CSVWRITE it's syntax error
>
> the query is
>
> CALL CSVWRITE('nag_log.csv', 'SELECT 'icetea--NagLogApplicationError--' ||
> SPOOLER_ID || '--critical--JOB ' || Job_NAME || ' status ERROR at time ' ||
> END_TIME || '--ROC' FROM SCHEDULER_HISTORY WHERE JOB_NAME = 'SMS_Test' AND
> ERROR = 'TRUE'', 'charset=UTF-8 fieldSeparator=||');
>
> and the error message is
>
> Syntax error in SQL statement "CALL CSVWRITE('nag_log.csv', 'SELECT
> 'ICETEA[*]
>
>
>
> ;
> "; expected "[, ::, *, /, %, +, -, ||, ~, !~, NOT, LIKE, REGEXP, IS, IN,
> BETWEEN, AND, OR, ,, )"; SQL statement:
> CALL CSVWRITE('nag_log.csv', 'SELECT 'icetea--NagLogApplicationError--' ||
> SPOOLER_ID || '--critical--JOB ' || Job_NAME || ' status ERROR at time ' ||
> END_TIME || '--ROC' FROM SCHEDULER_HISTORY WHERE JOB_NAME = 'SMS_Test' AND
> ERROR = 'TRUE'', 'charset=UTF-8 fieldSeparator=||'); [42001-175]
> <#[email protected]_> 42001/42001
> (Help)
> <http://h2database.com/javadoc/org/h2/constant/ErrorCode.html#c42001>
>
> What I missed the point? Thank you for your help.
>
> Phamorn Hongsawat
>
> On Tuesday, August 5, 2014 1:36:51 AM UTC+7, Thomas Mueller wrote:
>>
>> Hi,
>>
>> You could use a "java.util.Writer" of course, possibly in a user defined
>> function.
>>
>> Or you could still use the CSV tool, but disable the header, put
>> everything in one single column, and use a formula for that column (for
>> example "select 'Customer name ' || name || ' have a salary ' || salary
>> from tableName"). But you would need to set the CSV options correctly (as
>> for quoting and escaping).
>>
>> Regards,
>> Thomas
>>
>>
>>
>> On Mon, Aug 4, 2014 at 10:12 AM, Phamorn Hongsawat <[email protected]
>> > wrote:
>>
>>> I want to design output as a text file. Suppose I have a table with Name
>>> and Salary row like this
>>>
>>> Name | Salart
>>> _________________
>>>
>>> Peter | 20000
>>> _________________
>>>
>>> Michael | 30000
>>>
>>> I knew about CSVWRITE function but I want a text file like this
>>> (customize the sentence)
>>>
>>> Customer name Peter have a salary 20000
>>> Customer name Michael have a salary 30000
>>> .
>>> .
>>> .
>>>
>>> Is it possible? If so, how can I deal with?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "H2 Database" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/h2-database.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.