Re: Help converting ESQL/C from Informix 2.10 to 4.x/5.x
Posted in 1993
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Data Types & Schema Design
alan@po.den.mmc.com (Alan Popiel) writes: >Date: Wed, 13 Oct 93 09:28:02 MDT >From: alan@po.den.mmc.com (Alan Popiel) >To: inbladt@autelca.ascom.ch >Subject: Re: Help converting ESQL/C from Informix 2.10 to 4.x/5.x [ problem description deleted - NB. ] >->Here is an example of the code, so you can see what my problem is: >-> >->[...] >->$string DatabaseError; /* defining the host variable */ >->[...] >-> databaseerror = GermanDatabaseErrorText; /* host variable in C */ >->[...] >-> databaseerror = FrenchDatabaseErrorText; /* host variable in C */ >->[...] >->$select from ... into ... where text = $DatabaseError; /* host var. in esql */ >->[...] >-> >->If somebody has a tool to do the conversion (sed, awk, etc. is fine, perhaps >->even perl, although I have to port it to Interactive UNIX, first) >->please mail (or post) information about it to me. >-> >->Many thanks in advance, >-> >->Norbert. >->-- >->Norbert Bladt, Ascom Autelca AG, Worbstr. 201, CH-3073 Guemligen, Switzerland >->Phone: +41 31 999 65 52 FAX: +41 31 999 65 44 >->Mail: nbladt@autelca.ascom.ch UUCP: ..!uunet!mcsun!chsun!hslrswi!aut!nbladt >-> >It seems to me the simplest (maybe not the most efficient, but simple is good) >answer is a sed script something like this: >script fixup: >------------- >sed 's/VarOne/varone/g\\ >s/VarTwo/vartwo/g\\ >s/VarLast/varlast/g' $1 >$2 >The above is csh syntax. Omit the \\ for sh. I don't know what syntax >changes are needed for ksh, tsh, bash, etc. >The script's usage would be: >fixup filein fileout Thank you for this proposal. I good other answers, as well. One was using 'tr' to do the translation of the complete file. However, this would translate all the code and, even, strings to all lowercase. We are using, e.g., getenv ("LANG") to determine the language for the error messages, etc. So, 'tr' is no real choice. Your solution is much better. I got an answer from Informix (himself :-) ) This solution is like yours, but uses a program which I might get from Informix. On the other hand, I don't want to type in all variable names manually. So, I will write a small C program which will do the conversion. It should be easy and it will be completely automatic. It could even replace the original file with a copy of it, because no characters are added ! What do I have to do: 1. Search for a '$' sign in the code. 2. If one of the Informix data types (no structures in 2.10 !) is immediately following it, fine - replace all characters up to the next ';' with their lowercase equivalent. 3. If one of the SQL statements follow (insert, update, delete, select etc.) just ignore this word (or convert it to lower case, it shouldn't matter, I guess, because all those are in lower case, anyway). 4. If neither 2 or 3 is true, convert the complete word to lowercase. That should be all there is. It might even be easier than this: 1. Search for a '$' sign in the code. 2. Convert the complete word to lower case. 3. If the word is one of the Informix data types, convert all the following identifiers to lower case - up to the next ';'. Of course, it will take some time to write this code. On the other hand, once it runs, it will do the conversion automatically. That might be much faster than calling the compiler for every (couple of) undefined variable(s). Remember, there are a LOT of modules I have to extract from SCCS, modify and put it back under SCCS. Automating this procedure will help me a lot. I will try it this way. Thanks again for all the help I received from the net and, Informix. Norbert. P.S. I still can't believe that one of my former co-worker was the only person in the world writing this kind of sh*tty code. So, I might persuade my boss to give the code away for free, if somebody else is interested in it. -- Norbert Bladt, Ascom Autelca AG, Worbstr. 201, CH-3073 Guemligen, Switzerland Phone: +41 31 999 65 52 FAX: +41 31 999 65 44 Mail: nbladt@autelca.ascom.ch UUCP: ..!uunet!mcsun!chsun!hslrswi!aut!nbladt
Related threads
- listener-thread@soc_be.c:3073: err = -25582:
- Re: Strange error with date field (Online 5.01)
- Re: -1228 rc from rdefmtdate()???
- Shared Memory