1. Mihai Apostol
  2. PowerBuilder
  3. Thursday, 19 December 2019 18:45 PM UTC

Hi All, 

 

Is it possible in PB to get the query string I'm going to execute from PowerScript with the bind variables replaced like in sqlpreview() event of datawindow? How?

Exemple.

Insert into table_test (columA, columnB) Values (:colA, :colB);

I would like to take into a string variable the final statement the PB will send to DB like:

Insert into table_test (columnA, columnB) Values ('valueA', 'valueB')

Thanks

Accepted Answer
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 19 December 2019 19:15 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi Mapo;

  Have a look at the new "sqlpreview" event in the Transaction object (aka: SQLCA).

Regards ... Chris

Comment
  1. Mihai Apostol
  2. Friday, 20 December 2019 03:40 AM UTC
Thank you Chris!
  1. Helpful
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Friday, 20 December 2019 19:00 PM UTC
  2. PowerBuilder
  3. # 1

Chris, a question!

In many cases when I have looked at SQLSYNTAX in the SqlPreview event, the bind variables have not been replaced. In other words the sqlsyntax string includes

      "Insert into table_test (columA, columnB) Values (:colA, :colB)"

rather than including

      "Insert into table_test (columA, columnB) Values ("this is the actual value", 466)"

I have fiddled with the PARAMETER setting, changing DisableBind from 1 to 0, and nothing seems to change.

What am I missing?

 

Thanks,

Olan

Comment
  1. Chris Pollach @Appeon
  2. Friday, 20 December 2019 20:55 PM UTC
Hi Olan;

Hmmm ... I would have expected the DisableBind=0 setting to allow that. :-(

I would suggest opening a Support Ticket for this issue.

Regards ...Chris
  1. Helpful
  1. Olan Knight
  2. Friday, 20 December 2019 21:53 PM UTC
Thanks, Chris.

Olan
  1. Helpful
  1. Michael Kramer
  2. Friday, 20 December 2019 22:19 PM UTC
Hi Olan, as I remember DisableBind/StaticBind/etc. govern SQL generation for DataWindow engine only.

You have full control over any embedded SQL = read: You need to do the nitty gritty of replacing parameters with actual values.

NOTE: DisableBind=1 is the same as automating potential SQL injection attacks. I discourage DisableBind for that reason whenever I can.

/Michael
  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.