1. Daniel Vivier
  2. PowerBuilder
  3. Thursday, 23 November 2017 15:02 PM UTC

I'm testing some PB17 code that is uploading data from a local Firebird DB to a MySQL DB on our web server. It is being done through DataStores - load one from the local DB, copy the data to one connected to the web DB (with "dsTarget.Data = dsSource.Data"), and then Update().

If I do it with DisableBind=1 in the DbParm of the Transaction object for the web DB, so prepared statements aren't used, it works.

If I don't set DisableBind, so prepared statements ARE used, I start somewhat randomly getting errors such as:

Bind parameter value for ':3' is too big (2282)
No changes made to database.
Insert into tablename(columns, ) VALUES(?, ...)

The italic parts are filled in with the real table and column names of course.

What's weird is that (a) it works when not using prepared statements, and (b) the length stated in the first line of that message isn't too long for the 3rd column in the list of columns, which in this case is set in the DataWindow definition to a length of 8190. (And the actual MySQL column is MEDIUMTEXT, which holds up to about 16 million bytes!) Not only that, but there is no row of the table being updated that has a value in that column with the problem length (2282). The closest are 2257 and 2303. There's also one just under half the problem length at 1140.

On previous runs of this, it stopped at an earlier place in a different table being uploaded, where again the stated problem data length in the SqlErrText was less than the maximum column length for that field in the datawindow definition, and the complaint was of a length that didn't exist in the actual data - but a row with that column just under half the length did exist.

Both DBs are using UTF8.

Any bright ideas? Obviously we'd like to not have to use DisableBind, because this process is fairly slow already and using prepared statements should speed it up.

I also don't know whether this is in any way relevant, but when we added some code to show progress in the Update() statement, by having our custom DataStore user object call back to the window showing the progress of conversion, in its SqlPreview event, and having the window update a row number in a display DW (followed by Yield(), so you see it), the activity kept crashing at seemingly random places, often with a disconnect of the web DB! But the tests above weren't doing that.

Thanks.

Roland Smith Accepted Answer Pending Moderation
  1. Friday, 24 November 2017 20:11 PM UTC
  2. PowerBuilder
  3. # 1

Have you tried a database trace to see what exactly is being sent?

Comment
  1. Daniel Vivier
  2. Tuesday, 28 November 2017 12:56 PM UTC
I tried that by adding the documented stuff to my sqlca.DbParm, such as:



ConnectOption='SQL_OPT_TRACE,SQL_OPT_TRACE_ON;SQL_OPT_TRACEFILE,C:\folder\SQL.LOG'



but it didn't work for some reason - the file was created, but nothing was put into it. In any case, I solved this problem with the bizarre solution I noted in an earlier post on this thread, so I'm not going to spend more time on it.

  1. Helpful
There are no comments made yet.
Daniel Vivier Accepted Answer Pending Moderation
  1. Thursday, 23 November 2017 16:26 PM UTC
  2. PowerBuilder
  3. # 2

OK this is truly weird. The lengths it is complaining about in the bind are never the length of actual data. It appears the problem data is always exactly half that length in the message, minus 1.

And the lengths it is complaining about aren't the longest values in that column.

So I decided to see whether the longest values caused problems, by adding "ORDER BY char_length(problem column) DESC" to the SELECT of the data from the local source DB, so that it would try to update the longest columns first.

That seems to make the problem go away! I haven't tested it repeatedly, but it has solved it in order for 3 tables that were showing this problem until I added that ORDER BY.

Comment
There are no comments made yet.
Miguel Leeuwee Accepted Answer Pending Moderation
  1. Thursday, 23 November 2017 15:07 PM UTC
  2. PowerBuilder
  3. # 3

Not very relevant maybe, but I have had to take out the date, datetime and time format strings from the dbparm connection string for a similar problem with dates:

If I would have disablebind=0 everything would work (so the other way around of the problem you have).

If I would have disablebind=1 I would get an error on datetime implicit string to datetime conversion in INSERT statements (Oracle).

After taking out the date info from the connectiong string (which wasn't needed since we did an alter session for the dateformats anyway), both settings work.

Comment
  1. Daniel Vivier
  2. Thursday, 23 November 2017 16:23 PM UTC
Thanks, but we have never had any format strings in our DBParm.

  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.