in reply to Re^8: CGI Action call
in thread CGI Action call
Maybe some other instance of your program is changing the sort order at the same time?
Even the MySQL documentation tells us that this ordering will not respect changes to the table.
You shouldn't rely on such a feature but use the order by clause in your SELECT statements.
Also, you should show some representative examples of data in your table, and the exact SELECT statements you run, and the exact output you get, and the exact output you expect. It makes it relatively hard for us to slog through the reams of code you post, half of which is commented-out debris from other attempts by you.
Please take some time to prepare a short, self-contained example that we can run to reproduce and maybe fix your problem. It should be shorter than 20 lines.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^10: CGI Action call
by tultalk (Monk) on Mar 28, 2018 at 00:10 UTC | |
Tracked it down for now. I have a variable storing a sort index (0,1 or 2). It is correct after I search a name which is supposed to establish the the order. It does. When I execute the code to get the next record the sort index is 0 while for lastname it was 1 before entering the sub for navigating. The $sortIndex $sortindex is declared here: use vars qw($dataupdatemessage $dataupdatefilemessage $LoggedOnId $sortindex ); It should persist. Searched all instances and see nothing that would change it. | [reply] |
by poj (Abbot) on Mar 28, 2018 at 07:09 UTC | |
Do you mean it should persist between search_Records() and navigate_Records(). How, on the client in javascript ? poj | [reply] [d/l] [select] |
|
Re^10: CGI Action call
by tultalk (Monk) on Mar 27, 2018 at 21:13 UTC | |
Thanks for comments You say "Even the MySQL documentation tells us that this ordering will not respect changes to the table." I am aware of the effects of inserts, deletes and even mods to data IIRC. I tested that with an insert and it indeed broke the order which only requires re-invoking the alter table command I am only doing a select and am re-invoking the alter table after enetering the select subroutine. It does not help. So in SQL Sceibble, lets try the alter table order by name and change the SQL statements. That should demonstrate any problem without my trying to extract "20 lines of code" from my program to reproduce the result. You pointed to the problem earlier in you post in this thread. Using your already existing example should demonstrate the problem. You state "Also, your SQL seems faulty to me as the "previous record" seems to skip users:"
I just SQL scribbled with your scribble and
with 4 Returned "Pebbles" and with "2" returned "Wilma". That statement is working correctly so I am assuming my other statement will also work correctly. So are we saying that something in my program is de-ordering? I am not executing anything that would do that as far as I know. I will look further. Where can I get SQL Scribble? When I searched on it I only saw ref to MS-SQL. Best regards | [reply] [d/l] [select] |
by tultalk (Monk) on Mar 27, 2018 at 21:17 UTC | |
Help if I searched Fiddle and not Scribble!!!!! | [reply] |
by tultalk (Monk) on Mar 27, 2018 at 21:30 UTC | |
Found it. Tested my other statement. Works fine. Now on to alter table | [reply] |
by tultalk (Monk) on Mar 28, 2018 at 03:09 UTC | |
FIXED. Appears to work perfectly. I had some real screw ups in the javascript Took all this time to hunt the problems down and fix them. Thanks for help on this issue | [reply] |
by tultalk (Monk) on Mar 28, 2018 at 21:53 UTC | |
Spoke too soon Testing next and previous record calls When ORDER is set to user_id scrolling works fine both ways. When ORDER is set to lastname, next works fine but previous is stuck on current record No code posted as error logs and DBI-trace informs more thoroughly(In my opinion) in this case than "slogging" though code (More than 20 lines). Below are error logs and accompanying DBI->trace showing the steps through and the statement binding. looks to me exactly as it should except the JSON result from <-. Please note the JSON at the end of each error log. The Error Log -> moved to the next record which is the lastname = "Ebert" record while the Error Log <- previous is stuck on the lastname = "Dare" record. Repeated calls <- just loads the same record <"dare" is not the first record in the lastname order as it is preceded by 7 records and followed by more than 50 records. (alphabetical order)As I said before the -> statement and <- statement both work as expected in php Admin SQL with the ALTER TABLE users ORDER BY lastname ASC issued before the lastname tests. The DBI-Trace also shows the alter statement issued as it should be by my program
Line 321 is the call to restoreOrder($sortindex) to assure the table is sorted in coordination with the search criteria
As an aside, do you know why this unmatched " is there in 'Dare\"' and escaped \" ? | [reply] [d/l] [select] |
by poj (Abbot) on Mar 29, 2018 at 07:04 UTC | |
Looks like it comes in on the query param.
| [reply] [d/l] [select] |
by tultalk (Monk) on Mar 29, 2018 at 13:53 UTC | |
by poj (Abbot) on Mar 29, 2018 at 14:08 UTC | |
| |