473,386 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Issue Reagrding Structure type array variable in SQC code.

As i have defined a structure in EXEC SQL BEGIN and END section and i am declaring a structure type array variable after structure definition,but during precompilation it is throwing an error:
" SQL0008N The token "[" found in a host variable declaration is not valid."

Code is like this:

EXEC SQL BEGIN DECLARE SECTION

struct abc
{
int a,
int b,
char c[12];
char d[14];
.....
.....
....

} v_abc[20];

EXEC SQL END DECLARE SECTION

please suggest a solution asap....
Feb 18 '08 #1
4 3351
sakumar9
127 Expert 100+
Can you give the exact code text, I mean your BEGIN to END DECLARE SECTION.

Regards
- Sanjay
Feb 21 '08 #2
sakumar9
127 Expert 100+
You cannot have arrays in DECLARE section.

Example:
Expand|Select|Wrap|Line Numbers
  1. You cannot have this:
  2.      struct {
  3.      short vchar_len;
  4.      char  vchar_value[24];
  5.     } hv_vchar24[20];
  6.  
  7.  
  8. You can have this:
  9.  
  10.      struct {
  11.      short vchar_len;
  12.      char  vchar_value[24];
  13.     } hv_vchar24;
  14.  
  15.  

You can have such declarations out of the DECLARE section. I am not sure why do you need such variable because we declare host variables in DECLARE section. These host variables are used to pass values to and from database.

Let me know if it doesn't suits your requirement.

Regards
-- Sanjay
Feb 21 '08 #3
You cannot have arrays in DECLARE section.

Example:
Expand|Select|Wrap|Line Numbers
  1. You cannot have this:
  2.      struct {
  3.      short vchar_len;
  4.      char  vchar_value[24];
  5.     } hv_vchar24[20];
  6.  
  7.  
  8. You can have this:
  9.  
  10.      struct {
  11.      short vchar_len;
  12.      char  vchar_value[24];
  13.     } hv_vchar24;
  14.  
  15.  

You can have such declarations out of the DECLARE section. I am not sure why do you need such variable because we declare host variables in DECLARE section. These host variables are used to pass values to and from database.

Let me know if it doesn't suits your requirement.

Regards
-- Sanjay
Hi Sanjay,

Thanks for reply.....

I have used array of structures in PRO*C code,but this is not working in SQC.

I have also implemented this thing using linked list but pointer type varible is not being recognised by DB2 precompiler.


I need to declare aray of structure in SQL block,if it is declared outside then i cannot use it for DB manipulation.

Thanks
Nipun........
Feb 28 '08 #4
Hi nibakshi,

We cannot use 'int' inside the structure.

Use sqlint32 or sqlint64....
Jun 20 '14 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

22
by: Wynand Winterbach | last post by:
I think every C programmer can relate to the frustrations that malloc allocated arrays bring. In particular, I've always found the fact that the size of an array must be stored separately to be a...
12
by: anonymous | last post by:
Hi folks, I am in a fix trying to copy data to an array which is member of a structure. What I am doing right now is: char array = {0,1,2,3,4,5,6,7}; memcpy(structure.array, array, 8); Is...
2
by: vikas | last post by:
I have following structure in c++. typedef struct MMF_result_struct { int action; char text; int cols,rows; int month,day,year; } MMF_result; Now this structure is shared between C++ and C#...
2
by: Steve Turner | last post by:
I have read several interesting posts on passing structures to C dlls, but none seem to cover the following case. The structure (as seen in C) is as follows: typedef struct tag_scanparm { short...
8
by: Charles Law | last post by:
Can anyone suggest how I would marshal a variable length structure back from an API call. Specifically, I am looking at the WaitForDebugEvent function, which returns a DEBUG_EVENT structure. ...
14
by: zoltan | last post by:
Hi, Consider a structure as follows : struct dummy { int a; int b; int c; };
29
by: ataanis | last post by:
Hi, I have the following statement, and i'm trying to understand why when I do the second print it's giving me segmentation fault, both name and s_aliases are char arrays e.g THE FIRST PRINT...
0
by: slimdizzy | last post by:
I have a bit of code that when using POP in the imap_open connect string it will return the filenames of the attachments, but when using IMAP it does not. Been racking my brain over this for a...
2
by: Pedro Pinto | last post by:
Hi there! I'm presented with the following situation: I'm writing a server program that receives information and saves it to a structure i've created that goes by the name of tabela. The...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.