DataExport using ODBC

Hello specialists!
I have a question regarding an error i'm getting when trying to use the DataExport command to copy data form essbase to SQL.
[Wed Jun 20 10:35:19 2012]Local/RealApp/Plan2/admin/1744/Info(1021013)
ODBC Layer Error: [21S01] ==> [[Microsoft][ODBC SQL Server Driver][SQL Server]Column name or number of supplied values does not match table definition.]
Now, my question was regarding the number of columns and their names. The table in the SQL side has the exact name of the dimensions i'm passing.
Any has any idea of what might be happening? How about the order? I don't have any idea how to place the order of the dimensions in the command.
SET DATAEXPORTOPTIONS
DataExportLevel "Level0";
DataExportDynamicCalc "OFF";
DataExportrelationalFile "ON";
FIX( "Real","Base","NA","MRXMRH","BRVASS","OCSPROJREC","FY11")
     FIX("INDPAGSD", @RELATIVE (YearTotal,0))
          DATAEXPORT "DSN" "ODBC_NAME" "TABLE_NAME" "username" "password";
     ENDFIX
ENDFIX

Hi,
You will have to define the correct number of columns on the destination table. If each member belongs to a separate dimension than you will have 8 columns + 12 with the value for each month.

Similar Messages

  • How can I connect to the database using ODBC within excel.

    Hi,
    How can I connect to the database using ODBC within excel and just refresh the data when needed.
    Thanks,
    Priyanka
    Edited by: user554934 on Jun 9, 2009 2:53 AM

    This is NOT an APEX relevant question, try posting it in the SQL/PL/SQL Forum..
    Thank you,
    Tony Miller
    Webster, TX

  • Retrieving data from a remote DB using ODBC ?

    Hi,
    Has anybody tried to collect some data from a remote DB in InDesign plugin by using ODBC ? I want to know the basic steps including what I have to add in the Xcode project, how to connect to remote DB, and how to retrieve data in plugin by sql query ?
    TIA,
    Nima

    I think you need to add /usr/lib/libiodbc.a to your Xcode project. also you will want to look into sql.h and sqlext.h assuming you're connecting to database such as MySQL to see what's the API you will use to communicate thru ODBC. But the code should be purely C++, nothing InDesign specific, you can write it as a separate library or an InDesign Boss object.
    You will also need to install ODBC driver that's probably would be supplied by your database vendor. So for MySQL, there is a driver you need to download from MySQL site and install, and configure thru OSX's ODBC Administrator tool.
    Thanks!
    lee

  • Error while accessing excel file using ODBC

    Hi
    I am getting the below error message while accessing excel sheet using ODBC from Oracle:
    ERROR at line 1:
    ORA-28545: error diagnosed by Net8 when connecting to an agent
    Unable to retrieve text of NETWORK/NCR message 65535
    ORA-02063: preceding 2 lines from EXCL
    Can anyone help me on this...
    Cheers
    Pradeep
    Message was edited by:
    user634393

              Hi
              Thank you.Is there a way to read a file which is existing in the war file.
              Regards
              Anand Mohan
              "Wenjin Zhang" <[email protected]> wrote:
              >
              >In Weblogic, if your files are archived in a WAR, you cannot get an entry
              >as individual
              >file since it is only bytes in a large archive file. So getRealPath will
              >give
              >you null result. If you only want the path, try to use other getXXXPath,
              >getURL,
              >or getURI method. If you want to read the content, use getResource.
              >
              >
              >"Anand" <[email protected]> wrote:
              >>
              >>Hi
              >>I am having problem while accessing the file located in the server from
              >>a JSP
              >>page. I am not getting the RealPath from a JSP page using getRealPath(request.getServletpath()).
              >>
              >>The same code is working if the jsp placd under defaultwebApp directory
              >>and not
              >>working if i create a war and deploy the same.
              >>
              >>I am using weblogic server 7.0 trail version.I am setting the context
              >>path also.
              >>
              >>Can any help me in this regard.
              >>
              >>Thank And Regards
              >>
              >>Anand Mohan
              >
              

  • Crystal 2011 getting Logon failed IM004 error when using ODBC (RDO)

    I just installed Crystal Reports 2011 on Windows 7 Ultimate SP1.  Sporadically, but way too often (I would estimate about 60% of the time), when I go to set up an ODBC (RDO) connection or refresh an existing report and enter the password, I get the following error:
    Logon failed.
    Details: IM004:[Microsoft][ODBC Driver Manager] Driver's SQLAllocHandle on SQL_Handle_ENV failed
    Other times, it just works, with no changed made.  It seems to work slightly more often when using the SQL Server driver (the one for SQL 2000) as opposed to the SQL Native Client or SQL Server Native Client 10.0 drivers.  But not often enough for that to be the solution.
    I have tested this with a locally installed SQL Server (on the same machine as Crystal Reports) and remote SQL Servers, with SQL 2000, 2005 and 2008.  Same results.
    I have Crystal Reports 2008 installed on the same machine and have not once had this problem.  I have tried using the same ODBC connections I already had from Crystal 2008 with Crystal 2011 and also to create new ones, same results either way.
    Is this a known issue, or is there a switch/setting I need to change to make this work consistently?  I am especially puzzled by the fact that it seems random, I have not been able to find any pattern at all.

    Hi Victoria,
    MS SQL Server 2008 has a client install now, the MDAC/WDAC doesn't install it as MS used to do with all of their OS's. CR also had to update the use of SQL Server 2008 to include the SQLNCLI10 client engine.
    I suggest, if you have not already, install the Native 10 client from either the SQL Server CD or you can download the MSI from MS's site and only use the Native 10 driver.
    MS kind of dropped ODBC and moved to OLE DB. The native client actually uses the OLE DB driver so using ODBC just puts another layer on top of OLE DB anyways. It's more convenient to use ODBC for deploying applications but it can affect performance.
    Anyways, as noted, CR 2011 is still in Ramp up mode so this issue may have been tracked. If not though you can purchase a support case, if it's a bug then you'll get a refund, if it's a limitation in MS then no refund.
    There is [SP 1 for CR 2011|https://smpdl.sap-ag.de/~sapidp/012002523100007683092011E/cr2011sp1.exe] - http://service.sap.com/sap/bc/bsp/spn/bobj_download/main.htm
    Seems to be a problem with that page right now so try again later... and apply SP 1 or wait until it goes GA and test again. If it's still an issue then you can log a case.
    Firefox just got updated and it's failing, IE works though...
    Thanks again
    Don
    Edited by: Don Williams on Jun 22, 2011 8:51 AM

  • How to use ODBC SQLDriverConnect() without using tnsnames.ora file

    I have an ODBC application that connects to an Oracle 10g database. Currently, my SQLDriverConnect() function call uses the following connection string:
    DRIVER={Oracle in OraClient10g_home1}; DBQ=MyDB.world; DBA=W; UID=foo; PWD=bar
    This requires an entry in the tnsnames.ora file that looks like this:
    MyDB.world =
    (DESCRIPTION = (ADDRESS_LIST =
    (ADDRESS =
    (PROTOCOL = TCP)(Host = server1.intel.com)(Port = 1521)
    (ADDRESS =
    (PROTOCOL = TCP)(Host = server2.intel.com)(Port = 1521)
    (ADDRESS =
    (PROTOCOL = TCP)(Host = server3.intel.com)(Port = 1521)
    (ADDRESS =
    (PROTOCOL = TCP)(Host = server4.intel.com)(Port = 1521)
    (LOAD_BALANCE = yes)
    (CONNECT_DATA = (SERVER = DEDICATED)
    (SERVICE_NAME = MY_SRVC))
    However, I would really like to be able to connect using ODBC without having to create that entry in the tnsnames.ora file. I have tried to substitute the DBQ=MyDB.world with the entire (DESCRIPTION=..... string from the original tnsnames.ora file, but it returns the error:
    ORA-12154: TNS: Could not resolve the connect identifier specified.
    I have heard others are able to use sqlplus with no tnsnames.ora file and the do specify the entire (DESCRIPTION=.... string on the sqlplus connection string, but is this possible to do using the ODBC SQLDriverConnect() function? If so, do I need to use a different keyword/value pair other than DBQ=?
    Any help on this would be greatly appreciated.
    Thank you.

    How would that work in a load balanced configuration? Take a closer look at the tnsnames.ora example I included in my original post. I have 4 ADDRESS= sections to denote 4 servers that are part of the load balanced environment.
    Also, I'm not familiar with that syntax, I need to use the syntax supported by the SQLDriverConnect() API function, which looks like this:
    DRIVER={Oracle in OraClient10g_home1}; DBQ=MyDB.world; DBA=W; UID=foo; PWD=bar
    I don't know as SQLDriverConnect() would accept an alternative syntax. But the more important issue here is the ability to specify those 4 servers in the load balanced configuration as indicated by that tnsnames.ora entry.

  • 'Cannot obtain error message from server' when trying to use ODBC

    Post Author: Grant C
    CA Forum: Data Connectivity and SQL
    Hi, I'm developing some reports using Crystal XI on my local PC, using an Oracle 10i back end on a separate server.  The SQL for the report is in a method in an oracle package.
    When I set the datasource location, selecting 'Oracle Server' then entering the details works fine, and the report runs.  However, when I try to use an ODBC connection I get the following error:
    Database Connection Error: 'Cannot obtain error message from server.'
    The ODBC link is set up as a System DSN, which works fine when I test it.  I think I need to use ODBC as some of the reports (which I inherited) seem to fail when run on the Crystal Server, and it seeme to be the ones set up with ODBC which work.
    Any thoughts?  Thanks.

    Hi Mars-
    It sounds like your NI-DAQ installation may have become corrupted. I would suggest uninstalling and reinstalling the DAQmx 7.4 driver to correct this problem and ensure that you're up to date. This download is available here: NI-DAQ 7.4
    If the problem persists you may want to uninstall and reinstall LabVIEW and then NI-DAQ in that order. The error message will usually give an indication as to which VI the error occurred in. Please let us know which VI is failing if you're unable to avoid the error with these suggestions.
    Have a good day-
    Tom W
    National Instruments

  • How to call PL/SQL stored procedure using ODBC?

    Could anyone tell me how can I call PL/SQL stored procedure using
    ODBC? Are there any sample codes?
    Thanx!
    null

    You are correct on all counts, they all should work.
    Oracle Product Development Team wrote:
    : Hi,
    : I don't know the exact syntax in ODBC, but reasoning by analogy
    : with other API's, I'd bet one of the following works
    : (for a call to: procedure my_proc(n1 number, n2 number);):
    : "{ my_proc(1,2); }"
    : "{ call my_proc(1,2); }"
    : "{ begin my_proc(1,2); end }"
    : "begin my_proc(1,2); end;"
    : "begin my_proc(1,2); end"
    : Hope this helps. - Pierre
    : jiangbuf (guest) wrote:
    : : Could anyone tell me how can I call PL/SQL stored procedure
    : using
    : : ODBC? Are there any sample codes?
    : : Thanx!
    : Oracle Technology Network
    : http://technet.oracle.com
    null

  • Using ODBC without the 8i or 9i Client

    Connecting Access.mdb on a windows station to Oracle 8i or 9i using ODBC
    Can an oracle ODBC driver be installed programatically on a station without installing the complete 8i or 9i client?
    The Microsoft ODBC driver for Oracle produces a message stating that the client needs to be installed.
    Perhaps there is an automated way of installing the client by running a script or something.
    Ideally there would be a method of using one setup program on any station that would install all required elements for this application including the Oracle ODBC driver.
    Would InstallShield contain an Oracle ODBC driver that would work on 8i and 9i?

    In order to use the Oracle ODBC driver or the Microsoft ODBC driver for Oracle, the Oracle client needs to be installed. You can invoke the Oracle Universal Installer from InstallShield (optionally with a response file), but I'm not aware of a more 'integrated' solution.
    If the Oracle client is too large a fottprint, there are third parties (i.e. DataDirect) that would be more than happy to sell you a wire-protocol ODBC driver that can run without the Oracle client.
    Justin
    Distributed Database Consulting, Inc.
    www.ddbcinc.com

  • Can't select char type columns using ODBC link to SQL Server 2K

    I have set up a db link using hsodbc from 8.1.7 to SQL Server 2000. I can select numeric and date columns from the
    SQL Server table with no problem. But any character datatype (nchar or nvchar) column name included in the query
    returns an ORA-00904 ("invalid column name"). I know the column names are valid for SQL Server and can access
    these columns via EXCEL using the same user id and data source that is used for the link. I don't have a clue as to why ORACLE can't "see" the character type columns. Following is the hs trace file (HS_FDS_TRACE_LEVEL = debug) generated for "select assay_name from bio_assay@sqlsrvl":
    FRIDAY SEP 05 2003 10:39:47.674
    (0) hoagprd(2); Entered.
    (0) [Generic Connectivity Using ODBC] version: 2.0.4.0.0010
    (0) connect string is:
    (0) YEAR2000_POLICY=-1;CTL_DEBUG=T;CONSUMER_API=1;SESSION_BEHAVIOR_FLAGS=4;PARSER_-
    (0) DEPTH=2000;EXEC_FLAGS =
    (0) 131080;defTdpName=SQLSRVL;binding=(SQLSRVL,ODBC,"LIBERTY");
    (0) ORACLE GENERIC GATEWAY Log File Started at 05-Sep-03 10:39:47
    (0) Class version: 65
    (0) hoagprd(2); Exited with retcode = 0.
    (0) hoainit(3); Entered.
    (0) hoainit(3); Exited with retcode = 0.
    (0) hoalgon(7); Entered. name = XXXXXXXXXXX.
    (0) Created new ODBC connection (28382608)
    (0) Silent DB Function!!
    (0) (Last message occurred 4 times)
    (0) hoalgon(7); Exited with retcode = 0.
    (0) hoaulcp(4); Entered.
    (0) hoaulcp(4); Exited with retcode = 0.
    (0) hoauldt(5); Entered.
    (0) hoauldt(5); Exited with retcode = 0.
    (0) hoabegn(9); Entered. formatID = 306206, hoagttid
    (0) =XXXXXXXXXXXXXXXXXXXXXXXX, hoagtbid = , tflag = 0, initial = 1
    (0) hoabegn(9); Exited with retcode = 0.
    (0) hoapars(15); Entered. stmtType = 0, id = 1.
    (0) nvOUT (P:\Src\QP\QP_SQTXT.C 55): SELECT * FROM "BIO_ASSAY"
    (0) odbc_rec: select * from "BIO_ASSAY"
    (0) Silent DB Function!!
    (0) nvOUT (P:\Src\QP\QPT2SEXE.C 929):
    (0) SELECT "T0000"."WH_ADDED_DATE" AS c00010, "T0000"."ASSAY_MODIFIED_TIME" AS c0009, "T0000"."ASSAY_CREATED_TIME" AS c0008, "T0000"."ASSAY_DATE_COMPLETED" AS c0007, "T0000"."ASSAY_DATE_PLANNED" AS c0006, "T0000"."ASSAY_DATE_STARTED" AS c0005, "T0000"."ASSAY_STATUS_NO" AS c0004, "T0000"."TIMEFRAME_KEY" AS c0003, "T0000"."TARGET_KEY" AS c0002, "T0000"."ENVIRONMENT_KEY" AS c0001, "T0000"."ASSAY_KEY" AS c0000 FROM "BIO_ASSAY" T0000
    (0) nvOUT (P:\Src\QP\QPT2SEXE.C 932):
    (0) <<<<<<<<<<<<<<<<<<< Execution Strategy Begin <<<<<<<<<<<<<<<<<<<<<<<<<<<<
    (0) Original SQL:
    (0) SELECT * FROM "BIO_ASSAY"
    (0)
    (0)
    (0) Accessing Database "SQLSRVL" with SQL:
    (0) SELECT "T0000"."WH_ADDED_DATE" AS c00010, "T0000"."ASSAY_MODIFIED_TIME" AS c0009, "T0000"."ASSAY_CREATED_TIME" AS c0008, "T0000"."ASSAY_DATE_COMPLETED" AS c0007, "T0000"."ASSAY_DATE_PLANNED" AS c0006, "T0000"."ASSAY_DATE_STARTED" AS c0005, "T0000"."ASSAY_STATUS_NO" AS c0004, "T0000"."TIMEFRAME_KEY" AS c0003, "T0000"."TARGET_KEY" AS c0002, "T0000"."ENVIRONMENT_KEY" AS c0001, "T0000"."ASSAY_KEY" AS c0000 FROM "BIO_ASSAY" T0000
    (0)
    (0)
    Execution Strategy End >>>>>>>>>>>>>>>>>>>>>>>>>>>>(0) hoapars(15); Exited with retcode = 0.
    (0) hoaopen(19); Entered. id = 1.
    (0) hoaopen(19); Exited with retcode = 0.
    (0) hoadscr(16); Entered. id = 1.
    (0) hoastmt(195); Array fetch size is: 1.
    (0) ------ hoadscr() -------:
    (0) hoadamsz: 11, hoadasiz: 11, hoadambr: 1, hoadabrc: 1
    (0) row 0 - hoadambl: 20, hoadadty: 134, hoadaprc: 19, hoadacst: 0
    (0) row 0 - hoadascl: 0, hoadanul: 0, hoadanml: 9, hoadanam: ASSAY_KEY, hoadabfl:
    (0) 20, hoadamod: 0
    (0) row 1 - hoadambl: 20, hoadadty: 134, hoadaprc: 19, hoadacst: 0
    (0) row 1 - hoadascl: 0, hoadanul: 0, hoadanml: 15, hoadanam: ENVIRONMENT_KEY,
    (0) hoadabfl: 20, hoadamod: 0
    (0) row 2 - hoadambl: 20, hoadadty: 134, hoadaprc: 19, hoadacst: 0
    (0) row 2 - hoadascl: 0, hoadanul: 1, hoadanml: 10, hoadanam: TARGET_KEY,
    (0) hoadabfl: 20, hoadamod: 0
    (0) row 3 - hoadambl: 20, hoadadty: 134, hoadaprc: 19, hoadacst: 0
    (0) row 3 - hoadascl: 0, hoadanul: 0, hoadanml: 13, hoadanam: TIMEFRAME_KEY,
    (0) hoadabfl: 20, hoadamod: 0
    (0) row 4 - hoadambl: 2, hoadadty: 7, hoadaprc: 5, hoadacst: 0
    (0) row 4 - hoadascl: 0, hoadanul: 1, hoadanml: 15, hoadanam: ASSAY_STATUS_NO,
    (0) hoadabfl: 2, hoadamod: 0
    (0) row 5 - hoadambl: 7, hoadadty: 167, hoadaprc: 0, hoadacst: 0
    (0) row 5 - hoadascl: 0, hoadanul: 1, hoadanml: 18, hoadanam: ASSAY_DATE_STARTED,
    (0) hoadabfl: 7, hoadamod: 0
    (0) row 6 - hoadambl: 7, hoadadty: 167, hoadaprc: 0, hoadacst: 0
    (0) row 6 - hoadascl: 0, hoadanul: 1, hoadanml: 18, hoadanam: ASSAY_DATE_PLANNED,
    (0) hoadabfl: 7, hoadamod: 0
    (0) row 7 - hoadambl: 7, hoadadty: 167, hoadaprc: 0, hoadacst: 0
    (0) row 7 - hoadascl: 0, hoadanul: 1, hoadanml: 20, hoadanam:
    (0) ASSAY_DATE_COMPLETED, hoadabfl: 7, hoadamod: 0
    (0) row 8 - hoadambl: 7, hoadadty: 167, hoadaprc: 0, hoadacst: 0
    (0) row 8 - hoadascl: 0, hoadanul: 0, hoadanml: 18, hoadanam: ASSAY_CREATED_TIME,
    (0) hoadabfl: 7, hoadamod: 0
    (0) row 9 - hoadambl: 7, hoadadty: 167, hoadaprc: 0, hoadacst: 0
    (0) row 9 - hoadascl: 0, hoadanul: 1, hoadanml: 19, hoadanam: ASSAY_MODIFIED_TIME,
    (0) hoadabfl: 7, hoadamod: 0
    (0) row 10 - hoadambl: 0, hoadadty: 0, hoadaprc: 0, hoadacst: 0
    (0) row 10 - hoadascl: 0, hoadanul: 0, hoadanml: 13, hoadanam: WH_ADDED_DATE,
    (0) hoadabfl: 0, hoadamod: 0
    (0) hoadscr(16); Exited with retcode = 0.
    Note, the query I entered doesn't appear and I never entered the query "select * from bio_assay" - it appears that this is
    automatically generated by the hsodbc process and raises other questions (like wouldn't this return a lot of unneeded
    data ?). It also appears that the "select * from bio_assay" gets translated somehow into a select statement listing each column - however, non of the columns listed are character type columns like assay_name.
    Does this make sense to anyone? Any ideas ? HELP !

    Remote view gives the same error. I think the problem has to do with nchar and nvchar fields. It seems that the hsodbc agent issues a "select * from bio_assay" at the beginning of the session (see above trace).
    0) odbc_rec: select * from "BIO_ASSAY"
    (0) Silent DB Function!!
    (0) nvOUT (P:\Src\QP\QPT2SEXE.C 929):
    (0) SELECT "T0000"."WH_ADDED_DATE" AS c00010, "T0000"."ASSAY_MODIFIED_TIME" AS c0009, "T0000"."ASSAY_CREATED_TIME" AS c0008, "T0000"."ASSAY_DATE_COMPLETED" AS c0007, "T0000"."ASSAY_DATE_PLANNED" AS c0006, "T0000"."ASSAY_DATE_STARTED" AS c0005, "T0000"."ASSAY_STATUS_NO" AS c0004, "T0000"."TIMEFRAME_KEY" AS c0003, "T0000"."TARGET_KEY" AS c0002, "T0000"."ENVIRONMENT_KEY" AS c0001, "T0000"."ASSAY_KEY" AS c0000 FROM "BIO_ASSAY" T0000
    Apparently, the list of fields that is returned from the "select *" does not include any of the nchar or nvchar type columns. After this initial "select *" the oracle server only looks at the initial list of columns and gives an "invalid column" error for any fields that are not in this initial list. So the question is: how do I make the hsodbc agent see the nchar/nvchar type fields and include them in the initial list ? I've tried setting the HS_NLS_LANGUAGE and HS_NLS_NCHAR parameters but these seem to have no effect.
    Any clue as to what's going on ?

  • Poor performance of BLOB queries using ODBC

    I'm getting very poor performance when querying a BLOB column using ODBC. I'm using an Oracle 10g database and the Oracle 10g ODBC driver on Windows XP.
    I create two tables:
    create table t1 ( x int primary key, y raw(2000) );
    create table t2 ( x int primary key, y blob );
    Then I load both tables with the same data. Then I run the following queries using ODBC:
    SELECT x, y FROM t1;
    SELECT x, y FROM t2;
    I find that the BLOB query takes about 10 times longer than the RAW query to execute.
    However, if I execute the same queries in SQL*Plus, the BLOB query is roughly as fast as the RAW query. So the problem seems to be ODBC-related.
    Has anyone else come across this problem ?
    Thanks.

    Hi Biren,
    By GUID, are you referring to the Oracle Portal product?

  • DTW - Trouble using ODBC and Configuration Files

    I am using SBO SP1 PL2 and DTW 2005.
    I have been making use of saving the configuration for the import of an object and then using the command line to run it, as described in DTW help under "Schedule Run".
    I typically use tab-delimited files saved from Excel and the above method works very well.
    However, I would prefer to use ODBC directly from the template tables I have in a SQL database. It works perfectly using the GUI within DTW, and it lets me save the configuration file, but when I try to run DTW from the command line using ODBC, I get these error messages:
    Can not connect to ODBC data source.
    Can not get SQL handler.
    Does anyone have any suggestions on how I can use DTW from the command line while using ODBC sources?
    Thank you.

    I've got the same problem.
    I solve it once by editing the xml file's <ExID> tag from <ExID></ExID> to <ExID />
    So the problem resides at the XML syntax.
    My problem is that I lost the XML file I used and now I can't make it work again.
    Have anybody found the solution at this problem or is there an updated version of DTW?

  • SQL query from C++ application using ODBC 10.2.0.4 is very slow

    Hi,
    We are using ODBC oracle driver to access 10g Oracle server from C++ apllication. But the performace is very slow.
    Recently we tried with Microsoft Oracle ODBC driver, which we found faster than 10.2.0.4 Oracle ODBC driver.
    Please let me know is anything is ther any issue with this driver or is it better to use Microsoft ODBC driver.
    Thanks,
    Sabbi

    Hi StephenEP,
    As the issue is more related to C++ programming, I would like to recommend you post the question in the Visual C++ forum at
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vcgeneral  . It is appropriate and more experts will assist you.
    Thanks,
    Lydia Zhang

  • Whats wrong in this code using ODBC interface of T10 in C ?

    Hi!
    I am trying to connect TimesTen using ODBC in a C application, I am trying to use the dynamic binding of parameters the query. The problem is elaborated in the code. In the comments.
    #include <windows.h>
    #include <sql.h>
    #include <sqlext.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    int main()
    SQLRETURN rc = SQL_SUCCESS;
    /* General return code for the API */
    SQLHENV hEnv = SQL_NULL_HENV;
    /* Environment handle */
    SQLHDBC hDbc = SQL_NULL_HDBC;
    /* Connection handle */
    SQLHSTMT hStmt = SQL_NULL_HSTMT;
    /* Statement handle */
    SQLCHAR ConnOut[255];
    /* Buffer for completed connection string */
    SQLSMALLINT connOutLen;
    /* number of bytes returned in ConnOut */
    SQLCHAR ConnString = (SQLCHAR ) "DSN=testTT;PWD=spideradm;";
    /* Connection attributes */
    rc = SQLAllocEnv(&hEnv);
    if (rc != SQL_SUCCESS) {
    fprintf(stderr,"Unable to allocate an environment handle\n");
    exit(1);
    SQLINTEGER param1 = 0;
    SQLINTEGER paramstatus = 0;
    rc = SQLAllocConnect(hEnv, &hDbc);
    rc = SQLDriverConnect(hDbc, NULL,ConnString, SQL_NTS,ConnOut, 255,&connOutLen,SQL_DRIVER_NOPROMPT);
    hStmt = SQL_NULL_HSTMT;
    rc = SQLAllocStmt(hDbc, &hStmt);
    rc = SQLPrepare(hStmt,(SQLCHAR*) "select * from test where recno = ? ",SQL_NTS);
    rc = SQLBindParameter(hStmt,1,SQL_PARAM_INPUT,SQL_C_SHORT,SQL_INTEGER,0,0,¶m1,0,¶mstatus);
    param1= 1;
    rc = SQLExecute(hStmt); // here it goes very perfect
    param1 = 2;
    rc = SQLExecute(hStmt); // here is the problem it returns -1
    }

    There are (at least) 3 problems with this code:
    1. The error checking after each ODBC call is far too simplistic. Whenever an ODBC call returns something other than SQL_SUCCESS then you need to call the SQLError() function (multiple times in a loop until it returns SQL_NO_DATA) to retrieve the error or warning information which you should then report. If you do that then the error information would give you a clue to the problem.
    2. The parameter variable 'param1' is declared as a SQLINTEGER (32-bit integer) but you bind it in the SQLBindParameter() call as a SQL_C_SHORT. This is incorrect and will likely cause problems. It should be bound as a SQL_C_SLONG.
    3. When you execute a statement that retrieves data (such as the SELECT statement in your example) a cursor is created. The cursor remains open until (a) you explicitly close it with SQLFreeStmt(hStmt, SQL_CLOSE), or (b) you do a commit or rollback (which closes all open cursors on the connection).
    Your problem here is that the first SQLExecute opens a cursor for hStmt but you then do not fetch any data or close the cursor. When you try the second execute you get an error as there is already an open cursor for that statement. If you had used SQLError(0 to retrieve and report the error codes and messages you would see that you had incurred either an 'INVALID CURSOR STATE' or 'FUNCTION SEQUENCE ERROR' error.
    The fix is to insert the call:
    SQLFreeStmt(hStmt,SQL_CLOSE);
    after the each SQLExecute(0 call. Of course, in a real application there would also be a SQLFetch() loop first to retrieve and process the results of the query.
    Chris

  • Connect to SQL Server by using ODBC

    We use ODBC to connect to a Microsoft SQL Server database. We are able to describe and select in Oracle for those tables (in MS SQL) granted to us. However, we cannot select on the views created in MS SQL. Do we miss something? Here is the SQL statement in MS SQL:
    ELECT MRN, SSN, MaritalStatus, LastName, FirstName, MiddleName, MMaidenName, Address, City, State, Phone, DOB, CitizenshipStat, AlienNumber,
    ELADocType, ELASecNo, ELAExpDate, ELAISUDate, PCC, PCCCode, PCP, FileDate, LastUpdate, SystemDate, [TimeStamp], SystemSource,
    ENR_HASH_NO, ActiveMRN, RIGHT(PCCCode, 4) AS PCCshortname, AutoAssignPCC, AutoAssignPCCTimeStamp, AutoAssignInactivate,
    ActivePanelAssignment, ActivePanelIND
    FROM dbo.tblPatient
    WHERE (DeceasedIND <> 'Y') AND (IsTestPatient <> 'NY')

    Here is the sql statment:
    SELECT MRN, SSN, MaritalStatus, LastName, FirstName, MiddleName, MMaidenName, Address, City, State, Phone, DOB, CitizenshipStat, AlienNumber,
    ELADocType, ELASecNo, ELAExpDate, ELAISUDate, PCC, PCCCode, PCP, FileDate, LastUpdate, SystemDate, [TimeStamp], SystemSource,
    ENR_HASH_NO, ActiveMRN, RIGHT(PCCCode, 4) AS PCCshortname, AutoAssignPCC, AutoAssignPCCTimeStamp, AutoAssignInactivate,
    ActivePanelAssignment, ActivePanelIND
    FROM dbo.tblPatient
    WHERE (DeceasedIND <> 'Y') AND (IsTestPatient <> N'Y')

Maybe you are looking for

  • How do I consolidate music files from all the locations on my laptop where they currently exist?

    My music files are located in at least four different places on my computer. I find them in c:/(user)/Music (all just stored in various folders outside the ITunes folder), in c:/(user)/Music/ITunes/ITunes Media/Music, in c:/(user)/ITunes/ITunes Music

  • Authenticated Users & Users missing from Root

    Hello, Environment: MDT 2013, 2008 R2, Windows 7 x86.  MDT is located on Windows 7 x86 and is not integrated with SCCM or WDS. Process: Separate build, capture, and deployment task sequences. Problem:  After deployment the Authenticated Users and loc

  • VAIO S13: battery not charging over 80%

    Hi to all, I have a big question for you: Sony provides an utility (that of course runs only on win) that lets you set the maximum charge of the battery to 80% or even 50% (in order to avoid battery decay, they say). This program probably activates s

  • Can somebody explain to me how java and xml are related?

    Hi guys im new to java and xml.Been reading a lot regarding java and don't seem to have a problem with it... the problem is the xml part...im doing a simple GUI project using swing(online store) and i have to convert it to xml I have absolutely NO ID

  • Why does copying from Photoshop to InDesign turn Green?

    I've just installed photoshop and InDesign from Adobe Creative Suite premium onto my Apple Mac, all is running well but when I copy a photo from Photoshop to InDesign the picture turns green, is there something that Im missing or do I need to re-inst