Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hmmm. How to insert 2 64-bit array into NUMBERIC field

Status
Not open for further replies.

DCCoolBreeze

Programmer
Jul 25, 2001
208
US
I have a array of variables defined as 3-64-bit words or llValue[3] where
llValue is defined as a word64. I need to store this array in a NUMERIC
field in an Oracle table. I have tried defining a structure

struct ddd {
word64 llValue[3];
long lValue
char dtm[10];
} table_record;

then I attempted an insert

...(table_record& t)
{
EXEC SQL INSERT INTO TABLE VALUES :)t);
}

I am unable to store llValue into the NUMERIC field. I changed the
statement to

EXEC SQL INSERT INTO TABLE VALUES (222,:t.lValue,:t.dtm);

This works..therefore the problem seems to be with t.llValue

I understand that the NUMERIC field can hold upto 38 bytes so how do I load
the llValue array into the field??

 
use:
struct ddd {
union
{
word64 llValue[3];
long slValue[6];//this one for transfering data
};
long lValue
char dtm[10];
} table_record;


John Fill
1c.bmp


ivfmd@mail.md
 
I am still getting the following error message:

Semantic error at line 114, column 12, file /dev02/delaward/dev/working/test/ProC/TestProC.pc:
VALUES :)hrec.lValue,:hrec.cnt,:hrec.dtm);
...........1
PCC-S-02328, undefined struct member

I have redined the structure as requested and I am trying to insert it into a record. Here is the code...

...
EXEC SQL begin declare section;

varchar user[20];
varchar pass[20];

struct TestRecord
{
union
{
unsigned long long llValue[3];
unsigned long lValue[6];
};
unsigned long cnt;
char dtm[10];
} hrec;

EXEC SQL end declare section;

hrec.lValue[0] = 1;
hrec.lValue[1] = 2;
hrec.lValue[2] = 3;
hrec.lValue[3] = 4;
hrec.lValue[4] = 5;
hrec.lValue[5] = 6;
hrec.cnt = 1;
strcpy(hrec.dtm,"11/11/11");

EXEC SQL INSERT INTO
test_table(field1,field2,current_time)
VALUES :)hrec.lValue,:hrec.cnt,:hrec.dtm);

X-)

 
I figured it out. The statement is as follows:

insert into TABLE_NAME
values (Value(1) || Value(2) ||... Value(n) || Value(n+1))

The problem with this is it can get pretty big if the array is large. Perhaps there is an better way to reference arrays in an VALUE statement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top