Re: PRO*C / Forms 3.0
Date: 1995/07/14
Message-ID: <3u56ao$pqb_at_Titania.wintermute.co.uk>#1/1
rroberts_at_io.nosc.mil (Rod Roberts) wrote:
>People,
>I am trying to store ASCII files larger than 65Kbytes in a LONG
>column using PRO*C. The PRO*C compiler limits a VARCHAR
>declaration to a max of 65,533 bytes. Supposedly the LONG column has
>a capacity of about 2 Gigs. So, how does a person get the data into
>the column using PRO*C?
>Secondly, I am using Forms 3.0 and would like to display and
>edit a VARCHAR2 column via a Forms 3.0 application but am limited by a
>250 charcater maximum display restriction set by Oracle. Is there any
>way around this?
>Thanks in advance,
>Rod Roberts
Would advise that you don't create a VARCHAR data type in PRO*C. Best to use 'C' dynamic memory allocation. I would store the length of the text file as well as the file itself in the Oracle table.
Declare a host variable that is a character pointer of external data type STRING. Find the memory required to store the file, and use a malloc function to reserve the memory. Remember to null terminate the string containing the file.
e.g.
EXEC SQL BEGIN DECLARE
char *myfile;
EXEC SQL VAR myfile IS STRING;
int file_length;
EXEC SQL END DECLARE
/*
** Get the amount of memory required to store the file
*/
file_length = myfuncgetlength()
/*
** Allocate the memory.
*/
myfile = malloc(file_length)
/*
** Read the file from ....
*/
myfuncgetfile(myfile)
EXEC SQL
INSERT INTO <table> (FILE_CONTENTS, FILE_LENGTH) VALUES (:myfile, :file_length);
When you want to read the file back in via PRO*C then first fetch the ROWID and the FILE_LENGTH. Then allocate the memory using the malloc statement, and select the contents into the the host variable. Before selecting back into an external datatype of string defined in this way remeber to initialise the contents to it's full length.
e.g.
memset(myfile,' ',file_length)
This code hasn't been checked but it gives you an idea, hope it helps.
As far as SQL*Forms long fields are concerned, I think you can get more than 255 characters by defining the SQL*Forms field as a LONG. Beware when defining fields of this length since it will result in forms swapping out to disk earlier when navigating down through database rows.
Kenny Duncan - Aberdeen,Scotland Received on Fri Jul 14 1995 - 00:00:00 CEST