|
发表于 2014-3-18 09:11:18
|
显示全部楼层
Hi jimicron, seems like you misunderstood tomok's suggestion.
He generally suggests that you modify your Data tab code so single apostrophe gets replaced with double apostrophes.
Tomok suggests Scan function, I will suggest below character by character iteration (in case you have more than one apostrophe to handle in one string) [how much easier it would be having simple Replace fuction...].
The code below more or less should work, but please be aware I did not test/verify it, so even simple typo could occur.
Green is your code as it was, blue is what I added to or replaced in your code, red is also your code, but seems totally obsolete.
#****Begin: Generated Statements***
vAccountDescription=ATTRS('Account',vAccount,'Account Description');
vAccountGroupPrefix=ATTRS('Account',vAccount,'Account Group Prefix');
vAccountGroup=ATTRS('Account',vAccount,'Account Group');
vStatus=ATTRS('Account',vAccount,'Status');
#****End: Generated Statements****
vSingle = ' ';
sAccountDescription = '';
nCounter = Long ( vAccountDescription );
While ( nCounter > 0 );
sCharacter = SubSt ( vAccountDescription, nCounter, 1 );
If ( sCharacter @= '''' );
sCharacter = '''''';
EndIf;
sAccountDescription = sCharacter | sAccountDescription;
nCounter = nCounter - 1;
End;
ODBCOutPut('SERVER', Expand ('INSERT INTO database.table
(
Account ,
Account_Description ,
Account_Group_Prefix ,
Account_Group ,
Status
)
VALUES
(
''%vAccount%'' ,
''%sAccountDescription%'',
''%vAccountGroupPrefix%'' ,
''%vAccountGroup%'' ,
''%vStatus%''
)'));
And just few remarks at the end:
1. You are using automatically generated code in your TI, which is not the best practice, better to copy the code from between Generated Statements lines and switch all variables in Variable tab to Other.
2. If you insist on automatically generated code, you can at least switch off generating it for the Metadata tab - you will skip one full obsolete iteration on source rows.
3. If rest of the variables (not only Description) can have apostrophes, you need to include similar processing for those variables also.
Hope this helps anyhow |
|