It would really be of great help if you could suggest a solution for me.
Program:
I need to execute a stored procedure from an Oracle server through a C++ program using oci.h (Oracle Call Interface) libraries of C.
Expand|Select|Wrap|Line Numbers
- #include <oci.h>
- #define FMT "DAY, MONTH DD, YYYY"
- #define LANG "American"
- OCIDate v1_sqlret7 ;
- //binding for 7th output <This is because the Output Parameter No 7 would be in Date format>
- retVal = OCIBindByName( mystmthp, &myempwhatbindhp, myerrhp,
- (text *)":v_retval7", strlen(":v_retval7"), &v1_sqlret7,(sword) sizeof(v1_sqlret7) , SQLT
- _ODT, 0, 0, 0, 0,0, OCI_DEFAULT );
- if ( ( OCI_SUCCESS != retVal ) && ( OCI_SUCCESS_WITH_INFO != retVal ) )
- {
- OTCLIB_TRACER(MODULE) << "OCIBindByName failed for calling Output Parameter No 7" << endl;
- cout<< "OCIBindByName failed for calling Output Parameter No 7" << endl;
- }
- which means that the OCIBindByName is successful.Else it would return an error code. But when I try to display what has been stored in the variable 'v1_sqlret7', I use the following function after binding at runtime,
- if(OCIDateToText(myerrhp,&v1_sqlret7,(text *)FMT, (ub1) sizeof(FMT)-1, (text *)LANG,(ub4) sizeof(LAN
- G)-1 ,&buflen, errbuf)!=OCI_SUCCESS)
- {
- cout<<"OCI Error for converting date to Text"<<endl;
- }
- else
- {
- cout<<"The date is :: "<<errbuf<<endl;
- }
Output Date displayed after bind during execution:
The date is :: MONDAY , SAT 00, 9202
Here the date is bound but is not correct.We have asked for the format <DAY, MONTH DD, YYYY> which is in defined variable FMT.
The strange and funny part in this is that the output always remains the same as above even when I try to retrieve a record pertaining to different dates. But if I try to retrieve the output in a variable by connecting to the Oracle server directly using Sqlplus, I receive the correct date in the default Oracle Date format, that is, 'DD-MON-YY' as '06-APR-07' or '07-APR-07'. This date is quite different than what I receive after binding which indicates that there is some problem with binding only.
I do not know whether any version mismatch may cause this issue and hence have attached the version details of both the Sun Compiler and also the Oracle server.
Oracle Server Version:
Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production
Compiler Version:
[manir@DEVCTDB manir]$ version
Machine hardware: sun4u
OS version: 5.8
Processor type: sparc
Hardware: SUNW,Sun-Fire-280R
The following components are installed on your system:
Sun Studio 9
Sun Studio 9 C Compiler
Sun Studio 9 C++ Compiler
Sun Studio 9 Tools.h++ 7.1
Sun Studio 9 C++ Standard 64-bit Class Library
Sun Studio 9 Garbage Collector
Sun Studio 9 Fortran 95
Sun Studio 9 Debugging Tools (including dbx)
Sun Studio 9 Debugger GUI
Sun Studio 9 Performance Tools (including collect, ...)
Sun Studio 9 X-Designer
Sun Studio 9 VIM editor
Sun Studio 9 XEmacs editor
Sun Studio 9 Native Connector Tool
Sun Studio 9 LockLint
Sun Studio 9 Building Software (including dmake)
Sun Studio 9 Documentation Set
version of "/opt/Forte6.2/SUNWspro/bin/../prod/bin/../../bin/cc": Sun C 5.6 2004/07/15
version of "/opt/Forte6.2/SUNWspro/bin/../prod/bin/../../bin/CC": Sun C++ 5.6 2004/07/15
version of "/opt/Forte6.2/SUNWspro/bin/../prod/bin/../../bin/f90": Sun Fortran 95 8.0 2004/07/15
version of "/opt/Forte6.2/SUNWspro/bin/../prod/bin/../../bin/dbx": Sun Dbx Debugger 7.3 2004/07/15
version of "/opt/Forte6.2/SUNWspro/bin/../prod/bin/../../bin/analyzer": Sun Performance Analyzer 7.3 2004/07/15
version of "/opt/Forte6.2/SUNWspro/bin/../prod/bin/../../bin/dmake": Sun Distributed Make 7.5 2004/07/15
Regards
Mani.R