xsharp.eu • SqlSelect error with DB2 Driver ODBC
Page 1 of 1

SqlSelect error with DB2 Driver ODBC

Posted: Wed Sep 25, 2024 4:19 pm
by Cyril
Hi

I have a SQL error when I want to initiate a SQLSelect with a SQLConnection on DB2 database

This code perform correctly in VO but not in XSharp with this error:
[IBM][CLI Driver][DB2/AIX64] SQL30090N Opération incorrecte pour l'environnement d'exécution d'application. Code anomalie = "22". SQLSTATE=25000

Code: Select all

FUNCTION Start() AS INT
	LOCAL oDbDB2I		AS sqlConnection
	LOCAL oSqlSelect	AS SQLSelect

	? "DB2 connection testing"                      
	
  	oDbDB2I := sqlConnection{"DNS_NAME", "USER", "PASSWORD"}     
  	IF !IsNil(oDbDB2I:ErrInfo)    
  		? "Erreur Connection"
  		? oDbDB2I:ErrInfo:ErrorMessage 
  	ENDIF
	oSqlSelect := SqlSelect{"SELECT comm_no, demarch_car_no, f_valid_dat_ca FROM MVSDB2DET.VACMANRX", oDbDB2I}    
	IF oSqlSelect:Execute()
		? "requete OK"
	ELSE
		? oSqlSelect:ErrInfo:ErrorMessage
		? "requete KO"
	ENDIF  	
	
	oSqlSelect:Close()
	oDbDB2I:Disconnect()          
Could you help me please ?

Thanks
Cyril

Re: SqlSelect error with DB2 Driver ODBC

Posted: Thu Sep 26, 2024 5:45 am
by robert
Cyril,
Which version of VO were you using?
There were changes in the SQL classses between VO 2.7 and VO 2.8.
Our classes are compatible with VO 2.8.

Robert

Re: SqlSelect error with DB2 Driver ODBC

Posted: Thu Sep 26, 2024 7:21 am
by Cyril
Hi

We use 2.7 VO version :(
Is there a solution to fix our issue ?

Thank you
Cyril

Re: SqlSelect error with DB2 Driver ODBC

Posted: Thu Sep 26, 2024 9:40 am
by robert
Cyril,
Try this

Code: Select all

oDbDB2I := sqlConnection{"DNS_NAME", "USER", "PASSWORD"}     
  	IF !IsNil(oDbDB2I:ErrInfo)    
  		? "Erreur Connection"
  		? oDbDB2I:ErrInfo:ErrorMessage 
  	ENDIF
  	// The Cursor options are SQL_CUR_USE_IF_NEEDED, SQL_CUR_USE_ODBC, SQL_CUR_USE_DRIVER
  	// VO 2.7 used SQL_CUR_USE_ODBC. VO 2.8 and X# use SQL_CUR_USE_IF_NEEDED
        oDbDB2I:OdbcCursors := SQL_CUR_USE_ODBC  

        oSqlSelect := SqlSelect{"SELECT comm_no, demarch_car_no, f_valid_dat_ca FROM MVSDB2DET.VACMANRX", oDbDB2I}    
	IF oSqlSelect:Execute()
		? "requete OK"
	ELSE
		? oSqlSelect:ErrInfo:ErrorMessage
		? "requete KO"
	ENDIF  	
	
	oSqlSelect:Close()
	oDbDB2I:Disconnect()         
	

Re: SqlSelect error with DB2 Driver ODBC

Posted: Thu Sep 26, 2024 3:42 pm
by Cyril
Realy realy thanks !!

it's ok with this option

just a little correction for futur readers, we can't change option after open connection so we have to do this

Code: Select all

oDbDB2I := sqlConnection{}     

  	// The Cursor options are SQL_CUR_USE_IF_NEEDED, SQL_CUR_USE_ODBC, SQL_CUR_USE_DRIVER
  	// VO 2.7 used SQL_CUR_USE_ODBC. VO 2.8 and X# use SQL_CUR_USE_IF_NEEDED
        oDbDB2I:OdbcCursors := SQL_CUR_USE_ODBC  
        
	oDbDB2I:oDbDB2I:connect("DNS_NAME", "USER", "PASSWORD")
	
  	IF !IsNil(oDbDB2I:ErrInfo)    
  		? "Erreur Connection"
  		? oDbDB2I:ErrInfo:ErrorMessage 
  	ENDIF