Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1020181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:07:37+00:00 2026-05-16T11:07:37+00:00

I’m having an issue with temp tables using an ADO connection to my database.

  • 0

I’m having an issue with temp tables using an ADO connection to my database. The select into queries run fine, but it seems that they are dropping the tables after each select into. Their is no open recordset so I am unsure as to why the tables are dropping, it shouldn’t be opening a 2nd ADO connection that I can see.

Any idea what I can do to keep the temp tables from dropping?

  begin
    // Get Data


    // Build the work tables for case and claims
    // Find CasemmyyyyEOM for prior month
    //

    begin
        cmd := TStringList.Create;
        cmd.Add(
            'select casenumber, fundsavail, totalrcpts, totalobjectn, totaldisbursed, confirmdate, confirmcode into #casemasterwork from CaseMaster');

        cmd.Add(
            'select caseid, claimnumber, splitcode, prinpdtodate, intpdtodate into #claimswork from claims');
        fConnection.Execute(cmd.text);
{$IFDEF DEBUG}
        MessageLog(cmd.text, 'Query');
{$ENDIF}
        cmd.Free;

        // Sum up receipts posted after end of month
        cmd := TStringList.Create;
        cmd.Add(
            'select rcpthistcasekey, amount = sum(rcpthistamt) into #rcpts from rcptshist where ');
        If cbxRunbyDate.Checked = False then
            cmd.Add('substring(rcpthistinputid,1,4) > ''' + copy(sJrnlYM, 3,
                    4) + ''' And rcpthisttrandate > ''' + sMonthBegin + '''')
        Else
            cmd.Add(' rcpthisttrandate > ''' + sMonthEnd + ''' ');
        cmd.Add(' group by rcpthistcasekey');
{$IFDEF DEBUG}
        MessageLog(cmd.text, 'Query');
{$ENDIF}
        fConnection.Execute(cmd.text);
        cmd.Free;

        // Sum up disbursements by case posted after end of month
        cmd := TStringList.Create;
        cmd.Add(
            'select disbcasekey, amount = sum(disbprinamt + disbintamt) into #disb from disbursed where ');
        If cbxRunbyDate.Checked = False then
            cmd.Add('disbrunyrmo > ''' + sJrnlYM + '''')
        Else
            cmd.Add('DisbTrDate > ''' + sMonthEnd + '''');
        cmd.Add('group by disbcasekey');
{$IFDEF DEBUG}
        MessageLog(cmd.text, 'Query');
{$ENDIF}
        fConnection.Execute(cmd.text);
        cmd.Free;

        // Sum up disbursements by case/claim posted after end of month
        cmd := TStringList.Create;
        cmd.Add(
            'select disbcasekey, disbclaimnum, prinamt = sum(disbprinamt), intamt = sum(disbintamt) into #clmdisb from disbursed where');
        If cbxRunbyDate.Checked = False then
            cmd.Add('disbrunyrmo > ''' + sJrnlYM + '''')
        Else
            cmd.Add('DisbTrDate > ''' + sMonthEnd + '''');
        cmd.Add('group by disbcasekey, disbclaimnum');
{$IFDEF DEBUG}
        MessageLog(cmd.text, 'Query');
{$ENDIF}
        fConnection.Execute(cmd.text);
        cmd.Free;

        // back out the disbursements from the claims work table
        cmd := TStringList.Create;
        cmd.Add('update #claimswork set prinpdtodate = prinpdtodate - prinamt, intpdtodate = intpdtodate - intamt from #clmdisb');
        cmd.Add('where disbcasekey = caseid and disbclaimnum = claimnumber + splitcode');
{$IFDEF DEBUG}
        MessageLog(cmd.text, 'Query');
{$ENDIF}
        fConnection.Execute(cmd.text);
        cmd.Free;

        // back out the disbursements from the casemaster work table
        cmd := TStringList.Create;
        cmd.Add(
            'update #casemasterwork set fundsavail = fundsavail - amount, totalrcpts = totalrcpts - amount from #rcpts');
        cmd.Add('where casenumber = rcpthistcasekey');
{$IFDEF DEBUG}
        MessageLog(cmd.text, 'Query');
{$ENDIF}
        fConnection.Execute(cmd.text);
        cmd.Free;

        // back out the receipts from the casemaster work table
        cmd := TStringList.Create;
        cmd.Add(
            'update #casemasterwork set fundsavail= fundsavail + amount, totaldisbursed = totaldisbursed - amount from #disb');
        cmd.Add('where casenumber = disbcasekey');
{$IFDEF DEBUG}
        MessageLog(cmd.text, 'Query');
{$ENDIF}
        fConnection.Execute(cmd.text);
        cmd.Free;

        // Set the confirmcode based on the confirm transfer table
        Try

            cmd := TStringList.Create;
            cmd.Add('update #casemasterwork set confirmcode = ''U''');
            cmd.Add(
                'from confirmdxfer, #casemasterwork  where #casemasterwork.casenumber = confirmdxfer.casenumber');
            cmd.Add('and xferdate > ''' + sMonthEnd + '''');
            // del 11-28-2004 ebs   readded 10/25/2005 esatori
            // cmd.Add('and xferdate between ''' + sMonthBegin + ''' and ''' + sMonthEnd + ''' '); // 11-28-2004 ebs
{$IFDEF DEBUG}
            MessageLog(cmd.text, 'Query');
{$ENDIF}
            fConnection.Execute(cmd.text);
            cmd.Free;
        Except
        End;

        cmd := TStringList.Create;
        cmd.Add('select TotRcpts = sum(amount) from #rcpts');
{$IFDEF DEBUG}
        MessageLog(cmd.text, 'Query');
{$ENDIF}
        rs := fConnection.Execute(cmd.text);
        cmd.Free;
        rs.MoveFirst;
        cTotalCurRcpts := rs.Fields.Item('TotRcpts').Value;
        rs.Close;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:07:37+00:00Added an answer on May 16, 2026 at 11:07 am

    After much research on this issues I have found the answer. ADO has the tendency to open a second hidden connection to the DB. To avoid this, make sure all recordsets are closed before the temp tables are executed and be sure to close any recordset used in the temp table logic.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I would like to run a str_replace or preg_replace which looks for certain words

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.