1. GILBERT VENTRE
  2. PowerBuilder
  3. Thursday, 22 December 2022 11:37 AM UTC

Hello,
We have a problem with MSOLEDBSQL driver (v19.2.0.0) when we use a temporary table.

If we create a temporary table with the following syntax :

String ls_SQL
ls_SQL = "CREATE TABLE #tmp_WHO ( " + &
"spid smallint, ecid smallint, status nchar(30), loginame nchar(128), hostname nchar(128), " + &
"blk char(5), dbname nchar(128), cmd nchar(26), request_id int )"
EXECUTE IMMEDIATE :ls_SQL USING MyTransaction;

Insert data in the table with the following commands :

ls_SQL = "INSERT INTO #tmp_WHO EXEC('sp_who')"
EXECUTE IMMEDIATE :ls_SQL USING MyTransaction;

And use the SyntaxFromSQL function :

String ls_Select
String ls_Presentation
String ls_Errors
ls_Select = "SELECT spid, ecid, status, loginame, hostname, blk, dbname, cmd " + &
"FROM #tmp_WHO WHERE dbname = '" + MyTransaction.Database + "' "
ls_Presentation = "style(type=grid) " + &
"column(font.face='Arial' font.height=-8 font.family=2 font.pitch=2 font.weight=400) " + &
"text(font.face='Arial' font.height=-8 font.family=2 font.pitch=2 font.weight=700 background.mode=0 background.color=33541277)"
MyTransaction.SyntaxFromSQL( ls_Select, ls_Presentation, ls_Errors )

ls_Errors returns an empty string and I assume they are no errors.

 

BUT, Immediately after the SyntaxFromSQL if we launch a simple query, the  SQLCode from MyTransaction returns -1

For example, if I want to see if our database is compatible with the version of our application :

ls_SQL = "SELECT 1 WHERE EXISTS (SELECT 1 FROM VERSION WHERE NVERSION = 16 AND NRELEASE = 0 AND NRELEASEMINOR = 0)"
EXECUTE IMMEDIATE :ls_SQL USING MyTransaction;

Here are the error codes returned by the transaction :
SqlCode = -1
SqlDbCode = 208
SqlErrText = SQLSTATE = 42S02
Microsoft OLE DB Driver 19 for SQL Server
Invalid object name 'VERSION'.

When we use the old drivers (OLEDB or SQLNCLI), it works proprerly.

If we remove the # character from the name of the temporary table, it works without issues.

Have the standards changed with the MSOLEDBSQL driver ?

I checked, and the transaction is still connected to the database.

Here is the dbparm of the transaction :
MyTransaction.dbparm : PROVIDER='MSOLEDBSQL19',OJSyntax='ANSI',CommitOnDisconnect='No',DelimitIdentifier='No',PBNoCatalog='Yes',DisableBind=1,StaticBind=0,DATASOURCE='MyServer\SQL2019',PROVIDERSTRING='Database=MyDatabase;APP=MyApp',TrimSpaces=1,Encrypt=1,TrustServerCertificate=1,DateFormat='\''dd/mm/yyyy\''',DateTimeFormat='\''dd/mm/yyyy hh:mm:ss.fff\''',DecimalSeparator=','

Peter Pang @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 27 December 2022 03:38 AM UTC
  2. PowerBuilder
  3. # 1

Hi Gilbert,

 

I can reproduce the problem using your DBParm. The Database parameter is separated from PROVIDERSTRING due to a change in the MSOLEDBSQL driver parameter.

 For example: SQLCA.DBParm = "Database='qa_datawindow',Provider='MSOLEDBSQL19'"

 

Please modify your DBParm as follows and then verify if the problem is solved:

Database='MyDatabase',PROVIDER='MSOLEDBSQL19',OJSyntax='ANSI',CommitOnDisconnect='No',DelimitIdentifier='No',PBNoCatalog='Yes',DisableBind=1,StaticBind=0,DATASOURCE='MyServer\SQL2019',PROVIDERSTRING='Database=MyDatabase;APP=MyApp',TrimSpaces=1,Encrypt=1,TrustServerCertificate=1,DateFormat='\''dd/mm/yyyy\''',DateTimeFormat='\''dd/mm/yyyy hh:mm:ss.fff\''',DecimalSeparator=','  

 

Wish you all a merry Christmas & happy New Year! 

 

Best Regards,

Peter

Comment
  1. GILBERT VENTRE
  2. Tuesday, 27 December 2022 14:15 PM UTC
Hi Peter,

I Changed the DBParm as you adviced and it works properly now.

Thanks a lot.

Gilbert
  1. Helpful
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Thursday, 22 December 2022 14:03 PM UTC
  2. PowerBuilder
  3. # 2

Which version of PB are you using?

Comment
  1. Armeen Mazda @Appeon
  2. Thursday, 22 December 2022 15:40 PM UTC
Hi Christopher, Can you replicate with using v18.x of the MSOLEDBSQL driver? This is just troubleshooting step to help narrow-down if it is driver version specific issue or something else?
  1. Helpful
  1. Christophe Feyte
  2. Thursday, 22 December 2022 21:19 PM UTC
Yes, same issue with using v18.6.4.0 of the MSOLEDBSQL driver.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Thursday, 22 December 2022 22:12 PM UTC
Hi Christophe;

That is a definite DB driver bug. I've been using #<TableName> temporary tables in ASE & SS for decades from PB Apps. Please open a Support Ticket for this issue.

In the meantime, I wonder if using a 2nd Transaction Object connected to SS via SNC just for temporary table processing might work OK for your App (until Engineering can look into this issue deeper)?

Regards ... Chris
  1. Helpful 1
There are no comments made yet.
Markus Eckert Accepted Answer Pending Moderation
  1. Friday, 23 December 2022 09:59 AM UTC
  2. PowerBuilder
  3. # 3

Hi Gilbert

What happens if you fully address your table in the Select?

SELECT 1 WHERE EXISTS (SELECT 1 FROM dbname.dbo.VERSION WHERE NVERSION = 16 AND NRELEASE = 0 AND NRELEASEMINOR = 0)

Maybe the transaction for some reason switches the active database to master, tempdb or something else and thus the table "version" can't be resolved anymore.

Regards,
Markus

Comment
  1. GILBERT VENTRE
  2. Tuesday, 27 December 2022 14:23 PM UTC
Hi Markus , I did try to fully adress the table in the SELECT and it did work.

But the problem was not that.

My DBParam was not correct anymore, cos the Database parameter is separated from PROVIDERSTRING due to a change in the MSOLEDBSQL driver parameter.

I Changed the DBParm as adviced By Peter Pang and it works properly now.

Thanks looking into it.

Gilbert
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.