I have this query that I am using to export data from multiple tables to a CSV File but I keep getting 'ORA - 12704 Character Set Mismatch' error message. The query is:
select case rownum when 1 then
'#DATASOURCE,CONTNO,TRANNO, TRANMODE,TRANTYPE, TRANTYPEDESCRIPTION,
PRIMARYCURR, BUNIT,BUNITSHORTNAME, BUNITFULLNAME, CPTY, CPTYSHORTNAME,
CPTYFULLNAME, DEALDATE, VALUEDATE, PAYRECTYPEID, AMOUNT, REFERENCE,
ACTIONED, ACTIONEDDATE, OURBANKPAY, OURBANKREC, THEIRBANKPAY, THEIRBANKREC,
SETTLEMETHODCODE, DESCRIPTION, TRADEFLOWTYPEID, PORTCODE,LINKREF1, LINKREF2, LINKREF3'
else datasource || ',' || contno || ',' || tranno || ',' || tranmode || ',' || trantype || ',' ||
trantypedescription || ',' || primarycurr || ',' || bunit || ',' || bunitshortname || ',' ||
bunitfullname || ',' || cpty || ',' || cptyshortname || ',' || cptyfullname || ',' || dealdate || ',' ||
valuedate || ',' || payrectypeid || ',' || amount || ',' || reference || ',' || actioned || ',' ||
actioneddate || ',' || ourbankpay || ',' || ourbankrec || ',' || theirbankpay || ',' ||
theirbankrec || ',' || settlemethodcode || ',' || description || ',' || tradeflowtypeid || ',' ||
portcode || ',' || linkref1 || ',' || linkref2 || ',' || linkref3
end
from (SELECT ctf.datasource as datasource,
c.ContNo as ContNo,
c.TranNo as Tranno,
c.TranMode as TranMode,
c.TRANTYPE as TranType,
t.Description AS TranTypeDescription,
c.PrimaryCurr as PrimaryCurr,
c.BUnit as BUnit,
b.ShortName AS BUnitShortName,
b.FullName AS BUnitFullName,
c.Cpty as Cpty,
y.ShortName AS CptyShortName,
y.FullName AS CptyFullName,
ctf.DealDate as DealDate,
ctf.ValueDate as ValueDate,
ctf.PayRecTypeID as PayRecTypeID,
ctf.Amount as Amount,
ctf.Reference as Reference,
ctf.Actioned as Actioned,
ctf.ActionedDate as ActionedDate,
ctf.OurBankPay as OurBankPay,
ctf.OurBankRec as OurBankRec,
ctf.TheirBankPay as TheirBankPay,
ctf.TheirBankRec as TheirBankRec,
ctf.SettleMethodCode as SettleMethodCode,
tk.Description as Description,
0 AS TradeFlowTypeID ,
c.PortCode as PortCode,
c.LinkRef1 as LinkRef1,
c.LinkRef2 as LinkRef2,
c.LinkRef3 as LinkRef3
FROM table c
INNER JOIN table ctf ON c.ContNo = ctf.ContNo
INNER JOIN table tk ON c.TranNo = tk.TranNo
AND c.TranMode = tk.TranMode
INNER JOIN table t ON c.TranNo = t.TranNo
AND c.TranMode = t.TranMode
AND c.TranType = t.TranType
LEFT OUTER JOIN table y ON c.Cpty = y.Cpty
INNER JOIN table b ON c.BUnit = b.BUnit
WHERE (c.TranNo = 99)
AND (tk.TranCode = 1)
and to_char(valuedate, 'mm/dd/yyyy') = to_char(sysdate, 'mm/dd/yyyy'))
If I just run the select query then it runs fine.
select case rownum when 1 then
'#DATASOURCE,CONTNO,TRANNO, TRANMODE,TRANTYPE, TRANTYPEDESCRIPTION,
PRIMARYCURR, BUNIT,BUNITSHORTNAME, BUNITFULLNAME, CPTY, CPTYSHORTNAME,
CPTYFULLNAME, DEALDATE, VALUEDATE, PAYRECTYPEID, AMOUNT, REFERENCE,
ACTIONED, ACTIONEDDATE, OURBANKPAY, OURBANKREC, THEIRBANKPAY, THEIRBANKREC,
SETTLEMETHODCODE, DESCRIPTION, TRADEFLOWTYPEID, PORTCODE,LINKREF1, LINKREF2, LINKREF3'
else datasource || ',' || contno || ',' || tranno || ',' || tranmode || ',' || trantype || ',' ||
trantypedescription || ',' || primarycurr || ',' || bunit || ',' || bunitshortname || ',' ||
bunitfullname || ',' || cpty || ',' || cptyshortname || ',' || cptyfullname || ',' || dealdate || ',' ||
valuedate || ',' || payrectypeid || ',' || amount || ',' || reference || ',' || actioned || ',' ||
actioneddate || ',' || ourbankpay || ',' || ourbankrec || ',' || theirbankpay || ',' ||
theirbankrec || ',' || settlemethodcode || ',' || description || ',' || tradeflowtypeid || ',' ||
portcode || ',' || linkref1 || ',' || linkref2 || ',' || linkref3
end
from (SELECT ctf.datasource as datasource,
c.ContNo as ContNo,
c.TranNo as Tranno,
c.TranMode as TranMode,
c.TRANTYPE as TranType,
t.Description AS TranTypeDescription,
c.PrimaryCurr as PrimaryCurr,
c.BUnit as BUnit,
b.ShortName AS BUnitShortName,
b.FullName AS BUnitFullName,
c.Cpty as Cpty,
y.ShortName AS CptyShortName,
y.FullName AS CptyFullName,
ctf.DealDate as DealDate,
ctf.ValueDate as ValueDate,
ctf.PayRecTypeID as PayRecTypeID,
ctf.Amount as Amount,
ctf.Reference as Reference,
ctf.Actioned as Actioned,
ctf.ActionedDate as ActionedDate,
ctf.OurBankPay as OurBankPay,
ctf.OurBankRec as OurBankRec,
ctf.TheirBankPay as TheirBankPay,
ctf.TheirBankRec as TheirBankRec,
ctf.SettleMethodCode as SettleMethodCode,
tk.Description as Description,
0 AS TradeFlowTypeID ,
c.PortCode as PortCode,
c.LinkRef1 as LinkRef1,
c.LinkRef2 as LinkRef2,
c.LinkRef3 as LinkRef3
FROM table c
INNER JOIN table ctf ON c.ContNo = ctf.ContNo
INNER JOIN table tk ON c.TranNo = tk.TranNo
AND c.TranMode = tk.TranMode
INNER JOIN table t ON c.TranNo = t.TranNo
AND c.TranMode = t.TranMode
AND c.TranType = t.TranType
LEFT OUTER JOIN table y ON c.Cpty = y.Cpty
INNER JOIN table b ON c.BUnit = b.BUnit
WHERE (c.TranNo = 99)
AND (tk.TranCode = 1)
and to_char(valuedate, 'mm/dd/yyyy') = to_char(sysdate, 'mm/dd/yyyy'))
If I just run the select query then it runs fine.