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

Maximum Session Open Tables Exceeded

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

    Maximum Session Open Tables Exceeded

    I thought my code was ok, but suddenly I am getting an error of "Maximum Session Open Tables Exceeded". I have tried closing tables during this rather long iteration, but apparently I haven't found the problem so I am posting this code. Just so you know, this is an invoicing program which iterates through each Consumer, collects certain variables from other tables, then zaps a temp file and puts the results into that zapped table, so that the invoice can be written.

    Right now I am going through each record in a form, selecting the records to print and then printing each one. I was attempting to use this script to do this all automatically.

    I hope this makes sense:

    Code:
    'Date Created: 11-May-2014 02:58:41 PM
    'Last Updated: 15-Jun-2014 08:53:54 PM
    'Created By  : Charles Hoens
    'Updated By  : Charles Hoens
    
    NEXTT:
    dim global jac as c=""
    dim global wac as c=""
    dim global fac as c=""
    dim global sac as n=0
    dim global eac as c=""
    dim global rac as c=""
    dim global cac as n=22
    dim global yac as d
    dim global pac as c=""
    dim global xac as c=""
    dim global qac as l=.F.
    dim global mult as l=.F.
    
    
    debug(1)	
    s=table.open("consumers")
    
    query.filter="isactive=.T."
    qry3=s.query_create()
    s.fetch_first()
    while .not. s.fetch_eof()
    jac=s.conid
    wac=s.PROVId
    pac=s.consumerid
    fac=word(s.lastfirst,2)+" "+word(s.lastfirst,1)
    u=table.open("providers")
    query.filter="provid=var->wac"
    qry=u.query_create()
    dim global hac as c=u.pname
    qry.drop()
    
    if wac="P0001"
    	cac=22
    end if
    if wac="P0002"
    	cac=22
    end if
    if wac="P0003"
    	cac=10
    end if
    if wac="P0004"
    	cac=10
    end if
    if wac="P0005"
    	cac=10
    end if
    if wac="P0006"
    	cac=22
    end if
    if wac="P0007"
    	cac=10
    end if
    
    
    u=table.open("waivercodes")
    u.fetch_first()
    while .not. u.fetch_eof()
    sac=0
    yat=u.wcode
    'debug(1)
    r=table.open("temp_report.dbf")
    r.zap(.T.)
    
    t=table.open("timehours")
    query.filter = "conid = '" + jac + "'.and.isbilled='No'.and.wcode= '" + yat + "'"
    query.order = "edate"
    qry=t.query_create()
    
    opt=a5_get_records_in_query("timehours",query.filter)
    if opt=0
    	goto NEXTITER
    end if
    
    
    t.fetch_last()
    yac=t.edate
    if (t.empno="E100000070" .and. t.conid="C0039")
    	'qac=.T.
    	wac="P0003"
    	cac=10
    	'qac=.F.
    end if
    
    t.fetch_first()
    while .not. t.fetch_eof()
    	sac=sac+1
    	t.change_begin()
    	t.charge=.T.
    	t.change_end()
    	r.enter_begin()
    	r.empno = t.empno
    	r.lastfirst=t.lastfirst
    	r.edate=t.edate
    	r.sttime1=t.sttime1
    	r.sttime2=t.sttime2
    	r.edate2=t.edate2
    	r.endtime1=t.endtime1
    	r.endtime2=t.endtime2
    	r.tothours=t.tothours
    	if t.servicename="Day Program".or.t.servicename="Transport"
    		r.tothours2=1
    	else
    		r.tothours2=t.tothours2
    	end if
    	r.consumer=word(t.consumer,2)+" "+word(t.consumer,1)
    	r.conid=t.conid
    	r.servicename=t.servicename
    	r.serviceamt=t.serviceamt
    	r.waivercode=t.waivercode
    	r.totamount=t.totamount
    	r.nummiles=t.nummiles
    	r.print=t.print
    	r.sent=t.sent
    	r.provider=var->hac
    	r.outcome=t.outcome
    	r.service=t.service
    	r.ispaid=t.ispaid		
    	r.isbilled=t.isbilled
    	r.wcode=t.wcode
    	r.enter_end()
    	t.fetch_next()
    end while
    
    t.fetch_last()
    eac=cmonth(t.edate)
    rac=cyear(t.edate)
    xac=t.wcode
    t.close()
    
    while sac < cac
    	r.enter_begin()
    	r.conid="."
    	r.enter_end()
    	sac=sac+1
    end while
    qry.drop()
    r.close()
    
    query.filter = ""
    query.order = ""
    
    dim global invno as c=""
    e=table.open("Ident")
    invno=alltrim(e.invoiceno)
    e.close()
    
    
    SELECT
    
    	
    CASE wac="P0001"
    'prompt_result = ui_get_print_or_preview("Print")
    'If prompt_result = "Print" then
    	report.print("ES_Invoice2@c:\alpha5\foc\temp_report.ddd")
    'Else if prompt_result = "Preview" then
    '	report.preview("ES_Invoice2@c:\alpha5\foc\temp_report.ddd")	
    'End if
    
    CASE wac="P0002"
    'prompt_result = ui_get_print_or_preview("Print")
    'If prompt_result = "Print" then
    	report.print("DCF_Voucher1@c:\alpha5\foc\temp_report.ddd")
    'Else if prompt_result = "Preview" then 
    '	report.preview("DCF_Voucher1@c:\alpha5\foc\temp_report.ddd")
    'End if
    
    CASE wac="P0003"
    do_script("DoverCalc")
    'prompt_result = ui_get_print_or_preview("Print")
    'If prompt_result = "Print" then
    	report.print("Dover_Voucher2@c:\alpha5\foc\temp_report2.ddd")
    'Else if prompt_result = "Preview" then 
    '	report.preview("Dover_Voucher2@c:\alpha5\foc\temp_report2.ddd")
    'End if
    
    CASE wac="P0004"
    'prompt_result = ui_get_print_or_preview("Print")
    'If prompt_result = "Print" then
    	report.print("Parsipp_Voucher1@c:\alpha5\foc\temp_report.ddd")
    'Else if prompt_result = "Preview" then 
    '	report.preview("Parsipp_Voucher1@c:\alpha5\foc\temp_report.ddd")
    'End if
    
    CASE wac="P0006"
    'prompt_result = ui_get_print_or_preview("Print")
    'If prompt_result = "Print" then
    	report.print("CPEP_Voucher1@c:\alpha5\foc\temp_report.ddd")
    'Else if prompt_result = "Preview" then 
    '	report.preview("CPEP_Voucher1@c:\alpha5\foc\temp_report.ddd")
    'End if
    
    CASE wac="P0005"
    'prompt_result = ui_get_print_or_preview("Print")
    'If prompt_result = "Print" then
    	report.print("Coord_Voucher1@c:\alpha5\foc\temp_report.ddd")
    'Else if prompt_result = "Preview" then 
    '	report.preview("Coord_Voucher1@c:\alpha5\foc\temp_report.ddd")
    'End if
    
    CASE wac="P0007"
    'prompt_result = ui_get_print_or_preview("Print")
    'If prompt_result = "Print" then
    	report.print("Family_Voucher1@c:\alpha5\foc\temp_report.ddd")
    'Else if prompt_result = "Preview" then 
    '	report.preview("Family_Voucher1@c:\alpha5\foc\temp_report.ddd")
    'End if
    
    END SELECT
    
    
    		e=table.open("ident")
    		e.change_begin()
    		e.invoiceno=alltrim(str(val(invno)+1))
    		e.change_end()
    		e.close()
    	
    		
    		a_tbl = table.open("timehours")
    		query.order = "recno()"
    		query.filter = "charge=.T."
    		query.options = "I"
    		a_tbl.query_create()
    		update.fields = 2
    		update.field1 = "ISBILLED"
    		update.expr1 = "\"YES\""
    		update.field2 = "INVNO"
    		update.expr2 = "var->invno"
    		a_tbl.update()
    		a_tbl.close()
    		
    	
    a_tbl = table.open("timehours")
    
    DIM a5_operation_order as C
    a5_operation_order = ""
    query.order = a5_operation_order
    DIM a5_operation_filter as C
    a5_operation_filter = ".T."
    query.filter = a5_operation_filter
    query.options = "I"
    query.description = "Temporary Query"
    i_indx = a_tbl.query_create("N")
    
    update.fields = 1
    update.field1 = "CHARGE"
    update.expr1 = ".F."
    
    a_tbl.update()
    a_tbl.close()
    
    
    NEXTITER:
    
    u.fetch_next()
    sac=0
    end while
    
    s.fetch_next()
    end while

    #2
    Re: Maximum Session Open Tables Exceeded

    In every script where you issue a command like

    s=table.open("consumers")
    u=table.open("providers")
    a_tbl = table.open("timehours")

    there should be a corresponding

    s.close()
    u.close()
    a_tbl.close()

    et cetera.
    There can be only one.

    Comment


      #3
      Re: Maximum Session Open Tables Exceeded

      Thanks Stan. I've gone over this script again and again, but can't find the error. I thought I closed them all, so that each iteration should start fresh, but I don't know.

      Can you spot the trouble?

      Comment


        #4
        Re: Maximum Session Open Tables Exceeded

        OK. Well I did a little bit more investigating and found that these lines of code were what was creating the problem.

        Code:
        opt=a5_get_records_in_query("timehours",query.filter)
        if opt=0
        	goto NEXTITER
        end if
        When I commented this out, the script ran as expected. Not sure why though.

        Comment


          #5
          Re: Maximum Session Open Tables Exceeded

          When I tried to copy the script from the screen I apparently missed capturing some of it and didn't see the close() commands. For that large a script it might be better to save to a text file and attach.
          There can be only one.

          Comment


            #6
            Re: Maximum Session Open Tables Exceeded

            if one uses the notepad or notepad++ then search for corresponding close statement they can detect the missing statements easily than just reading the file.
            thanks for reading

            gandhi

            version 11 3381 - 4096
            mysql backend
            http://www.alphawebprogramming.blogspot.com
            [email protected]
            Skype:[email protected]
            1 914 924 5171

            Comment


              #7
              Re: Maximum Session Open Tables Exceeded

              I think its dangerous to re-use pointer names.

              In this case at the top of the script the pointer "u" gets used twice in quick succession, but the first instance is never closed, so far as I can tell.

              there are other instances of re-use scattered throughout.

              Comment


                #8
                Re: Maximum Session Open Tables Exceeded

                I can not find s.close() in your code. Could that be the issue?

                Gene FitzPatrick

                Comment


                  #9
                  Re: Maximum Session Open Tables Exceeded

                  If later sections of the script depend upon previous sections running to completion first, its prudent to place the previous sections in function blocks to assure that they run to completion before code execution drops through to later sections.

                  Comment


                    #10
                    Re: Maximum Session Open Tables Exceeded

                    Thanks for all the suggestions! (And I have made the corrections.)

                    However, the offending code was: a5_get_records_in_query("timehours",query.filter) which, when ran several times with the loop, was the thing that produced the open tables error.

                    So how can I get the count of the records in a table without using this code? I need that for the loop to work properly.

                    Thanks.

                    Comment


                      #11
                      Re: Maximum Session Open Tables Exceeded

                      Code:
                      t=table.open("timehours")
                      query.filter = "conid = '" + jac + "'.and.isbilled='No'.and.wcode= '" + yat + "'"
                      query.order = "edate"
                      qry=t.query_create()
                      
                      opt=a5_get_records_in_query("timehours",query.filter)
                      If I am understanding the flow correctly at that point in the script you have just used the same filter to run a query and assigned that query to a pointer called 'qry'

                      You should be able to use
                      Code:
                      opt = qry.records_get()
                      Tim Kiebert
                      Eagle Creek Citrus
                      A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

                      Comment


                        #12
                        Re: Maximum Session Open Tables Exceeded

                        Thanks Tim (and all!) What I ended up using was kind of simple and I was sorry I didn't think of it before:
                        Code:
                        t.fetch_first()
                        if t.fetch_eof()
                           goto Nextspot
                        end if
                        The point was though that the a5_records_in_query() function somehow opens and keeps open multiple sessions, which is not good for a loop of this nature.

                        Thanks.

                        Comment

                        Working...
                        X