Peculiar results from a simple looking query.

I’ve stumbled upon a peculiar result when querying Oracle which I have not experienced with other DBMS. Consider this example:
create table atable(field varchar(20))
insert into atable values ('This is a test')
select field from atable where cast(field as varchar(2))='Th'
Other DBMS return the single row:
This is a test
Oracle 9.2.10, however generates this result:
Th
Is this a widely known issue with Oracle? Can I change Oracle’s behaviour by tweaking configuration or applying a patch? Is this a bug?

The example I posted was obviously contrived – and I agree – yes I could replace the CAST with SUBSTR. In the real context using CAST just seems an obvious choice - and if I can avoid having to manually modify the queries which already use CAST successfully on other DBMS – then that appeals to my laziness. :-)
I’m finding it tough filing a TAR (what does that stand for?) with Metalink – the website seems to only want users who have a "Support Identifier" - I was not running the SQL on my own server… Any advice – or must I find someone with an existing account to ask on my behalf?
Steve

Similar Messages

  • Different results from all_objects

    Can someone please explain me,
    How it is possible to get different results from "all_objects", once I query it from "SQL Worksheet" and next time when I execute the procedure with the same query ?
    The procedure is created by schema user (owner) and it's executed by it.
    Same as the query.
    I am querying for objects which belongs to other owners.
    Is there a way how to trace which privileges are used for querying the "all_objects" ?
    Any hint will be very welcomed ?

    You are correct, sorry.
    Oracle 11g EE 11.2.0.1.0 - 64bit Production on Windows 2K8
    I already lost my whole day, probably I will lost the weekend, too.
    Here is the sample code:
    CREATE OR REPLACE PROCEDURE PROCEDURE1 AS
    BEGIN
    FOR c IN (SELECT object_name from all_objects d
    WHERE d.owner IN ('DWH_CM')
    LOOP
    dbms_output.put_line(c.object_name);
    end loop;
    END PROCEDURE1;
    Test
    exec procedure1;
    -- does not write anything in output and it is enabled
    select object_name
    from all_objects O
    WHERE o.owner IN ('DWH_CM');
    -- returns 99 rows
    Edited by: user9377205 on Aug 6, 2010 9:06 AM

  • How to get save result from EXECUTE from a dynamic SQL query in another table?

    Hi everyone, 
    I have this query:
    declare @query varchar(max) = ''
    declare @par varchar(10)
    SELECT @par = col1 FROM Set
    declare @region varchar(50)
    SELECT @region = Region FROM Customer
    declare @key int
    SELECT @key = CustomerKey FROM Customer
    SET @query = 'SELECT CustomerKey FROM Customer where ' + @par + ' = '+ @key+ ' '
    EXECUTE (@query)
    With this query I want get col1 from SET and compare it to the column Region from Customer. I would like to get the matching CustomerKey for it.
    After execution it says commands are executed successfully. But I want to save the result from @query in another table. I looked it up and most people say to use sp_executesql. I tried a few constructions as sampled and I would always get this error: 
    Msg 214, Level 16, State 2, Procedure sp_executesql, Line 12
    Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar'.
    So the output should be a list of CustomerKeys in another table.
    How can I save the results from EXECUTE into a variable? Then I assume I can INSERT INTO - SELECT in another table. 
    Thanks

    CREATE TABLE Customer
    (CustomerKey INT , Name NVARCHAR(100));
    GO
    INSERT dbo.Customer
    VALUES ( 1, N'Sam' )
    GO
    DECLARE @query nvarchar(max) = ''
    declare @par varchar(10) = 'Name',
    @key varchar(10) = 'Sam'
    CREATE TABLE #temp ( CustomerKey INT );
    SET @query =
    insert #temp
    SELECT CustomerKey
    FROM Customer
    where ' + @par + ' = '''+ @key+ ''' '
    PRINT @query
    EXEC sp_executesql @query
    SELECT *
    FROM #temp
    DROP TABLE #temp;
    DROP TABLE dbo.Customer
    Cheers,
    Saeid Hasani
    Database Consultant
    Please feel free to contact me at [email protected] as well as on Twitter and Facebook.
    [My Writings on TechNet Wiki] [T-SQL Blog] [Curah!]
    [Twitter] [Facebook] [Email]

  • Results table difference when running query from Alert compared to Query Manager

    Hello,
    I have following query - Aim is to create alert to tell employee which customers to make visit to in next 4 weeks
    SELECT DISTINCT T1.CardName, T1.U_VisitDue, T1.U_VisitReason, T1.U_Priority, T1.U_Region as 'Area', T1.U_VNotes
    FROM dbo.OCRD T1
    WHERE DateDiff(d,T1.U_VisitDue, GETDATE()) <29
    Group BY T1.CardName, T1.U_VNotes, T1.U_VisitDue, T1.U_VisitReason, T1.U_Priority, T1.U_Region
    FOR BROWSE
    My problem is that when I run query through alert the field U_VNotes is displayed differently.
    Running the query from Query Manager the contents of this field appear in one field of the result table.
    Running the query via Alery the content of this field is split into several fields in results table according to 'new line' in field entry.
    This makes the results table from the Query less 'user-friendly' because if you want to sort the table by 'Date' column for example it makes a mess of the table because of the extra rows.
    I want results table to look like top version in picture below ... but i want to run from alert.
    Is this possible?
    How can I achieve it?
    Thanks for any assistance
    Regards, Karen

    Hi
    check this support note:1774628 The SQL SELECT DISTINCT Statement does not work in ALERTS
    Kind regards
    Agustín Marcos Cividanes

  • Create Materialized View based on Results from LDAP Query

    Hi -- I'm trying to create a materialized view based on results from an LDAP query. Unfortunately, it looks like a materialized view can't be created based on a stored procedure, which is where the LDAP results are obtained (using nested loops).
    Does anyone have any idea how to do this without first kicking off a stored procedure that populates a temp table which would be used to create the materialized view? I'm trying to minimize the steps that the DBA's will need to go through when refreshing this new view.
    Thanks,
    ~Christine

    Can you give us more details about the stored procedure you're calling. It will help to know what parameters are involved and what data types they are.
    Off the top of my head though it looks like, at the very least, you would need a stored function that calls the stored procedure. I don't think there is any way to call stored procedures from CREATE ... commands. If you're going to create a stored function anyway ... well, you might as well just create a procedure that inserts values into a regular table instead of fussing with functions and materialized views. You'll probably want to schedule your new procedure to run periodically since it sounds like you'll need the values refreshed from time to time.

  • Getting number of results from mysql query.

    Hi,
    Is there an easy way to get the number of rows (results) returned by a mysql query without looping through each result and incrementing using the rs.next()?
    Statement statement = connection.createStatement();
                   ResultSet rs = statement.executeQuery("SELECT * FROM sometable WHERE name=\"John\"");
                   

    Have you looked at the mysql documentation at all ?
    What about "SELECT count(*) FROM sometable WHERE name=\"John\"");
    And if this value is going to be dynamic at all consider using a preparedStatement.
    Note Haven't worked with MySql so this isn't guarenteed to work, but you get the idea. This is more of a sql question than a java question

  • Unicode String Issue while Using Results from Another Query

    Hi All,
    In a webi report i have 2 queries say Sales Out and Investment. I need to have only those chains which are in Investement in Sales Out.
    So in Sales Out query i am using the option Results from another Query. The Chain values are in Unicode format.
    Though in universe i have Set Parameter Unicode_String ='Yes', this does not get applied when using option Results from another Query.
    Is there any solution to resolve this problem.
    Thanks
    Madhura

    leonhardtk wrote:
    I need to take values from the column of one table that meets certain critera, and create inserts into another table that includes this data.
    For example...
    {code}
    select emp_last_name from emp where emp_first_name like 'B%';
    Duncan
    Fitzgerald
    Johnson
    Smith
    {code}
    I then want to insert these values into another table:
    {code}
    insert into My_table values (
    sequence.nextval,99,99,[last_name]);
    {code}
    In the example above, I need it to insert a new row into My_table for where the "last_name" is each of the names from the select statement above (Duncan, Fitzgerald,Johnson,Smith).
    Based on other similar forum questions it looks like I should be doing something like:
    {code}
    INSERT INTO MY_TABLE
    (SELECT sequence.nextval,
                    99,
                    99,
                   (select EMP_LAST_NAME
                    FROM EMP
                    WHERE EMP_FIRST_NAME LIKE 'B%')
    {code}
    But this (obviously) doesn't work!
    Appreciate any assistance on this!
    KSL.
    Hi,
    Created this test data
    create table plch_test (name varchar2(50));
    insert into plch_test values('AKSHAY');
    insert into plch_test values('RAHUL');
    insert into plch_test values('APARNA');
    output
    1    AKSHAY
    2    RAHUL
    3    APARNA
    created another destnation table(in your case "my table")
    create table plch_test_1 (id number,name varchar2(50));
    created another sequence to generate employee ids
    create sequence test_seq;
    Now populated the desination table
    insert into plch_test_1(select test_seq.nextval,name from plch_test);
    verify the destination table
    select * from plch_test_1
    1    AKSHAY
    2    RAHUL
    3    APARNA
    Hope this helps
    Regards,
    Achyut Kotekal

  • How to compare result from sql query with data writen in html input tag?

    how to compare result
    from sql query with data
    writen in html input tag?
    I need to compare
    user and password in html form
    with all user and password in database
    how to do this?
    or put the resulr from sql query
    in array
    please help me?

    Hi dejani
    first get the user name and password enter by the user
    using
    String sUsername=request.getParameter("name of the textfield");
    String sPassword=request.getParameter("name of the textfield");
    after executeQuery() statement
    int exist=0;
    while(rs.next())
    String sUserId= rs.getString("username");
    String sPass_wd= rs.getString("password");
    if(sUserId.equals(sUsername) && sPass_wd.equals(sPassword))
    exist=1;
    if(exist==1)
    out.println("user exist");
    else
    out.println("not exist");

  • How to use Results from Another Query for SAP BW universes

    Hi Everyone,
    I have two SAP BI universes.In my First universe I have Sales Doc no (dimension) and Orderqty (Measure) and in my second universe I have Sales Doc no(Dimension) and BillQty (Measure).
    Here in my first dataprovider I have 1200 rows of data and in second dataprovider I have 75,000 rows. The report should fetch only the BillQty details that matches to corresponding  Sales doc no in first data provider.
    I want to place all these fileds into a single report like as shown.
    (Datarpovider1)                (Datarpovider1)                    (Datarpovider2)
    *Sales Doc No*               Orderqty                           BillQty
    Here I am able to generate single report using merge dimension but it is leading to performance issues. I want to restrict the values at query level by passing the First dataprovider Sales doc no to second Data provider Sales doc number using Results from Anothery Query feature so that It can fetch only the matching records.
    I tried it but it was giving the follwing error:
    A filter contains a wrong value. You cannot run this query. (Error: WIS 00007)
    How Can I get rid of this error. Can we use Results from Anothery Query option for OLAP universe. Are there any limitation on it.
    All this I am doing in Webi Rich Client.
    Appreciate your help
    Thanks &in Advance
    Kiran Saka

    Hi Kiran,
    I think the filter has a wrong operand. For example, a filter with an empty constant, or a filter that deals with numeric values is defined with an alphanumeric value.Check out for this.
    Regards,
    Neeraj

  • Can we use Result from another query in Webi using Bex uery universe?

    Hi,
    Can we use Result from another query filter option in Webi to create a report using a Bex Query universe?
    I need to create a report using two universes, one is Bex Query Universe and the other is Orcle universe. I have two queries, one is using Oracle universe; the other using Bex Query universe. I need to pass the Oracle data from the Oracle query to the Bex Query query to get the matched data from SAP Bex query.
    I used Result from another query in the query filter panel for the query using Bex query universe. But I got an error saying that 'A filter contains a wrong value. you cannot run this query. (Error: WIS 00007). The data used in the filter on both sides are the same. they are char.
    I have tested by using two queries from the same Bex query universe to see if the Result from another query filter option works. And I got the same error.
    Has anyone run into the same issue and if this is possible and what should be the solution?
    Thanks in advance!
    Edited by: BO_Haiyan on Oct 6, 2010 3:47 PM

    In that situation:
    Create two queries : Oracle and BW query.
    @ Report:
    As you have to see result set from both the Dataproviders, correct? To achieve thise one must have common dimension objects to merge them at report and use Objects those are coming from both queries to use them in single Table/Report.
    Unless you don't use Merge Dimensions, you don't get a chane to use both queries objects in single Table/Report. (It will give tooltip saying: You can't drop here -- Incompatable Objects)
    In case, if you don't have common dimensions, change object definitions to Detail objects, for those required.
    Hope it helps you.
    Thank You!!

  • Simple Select query but not arriving at results!

    Hello All,
    I have a table with primary key (antrag_nr, beladeflag, stempel)
    Desc test88
    Name Null? Type
    ANTRAG_NR NOT NULL NUMBER
    A_PROZESS NUMBER
    STEMPEL NOT NULL DATE
    BELADEFLAG NOT NULL VARCHAR2(1)
    desc test99
    Name Null? Type
    ANTRAG_NR NOT NULL NUMBER
    A_PROZESS NUMBER
    STEMPEL NOT NULL DATE
    BELADEFLAG NOT NULL VARCHAR2(1)
    select * from test99;
    ANTRAG_NR A_PROZESS STEMPEL B
    2 4 05-JAN-05 m
    1 6 07-JAN-05 m
    1 7 08-JAN-05 m
    1 8 09-JAN-05 m
    2 5 06-JAN-05 m
    select * from test88;
    ANTRAG_NR A_PROZESS STEMPEL B
    1 1 01-JAN-05 m
    1 2 02-JAN-05 m
    1 2 03-JAN-05 m
    1 3 04-JAN-05 m
    2 1 01-JAN-05 m
    2 2 02-JAN-05 m
    2 3 04-JAN-05 m
    1 4 05-JAN-05 m
    1 5 06-JAN-05 m
    1 6 07-JAN-05 m
    2 4 05-JAN-05 m
    ANTRAG_NR A_PROZESS STEMPEL B
    1     7 08-JAN-05 m
    My query:
    insert into test88
    (select a.antrag_nr, a.a_prozess, a.stempel, a.beladeflag from test88 a, test99 b
    where
    a.antrag_nr = b.antrag_nr
    and
    a.a_prozess not in (select a_prozess from test99 where antrag_nr = a.antrag_nr)
    and
    a.stempel = ( select max(stempel) from test88));
    what the query does is:
    selects the highest value for the entire stempel column in table test88 and checks the condition a.antrag_nr = b.antrag_nr &a.a_prozess not in (select a_prozess from test99 where antrag_nr = a.antrag_nr)
    but what I would like to have is
    that it should check the max(stempel) for each antrag_nr in test88 & then insert.
    For example when antrag_nr = 1 and then the max (stempel) in table test 88 => 08-jan-2005
    Then it should check with the antrag_nr =2
    and then max(stempel) in the table test88 => 05-JAN-05 and then insert the table test88 from the source table test99 & so on
    according to my query it checks the highest values of stempel column 08-jan-2005 where antrag_nr=1
    but it doesn’t check for antrag_nr = 2 at all.
    How can I arrive at such a result, Can anyone throw some insight..
    Thanks in advance,
    Karthik krishna.
    -- Thanks to splazm for answering my previous post!

    Hello All,
    I have a table with primary key (antrag_nr, beladeflag, stempel)
    Desc test88
    Name Null? Type
    ANTRAG_NR NOT NULL NUMBER
    A_PROZESS NUMBER
    STEMPEL NOT NULL DATE
    BELADEFLAG NOT NULL VARCHAR2(1)
    desc test99
    Name Null? Type
    ANTRAG_NR NOT NULL NUMBER
    A_PROZESS NUMBER
    STEMPEL NOT NULL DATE
    BELADEFLAG NOT NULL VARCHAR2(1)
    select * from test99;
    ANTRAG_NR A_PROZESS STEMPEL B
    2 4 05-JAN-05 m
    1 6 07-JAN-05 m
    1 7 08-JAN-05 m
    1 8 09-JAN-05 m
    2 5 06-JAN-05 m
    select * from test88;
    ANTRAG_NR A_PROZESS STEMPEL B
    1 1 01-JAN-05 m
    1 2 02-JAN-05 m
    1 2 03-JAN-05 m
    1 3 04-JAN-05 m
    2 1 01-JAN-05 m
    2 2 02-JAN-05 m
    2 3 04-JAN-05 m
    1 4 05-JAN-05 m
    1 5 06-JAN-05 m
    1 6 07-JAN-05 m
    2 4 05-JAN-05 m
    ANTRAG_NR A_PROZESS STEMPEL B
    1     7 08-JAN-05 m
    My query:
    insert into test88
    (select a.antrag_nr, a.a_prozess, a.stempel, a.beladeflag from test88 a, test99 b
    where
    a.antrag_nr = b.antrag_nr
    and
    a.a_prozess not in (select a_prozess from test99 where antrag_nr = a.antrag_nr)
    and
    a.stempel = ( select max(stempel) from test88));
    what the query does is:
    selects the highest value for the entire stempel column in table test88 and checks the condition a.antrag_nr = b.antrag_nr &a.a_prozess not in (select a_prozess from test99 where antrag_nr = a.antrag_nr)
    but what I would like to have is
    that it should check the max(stempel) for each antrag_nr in test88 & then insert.
    For example when antrag_nr = 1 and then the max (stempel) in table test 88 => 08-jan-2005
    Then it should check with the antrag_nr =2
    and then max(stempel) in the table test88 => 05-JAN-05 and then insert the table test88 from the source table test99 & so on
    according to my query it checks the highest values of stempel column 08-jan-2005 where antrag_nr=1
    but it doesn’t check for antrag_nr = 2 at all.
    How can I arrive at such a result, Can anyone throw some insight..
    Thanks in advance,
    Karthik krishna.
    -- Thanks to splazm for answering my previous post!

  • Query on results from another query

    Post Author: Duncan1980
    CA Forum: Crystal Reports
    Is it possible to query on the results from another query.  I have a query that produces a list of document numbers.  I want to use the output from that query as the filter criteria in a another query in the same Universe. 
    The output from the first query can be as much as 2000, so it would be very time consuming to cut and paste these into a filter.
    Both reports are built, but can not figure out how to link the first report output to the filtering criteria on the second report.  I
    I am using business objects XI release 2 web intelligence 11.5.3.417 enterprise.

    Hi Vivek,
    It was not directly solved but I applied alternate logic to over come the issue.
    Here's what I did to overcome:
    I used a sub query in place of the whole result from another query.
    For Ex:
    Dim1 inlist result from another query1
    I made it as
    Dim1 inlist (Dim0)
    where Conditions.
    Here Dim0 is the object which we use for Result from another query and Conditions will be the necessary filter conditions to arrive proper Dim0.  Make sure proper context is formed for the sub query.
    Even though it resolved my problem, It introduces an new issue. It causes increase in query run time when huge set of data is returned from sub query.
    Please let me know if i haven't explained clearly.
    Hi Aris_BO,
    Sorry for not responding earlier.  The logic would probably make more queries null & not null. Thats why I was not advised to use it.
    Thanks
    LN

  • Results from another Query - not available

    HI,
    My environment is Business Objects XI 3.1 SP2 Edge series , i have  below quereis with web Intelligence Reports
    1. not available  the functions/options  Results from another Query(Any) or Results from another Query(ALL) at Query Level.
    2. not getting list of Values for pronpt until i refresh values for prompt?
    Please suggest me is there any fix packs available for the same to availle that functionality.
    Best Regards,
    Reddeppa K

    not getting list of Values for pronpt until i refresh values for prompt?
    There is option called  "Automatic refresh before use"  for the object properties available in the universe designer.
    Please check the box for the object you are using for populating the list of values and export the universe.
    not available the functions/options Results from another Query(Any) or Results from another Query(ALL) at Query Level.
    There is a limitation for the query on query functionality that the both the queries can-not be from the OLAP universe.
    I guess the query which needs to be filtered should be built on universe from the relational data base.
    Regards,
    Rohit

  • Alternative for result from other query  and merge dimension option option

    Hi Everyone ,
    Am Developing one webi report over bex Query.
    Actual scenario is output of one webi report should be the input of other webi report.
    Eg:
    Table 1
    2010        Cus 1
    2010        Cus 2
    2011        Cus 3
    table 2
    cus1    m1   100
    cus2    m2   200
    Cus3    m1  400
    Report 1 designing 
    First report created using table 1 and prompt for year
    Report  2 designing
    Second report created using table2 and prompt for customer
    So when am Running first report it will ask for parameter year and if am selecting 2010 then the report will return C1 and C2
    this out put should e the input for report 2.
    So out put will be 100+200=300
    NOTE:1. Result from other query is not working in webi filter pane since am building on olap universe.
               2. Merge Dimension performance is very slow .
    Any Solution ?
    Regards,
    Kannan.B

    Hi,
    Thanks for ur reply
    As you said , If am giving hyperlink to other report .
    Eg: User selected Tamilnadu then report 1 opened  then  he has to click the some cell or hyperlink cell to view the actual report(2nd report).
    Suppose user Clicked that hyperlink cell and 2nd report opened and he is viewing the data for Tamil nadu and he decided to see the report for
    Andrapradesh so according to this logic he has to select first report and refresh the data for Andra and from there he has to come to 2nd report.
    totally 4 screen will be opened for seeing the two states report.
    So Some other alternative.......

  • Issue with Results from Another Query (Error on Null value)

    Hi All,
    We have a WebI report using "Result from Another Query" option of BO XI R3.1. The report was running fine till recently the dimension object using result from another query had a null value. Report suddenly throwed error as the query filters are invalid.
    Is there a way to make this filter optional if no data/null value is there ? Because we need those null values in report as well.
    Thank you for your time.
    Thanks & Regards
    LN

    Hi Vivek,
    It was not directly solved but I applied alternate logic to over come the issue.
    Here's what I did to overcome:
    I used a sub query in place of the whole result from another query.
    For Ex:
    Dim1 inlist result from another query1
    I made it as
    Dim1 inlist (Dim0)
    where Conditions.
    Here Dim0 is the object which we use for Result from another query and Conditions will be the necessary filter conditions to arrive proper Dim0.  Make sure proper context is formed for the sub query.
    Even though it resolved my problem, It introduces an new issue. It causes increase in query run time when huge set of data is returned from sub query.
    Please let me know if i haven't explained clearly.
    Hi Aris_BO,
    Sorry for not responding earlier.  The logic would probably make more queries null & not null. Thats why I was not advised to use it.
    Thanks
    LN

Maybe you are looking for

  • HT1349 I over scratched the code on my $25 iTunes Gift Card and I cant read it, what do I do?

    i overscratched the label on my $25 itunes card and about half of the redemption code is unavailble i dont want to waste the money value and i already went back to the retailer i purchased the card and they couldnt do anything and then i tried going

  • Re: [SunONE-JATO] JatoTutorial

    Fr?d?ric-- In the case of a GET, all the information required to reconstruct the target page is available in the address bar, and thus bookmarks work fine. When the user does a POST, the same information does not appear in the address bar and bookmar

  • Customer master data search and use limit

    Hello everyone I have a problem that our customer want to limit that A user of SAP  can search and use the customers master data which he or she created only .what should I do ?  thanks!

  • CRM 2007 Upgrade - Std Comm. Method not visible in "More Fields"

    Hi Gurus We recently upgraded from CRM 5.0 to CRM 2007. I'm verifying the Identify Account views, when I compare the "More Fields" view between CRM 5.0 and CRM 2007, the "Std Comm. Method field is not there. I though I could add this via configuratio

  • PSE 9 + Win 8.1

    Hallo - bin neu hier und habe die folgende Frage: Mit dem Öffnen der Panoramafunktion in PSE 9 stürzt PSE komplett ab. Betriebssystem Win 8.1 und leider kann ich da auch nicht alternativ was machen (ausser zurück Win7) Hat jemand einen Rat? Danke.