Extremely urgent: append cast function in physical query

Experts...
I have a physical query generated with a condition as:
T101123.date1 = T6786678.date2
But, I need that condition to be generated as..
T101123.date1 = CAST(T678878.date2 AS SMALLDATETIME)
Any help..this is an emergency issue..

Deep wrote:
when doing your physical join use a complex join and specify the condition you want to manually.Hi..I tried that..but its taking only DATE for cast....not smalldatetime ..
I tested i for varchar..its taking only CHAR.
Is there any way that it supports smalldateime?

Similar Messages

  • Using CAST Function in PL-SQL

    Hello guys,
    I'm writing a stored procedure which tries to convert a string representing a number to a fixed size number(with 2 positions fraction). For example, if the input was "15,456" the result would become 15.45.
    I was able to aschieve this ussing the CAST function within a query as follows:
    select cast ('15,456' as number(15,2)) from dual; -- (the comma in my case is configured as fraction separator). The previous query executes OK using a query analyzer like SQL Plus.
    However, when I try to use the same function within a stored procedure, it will complain about the number's size (15,2) and wont compile.
    v_importe_ingresado := CAST('15,456' AS NUMBER(15,2));
    Error output: PLS-00103 found '(' but expected one of the following: .)@%
    When removing the (15,2) it compiles ok
    ¿Any clue?
    I will appreciate any help.
    Thanks in advance,
    Bernabé

    ¿Any clue?¿¿¿Over complication???
    SQL> select round(15.456, 2), trunc(15.456, 2) from dual
      2  /
    ROUND(15.456,2) TRUNC(15.456,2)
              15.46           15.45
    SQL> Cheers, APC
    Blog : http://radiofreetooting.blogspot.com/

  • Use of sql group function in orcl:query-database - urgent

    All,
    Version: 10.1.3.4
    Two requirements for me:
    1. I want to use sum function in orcl:query-database. How to use it?
    For ex: I tried the following
    <xsl:value-of select='orcl:query-database("select sum(salary) from emp",false(),false(),"jdbc/DB1")'/>
    I got the following error
    oracle.xml.sql.OracleXMLSQLException: Character ')' is not allowed in an XML tag name.
    When I tried without sum function, it works fine
    2. I used the same table, but without the sum function as below
    <xsl:value-of select='orcl:query-database("select salary from emp",false(),false(),"jdbc/DB1")'/>
    This time, it returns the first employees salary!! I dont understand this logic. I expected either the query returns all the rows else it throws error, but none of them were true!
    Can anyone pls explain what is the behavior? I want your reply for both the queries!
    Currently I'm in a project where I'm working in the similar scenario, so please guru's let me know ASAP.
    Thanks,
    Sen

    Hi Sen,
    Create a normal variable variable in XSLT.
    Then use that variable.
    I mean variable name='Var_1' select='Your Query'
    Now use Var_1/yourcollection/...
    I am giving some example
    <xsl:variable name="Stopdetails" select="/ns0:MyEBM/ns0:DataArea/ns0:MyEBO/ns0:Stops/ns0:Stop[ns0:StopID=$TempStopId]"/>
                <xsl:variable name="AccStopTypeVar">
                        <xsl:value-of select="$Stopdetails/ns0:StopType"/>
    </xsl:variable>If you want you can loop on the created variable.
    You can do these in XSL.
    But DB calls those things ...it would be better , if u take them out. Spme debugging problems are there with XSL.
    Regards
    PavanKumar.M

  • Derive found flag in SQL with where clause using TABLE(CAST function

    Dear All,
    Stored procedure listEmployees
    ==========================
    CREATE OR REPLACE TYPE STRING_ARRAY AS VARRAY(8000) OF VARCHAR2(15);
    empIdList STRING_ARRAY
    countriesList STRING_ARRAY
    SELECT EMP_ID, EMP_COUNTRY, EMP_NAME, FOUND_FLAG_
    FROM EMPLOYEE WHERE
    EMP_ID IN
    (SELECT * FROM TABLE(CAST(empIdList AS STRING_ARRAY))
    AND EMP_COUNTRY IN
    (SELECT * FROM TABLE(CAST(countriesList AS STRING_ARRAY))
    =================
    I have a stored procedure which lists the employees using above simple query.
    Here I am using table CAST function to find the list of employees in one go
    instead of looping through each and every employee
    Everything fine until requirements forced me to get the FOUND_FLAG as well.
    Now I wanted derive the FOUND_FLAG by using rownum, rowid, decode functions
    but I was not successful
    Can you please suggest if there is any intelligent way to say weather the
    row is found for given parameters in the where clause?
    If not I may have to loop through each set of empIdList, countriesList
    and find the values individually just to set a flag. In this approach I can’t use
    the TABLE CAST function which is efficient I suppose.
    Note that query STRING_ARRAY is an VARRAY. It is very big in size and this procedure
    suppose to handle large sets of data.
    Thanks In advance
    Regards
    Charan
    Edited by: kmcharan on 03-Dec-2009 09:55
    Edited by: kmcharan on 03-Dec-2009 09:55

    If your query returns results, you have found them... so your "FOUND" flag might be a constant,...

  • Physical query generation: unneeded dimension tables get joined to the fact

    Hi there!
    The setup is the following:
    There is a logical fact table which is joined to 7 logical dimensions, it has 4 table sources which correspond to different time dimension levels (all other dimensions are mapped to Detail level).
    Time dimension logical table also has 4 different table sources (for days, months, quarters, and years).
    The data source is an Oracle Database 11gR2.
    The problem is:
    No matter what the logical query is, in the physical query all 7 joins are performed, even if the resulting data is then simply discarded. This results in very bad query performance.
    I feel that it is somehow related to the level-based fragmentation (since, for instance, inclusion of time dimension columns in SELECT list (not in WHERE) seems to affect physical queries), but lack sufficient knowledge to solve this problem or put up with it.
    My questions are the following:
    1) Have you ever encountered such a situation?
    2) Can unneeded joins be eliminated?
    2.1) If yes, how?
    2.2) If not, then why are they needed?
    Thanks in advance!

    Physical level:
    D01-D06 - ordinary physical tables.
    D_DATES - all time levels from dates to years, D_MONTHS - time levels from months to years, also D_QUARTERS and D_YEARS.
    F_DAILY - fact table joined to all of the D01-D06 and to D_DATES, F_MONTHLY - joined to D01-D06 and D_MONTHS, also F_QUARTERLY and F_YEARLY. All measure columns are the same.
    Logical level:
    D01-D06 correspond to ordinary logical tables with a single table source. Logical dimensions are created.
    D_TIME is a logical time dimension with four levels (dates, months, quarters, and years) and four table sources ( D_DATES, D_MONTHS, D_QUARTERS, and D_YEARS ).
    F is a fact table with four logical table sources ( F_DAILY, F_MONTHLY, F_QUARTERLY, and F_YEARLY ) with aggregation content levels set correspondingly.
    OBIEE correctly picks physical table sources for different time levels, but generates extremely inefficient SQL (joining all dimension sources in a WITH-subquery, doing ROW_NUMBER over a result set, and then discarding half the columns, which were not needed to start with).

  • Syntax error in OBIEE generated Physical query - Advance filter concept

    I encountered a syntax error when running a report with the help of advanced filter concept.
    I am getting syntax error at the physical query generated by the OBIEE for main report.
    I used a sub report with the help of advanced filter concept in main report.
    I am posting the physical query for the convenience.
    select D1.c2 as c1,
    D1.c1 as c2
    from
    (select sum(T600347.sales_usd) as c1,
    T601002.currency as c2
    from
    (Select distinct currency from pfact) T601002,
    pfact T600347
    where ( T600347.currency = T601002.currency and T600347.pdate between ( select distinct min(D1.c1) as c1* from
    (select D1.c1 as c1
    from
    (select D1.c1 as c1
    from
    *(select max(T600425.pdate) as c1*
    from
    *(select distinct pdate from pdates where pdate is not null) T600425*
    where  ( T600425.pdate < 11/22/2010 )
    *) D1*
    ) D1
    ) D1 ) and '11/25/2010')
    group by T601002.currency
    ) D1
    I executed the query against my database(sybase) in query tool. It showed error.
    I took out the column alias generated by the OBIEE ("as c1" as underlined). Then the query is working fine.
    How to disable OBIEE from generating the alias.
    Is there any way to do it.
    If obiee is generating the physical query, i am suprised to see a syntax error.
    The bold part is the query from Intermediate report
    I underlined the problematic part.
    Please help me. This is an urgent reuirement,
    Thanks in advance for the help.

    HI,
    When I execute the query on query tool ( my database is sybase)
    I am geting error at "as c1" part, as underlined in the query.
    when I remove that and execute the query, It is generating the output.
    here is the better view of query and error:
    http://img255.imageshack.us/img255/4719/25187227.jpg

  • CAST function issue

    Hi Experts,
    I have use CAST function for change INT to VARCHAR for Time data. When I run the query it through the below error
    *Data value out of range at OCI call OCIStmtFetch. [nQSError: 17012] Bulk fetch failed*
    Please let me know any suggestion.
    Thanks,
    Balaa...

    Hi bala,
    If you use cast function to convert it to varchar cast(column as char) would suffice.
    But the error might be due to the date format in your system....Try this way by giving cast('dd-mon-yy hh:mm:ss' as char) it might work.
    More info :- Convert string to a date
    Is it answered?
    Cheers,
    KK

  • Physical query not accessing Fact Table/Column

    Hi,
    I'm facing a weired issue. I have a report with 32 columns. 22 columns are from 8 dimensions and 10 columns from 3 Facts.
    But while observing the Physical query. Its not touching 1 particular Column coming from 1 Fact Table.
    So, in the query only 2 Fact columns are there and in the report its always Null value.
    When I'm adding a filter on that Fact Column to force Analytics to go and join with that Fact Table, Its not including that Fact Table/Column and producing a very funny query like the following:
    SELECT
    COLUMNS....
    FROM
    TABLES (8 DIMENSION AND 2 FACTS)
    GROUP BY COLUMNS....
    HAVING cast(NULL as DOUBLE PRECISION )>1234
    ================================
    "cast(NULL as DOUBLE PRECISION )>1234" - this is the filter, I have added on that Fact Column.
    Note- It may be because of RPD configurations/joins. But the system (Siebel Analytics 7.8) is in production for 2 years and 500 users using it and nobody reported any issue like this before.
    Can anyone please give me some helpful hint, idea, what is happening?
    Thanks in Advance
    Regards
    Sudipta

    Hi Kishore,
    Thanks for your reply.
    However, I did the analysis and found following, please let me know if your perspective is falling in the same line or not.
    Scenario:
    Suppose all the columns i'm trying to fetch, are coming from 5 dimensions [d1,d2,d3,d4,d5] (some of them are aliased table) and 3 fact tables [f1,f2,f3]
    Now, the report is not fetching data for c1 column which is coming from f3 fact table. Even f3 table is not included in the physical query.
    Now what i found that, there is a dimension suppose d3 which is not having any direct join with f3, but other facts like f1,f2 have joins with d3 table.
    If i remove the columns coming from d3 dimension from report, then f3 fact columns are getting populated in report.
    Problem:
    I need to provide a single physical query for that report, while those report columns are defined by the business.
    Questions:
    1. So is it really possible to create a query for that kind of report without changing the RPD design?
    2. If no, then is the only solution to split that report (i'm thinking) into 2-3 sub reports?
    Thanks all of you for replying and providing your thoughts.
    Regards
    Sudipta

  • Can I use table function inside Dynamic query ?

    Dear Gurus,
    I have following code
    DECLARE
    TYPE CRITERIA_LIST_TABLE AS TABLE OF VARCHAR2(20);
    OtherNoList CRITERIA_LIST_TABLE; /* CRITERIA_LIST_TABLE is index by table*/
    QUERY_STRING VARCHAR2(4000);
    BEGIN
    OtherNoList := CRITERIA_LIST_TABLE();
    SELECT DISTINCT REGEXP_SUBSTR('1,5,6,4', '[^\,]+',1, LEVEL ) BULK COLLECT INTO OtherNoList
    FROM DUAL
    CONNECT BY LEVEL <= REGEXP_COUNT('1,5,6,4', '\,') + 1 ;
    QUERY_STRING := 'INSERT INTO TAB1 (C1,C2) '||
    'SELECT C1,'||
    'C2 '||
    'FROM TAB1 ,'||
    'TABLE( '||
              'CAST (OtherNoList AS CRITERIA_LIST_TABLE) '||
                   ') OTHRNOS '||
    'WHERE TAB1.C1 = OTHRNOS.COLUMN_VALUE ';
    DBMS_OUTPUT.PUT_LINE('Query String is '||QUERY_STRING);
    EXECUTE IMMEDIATE QUERY_STRING;
    END;
    Can I use Table function inside dynamic query.
    Thanking in advance
    Sanjeev

    Try:
    DECLARE
    TYPE CRITERIA_LIST_TABLE AS TABLE OF VARCHAR2(20);
    OtherNoList CRITERIA_LIST_TABLE; /* CRITERIA_LIST_TABLE is index by table*/
    QUERY_STRING VARCHAR2(4000);
    BEGIN
    OtherNoList := CRITERIA_LIST_TABLE();
    SELECT DISTINCT REGEXP_SUBSTR('1,5,6,4', '[^\,]+',1, LEVEL ) BULK COLLECT INTO OtherNoList
    FROM DUAL
    CONNECT BY LEVEL <= REGEXP_COUNT('1,5,6,4', '\,') + 1 ;
    QUERY_STRING := 'INSERT INTO TAB1 (C1,C2) '||
    'SELECT C1,'||
    'C2 '||
    'FROM TAB1 ,'||
    'TABLE( '||
    'CAST (:OtherNoList AS CRITERIA_LIST_TABLE) '||
    ') OTHRNOS '||
    'WHERE TAB1.C1 = OTHRNOS.COLUMN_VALUE ';
    DBMS_OUTPUT.PUT_LINE('Query String is '||QUERY_STRING);
    EXECUTE IMMEDIATE QUERY_STRING using OtherNoList;
    END;p.s. not tested
    Amiel Davis

  • I need To Understand the "Type Cast Function"

    Dears,
    I need To Understand How the "Type Cast Function" Work, and if you can Give me an Example it will be Apperciated
    BR
    Ahmed

    In its simplest explanation Type Cast allows you to reinterpret a series of bytes. The numeric conversion functions convert from one data type to another and essentially do the same thing that Type Cast does, albeit with just numbers. Type Cast allows you to extend this to convert one data type to another, beyond just numbers. Thus, you could convert an array of 2 U8 values into a single U16 number by using Type Cast like this:
    or you could reinterpret an array of lots of U8 values into an array of U16 values like this:
    How you use it is entirely up to you, but it is an extremely powerful function. What are you trying to do?
    Attachments:
    Example_VI.png ‏6 KB
    Example2_VI.png ‏11 KB

  • Basic functions (high) in query formula for highest # of days past due

    Hi All,
    I hope you can help.  I am trying to create a formula in a query for FIAR Line Item Cube (0fiar_c03).  I would like to calculate the hightest number of days past due for open line items.  There is an operator 'high' in basic functions within the query formula.  Is it possible to use this?
    Regards,
    Cheryl Adamonis

    There is a workaround usind conditions.That is you can try to filter the top 10 % or top 10 after calculating the no of days past.However this way you will not be displaying complete dataset

  • What is the diff b/w logical query and physical query?

    Thanks In advance

    In OBIEE terms the logical query is how you query the BI Server, the Presentation services sends logical SQL to the BI Server, you can also write your own using JDBC , pull from BI Server using ODI etc.
    The BI Server engine takes this logical query and writes (a number of) phyiscal querie(s) to satisfy the logical request, depeninding on how your BMM and Physical layer is setup. There are a number of rules the BI Server evaluates before deciding the most appropriate Physical query to generate, rules include Physical Joins, Aggregate tales / Hierarchy levels and so on.
    Hope this helps,
    Good luck with interview :-)
    Alastair

  • Report- Pl/sql function returning sql query parsing page items as text?

    Hi Team,
    I am facing a strange issue .
    I have four page items namely
    1)JOB_CODE
    2)MIN_EXP
    3) MAX_EXP
    4) SOURCES1
    I have a report of the type "Pl/sql function returning sql query"
    declare
    v_sql varchar2(4000);
    begin
    if (:JOB_CODE IS NOT NULL and :MIN_EXP IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
    v_sql:= 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
    elsif (:JOB_CODE IS NULL and :MIN_EXP IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
    v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
    elsif (:MIN_EXP IS NULL and :JOB_CODE IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
    v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where v_experience_years <= :MAX_EXP and V_REQUIREMENT = :JOB_CODE and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
    elsif (:MAX_EXP is null and :JOB_CODE IS NOT NULL and :MIN_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
    v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
    end if;
    insert into query_list values (v_sql);
    insert into debug values (:JOB_CODE , :MIN_EXP , :MAX_EXP , :SOURCES1);
    return v_sql;
    end;
    Please not that I am insertin the query into a table called Query_list and the page item values into the table called Debug thru the pl/sql function which returns teh query.
    Now I select the data from the debug tables.
    select unique(query) from query_list;
    select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like '%:SOURCES1%'
    select * from debug;
    JOBCODE     MINEX     MAXEX     SOURCE
    21     1     10     donkeyHire
    And if I run the query in sql I get some records returned
    select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = 21 and v_experience_years >= 1 and v_experience_years <= and source like 'donkeyHire'
    V_CANDIDATE_ID     V_FNAME     V_CURRENT_EMPLOYER     V_EXPERIENCE_YEARS
    2     Vengu     Andale Tech     4
    But the record does not show up in the report!
    does this type of report parse page items as text?
    Why is it so?
    Waiting for an early reply.
    Thanks,
    venkat

    Venkat - You don't want to put ':SOURCES1' in quotes like that.
    Scott

  • Issue with running PL/SQL function returning Sql query

    hi, I am trying to create a report region by using the option of PL/SQL function returning sql query.
    I notice that it's very slow for the report region page to show up. In my PL/SQL function body, there are only 3 steps, first update all the 10 rows of varchar2 fields to null,then insert values to those fields, then select all from the table to show report results. It takes more than 5 minitues for the page to load up, how ever, if i run those steps in SQL*Plus, it only takes a couple of seconds to finish. Any suggestions?
    Thanks,
    gina

    Sergio, the codes are as followed,
    Declare
    q varchar2(32767); -- query
    Begin
    q := 'select "ID",'||
    '"ENTRY NAME","TOTAL","#CM","%CM","#CA",'||
    '"%CA", from Info_table';
    update info_table
    set "TOTAL" = '',
    "#CM" = '',
    "%CM" = '',
    "#CA" ='',
    "%CA"=''
    where "ID"<=10;
    // set all data in column Total to null,there is only 10 rows in the table
    update info_Table set Total = vTotal,
    "#CM" = vCM
    (those variables hold user key-in Text filed value)
    where ID = 1;
    return q;
    End;

  • Error in using aggregate function in Outer Query in Siebel Analytics

    Hi,
    When I am using aggregate function in outer query in Siebel Analytics I am facing error.
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 59111] The SQL statement must include a GROUP BY clause. (HY000)
    Bellow is the code.
    SELECT test1.username saw_0, test1.desg saw_1,COUNT (test2.querydate) saw_2
    FROM (SELECT POSITION.CBL username,
    POSITION.CBP desg
    FROM "CM"
    WHERE (POSITION.BPTCD = 'Marketing')
    AND (POSITION.EDate =TIMESTAMP '1899-01-01 00:00:00'
    ) test1,
    (SELECT users.UN username,
    measures."Query Count" querycount,
    measures."Max Total Time" secs,
    topic.db dashboardname,
    "Query Time".DATE querydate
    FROM "Plan"
    WHERE (topic."Dashboard Name" IN ('DS'))) test2
    WHERE test2.username = LOWER (test1.username)
    AND test2.dashboardname = 'DS'
    GROUP BY test1.username, test1.desg

    Should your query be a valid SQL query?
    I can't think that the query you have would be valid in a SQL plus window.
    Chris

Maybe you are looking for

  • On my 8500 a plus some apps say they cannot connect to server. others have no problem. Any ideas?

    HP officejet pro 8500 a plus with windows Vista. Since day one trying to use screen on printer to access apps I can access some and other "kids only for example" will say "the printer is unable to access the server. Check your internet connection and

  • Why can I no longer see CS6 in creative cloud

    Why can I no longer see CS6 to download in Creative Cloud?

  • InDesign 6 Buttons Not Displaying Correctly in Acrobat X

    Forgive me if this has been asked. When I create interactive buttons in InDesign 6, their display is erratic in Acrobat X. Sometimes they display correctly. Sometimes, their display is erratic and sometimes they do not display at all. I have noticed

  • White Space in Table

    Hi all, I have created a gallery http://www.davewharton-toastmaster.co.uk/new_site/gallery1.html but the white space is not consistent, there is more vertically than horizontally and looking at the HTML and CSS I can't see what is causing it, could s

  • Asset Depriciation Report (as AR01)

    I am Developing a Report for Asset Depriciation Details with fields - Asset no, Asset sno, Asset desc, Dep key, Plant, Cost  cntr, Asset class, ODep. start,  START BOOK VALUE, Depriciation, end book value & TRANS. ACQ. VALUE. In this, I am unable to