how to dump /load the data

sharkdim

Member
in GUI environment , i can copy excel cells into a GUI mode fields
when i dump the data ,it is not any error ,but when i load the data, it maybe have some errors

example:

dump data :

==============
...
"a","b","abcd
to 1.2
","","","","","XXXX",0
"a","b1","abcd to 1.2","","","","","XXXX",0
"a","b2","abcd to 1.2","","","","","XXXX",0
...
==============
have 3 records a-b,a-b1,a-b2 in this table
when i load them to database
the 1st record will cause an error and not load into database

i use ultra-edit to edit it ,i found after "abcd" , the string has "0x0d 0x0d 0x0a" three control character,

who can help me to find a way to avoid these three character when export data?

thanks
 

RealHeavyDude

Well-Known Member
To me it is not clear what it is you are trying to achieve. Therefore I can't give you any advise. You are talking about copy/paste from another application into Progress widgets and the you are talking about dump/load data into a database. What do these two do have to do with each other? Could you explain in detail what is happening where and where an error occurs and what the exact error message is?

Heavy Regards, RealHeavyDude.
 

sharkdim

Member
my mean is how to replace 0x0d and 0x0a which fields has in a table


find a way to resolve it...


output to code_mstr.d.
for each code_mstr:
export DELIMITER "," code_fldname code_value replace(replace(code_cmmt,chr(10),""),chr(13),"").
end.
output close.

(my English is not good ^_* )
 

RealHeavyDude

Well-Known Member
Now I am with you.

IMHO - you should make sure that invalid characters do not end up in the database in the first place, before you export them. But, as a last resort, you could also strip them off before you export them.

Instead of defining a list of illegal characters which you found out by having a short look at a file, you should define a list of legal characters and strip everything off that's not legal. Usually you will find illegal characters in input fields or database fields when users copy/paste selected text from a web browser into a fill-in widget - in those cases it is very likely that the selected text contains non-printable, illegal, characters.

Here is some codes snippet that I've used:
METHOD PROTECTED CHARACTER stringToXSD (
INPUT pcString AS CHARACTER, /* String value */
INPUT pcProviderIdSymbol AS CHARACTER, /* Identification symbol of the provider */
OUTPUT plModified AS LOGICAL ): /* Flag indicating that the string was modified */

/*------------------------------------------------------------------------------
Purpose: Properly format the given string value to conform with XML XSD
Notes: In another words, strip off or convert unwanted characters which
should not be present using ISO 8859-1 (Latin-1 / Western European)
encoding, e.g. ASCII. But since this logic is very expensive we only
want to do the full blown check if absouletly necessary. Therefore
we check the provider identification symbol to decide what check we
do.
------------------------------------------------------------------------------*/

&SCOPED-DEFINE ASCII-CODE '192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,216,217,218,219,220,221,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,248,249,250,251,252,253,255':U
&SCOPED-DEFINE ASCII-CHAR 'A,A,A,A,AE,A,AE,C,E,E,E,E,I,I,I,I,D,N,O,O,O,O,OE,O,U,U,U,UE,Y,ss,a,a,a,a,ae,a,ae,c,e,e,e,e,i,i,i,i,d,n,o,o,o,o,oe,o,u,u,u,ue,y,y':U

DEFINE VARIABLE cErrorMessage AS CHARACTER NO-UNDO.
DEFINE VARIABLE cString AS CHARACTER NO-UNDO.
DEFINE VARIABLE cCharacter AS CHARACTER NO-UNDO.
DEFINE VARIABLE iLoop AS INTEGER NO-UNDO.
DEFINE VARIABLE iPosition AS INTEGER NO-UNDO.
DEFINE VARIABLE iASCIICode AS INTEGER NO-UNDO.

STRING-TO-XSD-BLK:
DO ON ERROR UNDO STRING-TO-XSD-BLK, LEAVE STRING-TO-XSD-BLK:

/* Faulty characters should only be present in attributes which have been delivered from providers
other than Telekurs ... */
IF pcProviderIdSymbol <> 'TK':U THEN do:

DO iLoop = 1 TO LENGTH ( pcString ):

ASSIGN cCharacter = SUBSTRING ( pcString, iLoop, 1 )
iASCIICode = ASC ( cCharacter )
iPosition = LOOKUP ( STRING ( iASCIICode ), {&ASCII-CODE} ).

/* Replace CR/LF with blank ... */
IF iASCIICode = 10 THEN
ASSIGN cString = cString + ' ':U.

/* Standard ASCII characters (32 - 126) */
ELSE IF iASCIICode >= 32 AND iASCIICode <= 126 THEN
ASSIGN cString = cString + cCharacter.

/* Some special characters converted into similar ASCII characters */
ELSE IF iPosition > 0 THEN
ASSIGN cString = cString + ENTRY ( iPosition, {&ASCII-CHAR} )
plModified = TRUE.

/* Skip the rest ... */
ELSE
ASSIGN plModified = TRUE.

END.

END. /* Expensive check */

/* No work request - inexpensive check */
ELSE DO:
ASSIGN plModified = FALSE
cString = REPLACE ( pcString, CHR(10), ' ':U ).

END.

/* Error handling */
CATCH oAnyError AS Progress.Lang.Error:
{&BEGIN-CATCH-ANY-ERROR}
ASSIGN cErrorMessage = 'Unhandled exception formatting string value according to XSD [' + cErrorMessage + '].'
cString = ''.
{&END-CATCH-ANY-ERROR}
END CATCH.

END. /* STRING-TO-XSD-BLK */

RETURN cString.

&UNDEFINE ASCII-CODE
&UNDEFINE ASCII-CHAR

END METHOD.
HTH, RealHeavyDude.
 
Top