Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Result set fails on 2nd callback

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Result set fails on 2nd callback

    This code works:

    Code:
    ''Select Dimensions records
    ''-------------------------------
    SQL_Select = "SELECT * FROM Dimensions WHERE LDDIM_ID = :Load_id"
    flag = conn.execute(SQL_Select, args)
    vText = conn.callResult.text
    rs = conn.ResultSet
    
    
    rowFlag = rs.nextRow()
    while rowFlag
        vDim_Id = rs.data("DIM_ID") 
        vText = xbDupeDims(conn,args,vDim_Id,vNewLoad_Id)
        rowFlag = rs.nextRow()
    end while
    But the same code (i.e. Dimensions) fails after running the first result set (Stops - which works) shown as here:
    Code:
    ''Select Stops records
    ''-------------------------------
    SQL_Select = "SELECT * FROM Stops WHERE LDSTP_ID = :Load_id"
    flag = conn.execute(SQL_Select, args)
    vText = conn.callResult.text
    rs = conn.ResultSet
    
    
    rowFlag = rs.nextRow()
    while rowFlag
        vStop_Id = rs.data("STP_ID") 
        vText = xbDupeStops(conn,args,vStop_Id,vNewLoad_Id)
        rowFlag = rs.nextRow()
    end while
    
    
    ''Select Dimensions records
    ''-------------------------------
    SQL_Select = "SELECT * FROM Dimensions WHERE LDDIM_ID = :Load_id"
    flag = conn.execute(SQL_Select, args)
    vText = conn.callResult.text
    rs = conn.ResultSet
    
    
    rowFlag = rs.nextRow()
    while rowFlag
        vDim_Id = rs.data("DIM_ID") 
        vText = xbDupeDims(conn,args,vDim_Id,vNewLoad_Id)
        rowFlag = rs.nextRow()
    end while
    If I reverse them - i.e. run Dimensions first, that works but then Stops fails. I tried putting in conn.FreeResult() but that has no effect. I also tried renaming the 2nd result set using rs2 but that doesn't help either.

    Seems to be some kind of bug. Any ideas out there on a workaround?
    Peter
    AlphaBase Solutions, LLC

    [email protected]
    https://www.alphabasesolutions.com



    #2
    Re: Result set fails on 2nd callback

    I also tried the following between the 2 rs

    Delete SQL_Select
    Delete rs
    Delete rowFlag

    No dice.
    Peter
    AlphaBase Solutions, LLC

    [email protected]
    https://www.alphabasesolutions.com


    Comment


      #3
      Re: Result set fails on 2nd callback

      Oh. The error returned is "Not a valid result set" or "MySql server has gone away".

      Hint: it's not gone.
      Last edited by Peter.Greulich; 04-03-2014, 12:22 PM.
      Peter
      AlphaBase Solutions, LLC

      [email protected]
      https://www.alphabasesolutions.com


      Comment


        #4
        Re: Result set fails on 2nd callback

        Is it possible you indexing past the next row since it indexes each time it sees rs.NextRow() ? It can be a little finicky. I do it differently than you just so I don't have to worry about how many times it might be invoked. Here's an example from some of my code:
        Code:
        while rs.NextRow()
        	cnt = cnt + 1
        	'These are the repeating section controls for CONTAINER_2
        	eval("j.LAYOUTORD_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("layoutord")
        	eval("j.POSITION_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("position")
        	eval("j.DETAILSEQUENCE_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("sequence")
        	eval("j.TOOL_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("tool")
        	eval("j.TOOLINFO_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("toolinfo")
        	eval("j.DETAILNOTES_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("notes")
        	eval("j.DESC_2_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("desc2")
        end while
        With my code, you don't need to set the flag (which indexes it from zero to the first row) since the while call will do the same thing.

        Also, I don't think you don't need to do this in your while loop:
        Code:
        rowFlag = rs.nextRow()
        I think that may be your problem. If you only have that in the beginning but not in the loop I think it will work. I think just doing it my way without setting a flag is easier though.

        On the other hand, I may be smoking crack and I've misunderstood the problem.

        Comment


          #5
          Re: Result set fails on 2nd callback

          Good point. You remove an extra step. Unfortunately that doesn't help. Same problem.
          Peter
          AlphaBase Solutions, LLC

          [email protected]
          https://www.alphabasesolutions.com


          Comment


            #6
            Re: Result set fails on 2nd callback

            Where is your error checking for the connection? Could you try changing it up a bit more and seeing if the error returned is more useful from code something like the below:

            Once again, ditching flags....
            Code:
            ''Select Dimensions records
            ''-------------------------------
            dim jscmd as C
            if conn.open("::Name::yourconnectionname") then
            	SQL_Select = "SELECT * FROM Dimensions WHERE LDDIM_ID = :Load_id"
            	if conn.execute(SQL_Select, args) then
            		vText = conn.callResult.text
            		rs = conn.ResultSet
            		while rs.nextRow()
            		    vDim_Id = rs.data("DIM_ID") 
            		    vText = xbDupeDims(conn,args,vDim_Id,vNewLoad_Id)
            		end while
            	else
            	jscmd = "alert('Execute Error: " + js_escape(conn.CallResult.text) + "');"
            	end if
            else
            jscmd = "alert('Connection Error: " + js_escape(conn.CallResult.text) + "');"
            end if
            
            YourFunctionName = jscmd

            Comment


              #7
              Re: Result set fails on 2nd callback

              Thanks. Problem solved, it seems.

              The conn remains open. So that's not the issue. But it is related somehow. Rather than pass in the connection & args, I removed that from the functions and explicitly reopened/closed the conn within the functions themselves, and that seems to work. Lot of extra overhead though. I think I'll just bag the functions altogether and runs it as a straight loop. That way I won't have to close/open conns continuously.
              Peter
              AlphaBase Solutions, LLC

              [email protected]
              https://www.alphabasesolutions.com


              Comment


                #8
                Re: Result set fails on 2nd callback

                Ah, IC. In looking at some of my code, I wasn't seeing it as I pretty much always close my connections either after an execute error (just after the first end if in the code I posted above) or just before ending my functions.

                Comment


                  #9
                  Re: Result set fails on 2nd callback

                  Funny stuff, Jinx. Had to stick w. the functions and the repeating open/close conns. That works well. When i removed the functions and just ran the code in a loop I got the same error. Really strange.
                  Peter
                  AlphaBase Solutions, LLC

                  [email protected]
                  https://www.alphabasesolutions.com


                  Comment


                    #10
                    Re: Result set fails on 2nd callback

                    Hold on..... Are you making a call, and then changing your select statement/args to make another call to the same connection? All in the same callback? Because that should work fine. For some reason I confused that.

                    I can post some code I have that I know works, it actually makes three separate calls. I just delete my result set in between.

                    ETA: I think you also may have to dim rs as SQL::ResultSet after every delete. I have it that way in my code anyway. Must be some reason I did it. LOL

                    Comment


                      #11
                      Re: Result set fails on 2nd callback

                      Are you making a call, and then changing your select statement/args to make another call to the same connection? All in the same callback?
                      Yeah, basically.

                      conn.open

                      select
                      rs

                      seelct
                      rs

                      ...
                      conn close
                      Peter
                      AlphaBase Solutions, LLC

                      [email protected]
                      https://www.alphabasesolutions.com


                      Comment


                        #12
                        Re: Result set fails on 2nd callback

                        Try something like this maybe?
                        Code:
                        ''Select Stops records
                        ''-------------------------------
                        SQL_Select = "SELECT * FROM Stops WHERE LDSTP_ID = :Load_id"
                        if conn.execute(SQL_Select, args) then
                        	vText = conn.callResult.text
                        	dim rs as SQL::ResultSet
                        	rs = conn.ResultSet
                        	while rs.nextRow()
                        	    vStop_Id = rs.data("STP_ID") 
                        	    vText = xbDupeStops(conn,args,vStop_Id,vNewLoad_Id)
                        	end while
                        	
                        	delete rs
                        	
                        	''Select Dimensions records
                        	''-------------------------------
                        	SQL_Select = "SELECT * FROM Dimensions WHERE LDDIM_ID = :Load_id"
                        	if conn.execute(SQL_Select, args) then
                        		vText = conn.callResult.text
                        		dim rs as SQL::ResultSet
                        		rs = conn.ResultSet
                        		while rs.nextRow()
                        		    vDim_Id = rs.data("DIM_ID") 
                        		    vText = xbDupeDims(conn,args,vDim_Id,vNewLoad_Id)
                        		end while
                        	end if
                        end if
                        Sorry for my format changes, I'm just anal that way....

                        Anyway, that's closer to what I do. Maybe the key is dim-ing the result set again.


                        Here's my actual working code that I'm using to copy a record in a dialog. It makes three separate calls and still works fine on the latest pre-release build as of today:
                        Code:
                        function getRecordData as c (e as p)
                        	dim oldid as c
                        	oldid = e.dataSubmitted.UNIQUE_ID
                        	dim masterid as n
                        	masterid = oldid
                        	dim revtest as n = int(convert_type(e.nextrev,"N"))
                        	dim vjscmd as c
                        	dim vjsprg as c
                        	dim j as p
                        	dim cn as SQL::Connection
                        		if cn.open("::Name::MVWKS")	then
                        			dim sqlCommand as c = "SELECT * FROM machlayoutmaster WHERE unique_id = :masteruid"
                        			dim args as SQL::Arguments
                        			args.add("masteruid",masterid)
                        				if cn.Execute(sqlCommand,args) then
                        					dim rs as SQL::ResultSet
                        					rs = cn.ResultSet
                        						if rs.NextRow() then
                        							'These are the header controls
                        							j.MACHNO = rs.Data("machno")
                        							j.PARTNO = rs.Data("partno")
                        							j.DWGNO = rs.Data("dwgno")
                        							j.STATUS = rs.Data("status")
                        							j.MACHTYPE = rs.Data("machtype")
                        							j.NUMPARTS = rs.Data("numparts")
                        							j.OPNO = rs.Data("opno")
                        							if revtest < 1 then
                        								j.LAYOUTREV = rs.Data("layoutrev")
                        							else
                        								j.LAYOUTREV = rs.Data("layoutrev")+1
                        							end if
                        							j.MAINPRGNO = rs.Data("mainprgno")
                        							j.HASSUBS = rs.Data("hassubs")
                        							j.NOTES = rs.Data("notes")
                        							j.PROGRAMCALL = rs.Data("prgcall")
                        								sqlCommand = "SELECT * FROM machlayoutdetail WHERE layoutmaster_id = :masteruid"
                        									delete rs
                        								dim cnt as n = 0
                        									if cn.Execute(sqlCommand,args) then
                        										dim rs as SQL::ResultSet
                        										rs = cn.ResultSet
                        										while rs.NextRow()
                        											cnt = cnt + 1
                        											'These are the repeating section controls for CONTAINER_2
                        											eval("j.LAYOUTORD_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("layoutord")
                        											eval("j.POSITION_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("position")
                        											eval("j.DETAILSEQUENCE_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("sequence")
                        											eval("j.TOOL_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("tool")
                        											eval("j.TOOLINFO_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("toolinfo")
                        											eval("j.DETAILNOTES_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("notes")
                        											eval("j.DESC_2_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("desc2")
                        										end while
                        											sqlCommand = "SELECT * FROM machlayoutsubprograms WHERE layoutmaster_id = :masteruid"
                        												delete rs
                        													dim cnt1 as n = 0
                        														cn.Execute(sqlCommand,args)
                        														dim rs as SQL::ResultSet
                        														rs = cn.ResultSet
                        														while rs.NextRow()
                        															cnt1 = cnt1 + 1
                        															'These are the repeating section controls for CONTAINER_1
                        															eval("j.MAINPRG_A5INSTANCE" + alltrim(str(cnt1))) = rs.Data("mainprg")
                        															eval("j.SEQUENCE_A5INSTANCE" + alltrim(str(cnt1))) = rs.Data("sequence")
                        															eval("j.SUBPRG_A5INSTANCE" + alltrim(str(cnt1))) = rs.Data("subprg")
                        															eval("j.DESCRIPTION_A5INSTANCE" + alltrim(str(cnt1))) = rs.Data("description")
                        														end while
                        										'JavaScript returned to dialog
                        										vjscmd = "{dialog.object}._setRepeatingSectionRowCount('CONTAINER_2'," + cnt + ",true,true);"
                        										vjscmd = vjscmd + "{dialog.object}._setRepeatingSectionRowCount('CONTAINER_1'," + cnt1 + ",true,true);"
                        										vjscmd = vjscmd + "{dialog.object}.populate(" + varToJSON(j) + ",1,false,true);"
                        										'this is a test to add it as a new record right and wait four seconds before populating it
                        										vjscmd = "{Dialog.Object}.newRecord();setTimeout(function(){" + vjscmd + "},1000);"
                        									else
                        										vjscmd = "alert('No details found for this layout');"
                        									end if	
                        						else
                        							vjscmd = "alert('No header record found.');"
                        						end if
                        				else
                        					vjscmd = "alert('Execute Error: Error returned was: " + js_escape(cn.CallResult.text) + "');"
                        				end if
                        				cn.Close()
                        		else
                        			vjscmd = "alert('Connection Error: Error returned was: " + js_escape(cn.CallResult.text) + "');"
                        		end if
                        	debug(2)		
                        getRecordData = vjscmd
                        end function

                        Comment


                          #13
                          Re: Result set fails on 2nd callback

                          Thanks Jinx. At this point I've run the clock up and the client may be running out of patience.
                          Peter
                          AlphaBase Solutions, LLC

                          [email protected]
                          https://www.alphabasesolutions.com


                          Comment


                            #14
                            Re: Result set fails on 2nd callback

                            I love not having clients!....well, paying ones anyway.

                            Comment

                            Working...
                            X