Re: LONG RAW types using PRO*C - Please help!
Date: 21 Jun 1993 03:16:43 -0400
Message-ID: <grimes.740646727_at_access>
bbsst+_at_pitt.edu (Bryan B Sorrows) writes:
>I need to store ~ 2000 bytes of data ( < 2000 integers between 0 and 256 ),
>so I created a table with identifing info, and one LONG RAW column.
First, you just need a RAW for up to 2000 bytes. Secondly, the answer to your problem might be to use an EXEC SQL TYPE in your variable DECLARE SECTION. Here's some code that works for me (7.0.12); note that I'm just evaluating Oracle and don't have any depth of knowledge.
Seth, grimes_at_oecd.fr
#include <stdio.h>
typedef double xdouble[1000];
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR username[20], password[20];
char identifier[20], title[255], series_metadata[20]; char ident[20]; float factor; char units[4], frequency[4], startd[9], type[4];EXEC SQL TYPE xdouble IS LONG RAW (8000); xdouble x;
EXEC SQL END DECLARE SECTION; EXEC SQL INCLUDE sqlca;
int nelem=1000; int i, j, nrecs=10;
void sqlerror();
main() {
strcpy(username.arr,"SCOTT");
username.len=strlen(username.arr);
strcpy(password.arr,"TIGER");
password.len=strlen(password.arr);
EXEC SQL WHENEVER SQLERROR DO sqlerror();
EXEC SQL CONNECT :username IDENTIFIED BY :password; printf("\nConnected to Oracle as user: %s\n",username.arr);
for (i=0;i<nrecs;i++) {
sprintf(ident,"record %d\0",i);
EXEC SQL SELECT
identifier, title, units, factor, frequency, startd, type, series_metadata, data INTO :identifier, :title, :units, :factor, :frequency, :startd, :type, :series_metadata, :x FROM tstable WHERE identifier = :ident; printf("\nIdentifier: %s\n x[0]: %f x[1]: %f x[999]: %f\n", identifier,x[0],x[1],x[999]);
}
EXEC SQL COMMIT WORK RELEASE;
printf("\nI'm done, O most worthy master!!\n\n"); }
void sqlerror() {
EXEC SQL WHENEVER SQLERROR CONTINUE;
printf("\nOracle error detected:\n");
printf("% .70s\n",sqlca.sqlerrm.sqlerrmc);
EXEC SQL ROLLBACK RELEASE;
exit(1);
}
Received on Mon Jun 21 1993 - 09:16:43 CEST