how to take the result of a select query into a variable?
-
hi all, i am trying to run a query like this ---- CDatabase database; CString sDriver = "MICROSOFT ACCESS DRIVER (*.mdb)"; CString sDsn; CString sFile = "c:\\MDD.mdb"; sDsn.Format("ODBC;DRIVER={%s};DSN='';DBQ=%s",sDriver,sFile); TRY { database.Open(NULL,false,false,sDsn); } CATCH(CDBException, e) { } END_CATCH database.ExecuteSQL("SELECT MAX(dist) INTO temp FROM TempTable"); *********************************************************************** TempTable is a dynamically generated temporary table.My problem is that i need to get the result of the above query into a variable. any help to solve this problem will be appreciated.... Thanks and regards.
-
hi all, i am trying to run a query like this ---- CDatabase database; CString sDriver = "MICROSOFT ACCESS DRIVER (*.mdb)"; CString sDsn; CString sFile = "c:\\MDD.mdb"; sDsn.Format("ODBC;DRIVER={%s};DSN='';DBQ=%s",sDriver,sFile); TRY { database.Open(NULL,false,false,sDsn); } CATCH(CDBException, e) { } END_CATCH database.ExecuteSQL("SELECT MAX(dist) INTO temp FROM TempTable"); *********************************************************************** TempTable is a dynamically generated temporary table.My problem is that i need to get the result of the above query into a variable. any help to solve this problem will be appreciated.... Thanks and regards.
vcseeker wrote: database.ExecuteSQL("SELECT MAX(dist) INTO temp FROM TempTable"); Probably, in your query, you don't want to mean "INTO temp", you want to mean "AS TEMP". "INTO temp" creates a temporary table and does not return any record. "AS temp" names the column MAX(dist) as "temp". ORACLE One Real A$#h%le Called Lary Ellison
-
vcseeker wrote: database.ExecuteSQL("SELECT MAX(dist) INTO temp FROM TempTable"); Probably, in your query, you don't want to mean "INTO temp", you want to mean "AS TEMP". "INTO temp" creates a temporary table and does not return any record. "AS temp" names the column MAX(dist) as "temp". ORACLE One Real A$#h%le Called Lary Ellison
hi Daniel, Thanks for quick reply. Actuall i am running the Query-- database.ExecuteSQL("SELECT MAX(dist) FROM TempTable"); and i want to get the result in a local variable that is declared inside my function .I want to assign the value of MAX(dist) into this local vaiable. something like this... int local; local = database.ExecuteSQL("SELECT MAX(dist) FROM TempTable");//I Wish i could be able to do that. Can you help me in achieving this. Regards.
-
hi all, i am trying to run a query like this ---- CDatabase database; CString sDriver = "MICROSOFT ACCESS DRIVER (*.mdb)"; CString sDsn; CString sFile = "c:\\MDD.mdb"; sDsn.Format("ODBC;DRIVER={%s};DSN='';DBQ=%s",sDriver,sFile); TRY { database.Open(NULL,false,false,sDsn); } CATCH(CDBException, e) { } END_CATCH database.ExecuteSQL("SELECT MAX(dist) INTO temp FROM TempTable"); *********************************************************************** TempTable is a dynamically generated temporary table.My problem is that i need to get the result of the above query into a variable. any help to solve this problem will be appreciated.... Thanks and regards.
Just a suggestion: perhaps use the CRecordset class to navigate and getting data from your records. Take a look at the MSDN documentation. Hope this helps.
-
Just a suggestion: perhaps use the CRecordset class to navigate and getting data from your records. Take a look at the MSDN documentation. Hope this helps.