MS-DOS: Pro*C VARCHARS
Date: 27 Jan 92 10:46:55 GMT
Message-ID: <1992Jan27.104655.1345_at_praxis.co.uk>
Apologies, I shot past the original message, so I can't remember who had the problem. But basically their Pro*C precompiler was converting:
VARCHAR *foo[7];
- to: **
struct
{
...
} *foo;
This is *not* an error of the MS-DOS version of the Pro*C pre-compiler. I think you'll find all Pro*C precompilers do the same. The workaorund (and you need a lot of them with ORACLE!), is to #define some conversion macros. We hit a problem when we tried to pass VARCHARS (which are global structures, after the precompiler has been applied) by reference to another function. The solution was to #define VARCHAR-TO-STRING macros (and vica versa). Next, convert the VARCHAR to a STRING and *then* you can pass the string by reference. Phew!
/* NB: The line continuation slashes, and curly braces are very important */
#define VARCHAR_TO_STR(to,from) \
{ \ strncpy (to, from.arr, from.len); \ to[from.len] = '\0'; \}
#define STR_TO_VARCHAR(to,from) \
{ \ strcpy (to.arr, from); \ to.len = strlen(from); \}
BTW, if all you need is some sort of 2-dimensional VARCHAR then Pro*C does allow them:
VARCHAR foo[10][7];
-- \ ANDREW CAMPBELL andrewc_at_praxis.co.uk \ "... and remember \ \ Praxis South-East Ltd Software Engineers \ Baldrick, we're *not*\ \ 18-20 Church Street, Staines, Middx, TW18 4EP, UK.\ at home to Mr.Cockup"\ \ Tel +44 784 460694 Fax +44 784 463169 \ - Edmund Blackadder \Received on Mon Jan 27 1992 - 11:46:55 CET