Actionscript execution order with attachMovie statements

Hi I wonder if anyone's got any decent solutions to this...
Basically whenever I have a script generating an interface by
dynamically placing movie clips (using the attachMovie method), I
often need the actionscript of the attached movie clip to execute
before the rest of the code in the main script continues.
According to normal actionscript execution order, the current
script finishes before 1st frame actionscript of any attached
movies is executed, so say for example I had the following in frame
1 of my root timeline:
trace("start");
this.attachmovie("myMovieClip","movieClip1",this.getNextHighestDepth());
trace("end");
and the movie clip in my library with the linkage identifier
"myMovieClip" has the following on frame 1 of its timeline:
trace("middle");
Normally this would output:
start
end
middle
However I want it to output:
start
middle
end
The only appropriate way I've found so far to do this is to
have a function that is called on completion of the myMovieClip
actions, i.e. in the root timeline:
trace("start");
this.attachmovie("myMovieClip","movieClip1",this.getNextHighestDepth());
movieClip1.onLoaded=function() {
trace("end");
and in the timeline of the myMovieClip movie clip:
trace("middle");
this.onLoaded();
But the problem with this is that if I rather than the
trace("end"); statement I want a series of other commands,
some of them in turn using attachMovie methods, again wanting the
scripts to execute in the order above, I'm going to end up with a
lot of nested onLoaded functions and it's going to end up looking
pretty ugly!
Any thoughts?

you're welcome.
i generally load everything sequentially.  if you don't want user's to possibly advance into the display far enough to see a load-delay, then you can use some preload display.  here's an example i'm doing for a current client:
www.kglad.com/Files/tf
and click portfolio.
this client has a lot of images to load and wants them presented as soon as possible so i load them sequentially.  that makes for an orderly display (though this client only wants a few images viewable on-stage at any one time).

Similar Messages

  • Forcing code execution order in conditional statements?

    I don't know if the above subject line is the best description, but here is the issue.
    I have created an image gallery where each "slide" is an image loaded by one UILoader component.  Everything works, except I noticed that as a user it is annoying to wait for each new slide to load.
    So, even with my limited knowledge of AS3, I decided to figure out a way to load the next upcoming image before the user requests it. 
    My “dirty” solution was to have 2 UILoaders – one for odd numbered slides, one for even numbered slides.  That way, when the user is viewing a slide with an odd number in the first loader, the next image can be loaded into the second (currently invisible) loader and ready to go when requested.  A “next slide” button would simply toggle the visibility of these two loaders.
    Not an elegant solution, but I thought it would work.  Unfortunately, that is not the case.  The issue lies in the function that is called when the user clicks on the “next slide” button:
    function nextButton(event:MouseEvent):void
    imageNumber++;
                myModulo = imageNumber % 2;
                if (myModulo == 1)
                            Loader1.visible = false;
                            Loader2.visible = true;
                            loadNextSlide();
                            //where the loadNextSlide() functions loads the next image into the currently invisible loader
                else if (myModulo == 0)
                            Loader2.visible = false;
                            Loader2.visible = true;
                            loadNextSlide();
                            //where the loadNextSlide() functions loads the next image into the currently invisible loader
    Say the user is currently viewing slide 3, when they click the “next slide” button, imageNumber (which was = 3) is now  = 4, and that sets myModulo = 0, satisfying the second condition.
    I assumed that what would happen next was that the loaders’ visibility properties would immediately change and then the loadNextSlide function would be called.  In SIMULATED DOWNLOAD, however, it seems that none of the conditional code is executed until the loadNextSlide function runs.
    This completely defeats my effort, because when the user (who, in the example, is viewing slide 3) clicks on the “next slide” button, they have to wait to see slide 4 (which is already loaded) due to the loading of slide 5.
    I tried replacing "loadNextSlide();" with "dispatchEvent(new Event("loadNextSlide"));" and added an eventlistener that calls the loadNextSlide function, but I got the same result.
    Is this just the nature of the AS3 language? Or, more likely, am I thinking about this incorrectly? 
    If this really is the "law of the land", is there a way around it?  Is there a better way to load upcoming slides using a loader?

    you're welcome.
    i generally load everything sequentially.  if you don't want user's to possibly advance into the display far enough to see a load-delay, then you can use some preload display.  here's an example i'm doing for a current client:
    www.kglad.com/Files/tf
    and click portfolio.
    this client has a lot of images to load and wants them presented as soon as possible so i load them sequentially.  that makes for an orderly display (though this client only wants a few images viewable on-stage at any one time).

  • Issue when creating sales order with Sold-to/Ship-to Party's state

    Hi All,
    we have issue while creating Sales Order with picking up of State tax
    for Ship-to-party & Sold-to-party.
    <b>When we create a sales order, for the sold to party 140052732 and
    ship to party 140052733 it is picking state tax. Which should not
    suppose to pick? Because the partner is marked as tax exemption</b>.
    Can any body tell me how can we solve this issue!
    Why this is happening!
    How to make not to pick tax when it is marked for tax exemtion.
    As i am not Functional guy i am not aware what is happening here!
    Can anybody solve this issue!
    Thanks in advance.
    Thanks,
    Deep.

    Hi Deep
    What do you mean by "It is picking up state tax"? Does it mean that in the pricing procedure it is picking up a condition type which is meant for state tax?
    If so go and check the condition record meant for it. Follow the following steps
    1) Go to Sales order
    2) Select the line item for which the state tax is being picked.
    3) In the condition tab select analysis.
    4) In Analysis you shall find the condition type meant for state tax.
    5) See which condition record has been found.
    6) Go to VK12, enter the state tax condition type and check the condition record for that state tax.
    7) If wrong correct it.
    8) If anything else come back to the post and inform the details
    Thanks
    Regards
    Sunil

  • Issue when creating sales order with Sold-to/Ship-to Party's state tax

    Hi All,
    we have issue while creating Sales Order with picking up of State tax
    for Ship-to-party & Sold-to-party.
    <b>When we create a sales order, for the sold to party 140052732 and
    ship to party 140052733 it is picking state tax. Which should not
    suppose to pick? Because the partner is marked as tax exemption</b>.
    Can any body tell me how can we solve this issue!
    Why this is happening!
    How to make not to pick tax when it is marked for tax exemtion.
    As i am not Functional guy i am not aware what is happening here!
    Can anybody solve this issue!
    Thanks in advance.
    Thanks,
    Deep.

    Hi Deep
    What do you mean by "It is picking up state tax"? Does it mean that in the pricing procedure it is picking up a condition type which is meant for state tax?
    If so go and check the condition record meant for it. Follow the following steps
    1) Go to Sales order
    2) Select the line item for which the state tax is being picked.
    3) In the condition tab select analysis.
    4) In Analysis you shall find the condition type meant for state tax.
    5) See which condition record has been found.
    6) Go to VK12, enter the state tax condition type and check the condition record for that state tax.
    7) If wrong correct it.
    8) If anything else come back to the post and inform the details
    Thanks
    Regards
    Sunil

  • HT204032 Why can you not use powernap with a custom order iMac with solid state?

    Why can you not use powernap with a custom order iMac with solid state?
    Find it quite ridiculous that a 3 year old mba supports it and not a new iMac

    Agreed.  Why wouldn't you want your Photostream updated while your iMac is sleeping?  I am bummed about this.

  • SQL Tuning and OPTIMIZER - Execution Time with  " AND col .."

    Hi all,
    I get a question about SQL Tuning and OPTIMIZER.
    There are three samples with EXPLAIN PLAN and execution time.
    This "tw_pkg.getMaxAktion" is a PLSQL Package.
    1.) Execution Time : 0.25 Second
    2.) Execution Time : 0.59 Second
    3.) Execution Time : 1.11 Second
    The only difference is some additional "AND col <> .."
    Why is this execution time growing so strong?
    Many Thanks,
    Thomas
    ----[First example]---
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.3.0
    Connected as dbadmin2
    SQL>
    SQL> EXPLAIN PLAN FOR
      2  SELECT * FROM ( SELECT studie_id, tw_pkg.getMaxAktion(studie_id) AS max_aktion_id
      3                    FROM studie
      4                 ) max_aktion
      5  WHERE max_aktion.max_aktion_id < 900 ;
    Explained
    SQL> SELECT * FROM TABLE(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3201460684
    | Id  | Operation            | Name        | Rows  | Bytes | Cost (%CPU)| Time
    |   0 | SELECT STATEMENT     |             |   220 |   880 |     5  (40)| 00:00:
    |*  1 |  INDEX FAST FULL SCAN| SYS_C005393 |   220 |   880 |     5  (40)| 00:00:
    Predicate Information (identified by operation id):
       1 - filter("TW_PKG"."GETMAXAKTION"("STUDIE_ID")<900)
    13 rows selected
    SQL>
    Execution time (PL/SQL Developer says): 0.25 seconds
    ----[/First]---
    ----[Second example]---
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.3.0
    Connected as dbadmin2
    SQL>
    SQL> EXPLAIN PLAN FOR
      2  SELECT * FROM ( SELECT studie_id, tw_pkg.getMaxAktion(studie_id) AS max_aktion_id
      3                    FROM studie
      4                 ) max_aktion
      5  WHERE max_aktion.max_aktion_id < 900
      6    AND max_aktion.max_aktion_id <> 692;
    Explained
    SQL> SELECT * FROM TABLE(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3201460684
    | Id  | Operation            | Name        | Rows  | Bytes | Cost (%CPU)| Time
    |   0 | SELECT STATEMENT     |             |    11 |    44 |     6  (50)| 00:00:
    |*  1 |  INDEX FAST FULL SCAN| SYS_C005393 |    11 |    44 |     6  (50)| 00:00:
    Predicate Information (identified by operation id):
       1 - filter("TW_PKG"."GETMAXAKTION"("STUDIE_ID")<900 AND
                  "TW_PKG"."GETMAXAKTION"("STUDIE_ID")<>692)
    14 rows selected
    SQL>
    Execution time (PL/SQL Developer says): 0.59 seconds
    ----[/Second]---
    ----[Third example]---
    SQL> EXPLAIN PLAN FOR
      2  SELECT * FROM ( SELECT studie_id, tw_pkg.getMaxAktion(studie_id) AS max_aktion_id
      3                    FROM studie
      4                 ) max_aktion
      5  WHERE max_aktion.max_aktion_id < 900
      6    AND max_aktion.max_aktion_id <> 692
      7    AND max_aktion.max_aktion_id <> 392;
    Explained
    SQL> SELECT * FROM TABLE(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3201460684
    | Id  | Operation            | Name        | Rows  | Bytes | Cost (%CPU)| Time
    |   0 | SELECT STATEMENT     |             |     1 |     4 |     6  (50)| 00:00:
    |*  1 |  INDEX FAST FULL SCAN| SYS_C005393 |     1 |     4 |     6  (50)| 00:00:
    Predicate Information (identified by operation id):
       1 - filter("TW_PKG"."GETMAXAKTION"("STUDIE_ID")<900 AND
                  "TW_PKG"."GETMAXAKTION"("STUDIE_ID")<>692 AND
                  "TW_PKG"."GETMAXAKTION"("STUDIE_ID")<>392)
    15 rows selected
    SQL>
    Execution time (PL/SQL Developer says): 1.11 seconds
    ----[/Third]---Edited by: thomas_w on Jul 9, 2010 11:35 AM
    Edited by: thomas_w on Jul 12, 2010 8:29 AM

    Hi,
    this is likely because SQL Developer fetches and displays only limited number of rows from query results.
    This number is a parameter called 'sql array fetch size', you can find it in SQL Developer preferences under Tools/Preferences/Database/Advanced tab, and it's default value is 50 rows.
    Query scans a table from the beginning and continue scanning until first 50 rows are selected.
    If query conditions are more selective, then more table rows (or index entries) must be scanned to fetch first 50 results and execution time grows.
    This effect is usually unnoticeable when query uses simple and fast built-in comparison operators (like = <> etc) or oracle built-in functions, but your query uses a PL/SQL function that is much more slower than built-in functions/operators.
    Try to change this parameter to 1000 and most likely you will see that execution time of all 3 queries will be similar.
    Look at this simple test to figure out how it works:
    CREATE TABLE studie AS
    SELECT row_number() OVER (ORDER BY object_id) studie_id,  o.*
    FROM (
      SELECT * FROM all_objects
      CROSS JOIN
      (SELECT 1 FROM dual CONNECT BY LEVEL <= 100)
    ) o;
    CREATE INDEX studie_ix ON studie(object_name, studie_id);
    ANALYZE TABLE studie COMPUTE STATISTICS;
    CREATE OR REPLACE FUNCTION very_slow_function(action IN NUMBER)
    RETURN NUMBER
    IS
    BEGIN
      RETURN action;
    END;
    /'SQL array fetch size' parameter in SQLDeveloper has been set to 50 (default). We will run 3 different queries on test table.
    Query 1:
    SELECT * FROM ( SELECT studie_id, very_slow_function(studie_id) AS max_aktion_id
                         FROM studie
                  ) max_aktion
    WHERE max_aktion.max_aktion_id < 900
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      1.22       1.29          0       1310          0          50
    total        3      1.22       1.29          0       1310          0          50
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 93  (TEST)
    Rows     Row Source Operation
         50  INDEX FAST FULL SCAN STUDIE_IX (cr=1310 pr=0 pw=0 time=355838 us cost=5536 size=827075 card=165415)(object id 79865)
    Rows     Execution Plan
          0  SELECT STATEMENT   MODE: ALL_ROWS
         50   INDEX   MODE: ANALYZED (FAST FULL SCAN) OF 'STUDIE_IX' (INDEX)Query 2:
    SELECT * FROM ( SELECT studie_id, very_slow_function(studie_id) AS max_aktion_id
                         FROM studie
                  ) max_aktion
    WHERE max_aktion.max_aktion_id < 900
          AND max_aktion.max_aktion_id > 800
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.01          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      8.40       8.62          0       9351          0          50
    total        3      8.40       8.64          0       9351          0          50
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 93  (TEST)
    Rows     Row Source Operation
         50  INDEX FAST FULL SCAN STUDIE_IX (cr=9351 pr=0 pw=0 time=16988202 us cost=5552 size=41355 card=8271)(object id 79865)
    Rows     Execution Plan
          0  SELECT STATEMENT   MODE: ALL_ROWS
         50   INDEX   MODE: ANALYZED (FAST FULL SCAN) OF 'STUDIE_IX' (INDEX)Query 3:
    SELECT * FROM ( SELECT studie_id, very_slow_function(studie_id) AS max_aktion_id
                         FROM studie
                  ) max_aktion
    WHERE max_aktion.max_aktion_id = 600
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.01       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1     18.72      19.16          0      19315          0           1
    total        3     18.73      19.16          0      19315          0           1
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 93  (TEST)
    Rows     Row Source Operation
          1  INDEX FAST FULL SCAN STUDIE_IX (cr=19315 pr=0 pw=0 time=0 us cost=5536 size=165415 card=33083)(object id 79865)
    Rows     Execution Plan
          0  SELECT STATEMENT   MODE: ALL_ROWS
          1   INDEX   MODE: ANALYZED (FAST FULL SCAN) OF 'STUDIE_IX' (INDEX)Query 1 - 1,29 sec, 50 rows fetched, 1310 index entries scanned to find these 50 rows.
    Query 2 - 8,64 sec, 50 rows fetched, 9351 index entries scanned to find these 50 rows.
    Query 3 - 19,16 sec, only 1 row fetched, 19315 index entries scanned (full index).
    Now 'SQL array fetch size' parameter in SQLDeveloper has been set to 1000.
    Query 1:
    SELECT * FROM ( SELECT studie_id, very_slow_function(studie_id) AS max_aktion_id
                         FROM studie
                  ) max_aktion
    WHERE max_aktion.max_aktion_id < 900
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1     18.35      18.46          0      19315          0         899
    total        3     18.35      18.46          0      19315          0         899
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 93  (TEST)
    Rows     Row Source Operation
        899  INDEX FAST FULL SCAN STUDIE_IX (cr=19315 pr=0 pw=0 time=20571272 us cost=5536 size=827075 card=165415)(object id 79865)
    Rows     Execution Plan
          0  SELECT STATEMENT   MODE: ALL_ROWS
        899   INDEX   MODE: ANALYZED (FAST FULL SCAN) OF 'STUDIE_IX' (INDEX)Query 2:
    SELECT * FROM ( SELECT studie_id, very_slow_function(studie_id) AS max_aktion_id
                         FROM studie
                  ) max_aktion
    WHERE max_aktion.max_aktion_id < 900
          AND max_aktion.max_aktion_id > 800
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1     18.79      18.86          0      19315          0          99
    total        3     18.79      18.86          0      19315          0          99
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 93  (TEST)
    Rows     Row Source Operation
         99  INDEX FAST FULL SCAN STUDIE_IX (cr=19315 pr=0 pw=0 time=32805696 us cost=5552 size=41355 card=8271)(object id 79865)
    Rows     Execution Plan
          0  SELECT STATEMENT   MODE: ALL_ROWS
         99   INDEX   MODE: ANALYZED (FAST FULL SCAN) OF 'STUDIE_IX' (INDEX)Query 3:
    SELECT * FROM ( SELECT studie_id, very_slow_function(studie_id) AS max_aktion_id
                         FROM studie
                  ) max_aktion
    WHERE max_aktion.max_aktion_id = 600
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1     18.69      18.84          0      19315          0           1
    total        3     18.69      18.84          0      19315          0           1
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 93  (TEST)
    Rows     Row Source Operation
          1  INDEX FAST FULL SCAN STUDIE_IX (cr=19315 pr=0 pw=0 time=0 us cost=5536 size=165415 card=33083)(object id 79865)
    Rows     Execution Plan
          0  SELECT STATEMENT   MODE: ALL_ROWS
          1   INDEX   MODE: ANALYZED (FAST FULL SCAN) OF 'STUDIE_IX' (INDEX)And now:
    Query 1 - 18.46 sec, 899 rows fetched, 19315 index entries scanned.
    Query 2 - 18.86 sec, 99 rows fetched, 19315 index entries scanned.
    Query 3 - 18.84 sec, 1 row fetched, 19315 index entries scanned.

  • Ordering with Subquery Factoring

    Can I be assured that the results of this query will be ordered as defined by the 'order siblings by' clause?
    with hier as
       select ...
       from ...
       start with ...
       connect by ...
       order siblings by ...
    select ...
    from hier
    ;How about this one?
    with hier as
       select ...
       from ...
       start with ...
       connect by ...
       order siblings by ...
       subqry as
       select ...
       from ...
       where ...
    select ...
    from
       hier
       inner join subqry using ...
    ;I'm thinking I need something like this to ensure the proper order.
    with hier as
       select
          rownum rnum
       from ...
       start with ...
       connect by ...
       order siblings by ...
    select ...
    from hier
    order by rnum
    ;If not needed for the first query, is the above technique needed for the second?
    Thanks.

    It is true, the plan is changing but it is not really needed.
    Take a look at my queries and execution plans using the sample schema HR:
    with h as (
         select employee_id, first_name, last_name, department_id, manager_id
         from hr.employees
         start with manager_id is null
         connect by manager_id = prior employee_id
         order siblings by last_name
    select h.employee_id, h.first_name, h.last_name, h.department_id, h.manager_id, d.department_name
    from h join hr.departments d on d.department_id = h.department_id;
    | Id  | Operation                                  | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                           |             |    20 |  1900 |     4  (25)| 00:00:01 |
    |   1 |  NESTED LOOPS                              |             |       |       |            |          |
    |   2 |   NESTED LOOPS                             |             |    20 |  1900 |     4  (25)| 00:00:01 |
    |   3 |    VIEW                                    |             |    20 |  1300 |     4  (25)| 00:00:01 |
    |*  4 |     CONNECT BY NO FILTERING WITH START-WITH|             |       |       |            |          |
    |   5 |      TABLE ACCESS FULL                     | EMPLOYEES   |    20 |  1300 |     3   (0)| 00:00:01 |
    |*  6 |    INDEX UNIQUE SCAN                       | DEPT_ID_PK  |     1 |       |     0   (0)| 00:00:01 |
    |   7 |   TABLE ACCESS BY INDEX ROWID              | DEPARTMENTS |     1 |    30 |     0   (0)| 00:00:01 |
    with h as (
         select employee_id, first_name, last_name, department_id, manager_id, rownum
         from hr.employees
         start with manager_id is null
         connect by manager_id = prior employee_id
         order siblings by last_name
    select h.employee_id, h.first_name, h.last_name, h.department_id, h.manager_id, d.department_name
    from h join hr.departments d on d.department_id = h.department_id
    order by rownum;
    | Id  | Operation                                     | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                              |             |    20 |  1900 |     5  (40)| 00:00:01 |
    |   1 |  SORT ORDER BY                                |             |    20 |  1900 |     5  (40)| 00:00:01 |
    |   2 |   COUNT                                       |             |       |       |            |          |
    |   3 |    NESTED LOOPS                               |             |       |       |            |          |
    |   4 |     NESTED LOOPS                              |             |    20 |  1900 |     4  (25)| 00:00:01 |
    |   5 |      VIEW                                     |             |    20 |  1300 |     4  (25)| 00:00:01 |
    |   6 |       COUNT                                   |             |       |       |            |          |
    |*  7 |        CONNECT BY NO FILTERING WITH START-WITH|             |       |       |            |          |
    |   8 |         TABLE ACCESS FULL                     | EMPLOYEES   |    20 |  1300 |     3   (0)| 00:00:01 |
    |*  9 |      INDEX UNIQUE SCAN                        | DEPT_ID_PK  |     1 |       |     0   (0)| 00:00:01 |
    |  10 |     TABLE ACCESS BY INDEX ROWID               | DEPARTMENTS |     1 |    30 |     0   (0)| 00:00:01 |
    -------------------------------------------------------------------------------------------------------------

  • Execution order - group by and order by

    is there any execution order when we use group by and order by together in single query ?

    BOL: "Logical Processing Order of the SELECT statement
    The following steps show the logical processing order, or binding order, for a SELECT statement. This order determines when the objects defined in one step are made available to the clauses in subsequent steps. For example, if the query processor can bind to
    (access) the tables or views defined in the FROM clause, these objects and their columns are made available to all subsequent steps. Conversely, because the SELECT clause is step 8, any column aliases or derived columns defined in that clause cannot be referenced
    by preceding clauses. However, they can be referenced by subsequent clauses such as the ORDER BY clause. Note that the actual physical execution of the statement is determined by the query processor and the order may vary from this list.
    1. FROM
    2. ON
    3. JOIN
    4. WHERE
    5. GROUP BY
    6. WITH CUBE or WITH ROLLUP
    7. HAVING
    8. SELECT
    9. DISTINCT
    10. ORDER BY
    11. TOP"
    http://msdn.microsoft.com/en-us/library/ms189499.aspx
    Kalman Toth Database & OLAP Architect
    IPAD SELECT Query Video Tutorial 3.5 Hours
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Report with stored proc running multiple stored procedures with insert statement

    Hi,
    I wonder if this is possible in SSRS ... I use the 2012 version (Data Tools).
    I have a report that triggers a stored procedure. See below.
    Within this SP there are 2 insert statements getting data from 2 other SP's.
    When I make a dataset referring to the main SP below, SSRS does not show me any fields at all.
    Is this because it's a SP with insert statements and nested SP's?
    At the end of the SP I make a select so it should see all the fields.
    The parameters @month and @costcenter are multivalue params. I use a special function to convert the multivalues, selected in the report, into a string to pass it correctly to the query (comma separated).
    USE [TestDB]
    GO
    /****** Object:  StoredProcedure [dbo].[_Pink_SP_StandingsRegisterDataset]    Script Date: 15-4-2014 13:31:30 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[_Pink_SP_StandingsRegisterDataset]
    @year INT,
    @month NVARCHAR(50),
    @costcenter NVARCHAR(500),
    @GLaccount NVARCHAR(9)
    AS
    BEGIN
    /* Remove existing content*/
    DELETE FROM _Pink_TB_StandingsRegister
    /* Add records part 1 */
    INSERT INTO _Pink_TB_StandingsRegister
    EXEC _Pink_SP_StandingsRegister @year, @month, @costcenter, @GLaccount
    /* Add records part 2 */
    INSERT INTO _Pink_TB_StandingsRegister
    Type,
    Row,
    Year,
    Month,
    YearDatetable,
    MonthDatetable
    EXEC _Pink_SP_StandingsRegisterDatetable @year
    /* Select all records */
    SELECT *
    FROM _Pink_TB_StandingsRegister
    END
    GO

    Hi bijntjede2e,
    After testing a similar scenario in my own environment, it works well in Reporting Services. In my test, the stored procedure returns all the fields from _Pink_TB_StandingsRegister table in the dataset. Then I select some values from year, month, costcenter
    and Glaccount parameters, it inserts some values in the _Pink_TB_StandingsRegister table. So we can use this stored procedure as the dataset in the report.
    In order to solve the problem more efficiently, I need to clarify some information.
    Are you pass multiple values parameter to one stored procedure correctly? We can refer to the following thread:
    http://social.technet.microsoft.com/Forums/en-US/dbdfa101-cccc-4e9f-aa50-566dc5ebcc27/ssrs-2008-r2-report-dataset-call-a-stored-procedure?forum=sqlrep
    What results are you get when executing the stored procedure in SQL Server Management Studio? Is it works well? We should double those stored procedures.
    If there are any misunderstanding, please elaborate the issue for further investigation.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Error  -10  while closing a Production Order with DI API

    Hi,
    I've been trying to close some production orders using this code:
    Dim oProdOrder As SAPbobsCOM.ProductionOrders
            Try
                oProdOrder = Me.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductionOrders)
                If oProdOrder.GetByKey(intDocEntry) Then
                    oProdOrder.ProductionOrderStatus = SAPbobsCOM.BoProductionOrderStatusEnum.boposClosed
                    If oProdOrder.Update <> 0 Then
                        Me.Company.GetLastError(intError, sErrMsg)
                        If (0 <> intError) Then
                            sErrorMsg = sErrorMsg & "Production Order Close Error: " & CStr(intError) & "," & sErrMsg & _
                                ". DocEntry: " & oProdOrder.ProductionOrderOriginEntry & vbCrLf
                        End If
                    End If
                End If
    ...But I keep getting the same error every time I try: -10,Date out of reference date range, '_SYS00000005340'
    The error doesn't show when I close the Order with BO's Form. And I've checked the exchange rate for the posting and due date of the document (and also for my current date) and there seems to be no problem with it.
    I'm currently working with SAP BO 2004A PL 45.
    Anybody has a suggestion? a workaround?
    I'll appreciate any help you can give me.
    Thanks in advance...
    Alfredo

    Alfredo,
    just in case,
    what is the previous state of the production order (planned, released,...)?
    before you try to close the order, update the status to released:
    If oProdOrder.GetByKey(newID) Then
    'Cambio di stato dell'ordine da 'Planned' a 'Released'
                    oProdOrder.ProductionOrderStatus = boposReleased
    oProdOrder.Update
    I found this code in a DI API application written for 2004A. It was commented out so I suspect it didn't work.
    'Chiusura dell 'ordine
            'SelProductionOrder.ProductionOrderStatus = boposClosed
            'ret = SelProductionOrder.Update
            'If ret <> 0 Then
            '    sboCompany.GetLastError nErr, errMsg
            '    MsgBox "Errore " & nErr & " - " & errMsg
            'End If
    Hope this helps

  • BAPI FOR CREATING SALES ORDER WITH REFFERENCE TO QUOTATION

    Hi All,
    I am creating sales order with refference to quotation by using bapi "BAPI_SALESORDER_CREATEFROMDATA".Able to create sales order but its not refferencing qutation.Is there any other bapi for this scenario.Please guide me.
    Regards,
    Suresh

    Hi ,
    Thank you for giving reply I tried by using bapi BAPI_SALESORDER_CREATEFROMDAT2 after execution it giving sales order number but when I am trying to see that sales order system is giving error message as document is not exist.
    Please guide me.
    Suresh

  • Query in creating Sales Order with BAPI_SALESORDER_CREATEFROMDAT2?

    Hi,
    I am trying to create a Sales Order with the BAPI and have a contract as a reference. Do I need to explicity mention the line item details in case I need the data from Contract to be copied here. If not how do I acheive this functionality.
    P.S: I am able to create the Sales Order with the reference and I can see the Sales Order in the contracts workflow but not the line items in the Sales Order.
    Any suggestions?
    Regards,
    Karthik

    Hello, Karthik,
    By reading the documentation of BAPI
    BAPI_SALESORDER_CREATEFROMDAT2
    the mandatory data to be supplied to the BAPI, in order to succesfuly create the the Sales Order are:
    "1. ORDER_HEADER_IN :
                    DOC_TYPE Sales document type
                    SALES_ORG Sales organization
                    DISTR_CHAN Distribution channel
                    DIVISION Division
    2. ORDER_PARTNERS..:
                    PARTN_ROLE Partner role, SP sold-to party
                    PARTN_NUMB Customer number
    3. ORDER_ITEMS_IN..: MATERIAL Material number"
    The OSS note 93091 basically re-states the same thing.
    After studying this BAPI's source code, the conclusion seems to be the one the documentation points to: <b>the BAPI can only be used to create a sales order by supplying (manually) all the necessary data.</b>
    BTW: How did you manage to create the empty Sales Order with reference, you mentioned in your mail? Just by providing a reference document number? <b>And nothing more?</b>
    Bye,
    Bogdan

  • Problem in creating sales order with BAPI_SALESDOCU_CREATEFROMDATA1.

    Hi everybody
    I am not able create a sales order with BAPI_SALESDOCU_CREATEFROMDATA1.i also did debugging.its not throwing  up any errors in return table. return table is empty. but when i check the  BAPI in se37 with same data its creating the sales order.
    Here i am attaching my program.please kindly can anyone have a look and tell me whether i did anything wrong in  the program.
    thx in advance.
    *& Report  YORDERCREATE
    REPORT  YORDERCREATE.
    data: v_vbeln like vbak-vbeln.
    data: header like bapisdhead1.
    data: headerx like bapisdhead1x.
    data: item like bapisditem occurs 0 with header line.
    data: itemx like bapisditemx occurs 0 with header line.
    data: partner like bapipartnr occurs 0 with header line.
    data: return like bapiret2 occurs 0 with header line.
    data: it_schedules_inx like bapischdlx occurs 0 with header line.
    data: it_schedules_in like bapischdl occurs 0 with header line.
    types: begin of itab,
    auart like vbak-auart,
    vkorg like vbak-vkorg,
    vtweg like vbak-vtweg,
    spart like vbak-spart,
    kunnr like kuagv-kunnr,
    kunnr1 like kuwev-kunnr,
    posnr like  vbup-posnr,
    matnr like mara-matnr,
    Tquan type string,
    end of itab.
    data: it-out type table of itab with header line.
    data: menge(10) type c.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      = 'C:\VA01.TXT'
      FILETYPE                      = 'ASC'
       HAS_FIELD_SEPARATOR           = 'X'
      TABLES
        DATA_TAB                      = it-out.
    loop at it-out.
    header-doc_type = it-out-auart.
    headerx-doc_type = 'X'.
    header-sales_org = it-out-vkorg.
    headerx-sales_org = 'X'.
    header-distr_chan = it-out-vtweg.
    headerx-distr_chan = 'X'.
    header-division = it-out-spart.
    headerx-division = 'x'.
    headerx-updateflag = 'I'.
    *partner data
    partner-partn_role = 'SP'.
    partner-partn_numb = it-out-kunnr.
    append partner.
    partner-partn_role = 'SH'.
    partner-partn_numb = it-out-kunnr1.
    append partner.
    *item data
    itemx-updateflag = 'I'.
    item-itm_number = it-out-posnr.
    itemx-itm_number = 'X'.
    item-material = it-out-matnr.
    itemx-material = 'X'.
    item-target_qty = it-out-tquan..
    itemx-target_qty = 'X'.
    APPEND item.
    APPEND itemx.
    *loop at it-out.
    *write:/ it-out-auart,it-out-vkorg.
    *endloop.
    CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
      EXPORTING
       SALESDOCUMENT                 = v_vbeln
        SALES_HEADER_IN               = header
        SALES_HEADER_INX              = headerx
      SENDER                        = SENDER
      BINARY_RELATIONSHIPTYPE       = 'VORL'
      INT_NUMBER_ASSIGNMENT         = ' '
    IMPORTING
       SALESDOCUMENT_EX              = v_vbeln
    TABLES
       RETURN                        = return
       SALES_ITEMS_IN                = item
       SALES_ITEMS_INX               = itemx
       SALES_PARTNERS                = partner.
      SALES_SCHEDULES_IN            = SALES_SCHEDULES_IN
      SALES_SCHEDULES_INX           = SALES_SCHEDULES_INX
      SALES_CONDITIONS_IN           = SALES_CONDITIONS_IN
      SALES_CFGS_REF                = SALES_CFGS_REF
      SALES_CFGS_INST               = SALES_CFGS_INST
      SALES_CFGS_PART_OF            = SALES_CFGS_PART_OF
      SALES_CFGS_VALUE              = SALES_CFGS_VALUE
      SALES_CFGS_BLOB               = SALES_CFGS_BLOB
      SALES_CCARD                   = SALES_CCARD
      KEY_TABLE                     = KEY_TABLE
    endloop.
    loop at return where type  = 'E' or type = 'A'.
    exit.
    endloop.
    if sy-subrc = 0.
    write:/ 'error in creating document'.
    else.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
       WAIT          = 'X'
    IMPORTING
      RETURN        = RETURN
    commit work and wait.
    write:/ 'document',v_vbeln,'created'.
    endif.

    Hi Patrick,
    Here are a couple of issues/recommendations:
    1) Checkboxes must be populated by capital X (your headerx-division = 'x' is wrong)
    2) Why you are using the COMMIT WORK AND WAIT statement? The CALL BAPI_TRANSACTION_COMMIT does exactly the same! Comment it out or better delete one of them!
    3) Does one of your sales order tables (VBAK, VBAP, ....) have any customer appended fields? In this case you have to populate an additional value table and the related index table as well.
    Check it out,
    Heinz

  • Producer Consumer with a state machine within the consumer

        Hi All,
    I have been trying to develop a data acquisition system with the producer consumer architecture.  To the left of the two main loops I initialize the serial port and any constants and variables im using.  I also have an obtain queue VI needed for enqueue and dequeue. Then in the producer loop i have a state machine.  The first state is where I wait for a button press on the front panel to write a GO signal on the serial line which will tell the device connected to the serial port to begin sampling data.  After this button press I go into the next state which is called my read state.
    In the read state I use a property node to read all of the available bytes at the serial port and then enqueue this collected data into a queue.  The state machine then is directed to continously go to the read state again and collect more data.
    Now this is where my dilemma is......  The consumer loop has the dequeue VI inside it and after this VI i have a state machine (while loop and case structure) which contains the following states
    1.  Build Array - build an array from the dequeue element and if there is any left over data from the parsing states it will build an array with the left over data and the dequeued data
    2.  Determine packet type - this state looks for the packet type byte(not necessarily the first byte in the message) and also check the next byte (packet length) to ensure that I am at the begininng of this chunk of data.  This state may be a little slow because there can be three different packet types and based on this byte and the packet length it may have to search the array several time to find the valid starting point.  This state also determine the next state to go to based on the packet type.
    3 packet type 1 parsing - parse data and store the remaining data it leftOver array.  Go to exit state.
    4 packet type 2 parsing - "" ""
    5 packet type 3 parsing - "" ""
    6 exit - leave this state machine and fall back to the consumer while loop.
    After it exit I think it should fall back to the consumer while loop and dequeue more data and enter the state machine again to build a new array with the dequeued data and leftover data.  It seems to work when I trace the execution using the Highlight execution feature, however when I run this all at full speed, it seems to go into the consumers 1st and 2nd states back and forth and not completely go through the state machine.
    I tried adding in a delay in the producer loop to give the consumer loop time, but I didnt notice any difference.  Is it possible that my dequeue element is retreiving more data while im still in the state machine, causing the execution to leave the state machine before it finished all states?
    Is there a better approach to take to solve this problem. Basically I need to read data at a 1,000,000 baudrate and parse it as quickly as possible so that I can break it up into 3 different packet types, write the data to a file, and graph the actual data (header info removed) in realtime.  I need to also ensure that I am not losing any of the collected data.  Data loss cannnot occur.

    A couple of things more to go along with Ben's pointers:
    You convert your data from a string, to a U8 array, to a Hex string array in the producer loop, then convert back to a integer to determine what to do with it.  In the process, you create two or three copies of your data, slowing yourself down quite a bit.  The code would be quite a bit more efficient if you left the data as a U8 array.  You can change the format of the controls and indicators to show hex values instead of integer by right clicking on them and selecting Format and Precision...
    Your search code is fairly inefficient.  I made a whack at making it a bit better.  See attachment below.
    If you continue to run into race conditions, you can debug them using a calls to the Windows debug write sprinkled liberally about your code.  Check out the post here for more information.
    Don't let your lack of format LabVIEW training stop you.  The biggest thing to get is the data flow paradigm (aka data is wires, not registers).  Once you get past that and learn how to pass data around using shift registers, queues, events, etc, you are most of the way to mastering LabVIEW.  The rest is just learning the plethora of functionality LabVIEW gives you (yes, I have reimplemented LabVIEW native code more than once in the process of learning).
    Let us know if you need more help.
    This account is no longer active. Contact ShadesOfGray for current posts and information.
    Attachments:
    serialUtil_V3_DFG.zip ‏137 KB

  • Performance problem with MERGE statement

    Version : 11.1.0.7.0
    I have an insert statement like following which is taking less than 2 secs to complete and inserts around 4000 rows:
    INSERT INTO sch.tab1
              (c1,c2,c3)
    SELECT c1,c2,c3
       FROM sch1.tab1@dblink
      WHERE c1 IN (SELECT c1 FROM sch1.tab2@dblink);I wanted to change it to a MERGE statement just to avoid duplicate data. I changed it to following :
    MERGE INTO sch.tab1 t1
    USING (SELECT c1,c2,c3
       FROM sch1.tab1@dblink
      WHERE c1 IN (SELECT c1 FROM sch1.tab2@dblink) t2
    ON (t1.c1 = t2.c1)
    WHEN NOT MATCHED THEN
    INSERT (t1.c1,t1.c2,t1.c3)
    VALUES (t2.c1,t2.c2,t2.c3);The MERGE statement is taking more than 2 mins (and I stopped the execution after that). I removed the WHERE clause subquery inside the subquery of the USING section and it executed in 1 sec.
    If I execute the same select statement with the WHERE clause outside the MERGE statement, it takes just 1 sec to return the data.
    Is there any known issue with MERGE statement while implementing using above scenario?

    riedelme wrote:
    Are your join columns indexed?
    Yes, the join columns are indexed.
    You are doing a remote query inside the merge; remote queries can slow things down. Do you have to select all thr rows from the remote table? What if you copied them locally using a materialized view?Yes, I agree that remote queries will slow things down. But the same is not happening while select, insert and pl/sql. It happens only when we are using MERGE. I have to test what happens if we use a subquery refering to a local table or materialized view. Even if it works, I think there is still a problem with MERGE in case of remote subqueries (atleast till I test local queries). I wish some one can test similar scenarios so that we can know whether it is a genuine problem or some specific problem from my side.
    >
    BTW, I haven't had great luck with MERGE either :(. Last time I tried to use it I found it faster to use a loop with insert/update logic.
    Edited by: riedelme on Jul 28, 2009 12:12 PM:) I used the same to overcome this situation. I think MERGE needs to be still improved functionally from Oracle side. I personally feel that it is one of the robust features to grace SQL or PL/SQL.

Maybe you are looking for