Pure SQL query

I am trying to execute a pure SQL statement. But my DB adapter is not fetching any output.
select installation_type from oid_staa_desc_mapping where Acode in ('A','B')
I am not sure why this doesn't work.
Regards,
Balaji

Hi,
Read the following blog post:
http://soa-howto.blogspot.com/2009/05/how-to-use-sql-query-having-in-clause.html
Regards.
D

Similar Messages

  • Need Suitable Pure SQL Query

    Hi
    I have Pure SQL DataBase name of Table as per given Coloumn Name.
    User Name StartDate EndDate
    Mr.Jack 01/04/2010 05/04/2010
    Mr.Perlin 07/04/2010 10/04/2010
    Mr.Tinklin 01/05/2010 05/05/2010
    Mr.Kerlin 12/04/2010 15/04/2010
    Now I am using asp.net Form Using C#...
    Name --> TextBox
    StartDate -> TextBox
    EndDate --> TextBox
    Now User enter the Dates after Click Save Button....
    Here SQL Query Check Whether the User Dates Clause into Data Base Date's.
    For Examble..
    User Enter Start Date = 04/04/2010, EndDate =08/04/2010
    Now Query it check SQL DataBase, Already 01/04/2010 to 10/04/2010 Available so Dont allow Save.... only allow various dates...
    ---------------- This is task Condition -------
    i am using SQL Query
    DECLARE @StartDate DATETIME
    DECLARE @EndDate DATETIME
    SET @StartDate ='02/04/2010' --// This is User Start Date coming from Text Box
    SET @EndDate = '10/04/2010' --// This is User End Date coming from Text Box
    IF NOT EXISTS (SELECT PollID FROM Polls WHERE (StartDate<= CAST (CONVERT(VARCHAR,@StartDate,101) AS DATETIME) OR EndDate <= CAST (CONVERT (VARCHAR,@EndDate,101) AS DateTime)) AND STATUS<>'D')
    SELECT 'OK ALLLOW'
    ELSE
    SELECT 'NOT ALLOW'
    But it is not working Correctly....
    Pls give some correctful query for solve task Condition
    By
    Riyaz
    Edited by: 798225 on Sep 28, 2010 10:37 PM
    Edited by: 798225 on Sep 28, 2010 10:52 PM

    Now I am developing Polls Application in asp.net
    I am using Polls Concept,
    DateBase Name : Polls
    Fields : PollID          PollName                           StartDate                                     EndDate                     UserID
    In Asp.Form Having
    User Name :  TextBox
    PollName: TextBox
    StartDate: TextBox
    EndDate: TextBox
    Submit - Button
    Task Details
    Whenever User Click after fillup all data's... then SQL Query Check
    if StartDate or EndDate is exists in Between DataBase Date's.....
    Condition true means dont allow save.. else Save.....
    Examble:
    PollID PollName StartDate EndDate UserName
    01 Sample 23/09/2010 26/09/2010 Klit
    02 Sample 2 29/09/2010 30/09/2010 Jack
    Now User given follwing details and click Submit,
    User Name : James
    PollName: Test
    StartDate: 22/09/2010
    EndDate: 27/09/2010
    Submit - Button
    Here User StartDate: 22/09/2010 , EndDate: 27/09/2010
    SQL Query Check ,
    Condtion 1 : Those dates are avilable in Datebase???
    Result: Yes
    Because, Sample Poll date is 23/09/2010 to 26/09/2010, here Start Date is Not Exists, But End Date Exists.
    So dnt allow Save Operation....
    Now User Again given follwing details and click Submit,
    User Name : James
    PollName: Test
    StartDate: 27/09/2010
    EndDate: 28/09/2010
    Submit - Button
    Here User StartDate: 27/09/2010 , EndDate: 28/09/2010
    SQL Query Again Check ,
    Condtion 1 : Those dates are avilable in Datebase???
    Result: No
    Because, Sample Poll date is 23/09/2010 to 26/09/2010,
    Sample1 Poll Date is 29/09/2010 to 30/09/2010
    here Start Date is Not Exists, But End Date Not Exists.
    So Allow Save Operation....
    This a My Task....
    Could You give SQL Query for help to Check given condition??
    regd
    Riayz
    Edited by: Riyaz on Sep 30, 2010 1:08 AM

  • How to build dynamic query strings in the query using DB adapter 'Pure SQL'

    Dear Forum,
    I am building an application which will access DB to fetch some result set. The query involves retrieving data from multiple tables(nearly 10 tables). So I have created a DB adapter using 'execute pure sql' option. With this query works fine, but my inputs parameters will vary. So I need to make my query dynamic to append the query strings at runtime depending on the inputs.
    For example I have 3 input variables - input1,input2 and input3 (in my request xsd) which are used in the pure sql query. Now if I get a 4th input parameter input4 in the request, I need to append this to query string as 'AND input4=[some value]' at runtime. Otherwise my query should have only 3 parameters. Please suggest how this can be achieved.
    Regards,
    Satya.

    This is a strange requirement, depending on the columns you have and what are optional in them, one way is to have separate operations and each opeartion will have different inputs and for each operation , a different DB Adapter is called. But this way, it results in more number of operations for the service as well as more number of references in the composite. Even if you pass the column inputs to the SQL procedure, it will result in a large number of if-else cases..
    Thanks,
    N

  • Dynamic SQL Query to Find Special Characters in Table columns

    Hi,
    I am new to OTN FORUMS.
    I am trying to find the columnsi of a table which have special characters in them.
    I am planning on using this query
    select ' select INSTR('||column_name||', chr(0))
    from '||table_name||'where INSTR('||column_name||', chr(0)) >0' from user_tab_columns
    where table_name='Account'
    and spool the output to run as a script.
    Is this the right way or do u suggest any modifications to the query?
    Thanks in advance.

    Hi,
    I think your basic approach is right. Since you can't hard-code the table- or column names into the query, you'll need dynamic SQL.
    Instead SQL-from-SQL (that is, writing a pure SQL query, whose output is SQL code), you could do the whole job in PL/SQL, but I don't see any huge advantage either way.
    When you say "Special character<b>s</b>", do you really mean "one given special character" (in this case, CHR(0))?
    Will you ever want to search for multiple special characters at once?
    What if table foo has a column bar, and in 1000 rows of foo, bar contains CHR (0). Do you want 1000 rows of output, each showing the exact position of the first CHR(0)? If the purpose is to look at theese rows later, shouldn't you include the primary key in the output? What if CHR(0) occurs 2 or more times in the same string?
    If you'd rather have one row of output, that simply says that the column foo.bar sometimes contains a CHR(0), then you could do something like this:
    SELECT     'foo',     'bar'
    FROM     dual
    WHERE     EXISTS (
                SELECT  NULL
                FROM       foo
                WHERE       INSTR ( bar
                            , CHR (0)
                        ) > 0
                );

  • SQL- Query that return only one record

    Hello,
    is it possible to execute a pure SQL-Query which returns only one row although multiple rows are found.
    It is no problem in PL/SQL, but I have no idea if the same is also possible in SQL.
    thanks in advance
    Michael

    Why not? There are 4 records in this table, but only selected one.
    SQL> with t
      2  as
      3  (
      4     select '#%$@#$@$@##$' Addr from dual
      5     union all
      6     select '18 Jalan Scott' from dual
      7     union all
      8     select '18 Lemana St' from dual
      9     union all
    10     select '32-penstation' from dual
    11     union all
    12     select '99999999999' from dual
    13  )
    14  select addr
    15    from t
    16   where rownum =1
    17  /
    ADDR
    #%$@#$@$@##$
    SQL>Cheers
    Sarma.

  • Crosstab query using pure SQL only

    Hi all,
    Found a lot of threads on crosstab, but none seems to address what I need. I need to perform crosstab query using pure SQL only & the number of columns are dynamic. From a query, I obtained the below table:
    Name Date Amount
    Alex 2005-06-10 1000
    Alex 2005-06-20 1000
    Alex 2005-07-10 1000
    Alex 2005-07-20 1000
    Alex 2005-08-10 1000
    Alex 2005-08-20 1000
    John 2005-06-10 2000
    John 2005-06-20 2000
    John 2005-07-10 2000
    John 2005-07-20 2000
    John 2005-08-10 2000
    John 2005-08-20 2000
    And I need to transform it into:
    Name 06-2005 07-2005 08-2005
    Alex 2000 2000 2000
    John 4000 4000 4000
    Reason for the columns being dynamic is because they'll be a limit on the date ranges to select the data from. I'd have a lower & upper bound date say June-2005 to August-2005, which explains how I got the data from the above table.
    Please advise.
    Thanks!

    Hi,
    I couldn't resist the intellectual challenge of a pure SQL solution for a pivot table with a dynamic number of columns. As Laurent pointed out, a SQL query can only have a fixed number of columns. You can fake a dynamic number of columns, though, by selecting a single column containing data at fixed positions.
    <br>
    <br>
    If it were me, I'd use a PL/SQL solution, but if you must have a pure SQL solution, here is an admittedly gruesome one. It shows the sum of all EMP salaries per department over a date range defined by start and end date parameters (which I've hardcoded for simplicity). Perhaps some of the techniques demonstrated may help you in your situation.
    <br>
    <br>
    set echo off
    set heading on
    set linesize 100
    <br>
    select version from v$instance ;
    <br>
    set heading off
    <br>
    column sort_order noprint
    column sal_sums format a80
    <br>
    select -- header row
      1        as sort_order,
      'DEPTNO' as DEPTNO ,
      sys_connect_by_path
        ( rpad
            ( to_char(month_column),
              10
          ' | '
        ) as sal_sums
    from
        select
          add_months( first_month, level - 1 ) as month_column
        from
          ( select
              date '1981-01-01' as first_month,
              date '1981-03-01' as last_month,
              months_between( date '1981-03-01', date '1981-01-01' ) + 1 total_months
            from dual
        connect by level < total_months + 1
      ) months
    where
      connect_by_isleaf = 1
    connect by
      month_column = add_months( prior month_column, 1 )
    start with
      month_column = date '1981-01-01'
    union all
    select -- data rows
      2 as sort_order,
      deptno,
      sys_connect_by_path( sum_sal, ' | ' ) sal_sums
    from
      select
        dept_months.deptno,
        dept_months.month_column,
        rpad( to_char( nvl( sum( emp.sal ), 0 ) ), 10 ) sum_sal
      from
          select
            dept.deptno,
            reporting_months.month_column
          from
            dept,
            ( select
                add_months( first_month, level - 1 ) as month_column
              from
                ( select
                    date '1981-01-01' as first_month,
                    date '1981-03-01' as last_month,
                    months_between( date '1981-03-01', date '1981-01-01' ) + 1 total_months
                  from
                    dual
              connect by level < total_months + 1
            ) reporting_months
        ) dept_months,
        emp
      where
        dept_months.deptno = emp.deptno (+) and
        dept_months.month_column = trunc( emp.hiredate (+), 'MONTH' )
      group by
        dept_months.deptno,
        dept_months.month_column
    ) dept_months_sal
    where
      month_column = date '1981-03-01'
    connect by
      deptno = prior deptno and
      month_column = add_months( prior month_column, 1 )
    start with
      month_column = date '1981-01-01'
    order by
      1, 2
    <br>
    VERSION
    10.1.0.3.0
    <br>
    DEPTNO      | 81-01-01   | 81-02-01   | 81-03-01
    10          | 0          | 0          | 0
    20          | 0          | 0          | 0
    30          | 0          | 2850       | 0
    40          | 0          | 0          | 0
    <br>
    Now, if we substitute '1981-03-01' with '1981-06-01', we see 7 columns instead of 4
    <br>
    DEPTNO      | 81-01-01   | 81-02-01   | 81-03-01   | 81-04-01   | 81-05-01   | 81-06-01
    10          | 0          | 0          | 0          | 0          | 0          | 2450
    20          | 0          | 0          | 0          | 2975       | 0          | 0
    30          | 0          | 2850       | 0          | 0          | 2850       | 0
    40          | 0          | 0          | 0          | 0          | 0          | 0
    <br>To understand the solution, start by running the innermost subquery by itself and then work your way outward.

  • Pure SQL of Select query on multiple tables in DB Adapter

    I am trying use pure sql approach for a custom sql query on multiple tables for a DB adapter by modifying toplink_mappings.xml. But i am not getting other tables in my xsd. Please help.

    hi Ravi,
    can you pls be a bit clear? what is this about? where you are using?
    thanks,
    sneha.

  • How to create a Matrix table using this data in SQL Query Analyzer

    Hello all,
    I have a problem while I am trying to represent my Sql Table namely table1 in Matrix form
    my table Format is
    city1 city2 Distance--------------------------------------------------------
    Mumbai Delhi 100
    Delhi Banaras 50
    Mumbai Rajasthan 70
    Banaras haryana 40
    Mumbai Mumbai 0
    784 entries
    there are 784 cities each having link to other
    Now i want my output as
    Mumbai Delhi Banaras haryana
    Mumbai 0 100 -- --
    Delhi 100 0 50 --
    Banaras
    haryana
    respective distance from one city to other should be shown
    final Matrix would be 784*784
    I am using SQL Query Analyser for this
    Please help me in this regard

    I'm pretty much certain that you don't want to do this in pure SQL. So that means that you want to do it with a reporting tool. I'm not familiar with SQL Query Analyzer, but if it is in fact a reporting tool you'll want to consult its documentation looking for the terms "pivot" or perhaps "cross tab."

  • Help Required -- Can we use SQL Query to READ data from SAP MDM Tables

    Hi All,
    Please help.........
    Can we use SQL Query to READ(No Creation/Updation/Deletion  just Read) Data from SAP MDM tables directly, without using MDM Syndicator.
    Or direct SQL access to SAP MDM tables is not possible. Only through MDM Syndicator can we export data.
    Thanks in Advance
    Regards

    All the tables you create in Repository comes under A2i_CM_Tables in Database named as your repository name. So the tables names are fields of table A2i_CM_Tables. Now i tried it but cant make it.
    Now, I dont think its possible to extract all fields in tables and there values using select query. May be pure sql guy can do that or not.
    But there is no relation of data extraction and syndicator. Data is viewed in Data Manager. and you can also store data in a file from DM also.
    BR,
    Alok

  • Dynamically Pass sql query in Database adapter

    hi',
    How can we dynamically pass sql query in Database adapter, is there any way, I am using SOA 11G.
    Thanks
    Yatan

    Hi,
    Tried that too. No luck. Gives me this.
    The selected operation process could not be invoked.
    An exception occured while invoking the webservice operation. Please see logs for more details.
    oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: Exception occured when binding was invoked.
    Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'selectUsingIn' failed due to: Pure SQL Exception.
    Pure SQL Execute of select interface_id, property_name, property_value from ( (?) ) failed.
    Caused by java.sql.SQLSyntaxErrorException: ORA-00903: invalid table name
    The invoked JCA adapter raised a resource exception.
    Please examine the above error message carefully to determine a resolution.
    Regards,
    Neeraj Sehgal

  • Newbie - help with a SQL query for a bar chart  - Originally posted in APEX

    I originally posted this in the APEX forum but someone there suggested this is more of a SQL question.  Anyone out there who can provide some assistance?
    Hi,
    I'm a new user on APEX with no real SQL knowledge and I'm trying to build a dashboard with charts into an existing APEX application. Based on another application, I have come up with the following SQL code:
    select null link
    , CATEGORY label
    , count (decode(PROJECT_STATUS,'1',PROJECT_ID))"Active"
    , count (decode(PROJECT_STATUS,'2',PROJECT_ID))"Complete"
    , count (decode(PROJECT_STATUS,'3',PROJECT_ID))"On Hold"
    , count (decode(PROJECT_STATUS,'4',PROJECT_ID))"Pipeline"
    , count (decode(PROJECT_STATUS,'5',PROJECT_ID))"Pending Review"
    from GRAPO_PROHEADTRK
    where (PROJECT_STATUS='1' or PROJECT_STATUS='2' or PROJECT_STATUS='3' or PROJECT_STATUS='4' or PROJECT_STATUS='5' or PROJECT_STATUS='6')
    group by CATEGORY
    Order by COUNT(PROJECT_ID) DESC
    The code from the other app was:
    select null link
    , FUNCTIONAL_AREA label
    , count (decode(PROJECT_STATUS,'Active',PROJECT_ID))"Active"
    , count (decode(PROJECT_STATUS,'Complete',PROJECT_ID))"Complete"
    , count (decode(PROJECT_STATUS,'On Hold',PROJECT_ID)) "On Hold"
    , count (decode(PROJECT_STATUS,'Recurring',PROJECT_ID))"Recurring"
    , count (decode(PROJECT_STATUS,'Pipeline',PROJECT_ID))"Pipeline"
    , count (decode(PROJECT_STATUS,'Not Approved',PROJECT_ID))"Not Approved"
    from PM_V2
    where LOB='S2S' and (FUNCTIONAL_AREA='Accounts Payable' or FUNCTIONAL_AREA='Expense' or FUNCTIONAL_AREA='Procurement' or FUNCTIONAL_AREA='Fixed Assets')
    group by FUNCTIONAL_AREA
    Order by COUNT(PROJECT_ID) DESC
    I'm getting a "Failed to parse SQL query!" error when I try to run validation.
    Is this enough info for some assistance? Any help would really be appreciated.
    Thanks,
    Rachel

    Hi, Rachel,
    user10774102 wrote:
    I originally posted this in the APEX forum but someone there suggested this is more of a SQL question.  Anyone out there who can provide some assistance?
    Hi,
    I'm a new user on APEX with no real SQL knowledge and I'm trying to build a dashboard with charts into an existing APEX application. Based on another application, I have come up with the following SQL code:
    select null link
    , CATEGORY label
    , count (decode(PROJECT_STATUS,'1',PROJECT_ID))"Active"
    , count (decode(PROJECT_STATUS,'2',PROJECT_ID))"Complete"
    , count (decode(PROJECT_STATUS,'3',PROJECT_ID))"On Hold"
    , count (decode(PROJECT_STATUS,'4',PROJECT_ID))"Pipeline"
    , count (decode(PROJECT_STATUS,'5',PROJECT_ID))"Pending Review"
    from GRAPO_PROHEADTRK
    where (PROJECT_STATUS='1' or PROJECT_STATUS='2' or PROJECT_STATUS='3' or PROJECT_STATUS='4' or PROJECT_STATUS='5' or PROJECT_STATUS='6')
    group by CATEGORY
    Order by COUNT(PROJECT_ID) DESCIs there a problem with the code above?
    It's curious that the WHERE clause includes "PROJECT_STATUS='6'", but there is no pivoted column for project_status='6', like there is for '1' through '5'. That's not necessarily a mistake, and it wouldn't raise an error in any case.
    Instead of
    where (PROJECT_STATUS='1' or PROJECT_STATUS='2' or PROJECT_STATUS='3' or PROJECT_STATUS='4' or PROJECT_STATUS='5' or PROJECT_STATUS='6')you could say
    where PROJECT_STATUS  IN ('1', '2', '3', '4', '5', '6')but that probably has nothing to do with your current problem.
    The code from the other app was:
    select null link
    , FUNCTIONAL_AREA label
    , count (decode(PROJECT_STATUS,'Active',PROJECT_ID))"Active"
    , count (decode(PROJECT_STATUS,'Complete',PROJECT_ID))"Complete"
    , count (decode(PROJECT_STATUS,'On Hold',PROJECT_ID)) "On Hold"
    , count (decode(PROJECT_STATUS,'Recurring',PROJECT_ID))"Recurring"
    , count (decode(PROJECT_STATUS,'Pipeline',PROJECT_ID))"Pipeline"
    , count (decode(PROJECT_STATUS,'Not Approved',PROJECT_ID))"Not Approved"
    from PM_V2
    where LOB='S2S' and (FUNCTIONAL_AREA='Accounts Payable' or FUNCTIONAL_AREA='Expense' or FUNCTIONAL_AREA='Procurement' or FUNCTIONAL_AREA='Fixed Assets')
    group by FUNCTIONAL_AREA
    Order by COUNT(PROJECT_ID) DESC
    I'm getting a "Failed to parse SQL query!" error when I try to run validation.Is that an Apex error message? Sorry, I don't know anything about Apex.
    If you can't get a more specific error message from Apex, then try debugging this statement in SQL*Plus. When you get it fixed, then you can copy it back into Apex.
    If this is a SQL problem, then you should be able to re-create the problem in pure SQL.
    If you can't re-create the problem in pure SQL, then it's probably an Apex problem, and belongs in the Apex forum, not here.
    I don't see anything obviously wrong with your code, but I can't tell if, for example, you spelled a column name wrong, or if something has the wrong data type
    Is this enough info for some assistance? Any help would really be appreciated.It wiould be better if you posted a completE script that people could run to re-create the problem, and to test their ideas.
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    Always say which version of Oracle (and any other software, such as Apex) you're using.

  • Pure sql in DB adapter

    Hi All,
    Here is my scenario:
    I wnat to take teh dat from the database tables and generate teh reports in BAM. Al;ready I have SQL queries to generate the report. I want to pool the db tables for every 2 mins and generate the report .
    My question is :
    Is there is any way to trigge teh pure SQL in DB adapter for every certain intervat of time? Please help me on this. also suggest me best approach..
    Thanks
    Venkat

    Hi Venkat
    1. Hope you are familiar with BAM Reports architecture and how it works. Its pretty straight forward.
    2. First you create a DataSource to any external Database giving the db host, port, sid, username/password. This database contains like Tables, Views, etc etc.
    3. You create a DataObject that References any component of this database like Table, View etc. So you have a SQL that joins multiple tables and fetches data. Simply Create a View for that SQL Query on database side like database View. Then create a BAM Data Object for that View. It shows all Columns from that View. Simply Rename them if you want or just leave as it is. Just run the View and it shows all the data records. Remember this is dynamic. There is no need to refresh or trigger. Say if the table had a new row, the View will just show that new row.
    4. Now create a Report (Web or excel format) for the above Data Object. Report by default will show all the column from Data Object. Pick the columns you want to add to that Report.
    Run the Report. Data in Report is 100% Dynamic. If backend tables had new rows or deleted rows, just run the Report and you will see the results.
    Thanks
    Ravi Jegga

  • Pure SQL to partition date-time occurrences into non-overlapping windows?

    i've a question that so far, i've never been able to solve via a pure SQL option.
    it's hard to explain in words, but it's something like this:
    given a set of date-time, i would like to partition the data into non-overlapping windows of 30 minutes each.
    the data is supposed to be partitioned into windows of 30 minutes, meaning when the data is within 30 minutes of the first occurrence, only the first occurrence will be returned. in the next second after the 30th minute, the record will be considered as the start of a new window and is also returned. so those data that occurs within the window period are suppressed. the first occurrence is not necessarily occurring on the 00th minute, so the window start will never be constant.
    run the below query to look at the dummy data.
    SELECT     'A' AS ID
              , TRUNC(SYSDATE) + 7 / 24 + 1 *(ROWNUM - 1) / 1440 AS datetime
          FROM DUAL
    CONNECT BY ROWNUM <= 50
    UNION ALL
    SELECT     'A' AS ID
              , TRUNC(SYSDATE) + 9 / 24 + 8 / 1440 + 1 *(ROWNUM - 1) / 1440 AS datetime
          FROM DUAL
    CONNECT BY ROWNUM <= 35
    UNION ALL
    SELECT     'B' AS ID
              , TRUNC(SYSDATE) + 7 / 24 + 5 *(ROWNUM - 1) / 1440 AS datetime
          FROM DUAL
    CONNECT BY ROWNUM <= 15this is supposed to be the output.
    ID     DATETIME
    A     5/19/2010 07:00:00
    A     5/19/2010 07:30:00
    A     5/19/2010 09:08:00
    A     5/19/2010 09:38:00
    B     5/19/2010 07:00:00
    B     5/19/2010 07:30:00
    B     5/19/2010 08:00:00so far, i'm using a PL/SQL to pipe the records. but i would like to know if this is achievable via SQL or not.
    i've tried looking at analytics, width_bucket, ntile and alll options i can think of, but i just can't solve this at all.

    hey Bob,
    your answer is most definitely correct and does what i want. i've verified it again my data set and it returns the results as required!
    you've definitely proven me wrong. i was always under the impression that this wasn't possible. thanks!
    just a small note:
    i need the windows to be binned by seconds, so have changed the numtodsinterval to raw numbers.
    WITH t AS
         (SELECT 'A' AS ID
                , TRUNC(SYSDATE) +(6.75 / 24) AS datetime
            FROM DUAL
          UNION ALL
          SELECT 'A' AS ID
                , TRUNC(SYSDATE) +(6.75 / 24) AS datetime
            FROM DUAL
          UNION ALL
          SELECT     'A' AS ID
                    , TRUNC(SYSDATE) + 7 / 24 + 1 *(ROWNUM - 1) / 1440 AS datetime
                FROM DUAL
          CONNECT BY ROWNUM <= 50
          UNION ALL
          SELECT     'A' AS ID
                    , TRUNC(SYSDATE) + 9 / 24 + 8 / 1440 + 1 *(ROWNUM - 1) / 1440 AS datetime
                FROM DUAL
          CONNECT BY ROWNUM <= 35
          UNION ALL
          SELECT     'B' AS ID
                    , TRUNC(SYSDATE) + 7 / 24 + 5 *(ROWNUM - 1) / 1440 AS datetime
                FROM DUAL
          CONNECT BY ROWNUM <= 15)
        ,a AS
         (SELECT ID
                ,datetime
                ,LAG(datetime) OVER(PARTITION BY ID ORDER BY datetime) AS prevtime
                ,LAST_VALUE(datetime) OVER(PARTITION BY ID ORDER BY datetime RANGE BETWEEN CURRENT ROW AND 30 / 1440 + 1 / 86400 FOLLOWING) AS interval_end
            FROM t)
        ,b AS
         (SELECT ID
                ,datetime
                ,LEAD(datetime) OVER(PARTITION BY ID ORDER BY datetime) AS nexttime
            FROM t)
        ,ab AS
         (SELECT a.ID
                ,a.datetime
                ,a.prevtime
                   ,a.interval_end
                   ,b.datetime as b_datetime
                ,b.nexttime
            FROM a JOIN b ON(a.ID = b.ID
                             AND a.interval_end = b.datetime)
    SELECT     ID
              ,datetime
          FROM ab
    START WITH prevtime IS NULL
    CONNECT BY ID = PRIOR ID
           AND datetime = PRIOR nexttime
      ORDER BY ID
              ,datetime;this most definitely proves that i'm still not sure of how to use hierarchy queries.
    Edited by: casey on May 20, 2010 11:20 AM

  • Pure SQL and Border Use Cases?

    Hi Gurus
    I was developing a DB Adapter to select data from Shipping tables. I did it by polling as well as with Custom SQL. While using the custom SQL I got the following error in my domain.log
    (my query that I wrote) failes, Caused by java.sql.SQLException: Invalid column index.
    The Pure SQL option is for border use cases only and provides simple yet minimal functionality. Possibly try the "Perform an operation on a table" option instead.
    What is a border use case, how do I decide that. So BPEL support the custom sql option very loosely?
    Thx

    The thing is that XSLT often doesn't deliver the functionality required when it comes to times.
    You suggest appening "Z" to the time but this means that the time is now in UTC time. What if the system from where the date is being converted is running in NZ using local time? Other systems that recieve the date (and correctly handle the time zone) will now have a time that is out by a number of hours.
    You often can't ignore the time zone (drop the 'Z') as if you send the time to a system it has to either assume the time is local to it (which may not be the case... the other system coudl be in a different time zone) or assume the time is UTC (I think crossfire does this by default).
    Typically can't just append a time zone (e.g. +11:00) either as many places have daylight savings so the value to appended is variable (you then need some way of determining what the value is... either Java Embedding or a Service).
    As you mention it does depend on the use case but in many circumstances using Jaba Embedding, not as suggested above but with the appropriate Java.util.Calendar classes, is the best way to handle date and time in BPEL. Even still you need to ascertain the format of times external to the system and ensure you parse them correctly.
    ANd even if you do all this you can still run into problems. I've seen a real world example where two systems which both handled time zones correctly and had previously been working together for quite a while, satrted reporting different times. It turns out that only one of them had had the most recent Java Time Zone patches applied and there had been a change in the dates for daylight savings here (Australia). Be warned!

  • DB Adapter Pure Sql Option urgent

    Hi All,
    I have query like this .
    select
    supp.segment1 supplier_number,
    supp.vendor_name supplier_name,
    ph.segment1 po_number,
    ph.org_id,
    ph.creation_date po_date,
    pl.line_num po_line_number,
    pl.unit_price,
    pl.quantity line_quantity,
    pl.line_type,
    pl.item_number,
    pl.item_description,
    pl.UNIT_MEAS_LOOKUP_CODE UOM,
    pll.shipment_num po_shipment_number,
    pll.shipment_type,
    pll.ship_to_organization_code,
    pll.ship_to_location_code,
    pll.quantity shipment_quantity,
    pll.QUANTITY_ACCEPTED shipment_quantity_accepted,
    pll.QUANTITY_BILLED shipment_quantity_billed,
    pll.QUANTITY_CANCELLED shipment_quantity_cancelled,
    pll.QUANTITY_RECEIVED shipment_quantity_received,
    pll.QUANTITY_REJECTED shipment_quantity_rejected,
    pll.need_by_date,
    nvl(pll.inspection_required_flag,'N'), -- if its Yes then ites 4 Way Matching
    nvl(pll.receipt_required_flag,'N'), -- If Its Yes then its 3 Way Matching
    decode(nvl(pll.inspection_required_flag,'N'),'Y','4 WAY MATCHING',
    decode(nvl(pll.receipt_required_flag,'N'),'Y','3 WAY MATCHING', '2 WAY MATCHING'))
    matching_type,
    pll.qty_rcv_tolerance,
    pll.qty_rcv_exception_code,
    pll.category item_category,
    decode(pll.match_option,'P','Purchase Order','Receipt') Invoice_matching_option,
    pll.AMOUNT_RECEIVED shipment_amount_received,
    pll.AMOUNT_BILLED shipment_amount_billed,
    pll.amount_cancelled shipment_amount_cancelled,
    pll.amount_accepted shipment_amount_accepted,
    pll.amount_rejected shipment_amount_rejected,
    pd.distribution_num po_distribution_number,
    pd.amount_billed dist_amount_billed,
    pd.destination_context dist_destination,
    pd.DESTINATION_SUBINVENTORY,
    pd.quantity_ordered dist_quantity_ordered,
    pd.quantity_delivered dist_quantity_delivered,
    pd.quantity_cancelled dist_quantity_cancelled,
    pd.quantity_billed dist_quantity_billed,
    pd.amount_ordered dist_amount_ordered,
    pd.amount_delivered dist_amount_delivered,
    pd.amount_cancelled dist_amount_cancelled
    from
    po_headers_v ph,
    po_lines_v pl,
    po_line_locations_v pll,
    po_distributions_v pd,
    ap_suppliers supp,
    ap_supplier_sites_all supp_site
    where
    ph.authorization_status = 'APPROVED' -- Po Must be Approved
    and ph.po_header_id = pl.po_header_id
    and ph.closed_code = 'OPEN' --PO is still Open
    and pl.po_line_id = pll.po_line_id
    and pll.line_location_id = pd.line_location_id
    and ph.vendor_id = supp.vendor_id
    and ph.vendor_site_id = supp_site.vendor_site_id
    and pl.cancel_flag = 'N' --PO Line is not Cancelled
    and pl.closed_flag = 'N' --PO Line is Still Open
    and pll.approved_flag = 'Y' --Shipment is Approved
    and nvl(pll.cancel_flag,'N') = 'N' --Shipment is not cancelled
    and pll.closed_code = 'OPEN' --Shipment is still Open
    Iam trying to use pure sql option , i have pasted the modified query in this way below >
    select
    supp.segment1 supplier_number,
    supp.vendor_name supplier_name,
    ph.segment1 po_number,
    ph.org_id,
    ph.creation_date po_date,
    pl.line_num po_line_number,
    pl.unit_price,
    pl.quantity line_quantity,
    pl.line_type,
    pl.item_number,
    pl.item_description,
    pl.UNIT_MEAS_LOOKUP_CODE UOM,
    pll.shipment_num po_shipment_number,
    pll.shipment_type,
    pll.ship_to_organization_code,
    pll.ship_to_location_code,
    pll.quantity shipment_quantity,
    pll.QUANTITY_ACCEPTED shipment_quantity_accepted,
    pll.QUANTITY_BILLED shipment_quantity_billed,
    pll.QUANTITY_CANCELLED shipment_quantity_cancelled,
    pll.QUANTITY_RECEIVED shipment_quantity_received,
    pll.QUANTITY_REJECTED shipment_quantity_rejected,
    pll.need_by_date,
    nvl(pll.inspection_required_flag,'N'), -- if its Yes then ites 4 Way Matching
    nvl(pll.receipt_required_flag,'N'), -- If Its Yes then its 3 Way Matching
    decode(nvl(pll.inspection_required_flag,'N'),'Y','4 WAY MATCHING',
    decode(nvl(pll.receipt_required_flag,'N'),'Y','3 WAY MATCHING', '2 WAY MATCHING'))
    matching_type,
    pll.qty_rcv_tolerance,
    pll.qty_rcv_exception_code,
    pll.category item_category,
    decode(pll.match_option,'P','Purchase Order','Receipt') Invoice_matching_option,
    pll.AMOUNT_RECEIVED shipment_amount_received,
    pll.AMOUNT_BILLED shipment_amount_billed,
    pll.amount_cancelled shipment_amount_cancelled,
    pll.amount_accepted shipment_amount_accepted,
    pll.amount_rejected shipment_amount_rejected,
    pd.distribution_num po_distribution_number,
    pd.amount_billed dist_amount_billed,
    pd.destination_context dist_destination,
    pd.DESTINATION_SUBINVENTORY,
    pd.quantity_ordered dist_quantity_ordered,
    pd.quantity_delivered dist_quantity_delivered,
    pd.quantity_cancelled dist_quantity_cancelled,
    pd.quantity_billed dist_quantity_billed,
    pd.amount_ordered dist_amount_ordered,
    pd.amount_delivered dist_amount_delivered,
    pd.amount_cancelled dist_amount_cancelled
    from
    po_headers_v ph,
    po_lines_v pl,
    po_line_locations_v pll,
    po_distributions_v pd,
    ap_suppliers supp,
    ap_supplier_sites_all supp_site
    where
    ph.authorization_status = 'APPROVED'
    and ph.po_header_id = ?
    and ph.closed_code = 'OPEN'
    and pl.po_line_id = ?
    and pll.line_location_id = ?
    and ph.vendor_id = ?
    and ph.vendor_site_id = ?
    and pl.cancel_flag = 'N'
    and pl.closed_flag = 'N'
    and pll.approved_flag = 'Y'
    and nvl(pll.cancel_flag,'N') = 'N'
    and pll.closed_code = 'OPEN'
    My Question is : The Pasted modified query is correct ???, and this type of below
    nvl(pll.inspection_required_flag,'N'), -- if its Yes then ites 4 Way Matching
    nvl(pll.receipt_required_flag,'N'), -- If Its Yes then its 3 Way Matching
    decode(nvl(pll.inspection_required_flag,'N')
    Is Allowed ???????
    Edited by: anantwag on Apr 11, 2011 3:01 AM

    yeah , i was getting some error for that "--" but then i changed the query and now it does not have "---"
    But i have a question here the xsd generated is like this ...
    and query contains nvl(pll.cancel_flag,'N') which in xsd looks like below.
    <xs:element name="nvl" type="xs:string" nillable="true"/>
    <xs:element name="nvl" type="xs:string" nillable="true"/>
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <xs:schema targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/db/DBSelect" xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/DBSelect" elementFormDefault="qualified" attributeFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="DBSelectInput" type="DBSelectInput"/>
    <xs:complexType name="DBSelectInput">
    <xs:sequence>
    <xs:element name="arg1" type="xs:string" nillable="true"/>
    <xs:element name="arg2" type="xs:string" nillable="true"/>
    <xs:element name="arg3" type="xs:string" nillable="true"/>
    <xs:element name="arg4" type="xs:string" nillable="true"/>
    <xs:element name="arg5" type="xs:string" nillable="true"/>
    </xs:sequence>
    </xs:complexType>
    <xs:element name="DBSelectOutputCollection" type="DBSelectOutputCollection"/>
    <xs:complexType name="DBSelectOutputCollection">
    <xs:sequence>
    <xs:element name="DBSelectOutput" type="DBSelectOutput" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="DBSelectOutput">
    <xs:sequence>
    <xs:element name="supplier_number" type="xs:string" nillable="true"/>
    <xs:element name="supplier_name" type="xs:string" nillable="true"/>
    <xs:element name="po_number" type="xs:string" nillable="true"/>
    <xs:element name="ph_org_id" type="xs:string" nillable="true"/>
    <xs:element name="po_date" type="xs:string" nillable="true"/>
    <xs:element name="po_line_number" type="xs:string" nillable="true"/>
    <xs:element name="pl_unit_price" type="xs:string" nillable="true"/>
    <xs:element name="line_quantity" type="xs:string" nillable="true"/>
    <xs:element name="pl_line_type" type="xs:string" nillable="true"/>
    <xs:element name="pl_item_number" type="xs:string" nillable="true"/>
    <xs:element name="pl_item_description" type="xs:string" nillable="true"/>
    <xs:element name="UOM" type="xs:string" nillable="true"/>
    <xs:element name="po_shipment_number" type="xs:string" nillable="true"/>
    <xs:element name="pll_shipment_type" type="xs:string" nillable="true"/>
    <xs:element name="pll_ship_to_organization_code" type="xs:string" nillable="true"/>
    <xs:element name="pll_ship_to_location_code" type="xs:string" nillable="true"/>
    <xs:element name="shipment_quantity" type="xs:string" nillable="true"/>
    <xs:element name="shipment_quantity_accepted" type="xs:string" nillable="true"/>
    <xs:element name="shipment_quantity_billed" type="xs:string" nillable="true"/>
    <xs:element name="shipment_quantity_cancelled" type="xs:string" nillable="true"/>
    <xs:element name="shipment_quantity_received" type="xs:string" nillable="true"/>
    <xs:element name="shipment_quantity_rejected" type="xs:string" nillable="true"/>
    <xs:element name="pll_need_by_date" type="xs:string" nillable="true"/>
    <xs:element name="nvl" type="xs:string" nillable="true"/>
    <xs:element name="nvl" type="xs:string" nillable="true"/>
    <xs:element name="matching_type" type="xs:string" nillable="true"/>
    <xs:element name="pll_qty_rcv_tolerance" type="xs:string" nillable="true"/>
    <xs:element name="pll_qty_rcv_exception_code" type="xs:string" nillable="true"/>
    <xs:element name="item_category" type="xs:string" nillable="true"/>
    <xs:element name="Invoice_matching_option" type="xs:string" nillable="true"/>
    <xs:element name="shipment_amount_received" type="xs:string" nillable="true"/>
    <xs:element name="shipment_amount_billed" type="xs:string" nillable="true"/>
    <xs:element name="shipment_amount_cancelled" type="xs:string" nillable="true"/>
    <xs:element name="shipment_amount_accepted" type="xs:string" nillable="true"/>
    <xs:element name="shipment_amount_rejected" type="xs:string" nillable="true"/>
    <xs:element name="po_distribution_number" type="xs:string" nillable="true"/>
    <xs:element name="dist_amount_billed" type="xs:string" nillable="true"/>
    <xs:element name="dist_destination" type="xs:string" nillable="true"/>
    <xs:element name="pd_DESTINATION_SUBINVENTORY" type="xs:string" nillable="true"/>
    <xs:element name="dist_quantity_ordered" type="xs:string" nillable="true"/>
    <xs:element name="dist_quantity_delivered" type="xs:string" nillable="true"/>
    <xs:element name="dist_quantity_cancelled" type="xs:string" nillable="true"/>
    <xs:element name="dist_quantity_billed" type="xs:string" nillable="true"/>
    <xs:element name="dist_amount_ordered" type="xs:string" nillable="true"/>
    <xs:element name="dist_amount_delivered" type="xs:string" nillable="true"/>
    <xs:element name="ph" type="xs:string" nillable="true"/>
    <xs:element name="pl" type="xs:string" nillable="true"/>
    <xs:element name="pll" type="xs:string" nillable="true"/>
    <xs:element name="pd" type="xs:string" nillable="true"/>
    <xs:element name="supp" type="xs:string" nillable="true"/>
    <xs:element name="OPEN" type="xs:string" nillable="true"/>
    </xs:sequence>
    </xs:complexType>
    </xs:schema>
    Please help me out as, if the same thing will not work then i have to wrap the same query in the stored Procedure.

Maybe you are looking for

  • I renewed my skype number yesterday but when as of...

    how do I get in touch with skyoe to help me with this?

  • Strange explain plan when query SYS tables

    Oracle Version 9.2.0.7 We have an application that runs the following query on Oracle 9.2.0.7 SELECT T1.TABLE_NAME,T1.COLUMN_NAME, T1.SRID, T2.SDO_UB, T2.SDO_LB, T1.OWNER FROM ALL_SDO_GEOM_METADATA T1, TABLE(T1.DIMINFO) T2 WHERE T1.OWNER=UPPER(:"SYS_

  • Blocks in ALV side by side

    Hi Experts, I have a requirement that is of output with 3 Blocks of ALV side by side. How can I do this. Can anybody help me in this regard. Thanks, bsv.

  • Multiple erro messages when installing itunes 9

    I have tried to install iTunes 9 multiple times but I get different error messages. One says Windows error 112 and another the occurs in the middle of installation that says: An error occurred during the installation of assembly 'policy.8.0.Microsoft

  • EF6 does not commit changes to Database

    Hey Guys.  Actually it looks quite simple, but I won't get it right.  I try to save changes made to an object from an project-included DB using EntityFramework 6. the changes are correctly updated in the local objects instance and the EnitityEntry -