In SSMS (SQL Server Management Studio) debugger shows question mark for substring's return value when called from a function - sql-server

In SSMS (SQL Server Management Studio) debugger shows question mark for substring's return value when called from a function
I have a query with these two lines
SELECT SUBSTRING(N'אאא',1,1);
SELECT dbo.testsubstring5(N'א');
I put a breakpoint on the first and hit debug.
As you can see SUBSTRING works fine so far. That's when outside of the function call.
Now we when we go inside dbo.testsubstring5 then for some reason SUBSTRING doesn't output the correct result in the debugger, though it does still work correctly outside of the debugger.
Look at the watch window of the debugger in the picture below
Notice the problem, that
SUBSTRING(#str,1,1) fails, it gives the result of ?
Also as you see in that watch window, UNICODE(SUBSTRING(#str,1,1)) gives the value of 63 which is the ASCII value of question mark.
The correct values are returned in the program though, for example, the watch window shows the correct values for #zzz, #zzz1, and #zzz2
So it seems to be an issue with the debugger window , for substring, when substring is called within a function. I must be missing something though I don't know what.

SQL Server seems to have some issues displaying UNICODE characters in grid (result or watch). If you try to print output to TEXT (CTRL + T) rather that debugging, it should print correct value.
Edited with image of result for the guy who voted the answer down.
Result in watch windows while debugging
Result when printed to TEXT
Seems that problem with result grid is resolved. I am using SSMS version 2012 and don's see this issue now. I remember having this issue in older version of SSMS. But this is still an issue with debug.

Related

DataReader: pass a parameter as a String with case change does not give results

I've a DataReader which its Command involves a LIKE clause. For it to be executed, a String is passed as a paremeter from a TextBox at the UI. All data in the DB is stored as UpperCase strings. The scenario I face is as follows:
If the user inputs an Uppercase String at the UI, the DataReader gives results without problem
I've tried to give a sort of "protecction" to the input, so if the user inputs TitleCase or LowerCase, then the query still works as intended. Yet, when I use CultureInfo.CurrentCulture.TextInfo.ToUpper(myTextBox.Text) or
myTextBox.Text.ToUpper() , if I check the debugger, it even shows that the parameter is changed to UpperCase, yet, the dbConn.dbCommand.ExecuteReader() sends no results.
Could anyone give any hint or explanation of why this is not working? (and suggest a solution).
Thaks a lot in advanced for any help.

Error on one page that does not appear anywhere else

Hi so my wordpress site has just started acting up, I am not sure if its an update that has caused this but only on this one page I am getting this error regarding
Notice: Array to string conversion in /customers/c/1/7/veganantics.co.uk/httpd.www/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/StoreApi/Schemas/ImageAttachmentSchema.php on line 95
I can't seem to find the issue, I have tried replacing the file with a new core file and the error is still there, would really appreciate some help
This is the page: https://veganantics.co.uk/vegan-gifts/
Thank you
Ash
The theme, a plugin or some custom code is probably using the wp_calculate_image_sizes filter and returning an array instead of a string.
Do a text search on your install and look for wp_calculate_image_sizes. The function that you need to find will look similar to
add_filter('wp_calculate_image_sizes', 'something');
Explanation:
ImageAttachmentSchema.php on line 95 is calling wp_get_attachment_image_sizes which must be a string.
wp_get_attachment_image_sizes is returning wp_calculate_image_sizes( $size_array, $image_src, $image_meta, $attachment_id ) which again must be a string.
wp_calculate_image_sizes returns a filtered value, and that's the only place where such an error (array instead of a string) can happen. So, if the filter incorrectly returns an array, it bubbles up to the function that you see in the error log.

PETSC_VIEWER_DRAW_WORLD shows nothing

I just started with PETSC and I'm trying to plot a matrix using matView. My code is like:
MatCreateSeqAIJWithArrays(PETSC_COMM_WORLD, nodes, nodes, rows, cols, values, net); //I want to visualize "net"
//Visualization
if(display >= 1){
PetscPrintf(PETSC_COMM_WORLD, "CSR structure created.\n");
MatView(*net,PETSC_VIEWER_DRAW_WORLD);
}
When I use MatView this way:
MatView(*net,PETSC_VIEWER_STDOUT_WORLD);
I can see a list with the rows. But when I change it to
MatView(*net,PETSC_VIEWER_DRAW_WORLD);
nothing happens.
I can't see anything about net structure, not even the list.
I tried to run the examples but they don't work at all. Also, the PETSC documentation just makes things worse. Can someone help me? I don't want to see a list of rows, but the matrix (graphically).
More context from the comments:
X windows is functioning properly -- was able to confirm with gvim, xlogo, xeyes, etc.
Library has been rebuilt using --with-x option in configure. Still nothing appears.
Try using "-draw_pause -1" as an argument to your PETSc program, if you're not doing it yet.
-draw_pause - Sets time (in seconds) that the program pauses after PetscDrawPause() has been called (0 is default, -1 implies until user input).

Update database version in Lua

I'm trying to update the database version but, I'm facing a strange problem...
Here's my code:
version = 2
local cur_db_version=nil
for data in db:nrows("PRAGMA user_version") do
cur_db_version=data
break
end
local db_version=cur_db_version.user_version
print(db_version)
print(version)
if (db_version~=version) then
create()
db:exec("PRAGMA user_version="..version)
end
Imagining that the database version is 1, I'm expecting that my script prints this:
1
2
But what it is printing is:
2
2
Why? I don't know but, I do know that if I comment the line db:exec("PRAGMA user_version="..version), then it really prints this:
1
2
So, what's wrong in my code that causes the wrong output? Is the line db:exec("PRAGMA user_version="..version) somehow being executed before the prints? If so, how can I change my code in order that it only calls create() when version changes?
By the way, I'm using Corona SDK but, I don't believe that the problem is related to it right?
Ok, I found the issue... The above code is correct and the problem was with a script that I have on sublime to relaunch the simulator when I save the file and what was happenning is that somehow, the script was relaunching the simulator 2 consecutive times and due to the many prints that I have, I didn't saw the correct output above on the console...
I will keep this question here just because there could be someone else that want to know how to update the database version on corona/lua.

Arrays in PowerBuilder

I have this code
n_userobject inv_userobject[]
For i = 1 to dw_1.Rowcount()
inv_userobject[i] = create n_userobject
.
.
.
NEXT
dw_1.rowcount() returns only 210 rows. Its so odd that in the range of 170 up, the application stop and crashes on inv_userobject[i] = create n_userobject.
My question, is there any limit on array or userobject declaration using arrays?
I already try destroying it after the loop so as to check if that will be a possible solution, but it is still crashing.
Or how can i be able to somehow refresh the userobject?
Or is there anyone out there encounter this?
Thanks for all your help.
First, your memory problem. You're definitely not running into an array limit. If I was to take a guess, one of the instance variables in n_userobject isn't being cleaned up properly (i.e. pointing to a class that isn't being destroyed when the parent class is destroyed) or pointing to a class that similarly doesn't clean itself up. If you've got PB Enterprise, I'd do a profiling trace with a smaller loop and see what is being garbage collected (there's a utility called CDMatch that really helps this process).
Secondly, let's face it, you're just doing this to avoid writing a reset method. Even if you get this functional, it will never be as efficient as writing your own reset method and reusing the same instance over again. Yes, it's another method you'll have to maintain whenever the instance variable list changes or the defaults change, but you'll easily gain that back in performance.
Good luck,
Terry.
I'm assuming the crash you're facing is at the PBVM level, and not a regular PB exception (which you can catch in your code). If I'm wrong, please add the exception details.
A loop of 170-210 iterations really isn't a large one. However, crashes within loops are usually the result of resource exhaustion. What we usually do in long loops is call GarbageCollect() occasionally. How often should it be called depends on what your code does - using it frequently could allow the use of less memory, but it will slow down the run. Read this for more.
If this doesn't help, make sure the error does not come from some non-PB code (imported DLL or so). You can check the stack trace during the crash to see the exception's origin.
Lastly, if you're supported by Sybase (or a local representative), you can send them a crash dump. They can analyze it, and see if it's a bug in PB, and if so, let you know when it was (or will be) fixed.
What I would normally do with a DataWindow is to create an object that processes the data in a row and call it for each row.
the only suggestion i have for this is to remove the rowcount from the for (For i = 1 to dw_1.Rowcount()) this will cause the code to recount the rows every time it uses one. get the count into a variable and then use the variable. it should run a bit better and be far more easy to debug.

Resources