Re: pro-C host variable VARCHAR sizes

From: Scott Urman <surman_at_oracle.com>
Date: 1996/01/06
Message-ID: <4cmoqe$b7e_at_inet-nntp-gw-1.us.oracle.com>#1/1


In article <4ck370$5qi_at_ixnews5.ix.netcom.com>, mprather_at_ix.netcom.com (Michael Prather ) writes:
|> I have a problem when declaring the host variables from within the
|> 'DECLARE SECTION' of embeded SQL. I have not yet been able to find a
|> way to use a defined variable length when defining a VARCHAR or CHAR
|> within this section. The only way that I have been able to get the
|> declaration to work is to put hard-coded numbers within the statement.
|>
|> For example, I would like to use something like:
|>
|> #define VAR_LENGTH 10
|> #define VAR2_LENGTH 20
|> ...
|> EXEC SQL BEGIN DECLARE SECTION;
|> VARCHAR hostVariableName[VAR_LENGTH];
|> CHAR hostVaribleName2[VAR2_LENGTH];
|> EXEC SQL END DECLARE SECTION;
|>
|> I believe that it is not working because proc does not have a
|> pre-processor to convert the #defines.
|>
|> I have also tried to use:
|>
|> unsigned int VAR_LENGTH = 10;
|> unsigned int VAR2_LENGTH = 20;
|> ...
|> EXEC SQL BEGIN DECLARE SECTION;
|> VARCHAR hostVariableName[VAR_LENGTH];
|> CHAR hostVaribleName2[VAR2_LENGTH];
|> EXEC SQL END DECLARE SECTION;
|>
|>
|> The only thing that I have found that will work is exactally what I do
|> not want to use -- hard-coded numbers:
|>
|> EXEC SQL BEGIN DECLARE SECTION;
|> VARCHAR hostVariableName[10];
|> CHAR hostVaribleName2[20];
|> EXEC SQL END DECLARE SECTION;
|>
|> We have even tried to use 'const' in the C++ compiler and the same
|> situation occurs.
|>
|> Does anyone know a way that either #defines or variables can be used
|> for the array size versus using hard-coded numbers?
|>
You don't mention your version, but I assume that it is 1.x. Pro*C 2.0 and higher supports using #defines in declarations. I suggest you upgrade. If this isn't possible, try running the c preprocessor (cpp on unix) first, then the precompiler, then the C compiler. Received on Sat Jan 06 1996 - 00:00:00 CET

Original text of this message