Needs Time Calculation in SQL Querry

Dear ALL,
I am having One Finished Good (X )  which is make item and machine is defined in one of the UDF in Item master (U_MACH) and Speed of the machine is also defined in Item Master. (U)Speed)
now the scenario is :
I got an Sales order for X , qty is 100000
Now i want to calculate the time
speed of the machine is 400 per min and name of the machine is M1
so
100000/400 = 250 /60  = 4,16 Hrs
and my end time is 10AM 
i want a querry to calculate 10:00:00 - 4:16.00 = 5:44:00
Thanks In Advance
Ashish Gupte

Hi,
I have a sample code right here.Just change Hour1 and Hour 2 into your corresponding Table.FieldName.
Note: the only difference here is Time start - Time end - 15 mins. Kindly remove @lessmin.
DECLARE @lessmin int;
DECLARE @ms int;
DECLARE @datetime1 datetime;
DECLARE @datetime2 datetime;
Declare @hour1 as datetime
Declare @hour2 as datetime
Declare @date1 as datetime
Declare @date2 as datetime
set @date1 ='2011-08-25'
set @date2 ='2011-08-25'
set @hour1=(Select $[OPDN.U_LoadTimeStart])
set @hour2 =(Select $[OPDN.U_LOadTimeEnd])
SET @lessmin = -15;
SET @datetime1 = @date1 + @hour1 ;
SET @datetime2 = @date2 + @hour2;
SET @ms = DATEDIFF(ms,@datetime1,DATEADD(mi,@lessmin,@datetime2));
select  convert(varchar(13),@ms/3600000)+':'+right('0'+convert(varchar(2),(@ms % 3600000)/60000),2)
Regards,
Darius Gragasin

Similar Messages

  • Need sql querry to retive the data from sysdate to last365 days data.

    Hi ,
    I need sql querry to retrive the data based on this condition:date Between Previous 365 days and current day.
    emp sal date
    1 200 03-mar-2011
    1 200 03-mar-2008
    1 200 06-mar-2012
    1 200 03-mar-2003
    1 200 03-mar-2004
    1 200 03-mar-2005
    and so on.......lot of records....
    i need the all the employee data from currentdate(sysdate) to previous 365 days data...
    Edited by: 937506 on Jun 7, 2012 4:26 AM

    937506 wrote:
    Hi ,
    I need sql querry to retrive the data based on this condition:date Between Previous 365 days and current day.
    emp sal date
    1 200 03-mar-2011
    1 200 03-mar-2008
    1 200 06-mar-2012
    1 200 03-mar-2003
    1 200 03-mar-2004
    1 200 03-mar-2005
    and so on.......lot of records....
    i need the all the employee data from currentdate(sysdate) to previous 365 days data...
    Edited by: 937506 on Jun 7, 2012 4:26 AMJust you can do this
    <date_column> between sysdate-365 and sysdateAnd DATE is a reserved word and you cannot use it as a column name.

  • Execution time calculation issue

    Hi,
    I have a proceudre which update the tables data and it will capture the execution time for each and every table.
    For that i am using below procedure and its giving incorrect values. i.e., its giving end_time<start_time
    PFB code(Line nos 25,26,33,73,7679,80 code for exeution time calculation) and output.
    1 CREATE OR REPLACE PROCEDURE my_proc
    2 IS
    3 CURSOR c
    4 IS
    5 SELECT tablename, TYPE
    6 FROM table_list;
    7
    8 TYPE emp_record IS RECORD (
    9 empkey tab1.pkey%TYPE,
    10 rid ROWID,
    11 ID tab_join.ID%TYPE,
    12 dt tab_join.dt%TYPE
    13 );
    14
    15 TYPE emp_type IS TABLE OF emp_record
    16 INDEX BY BINARY_INTEGER;
    17
    18 v_emp emp_type;
    19
    20 TYPE emp_type_rowid IS TABLE OF ROWID
    21 INDEX BY BINARY_INTEGER;
    22 tab_no Number:=0;
    23 emp_rowid emp_type_rowid;
    24 r_cur sys_refcursor;
    25 v_start_time TIMESTAMP; /** Added for time calculation*/
    26 v_end_time TIMESTAMP; /** Added for time calculation*/
    27 string1 VARCHAR2 (1000) := 'SELECT b.empkey, b.ROWID rid, a.id id, a.dt dt FROM emp_base a,';
    28 string2 VARCHAR2 (1000) := ' b WHERE a.empkey = b.empkey';
    29 rowcnt Number;
    30BEGIN
    31 FOR c1 IN c
    32 LOOP
    33 tab_no:=tab_no+1;
    34 v_start_time := SYSTIMESTAMP; /** Added for time calculation*/
    35 BEGIN
    36 string_d := string1 || c1.tablename || string2;
    37
    38 OPEN r_cur FOR string_d;
    39
    40 LOOP
    41 FETCH r_cur
    42 BULK COLLECT INTO v_emp LIMIT 50000;
    43
    44 IF v_emp.COUNT > 0
    45 THEN
    46 FOR j IN v_emp.FIRST .. v_emp.LAST
    47 LOOP
    48 emp_rowid (j) := v_emp (j).rid;
    49 END LOOP;
    50
    51 upd_string := ' UPDATE ' || c1.tablename || ' SET id = ' || v_emp (1).ID || 'WHERE ROWID = :emp_rowid';
    52 FORALL i IN emp_rowid.FIRST .. emp_rowid.LAST
    53 EXECUTE IMMEDIATE upd_string
    54 USING emp_rowid (i);
    55 rowcnt := rowcnt + emp_rowid.COUNT;
    56 END IF;
    57
    58 EXIT WHEN v_emp.COUNT < 50000;
    59 v_emp.DELETE;
    60 emp_rowid.DELETE;
    61 END LOOP;
    62
    63 v_emp.DELETE;
    64 emp_rowid.DELETE;
    65
    66 CLOSE r_cur;
    67 EXCEPTION
    68 WHEN OTHERS
    69 THEN
    70 DBMS_OUTPUT.put_line (SQLERRM);
    71 END;
    72
    73 v_end_time := SYSTIMESTAMP; /** Added for time calculation*/
    74
    75 INSERT INTO exec_time
    76 VALUES (tab_no||' '||c1.tablename, v_start_time, v_end_time, v_end_time - v_start_time, rowcnt); /** Added for time calculation*/
    77
    78 COMMIT;
    79 v_start_time := NULL; /** Added for time calculation*/
    80 v_end_time := NULL; /** Added for time calculation*/
    81 rowcnt := 0;
    82 END LOOP;
    83END;
    Output :
    TableName: exec_time
    "TABLE_NAME"      "START_TIME"     "END_TIME"      "EXCUTION_TIME"      "NO_OF_RECORDS_PROCESSED"
    TAB7      5/29/2013 10:52:23.000000 AM      5/29/2013 10:52:24.000000 AM      +00 00:00:00.521707      773
    TAB5      5/29/2013 10:52:18.000000 AM      5/29/2013 10:52:15.000000 AM      -00 00:00:03.381468      56525
    TAB6      5/29/2013 10:52:15.000000 AM      5/29/2013 10:52:23.000000 AM      +00 00:00:08.624420      49078
    TAB2      5/29/2013 10:51:54.000000 AM      5/29/2013 10:51:42.000000 AM      -00 00:00:11.932558      529
    TAB4      5/29/2013 10:51:47.000000 AM      5/29/2013 10:52:18.000000 AM      +00 00:00:31.208966      308670
    TAB1      5/29/2013 10:51:45.000000 AM      5/29/2013 10:51:54.000000 AM      +00 00:00:09.124238      65921
    TAB3      5/29/2013 10:51:42.000000 AM      5/29/2013 10:51:47.000000 AM      +00 00:00:04.502432      12118
    Issue: I am getting execution time in negitive values because end_time<start_time coming.
    Please suggest me how to resolve this.
    Thanks.

    Welcome to the forum!!
    Please read {message:id=9360002} from the FAQ to know the list of details (WHAT and HOW) you need to specify when asking a question.
    I primarily hate 3 things in your code
    1. The way you have used BULK update which is totally unnecessary
    2. COMMIT inside LOOP
    3. The use of WHEN OTHERS exception.
    Your code can be simplified like this
    create or replace procedure my_proc
    is
       v_start_time timestamp;
       v_end_time   timestamp;
       v_rowcnt     integer;
    begin
       for c1 in (
                     select rownum tab_no
                          , tablename
                          , type
                       from table_list
       loop
          sql_string := q'[
                                  merge into #tablename# a
                                  using (
                                          select id, dt
                                            from emp_base
                                        ) b
                                     on (
                                          a.empkey = b.empkey
                                    when matched then
                                        update set a.id = b.id;
          sql_string := replace(sql_string, '#tablename#', c1.tablename);
          v_start_time := systimestamp;
          execute immediate sql_string;
          v_end_time   := systimestamp;
          v_rowcnt     := sql%rowcount;
          insert into exec_time
               values
                    c1.tab_no || ' ' || c1.tablename
                  , v_start_time
                  , v_end_time
                  , v_end_time - v_start_time
                  , v_rowcnt
       end loop;
       commit;
    end; In the INSERT statement on the table EXEC_TIME try to include the column list.
    NOTE: The above code is untested.

  • How to find out the execution time of a sql inside a function

    Hi All,
    I am writing one function. There is only one IN parameter. In that parameter, i will pass one SQL select statement. And I want the function to return the exact execution time of that SQL statement.
    CREATE OR REPLACE FUNCTION function_name (p_sql IN VARCHAR2)
    RETURN NUMBER
    IS
    exec_time NUMBER;
    BEGIN
    --Calculate the execution time for the incoming sql statement.
    RETURN exec_time;
    END function_name;
    /

    Please note that wrapping query in a "SELECT COUNT(*) FROM (<query>)" doesn't necessarily reflect the execution time of the stand-alone query because the optimizer is smart and might choose a completely different execution plan for that query.
    A simple test case shows the potential difference of work performed by the database:
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    Session altered.
    SQL>
    SQL> drop table count_test purge;
    Table dropped.
    Elapsed: 00:00:00.17
    SQL>
    SQL> create table count_test as select * from all_objects;
    Table created.
    Elapsed: 00:00:02.56
    SQL>
    SQL> alter table count_test add constraint pk_count_test primary key (object_id)
    Table altered.
    Elapsed: 00:00:00.04
    SQL>
    SQL> exec dbms_stats.gather_table_stats(ownname=>null, tabname=>'COUNT_TEST')
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.29
    SQL>
    SQL> set autotrace traceonly
    SQL>
    SQL> select * from count_test;
    5326 rows selected.
    Elapsed: 00:00:00.10
    Execution Plan
    Plan hash value: 3690877688
    | Id  | Operation         | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |            |  5326 |   431K|    23   (5)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| COUNT_TEST |  5326 |   431K|    23   (5)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
            419  consistent gets
              0  physical reads
              0  redo size
         242637  bytes sent via SQL*Net to client
           4285  bytes received via SQL*Net from client
            357  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
           5326  rows processed
    SQL>
    SQL> select count(*) from (select * from count_test);
    Elapsed: 00:00:00.00
    Execution Plan
    Plan hash value: 572193338
    | Id  | Operation             | Name          | Rows  | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT      |               |     1 |     5   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE       |               |     1 |            |          |
    |   2 |   INDEX FAST FULL SCAN| PK_COUNT_TEST |  5326 |     5   (0)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
             16  consistent gets
              0  physical reads
              0  redo size
            412  bytes sent via SQL*Net to client
            380  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    SQL>As you can see the number of blocks processed (consistent gets) is quite different. You need to actually fetch all records, e.g. using a PL/SQL block on the server to find out how long it takes to process the query, but that's not that easy if you want to have an arbitrary query string as input.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle:
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • How to reduce Parse time in dynamic SQL

    I'm using for a part of my code dynamic SQL with DBMS_SQL Package, this dynamic SQL code is located in a loop with say 1000 repeatations, if we trace the code we see that this sql statement is parsed 1000 times and this causes
    a serios performance issue. If i convert this part of code into static PLSQL code , the statement is parsed only one time as expected. i would like
    to know how i can resolve this problem in the dynamic SQL code.
    Why in case of static SQL, despite it is inside the loop, it is parsed
    only one time by ORACLE and in case of dynamic SQL as many as the upper limit of counter.
    Why the ORACLE has different behaviour to parse them? Is there any way or trick
    to force ORACLE to parse it only one time like static SQL?

    despite the open cursor is also inside the loop but oracle parse it only one time.That is because PL/SQL is caching your cursor and resuing it. With DBMS_SQL you are opening a new cursor area in the loop for each iteration (DBMS_SQL.OPEN_CURSOR).
    what you need to do is open/parse once and bind the value each time through the loop:
    DECLARE
        expr      VARCHAR2(1000);
        check_cur PLS_INTEGER;
        nDummy    PLS_INTEGER;
        nFetched  PLS_INTEGER;
    BEGIN
        -- Open Cursor
        check_cur := dbms_sql.open_cursor;
        expr      := 'select 1 from dual where ' || ':bindvar1 ' || '=' ||
                     ' ''bindvar1'' ';
        -- Parse Cursor
        dbms_sql.parse(check_cur,
                       expr,
                       1);
        FOR counter IN 1 .. 1000
        LOOP
            -- Define Column
            DBMS_SQL.define_column(check_cur,
                                   1,
                                   1);
            -- Do Binding
            dbms_sql.bind_variable(check_cur,
                                   ':bindvar1',
                                   'bindname1');
            -- Execute Cursor
            nDummy := DBMS_SQL.EXECUTE(check_cur);
            -- Fetch Rows
            nFetched := DBMS_SQL.fetch_rows(check_cur);
        END LOOP;
        -- Close Cursor
        dbms_sql.close_cursor(check_cur);
    END;
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.21       0.23          0          0          0           0
    Execute   1000      0.11       0.10          0          0          0           0
    Fetch     1000      0.03       0.01          0          0          0           0
    total     2001      0.35       0.35          0          0          0           0

  • Help required in writing an sql querry

    Hi guys,
    Could any one hlep me out in writing an sql querry for the below requirement.
    the requirement is: for a perticular ID if we have different names then we need to get it out as multiple else the name itselef. I have given the sample input and the expected output.
    ID Name
    1 A
    1 B
    2 F
    2 F
    3 C
    4 D
    4 E
    Out put should look like
    ID Name
    1 Multiple
    2 F
    3 C
    4 Multiple
    Thanks in advance
    Shylender.
    Edited by: 959345 on Nov 22, 2012 10:13 PM

    May be this:
    WITH t AS
            (SELECT 1 id, 'A' str FROM DUAL
             UNION ALL
             SELECT 1, 'B' FROM DUAL
             UNION ALL
             SELECT 2, 'F' FROM DUAL
             UNION ALL
             SELECT 2, 'F' FROM DUAL
             UNION ALL
             SELECT 3, 'C' FROM DUAL
             UNION ALL
             SELECT 4, 'D' FROM DUAL
             UNION ALL
             SELECT 4, 'E' FROM DUAL),
         t1 AS
            (SELECT id,
                    CASE
                       WHEN COUNT (DISTINCT str) OVER (PARTITION BY id) > 1 THEN
                          'MULTIPLE'
                       ELSE
                          str
                    END
                       str
               FROM t)
      SELECT id, str
        FROM t1
    GROUP BY id, str
    ORDER BY 1;Cheers,
    Manik.

  • Execution time, elapsed time  of an sql query

    Can you please tell me how to get the execution time, elapsed time of an sql query

    user8680248 wrote:
    I am running query in the database
    I would like to know how long the query take the time to completeWhy? That answer can be totally meaningless as the VERY SAME query on the VERY SAME data on the VERY SAME database in the VERY SAME Oracle session can and will show DIFFERENT execution times.
    So why do you want to know a specific query's execution time? What do you expect that to tell you?
    If you mean that you want to know how long an existing query being executed is still going to take - that's usually quite difficult to determine. Oracle does provide a view on so-called long operations. However, only certain factors of a query's execution will trigger that this query is a long operation - and only for those specific queries will there be long operation stats that provide an estimated completion time.
    If your slow and long running query does not show in long operation, then Oracle does not consider it a long operation - it fails to meet the specific criteria and factors required as a long operation. This is not a bug or an error. Simply that your query does not meet the basic requirements to be viewed as a long operation.
    Oracle however provides the developer with the means to create long operations (using PL/SQL). You need to know and do the following:
    a) need to know how many units of work to do (e.g. how many fetches/loop iterations/rows your code will process)
    b) need to know how many units of work thus far done
    c) use the DBMS_APPLICATION_INFO package to create a long operation and continually update the operation with the number of work units thus far done
    It is pretty easy to implement this in PL/SQL processing code (assuming requirements a and b can be met) - and provide long operation stats and estimated completion time for the DBA/operators/users of the database, waiting on your process to complete.

  • Set out of range value to a time datatype in sql server 2008

    Hi,
    I have a variable set to time datatype in SQL server 2008. I need to set a value more than 24 hrs to that. Is there any way? I get an error like Conversion failed when converting date and/or time from character string. .Below is my scenario
    declare @QuietBeginTime time
    SET @QuietBeginTime  = (SELECT value FROM #RCQD where id=8)
    ---------This has a value like '24:45'
    Print @QuietBeginTime
    Please help me.
    Deepa

    declare @QuietBeginTime time
    SET @QuietBeginTime  = (SELECT value FROM #RCQD where id=8)
    ---------This has a value like '24:45'
    Print @QuietBeginTime
    Above is my scenario. Your example is fine, But main thing is i want to set a value to a variable, That
    i am unable to do
    Deepa

  • Time Calculation Shell dimension is slow compared to hardcoded measure?

    Hi,
    I have a measuregroup with 200m+ rows with about 20 measures (sums). I've created a shell dimension to hold my time calculation members such as mtd, qtd, ytd, etc. My problem is that it performs REALLY poorly when using the time calculation dimension.
     My script looks like this:
    SCOPE
    Measuregroupmeasures("MyMeasureGroup");
    SCOPE
    [Time Calculation].[Calculation].&[None];
    THIS =
    [Measures].CurrentMember;
    END SCOPE;
    SCOPE
    [Time Calculation].[Calculation].&[MTD];
    THIS =
    Aggregate
    [Time Calculation].[Calculation].&[None]
    MTD([Date].[Calendar (YQMD)].CurrentMember)
    END SCOPE;
    SCOPE
    [Time Calculation].[Calculation].&[QTD];
    THIS =
    Aggregate
    [Time Calculation].[Calculation].&[None]
    QTD([Date].[Calendar (YQMD)].CurrentMember)
    END SCOPE;
    SCOPE
    [Time Calculation].[Calculation].&[YTD];
    THIS =
    Aggregate
    [Time Calculation].[Calculation].&[None]
    YTD([Date].[Calendar (YQMD)].CurrentMember)
    END SCOPE;
    END SCOPE;
    When I use my Calendar hierarchy and time calculation dimension as a background selection it takes forever. It never returns anything. A profiler trace shows that it's just pushing 1 and 21 events (cache data).
    If I create the following measure:
    CREATE
    MEMBER CURRENTCUBE.[Measures].[TestMTD] AS
    SUM(MTD([Date].[Calendar (YQMD)].CurrentMember), [Measures].[MyMeasure]),
    VISIBLE = 1 ;
    it works just fine but the whole point here is I want to avoid creating new measure for every time calculation.
    The measuregroup has been partitioned by month and I've set each partition slice to the corresponding month in the calendar hierarchy.
    Why doesn't my script perform - please advice :)
    Thanks.

    Hi Mortenbpost,
    According to your description, the issue was solved by change Aggregate() function to Sum() function, now you want to know why it behaves like that, right?
    In Aggregate function, if a numeric expression is not provided, this function aggregates each measure within the current query context by using the default aggregation operator that is specified for each measure. Here is a thread which discuss difference
    between AGGREGATE() and SUM()https://social.msdn.microsoft.com/Forums/sqlserver/en-US/ef4b2555-45f2-4871-9137-a12a637ce2f5/whats-the-difference-between-aggregate-and-sum?forum=sqlanalysisservices
    Besides, you can use SQL profiler to monitor what's the difference between using AGGREGATE() and using SUM().
    Regards,
    Charlie Liao
    TechNet Community Support

  • I need to syncronize MS SQL Server 2000 with Oracle DB

    Hello
    I need to syncronize MS SQL Server 2000 with Oracle Database. I have created both DB connections succesfully.
    1. Oracle DB: Oracle (JDBC)
    2. SQL Server JDBC-ODBC (bridge)
    When i create a partner link and select a DB Adapter i try to query SQL Server but it never brings the tables back to me.
    I´ve tried to configure connection 2 (MSSQL) using thrid party but i really don´t know how.
    Driver Class??
    Library?
    Library Name??
    Location??
    Class Path?
    Source Path??
    Doc Path??
    URL??
    help is appreciated. Thank you.
    F.

    Here is my setup:
    Driver Class: com.microsoft.jdbc.sqlserver.SQLServerDriver
    Library: SQLSERVER
    ClassPath: Depends on where your jar file is.
    URL: jdbc:microsoft:sqlserver://your ip address or DNS name goes here.
    The above is how my database connection is defined.
    When I create a partner link and it gets to the screen where it imports tables it takes a while for the "Querying Database Ojects..." to finish. When it does I have not tables. I then select <all schemas> AGAIN and this time I get the tables.
    If you get succeed when you do a test on the connection then I assume the connection is setup right. Perhaps the problem is like mine above and you have to select <all schemas> a second time.

  • Getting the current time using java.sql.Time

    I need to set the current time in a database field. I tried the following code (using my logic) to set the current time. But, I end up getting "Jan 1, 1970" in the time field in the database.
    Here is the code :
    Calendar cal = Calendar.getInstance();
    Java.sql.Time now = java.sql.Time.valueOf(
              cal.get(Calendar.HOUR_OF_DAY) + ":" +
              cal.get(Calendar.MINUTE) + ":" +
              cal.get(Calendar.SECOND));
    What should I do to get the current time in the "now" variable? Right now, it ends up in the database as "Jan 1, 1970".
    Thanx in advance.

    Can you show me the code to do SimpleDateFormat?
    Assuming that I use the following skeleton to get the
    time value from the database, can you show me the
    code for the missing link (so as to display in the
    format "hh:mm:ss") ?
    java.sql.Time timeFromDb =
    obj.getActionTime();
    // The above code gets the "time" field from
    the database into "timeFromDb"
    // Use SimpleDateFormat to display the time
    java.text.SimpleDateFormat sdf = new
    java.text.SimpleDateFormat("hh:mm:ss");
    // Now what do I do with "sdf" and
    "timeFromDb" ?
    // Print out the time value
    System.out.printf("Time is : %s\n",
    .... );Hi,
    I don't know if you want 24h clock or not. This is the pattern for 24h clock.
    "HH:mm:ss"
    You get the text string by calling sdf.format(timeFromDb)
    Kaj

  • How long an i phone 5 need time to be fully recharged

    hi , '
    how long an i phone 5 need time to be fully recharged

    Hi amin amri 1!
    I have an article here that is relevant to your question and can help you understand a little more about charging your iPhone battery:
    iPhone and iPod touch: Charging the battery
    http://support.apple.com/kb/HT1476
    Thanks for coming to the Apple Support Communities!
    Regards,
    Braden

  • New To Oracle.. Needs Help:: Conversion from SQL Server to Oracle 11g

    I am new to Oracle 11g and badly need the conversion of SQL Server Functions to Oracle.. Sample Pasted Code not working .. end with error.. pls help
    Create Table TempT (ID1 Varchar (10),
    ID2 Varchar (10)
    CREATE OR REPLACE PACKAGE GLOBALPKG
    AS
    TYPE RCT1 IS REF CURSOR;
    TRANCOUNT INTEGER := 0;
    IDENTITY INTEGER;
    END;
    CREATE OR REPLACE FUNCTION fTempT
    i IN VARCHAR2 DEFAULT NULL
    RETURN GLOBALPKG.RCT1
    IS
    REFCURSOR GLOBALPKG.RCT1;
    BEGIN
    OPEN REFCURSOR FOR
    SELECT TT.*
    FROM TempT TT
    WHERE (fTempT.i = ''
    OR TT.ID1 = fTempT.i)
    RETURN REFCURSOR;
    END;
    CREATE OR REPLACE FUNCTION fTempTF
    i IN VARCHAR2 DEFAULT NULL
    RETURN GLOBALPKG.RCT1
    IS
    REFCURSOR GLOBALPKG.RCT1;
    BEGIN
    OPEN REFCURSOR FOR
    SELECT *
    FROM TABLE(fTempT(i))
    RETURN REFCURSOR;
    END;
    LAST FUNCTION ENDs WITH ERROR
    Error(13,7): PL/SQL: ORA-22905: cannot access rows from a non-nested table item

    2. The major purpose is to get a simplest way to create a parameterized function who can return a table like output. 2nd function has no use instead i was testing the result of First Function like thisIf you just want to select from a select, you should use a view not a function.
    1. which program is more help ful for writing and executing queries bcoz after using Query Analyzer of Microsoft It seems difficult to work on SQL Developer.
    sqlplus? If you are having difficulty learning new tools because of an old one you used, probably best to forget the old one and concentrate on learning the new one because it will be different. This goes for the database itself also.
    2. Can DMLs be used within a Function.Yes, you just can't execute the function in another SQL statement if it modifies data and this is a good thing.
    3. Can temporary tables be used within a function.Unfortunately yes, but they shouldn't be unless you are in a slowest application competition.
    5. Each Function which is a Table Function must be accompanied with Type Definitions?? its a bit longer way of doing the things than SQL ServerThat is why it is better to use views instead, is there any reason you want a select that you can select from inside a function?
    SQL Server for last 9 years thats why i refer this toolThat is not in itself a problem, if you try and do what you did in SQLServer in Oracle, that will be a problem though.

  • How is Processing time calculated in Simulation

    Hi,
    How is processing time calculated for every simulation-relevant object?
    say for example,
    i have 2 objects of person type (p1 and p1)
    4 human tasks (T1, T2, T3, T4)
    T1 assigned to p1, processing time 2hrs
    T2 assigned to p1, processing time 2hrs
    T3 assigned to p2, processing time 2hrs
    T4 assigned to p2, processing time 2hrs
    start --&gt; T1(p1) --&gt; T2(p1) --&gt; T3(p2) --&gt; T4(p2) --&gt; end
    Have not set any other simualtion parameters. now,
    * Duration for simulation is set to 6hrs,
    T1, T2, and T3 are getting processes once, but start event is getting processed twice
    # Why is start event getting processed second time?
    # Will this take any processing time..
    * Duration for simulation set to 7hrs,
    start event and T1 gets processed 2 times, T2 and T3 once..
    and the total processing time becomes *8hrs*..
    # At wht point of time does the second processing of T1 start.
    # If it is not after after the completion of one full process cycle, in this case, why not the second processing start at the end # of 2nd hour, or 4th hour.
    Thanks,
    Vishnupriya

    Hi Vishnupriya,
    "Why is start event getting processed second time?"Can you check the "Frequency" attribute of your start event? There you can specify how often the process will be triggered.
    "At wht point of time does the second processing of T1 start."You should be able to check it in the Processes (det.). It provides an overview regarding the process instances started during the simulation run. Furthermore you can check the Events (det.) category.
    Best regards,
    Danilo

  • How to create services for sql querry with joint 2 tables ?

    Hi all,
    I start to learn the php services function for mysql querry in flex 4.5 and all seam to be ok.
    But i don't find anny help or tutorial to create service that call a sql querry with joint to tables, like this :
    Select table01.fieldA table02.fieldA WHERE table01.fieldC LIKE table02.fieldC
    Are there a way to do that in flashBuilder creation services interfaces, or not ?
    Does we make a special value Object and all the AS3  classes and not use the template opperations ?
    Thank's for your help or link
    fbm

    Hi Fabien,
    I'm afraid you'll have to learn a bit more about PHP...
    Joined tables is a relational database feature. It has nothing to do with PHP, and PHP has nothing to do with Flex...
    The "magic" of the flex framework is that it can plug itself into any backend (.Net, Java, PHP...)
    The new way Flash Builder interacts with PHP is through AMF (Actionscript Messaging Format) with the help of Zend and Zend_Amf. You've been able to do it on your own for a while, but it was a bit tricky to set up... The new IDE helps you doing those mapping with wizards. What it does is that it serializes and deserializes objects from PHP to Actionscript, and also generates Actionscript value objects.
    So what you'll have to do is to write your own PHP services to retrieve your data from joined tables in MySQL. Those services will return simple arrays. Then start the wizard, select your services. Flash Builder will then map the objects contained in the PHP arrays into Actionscript typed objects.
    I suggest you have a deep look into Zend_Tables...
    Hope it'll help.
    Julien.

Maybe you are looking for