Home » Developer & Programmer » Precompilers, OCI & OCCI » sqladt is initialized twice.
sqladt is initialized twice. [message #564352] Thu, 23 August 2012 01:04 Go to next message
sarada6378
Messages: 3
Registered: August 2012
Junior Member
Hi,

I am a newbie working with c++ and pro c.
I have created a structure and am fetching the values from the select query into the structure.
I am trying to add the structure into a vector.

Here is the code snippet


EXEC SQL AT :O_dbhandle DECLARE DISCDEF CURSOR FOR SELECT CUSTOMER_ID,START_DATE,END_DATE,DISCOUNT_TYPE,DISCOUNT_VALUE FROM S
H_IVDC_DISCOUNT_DEFINITIONS;

EXEC SQL AT :O_dbhandle OPEN DISCDEF ;
EXEC SQL WHENEVER NOT FOUND DO print_not_found_msg();
for(int i=0;i<miCfcode;i++){
EXEC SQL FETCH DISCDEF INTO :shdef;
discvals.push_back(shdef);

}
EXEC SQL CLOSE DISCDEF;

I am getting the following error on compilation

Error: sqladt is initialized twice.
Error: Multiple declaration for sqladt.
Error: sqltds is initialized twice.
Error: Multiple declaration for sqltds.
Error: sqlfpn is initialized twice.
Error: Multiple declaration for sqlfpn.
Error: sqlctx is initialized twice.
Error: Multiple declaration for sqlctx.

Please let me know the problem/issue

Re: sqladt is initialized twice. [message #564362 is a reply to message #564352] Thu, 23 August 2012 02:39 Go to previous messageGo to next message
dws1
Messages: 14
Registered: July 2012
Junior Member
Could you use copy and paste to paste in the *exact* errors you get, ensuring to include any error codes? These appear to be your interpretations of what the tool said, rather than what it actually said (so as a result, when I Googled "sqladt is initialized twice", I only got this page).

Also (although this might become clear from the answer to the previous question), which stage of the build fails? Is it the precompiler that throws these errors, or the C++ compiler, or the linker? A very common "newbie" mistake is to use "compile" to refer to any or all of these, but they are very different from each other.
Re: sqladt is initialized twice. [message #564367 is a reply to message #564362] Thu, 23 August 2012 03:14 Go to previous messageGo to next message
sarada6378
Messages: 3
Registered: August 2012
Junior Member
Thanks for your prompt reply.

The errors that i posted are the exact error i got during the c++ compilation.

The .pcpp file got compiled successfully to .cpp and then i got the error.

Code :

EXEC SQL AT :O_dbhandle OPEN DISCDEF ;
EXEC SQL WHENEVER NOT FOUND DO print_not_found_msg();
for(int i=0;i<miCfcode;i++){
EXEC SQL FETCH DISCDEF INTO :shdef;
discvals.push_back(shdef); /* Error only when i add this line */}
EXEC SQL CLOSE DISCDEF;

Structure defined

EXEC SQL BEGIN DECLARE SECTION;
struct test{
int customer_id ;
int sccode ;
int tmcode ;
int sncode ;
int zpcode;
char startdate[20];
char enddate[20];
char disctype[1];
int discvalue;
}shdef;
EXEC SQL END DECLARE SECTION;


Re: sqladt is initialized twice. [message #564384 is a reply to message #564367] Thu, 23 August 2012 05:04 Go to previous messageGo to next message
dws1
Messages: 14
Registered: July 2012
Junior Member
Which operating system are you using? Give the full details please - so if it's Windows, don't just say "Windows" but give me the full spec, e.g. "Windows 2003 R2".
Is it a 32-bit or 64-bit OS?
Are you building a 32-bit or 64-bit application?
Which version of Oracle Pro*C are you using?
Which version of the database will the application connect to?
Which compiler are you using (including version)? (I'm surprised those are the exact errors; most of the compilers I've met give error codes and line numbers as well as some text.)
Are you able to reproduce the problem with a small test program - say, 20 lines or so at the most, cut down as much as possible? This would help a lot. I would also need the CREATE TABLE SH_IVDC_DISCOUNT_DEFINITIONS statement.
Re: sqladt is initialized twice. [message #564385 is a reply to message #564384] Thu, 23 August 2012 05:07 Go to previous messageGo to next message
dws1
Messages: 14
Registered: July 2012
Junior Member
Having said that though, there's a mismatch between your SELECT and your structure:

SELECT CUSTOMER_ID,START_DATE,END_DATE,DISCOUNT_TYPE,DISCOUNT_VALUE

but:

struct test{
int customer_id ;
int sccode ;
int tmcode ;
int sncode ;
int zpcode;
char startdate[20];
char enddate[20];
char disctype[1];
int discvalue;
}

Do you still get the errors if you remove sccode, tmcode, sncode and zpcode from the structure?
Re: sqladt is initialized twice. [message #564455 is a reply to message #564385] Fri, 24 August 2012 00:31 Go to previous messageGo to next message
sarada6378
Messages: 3
Registered: August 2012
Junior Member
I still get the error even though i used the query

EXEC SQL AT :O_dbhandle DECLARE DISCDEF CURSOR FOR SELECT CUSTOMER_ID,SCCODE,TMCODE,SNCODE,ZPCODE,START
_DATE,END_DATE,DISCOUNT_TYPE,DISCOUNT_VALUE FROM SYSADM.SH_IVDC_DISCOUNT_DEFINITIONS;

Any operation that i do other than printing between the lines

EXEC SQL FETCH DISCDEF INTO :shdef;

and

EXEC SQL CLOSE DISCDEF;

I get the following error

"vdhOracle.cpp", line 41: Error: sqladt is initialized twice.
"vdhOracle.cpp", line 41: Error: Multiple declaration for sqladt.
"vdhOracle.cpp", line 53: Error: sqltds is initialized twice.
"vdhOracle.cpp", line 53: Error: Multiple declaration for sqltds.
"vdhOracle.cpp", line 65: Error: sqlfpn is initialized twice.
"vdhOracle.cpp", line 65: Error: Multiple declaration for sqlfpn.
"vdhOracle.cpp", line 72: Error: sqlctx is initialized twice.
"vdhOracle.cpp", line 72: Error: Multiple declaration for sqlctx.
"vdhOracle.cpp", line 114: Error: sqlstm is initialized twice.
"vdhOracle.cpp", line 114: Error: Multiple declaration for sqlstm.
"vdhOracle.cpp", line 128: Error: IAPSUCC is initialized twice.
"vdhOracle.cpp", line 128: Error: Multiple declaration for IAPSUCC.
"vdhOracle.cpp", line 128: Error: IAPSUCC is initialized twice.
"vdhOracle.cpp", line 129: Error: IAPFAIL is initialized twice.
"vdhOracle.cpp", line 129: Error: Multiple declaration for IAPFAIL.
"vdhOracle.cpp", line 129: Error: IAPFAIL is initialized twice.
"vdhOracle.cpp", line 130: Error: IAPFTL is initialized twice.
"vdhOracle.cpp", line 130: Error: Multiple declaration for IAPFTL.
"vdhOracle.cpp", line 130: Error: IAPFTL is initialized twice.
"vdhOracle.cpp", line 133: Error: sq0003 is initialized twice.
"vdhOracle.cpp", line 133: Error: Multiple declaration for sq0003.
"vdhOracle.cpp", line 138: Error: Multiple declaration for VARCHAR.
"vdhOracle.cpp", line 139: Error: Multiple declaration for varchar.
"vdhOracle.cpp", line 142: Error: sqlcud0 is initialized twice.
"vdhOracle.cpp", line 142: Error: Multiple declaration for sqlcud0.
Compilation aborted, too many Error messages.
Re: sqladt is initialized twice. [message #564722 is a reply to message #564455] Tue, 28 August 2012 02:10 Go to previous message
dws1
Messages: 14
Registered: July 2012
Junior Member
Please also answer the questions in my other post.
Previous Topic: Data Loading problem of French Input file
Next Topic: Call Stored procedure with input variable as object type in pro *c
Goto Forum:
  


Current Time: Fri Nov 28 00:06:16 CST 2014

Total time taken to generate the page: 0.09863 seconds