Re: PRO* variable equivalencing
Date: 26 Aug 1993 04:01:35 -0500
Message-ID: <CCCzMJ.2EH_at_uk.ac.brookes>
Seth Grimes (grimes_at_access.digex.net) wrote:
> p0070621_at_oxford-brookes.ac.uk (Tommy Wareing) writes:
> >There doesn't seem to be a great deal changed, except for the addition of
> >datatype equivalencing.
> With VARCHAR types, you have to specify a (maximum) length in the declaration
> and then set variable.len. VARCHAR types are really structures with .len
> and .arr, the latter holding the actual string. Is this what you're talking
> about?
Unfortunately, no. There is a new EXEC SQL VAR command. The first example
of this is:
EXEC SQL BEGIN DECLARE SECTION;
char emp_name[11];
EXEC SQL VAR emp_name IS STRING(11);
EXEC SQL END DECLARE SECTION;
which declares emp_name as 10 characters, followed by a null. This is nicer
than using VARCHARS (no copying the null in and out of the length, and the
arrays is not of unsigned chars, so my type checkings happier).
But... I've still got to declare the length twice. :-(
The next example is:
struct {short len; char buff[4000];} graphics;
EXEC SQL BEGIN DECLARE TYPE graphics IS VARRAW (4000);
graphics crt;
EXEC SQL END DECLARE SECTION;
so you can now use a new type (graphics) to hold VARRAW data of upto 4000
bytes. But again the length has to be given twice, and there's no
documentation on where that "short len" came from. I can guess, but :-(
The last example is best, using REFERENCE to declare a type as a pointer to a VARRAW of upto 4000 bytes. I quote (my CAPITALS): "In this example, you malloc'ed edditcional memory over and above the type length (4000). This is necessary because the precompiler also returns the length (2 bytes), and can add padding after the length due to alignment restrictions on your system. IF YOU DO NOT KNOW THESE RESTRICTIONS, YOU CAN WRITE SOME SIMPLE TEST CASES TO DISCOVER HOW THEY WORK." So, alignment padding has to be determined *before* compilation? Bleurgh :-(
> Seth
-- _________________________ __________________________________________ / Tommy Wareing \ / I've been looking for an original sin, \ | p0070621_at_brookes.ac.uk X One with a twist and a bit of a spin | \ 0865-483389 / \ -- Pandora's Box, Jim Steinman / ~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Received on Thu Aug 26 1993 - 11:01:35 CEST