1. Jim Reese
  2. PowerServer
  3. Thursday, 28 September 2023 16:54 PM UTC

We're attempting to migrate our large 20+ year old application to PowerServer 2022 R2. We have an ORACLE database, and have a number of RPCs as well as a few datawindows using stored procedure updates. Some of the remote procedures have PRAGMA autonomous transactions with their own commit/rollback, some are not autonomous transactions but do have commit/rollback in them, some return values with no DB updates, and some do DB updates and rely on the script calling them to perform the commit/rollback. Autocommit is false.

As a result, some of the RPC calls should start the transaction when they are executed, and some should not.

My question is: Can the transaction object's dbparm value be changed in the sqlpreview event of the transaction object itself, to set the appropriate value of ProcedureInTransaction based on the name of the RPC (which is found in the sqlsyntax argument), or does it need to be set earlier than that?

Here is some of the code in n_tr.sqlpreview event we're hoping to use. It includes some logging to a file, so we can see that the values are getting recognized and set, but we don't know if the changing of ProcedureInTransaction to the desired value of 0 or 1 is actually effective at this point.

IF gb_ispowerserverapp THEN
	integer i, li_FileNum
	String	ls_sqlfunc, ls_syntax
	String	ls_default

	CHOOSE CASE sqlfunc
		CASE SQLDBProcedure!,SQLDBRPC!
			CHOOSE CASE sqlfunc
				CASE SQLDBProcedure!
					ls_sqlfunc = "SQLDBProcedure"
					CHOOSE CASE upper(trim(ls_syntax))
						CASE	"EXECUTE CB_LEASE_PMT"	,&
							"EXECUTE CB6.CB_DATAACCESS.P_CBXML_INSERT"	,&
							"EXECUTE DBMS_SESSION.SET_IDENTIFIER"	
							this.of_set_procedureintransaction(0)
						CASE	"EXECUTE CB6.CB_DATAACCESS.P_CBATTACHMENT_DELETE"	,&
							"EXECUTE CB6.CB_DATAACCESS.P_CBATTACHMENT_INSERT"	,&
							"EXECUTE CB6.CB_DATAACCESS.P_CBATTACHMENT_UPDATE"	
							this.of_set_procedureintransaction(1)
						CASE ELSE
							this.of_set_procedureintransaction(1)
							ls_default = "~tNO MATCH IN CASE, DEFAULT TO 1"
					END CHOOSE //upper(trim(ls_syntax))
				CASE SQLDBRPC!
					ls_sqlfunc = "SQLDBRPC"
					CHOOSE CASE trim(ls_syntax)
						CASE	"RPCEXECUTE CB6.CB_DATAACCESS.F_CBATTACHMENT_BLOB_UPDATE"	,&
							"RPCEXECUTE CB6.CB_DATAACCESS.F_CBERROR_INSERT"	,&
							"RPCEXECUTE CB6.PKG_TERRITORY.VALIDATE_MODEL"
							this.of_set_procedureintransaction(0)
						CASE	"RPCEXECUTE CB6.ARCHIVE_AND_DELETE.CANCEL_BATCH"	,&
							"RPCEXECUTE CB6.ARCHIVE_AND_DELETE.CREATE_BATCH"	,&
							"RPCEXECUTE CB6.PKG_TERRITORY.REFRESH_UPDATED_COMPANY"	
							this.of_set_procedureintransaction(1)
						CASE ELSE
							this.of_set_procedureintransaction(1)
							ls_default = "~tNO MATCH IN CASE, DEFAULT TO 1"
					END CHOOSE //trim(ls_syntax)
			END CHOOSE //sqlfunc inner
			li_FileNum = FileOpen("C:\Temp\RPCCALLS.txt",LineMode!,Write!,LockReadWrite!,Append!,EncodingANSI!)
			FileWrite(li_FileNum, string(today(),"yymmdd hh:mm:ss") + "~t" + ls_sqlfunc + "~t~t" + ls_syntax + ls_default)
			FileClose(li_FileNum)
		CASE else
			this.of_set_procedureintransaction(1) //set back to a 1 ??
			//other sqldb calls, show 1st 240 chars, but change carriage return and linefeed so shows on 1 line in logfile, but can convert back if needed when examining log
			ls_syntax = sqlsyntax
			ls_syntax = f_globalreplace(mid(ls_syntax,1,240),"~r","<CR>",true)
			ls_syntax = f_globalreplace(mid(ls_syntax,1,240),"~n","<LF>",true)
			li_FileNum = FileOpen("C:\Temp\RPCCALLS.txt",LineMode!,Write!,LockReadWrite!,Append!,EncodingANSI!)
			FileWrite(li_FileNum, string(today(),"yymmdd hh:mm:ss") + "~t" + ls_syntax )
			FileClose(li_FileNum)
	END CHOOSE //sqlfunc outer
END IF
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 28 September 2023 18:25 PM UTC
  2. PowerServer
  3. # 1

Hi Jim;

  Basically, PS ignores all the settings in your Transaction object except for ...

  • SQLCA.DBParm = "CacheName='mydbcache'"   // And/Or
  • SQLCA.DBParm = "LongConnection=1"

To control what you are describing, I would have a look at ..

  • DB "advanced" Settings in your PS Project    // And/Or
  • Use a secondary Transaction Object

HTH

Regards ... Chris

 

Comment
  1. Jim Reese
  2. Thursday, 28 September 2023 18:30 PM UTC
Chris, if that is so, then why did Appeon add and document the DBParm "ProcedureInTransaction=0/1" for PowerServer???
  1. Helpful 1
  1. Chris Pollach @Appeon
  2. Thursday, 28 September 2023 19:03 PM UTC
Hi Jim;

My Bad .. I missed the fact that your are on PB 2022 R2 or PS 2.1.0. Yes, the following DBParm settings are then valid ...

CacheName -- Specifies the database connection cache to be used by the installable cloud app.

CacheGroup -- Specifies the cache group to be used by the installable cloud app.

ProcedureInTransaction -- Specifies whether to start the transaction when executing a stored procedure for the installable cloud app. The default value is 1 (Start the transaction).

LongConnection -- Enables the installable cloud app to have the same long running database connection as the PowerBuilder native C/S app. For more, refer to DB connection.

TimeStamp (Oracle only)

NCharBind (Oracle and SQL Server only)

Regards ... Chris
  1. Helpful 1
  1. Tracy Huang @Appeon
  2. Saturday, 7 October 2023 06:36 AM UTC
Hi Jim,

Not sure if the following links are helpful or not:

This page talks about why there is and how to resolve transaction timeout issue in stored procedure:

https://docs.appeon.com/ps2022r2/Stored_procedure.html

This page talks about the usages and code examples for ProcedureInTransaction:

https://docs.appeon.com/pb2022r2/connection_reference/ProcedureInTransaction.html

Regards

Tracy
  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.