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

Stored Procedure didn't run all the way when executed from Alpha

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

    Stored Procedure didn't run all the way when executed from Alpha

    Hi! so basically my problem is that I made a new stored procedure without passing any variable and tested it by directly executing it from sql. It runs perfectly, so the next thing I tried is running it on xbasic from alpha, but when I checked the database, it seems only part of the data was processed while when I debugged the code from alpha the callresult.text says "success".

    My SP is used to process data from table A and insert it from table B, first I created a new table Temp and inserted data from table A to Temp, do a while loop based on this Temp table and inside the loop I collected the data necessary from another table, stored it in a variable and inserted it to table B and lastly update a column in both table A and Temp called "ProcessedStatus" from 0 to 1.

    What I noticed was, first, when I executed the SP from sql, all 1068 rows of data got the column ProcessedStatus updated from 0 to 1. But when I executed it from xbasic, only around 80-300 rows for affected. I didn't pass any parameter to this SP since all the data I need is from another table so I don't think the problem lies on the data processed and no error showed up when I executed it from sql directly.
    Secondly, I have another SP that has the same function to the one I said before, process data from a table and inserted it to another. But the message shown in sql is different. Where my SP in question shows
    Code:
    (1068 row(s) affected)
    
    (1 row(s) affected)
    
    (1 row(s) affected)
    
    (1 row(s) affected)
    
    (1 row(s) affected)
    and so on until the loop ends (1068 times), where the other shows
    Code:
    Command(s) completed successfully.
    is this have anything to do with why my SP didn't run all the way?

    Thirdly, my xbasic code runs 3 SP in the same script, where 2 of them, let's call them SP_A and SP_B are the one that returns "Command(s) completed successfully." and there's a few seconds time lag when I'm at the line where the SP got executed, and the third one, SP_C is the SP that didn't run all the way, when I wen't over the line that executed the SP, I got a little to no time lag. So I didn't think this problem was because a timed out from alpha.

    And lastly I encounter the same problem when I was developing SP_A and SP_B where they won't complete all the way from alpha, and I asked about it too in this forum. A few people says it's because I used cursor to loop which didn't have a good performance, and they advised me to use temporary table. And so I did and my problem was solved. But now I'm encountering the same problem while I'm using temporary table.

    And I got stuck around this problem for the past few days, is there any way to solve this? And what is the reasons behind this problem?

    #2
    Re: Stored Procedure didn't run all the way when executed from Alpha

    I run stored procedures all the time without these issues. Can you run 1 stored procedure and have that procedure call the other stored procedures? Also, it seems like you added a temp table but still have a loop statement. I remember using loops in SQL about twenty years ago when I first came from ISAM files, it would be interesting to see why you need a loop.

    Comment


      #3
      Re: Stored Procedure didn't run all the way when executed from Alpha

      At the top of your SQL procedures put:

      Code:
      SET NOCOUNT ON;
      Perhaps that will fix the issue.

      Comment


        #4
        Re: Stored Procedure didn't run all the way when executed from Alpha

        I use cursors in a number of stored procedures and have no problem with them. In fact last night I ran one on a table with 1.2 million records and it processed successfully in about 16 hours. So I don't think cursor versus temp table is the problem.

        I think your problem is related to the 1068 responses. If those responses are feeding back to Alpha in a result set, I can see Alpha choking on them.

        I have another SP where I use Lee's suggestion of a master SP that calls the other SP's gathering data from 6 different tables, formatting it and inserting it into another (memory engine) table. This also works fine, but what I learned in that process was:
        Where you can, create your sub SPs as functions instead of stored procedures.
        If you must use procedures, then don't feed back results. Instead check the results in the table or use counters in the SP and feed back a single result.
        Pat Bremkamp
        MindKicks Consulting

        Comment


          #5
          Re: Stored Procedure didn't run all the way when executed from Alpha

          Ivasic : I did with SP_A and SP_B but when i got that error before, i split it for alpha to call 2 SP instead, when my problem was solved I didn't merge them back in worry it would interfere my solved problem. I loop based on the temp table because I want to do a process for each row, the first thing I tried was
          Code:
          while @id < @lastid
          begin
          ..........
          set @id = @id +1
          end
          but then I think I can't use that since I can't be sure the ID is always previous ID+1, so I created another table and insert data to it to get incremental ID from 1 to last ID = total rows and do while like I wrote above


          RichCPT : Oh wow haha It works! I never knew what this line was for so I didn't bother to use it, Thank you!


          Pat Bremkamp : And it seems those 1068 responses really is the culprit, when I used Rich's suggestion it ran all the way from alpha.
          I didn't knew how to create a function yet, but I'll keep that in mind to create function instead of SP next time

          Comment


            #6
            Re: Stored Procedure didn't run all the way when executed from Alpha

            Have you tried using ROW_NUMBER()?

            Comment

            Working...
            X