Different Result for SQL and PL/SQL query..need a bit of help

If i just run:
SELECT COUNT(*) from DB where (CLOSE_TIME-OPEN_TIME<5) and (CLOSE_TIME-OPEN_TIME>=1) and OPEN_TIME>'1/1/2011';
It works great.
If I run
BEGIN
SELECT COUNT(*) from DB where (CLOSE_TIME-OPEN_TIME<5) and (CLOSE_TIME-OPEN_TIME>=1) and OPEN_TIME>'1/1/2011';
END
I get the following error.
ORA-04052: error occurred when looking up remote object [email protected]
ORA-00604: error occurred at recursive SQL level 3
ORA-06552: PL/SQL: Compilation unit analysis terminated
ORA-06553: PLS-488: invalid variable declaration: object 'NUMBER' must be a type or subtype
ORA-02063: preceding 2 lines from SMGLINK

Hi,
Whenever you have a problem, post a complete test script that people can run to re-create the problem and test their ideas. Include CREATE TABLE and INSERT statements for any or your own tables needed.
Post the results you want from that sample data.
Always say which version of Oracle you're using.
bostonmacosx wrote:
If i just run:
SELECT COUNT(*) from DB where (CLOSE_TIME-OPEN_TIME<5) and (CLOSE_TIME-OPEN_TIME>=1) and OPEN_TIME>'1/1/2011';If OPEN_TIME is a DATE, then don't try to compare it to a string, such as '1/1/2011'. (This is not related to the present problem, only a future one.)
It works great.
If I run
BEGIN
SELECT COUNT(*) from DB where (CLOSE_TIME-OPEN_TIME<5) and (CLOSE_TIME-OPEN_TIME>=1) and OPEN_TIME>'1/1/2011';
END
I get the following error.
ORA-04052: error occurred when looking up remote object [email protected]
ORA-00604: error occurred at recursive SQL level 3
ORA-06552: PL/SQL: Compilation unit analysis terminated
ORA-06553: PLS-488: invalid variable declaration: object 'NUMBER' must be a type or subtype
ORA-02063: preceding 2 lines from SMGLINKI would expect a different error "PLS_00428: an INTO clause is expected".

Similar Messages

  • Different Results from SQL-Query in Oracle 10.2 and  Oracle 11.2

    Look at the following example:
    CREATE TABLE GZP_PLAN (GZP_ID
    NUMBER(9) NOT NULL, PARENT_GZP_ID NUMBER(9),
    CONSTRAINT GZP_PLAN_PK1 PRIMARY KEY(GZP_ID)
    USING INDEX
    TABLESPACE USERS
    TABLESPACE USERS;
    insert into GZP_PLAN values(1,NULL);
    CREATE TABLE GZP_WB (OBJECTID NUMBER
    NOT NULL, GZP_ID NUMBER(10),
    CONSTRAINT GZP_WB_PK1_1 PRIMARY KEY(OBJECTID)
    USING INDEX
    TABLESPACE USERS
    TABLESPACE USERS;
    insert into GZP_WB values(1,1);
    CREATE OR REPLACE VIEW VW_GZP (GZP_ID1) AS
    SELECT xxx.gzp_id
    FROM gzp_plan xxx
    WHERE gzp_id IN (
    SELECT MAX (z.gzp_id) zzz
    FROM gzp_plan z
    START WITH z.gzp_id = xxx.gzp_id
    CONNECT BY PRIOR gzp_id = parent_gzp_id);
    -- query
    select a.* from GZP_WB a where gzp_id in (select gzp_id1 from vw_gzp);
    Result in Oracle 10.2. (Windows Server 2003 32-bit, Oracle 10.2.0.2 or Oracle 10.2.0.5, Enterprise Edition)
    OBJECTID     GZP_ID
    *1 1*
    Result in Oracle 11.2 (Windows Server 2008 64-bit, Oralcle 11.2.0.2, Enterprise Edition or Standard Edition One)
    no rows selected
    The result of the following queries are identical in Oracle 10.2 and 11.2
    SQL> select * from GZP_WB where to_char(gzp_id) in
    2 (select to_char(gzp_id1) from vw_gzp);
    OBJECTID GZP_ID
    1 1
    SQL>
    SQL> select a.* from GZP_WB a, vw_gzp b where a.gzp_id=b.gzp_id1;
    OBJECTID GZP_ID
    1 1

    The solution is Oracle 11.2.0.3 - patchset released 11th November.

  • Different results for table and dimension operator

    hi
    I am new to Oracle and specially Data Warehousing.
    I created a mapping with a target operator Dimension, it does not give the desired result. Then I changed the target operator to a table, which gives the expected result. All others are the same like the join condition etc.
    I think there is some problem with the dimension, please, help me finding the problem of the dimension.
    Details of the dimension: there are two levels in the dimension. the surrogate key for both the levels is the same (ID) but business keys are different. The business key of the level 1 appears in level 2 and is properly mapped to the same attribute. the surrogate key of both the levels in not mapped to any attributes.
    regards
    Arif
    P.S: I tried to include a screen dump of the mapping here, but not possible.

    I used @section and <?fo:page-number?> of <?fo:page-number-citation:xdofo:lastpage-joinseq?> but I still get wrong numbering by group
    Group1:- 1 of 6
    Group1:- 2 of 6
    Group2:- 1 of 6
    Group3:- 1 of 6
    Group4:- 1 of 6
    Group4:- 2 of 6
    the syntax <?fo:page-number-citation:xdofo:lastpage-joinseq?> is getting total document pages instead of group pages. Desired output is
    Group1:- 1 of 2
    Group1:- 2 of 2
    Group2:- 1 of 1
    Group3:- 1 of 1
    Group4:- 1 of 2
    Group4:- 2 of 2
    Below is my syntax
    In Header section <?for-each@section:G_VENDOR?>
    <?fo:page-number?> of <?fo:page-number-citation:{generate-id()}?>
    In Body
    <?start:body?>
    <?end body?>
    <?split-by-page-break:?>
    <?end for-each?><fo:block id="{generate-id()}"/> --this is in form field
    Please help.
    Thanks,
    Venkat

  • 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");

  • SQL query needed to identify cancelled invoice where distribution lines

    SQL query needed to identify cancelled invoice where distribution lines Debit is not equal Credit line item in particular
    Is there a way from back end FROM ap_invoice_distributions_all where we can find for the cancelled invoice where distribution lines Debit is not equal Credit line item
    Regards,
    Prakash Ranjan

    Hello Prakash
    Can you please see if this query helps you?
    SELECT i.invoice_id, i.invoice_amount, nvl(sum(d.amount),0)
    FROM ap_invoice_distributions_all d, ap_invoices_all i
    WHERE i.org_id = <you org_id>
    AND i.invoice_id = d.invoice_id
    AND d.line_type_lookup_code not in ('PREPAY')
    AND i.cancelled_date IS NOT NULL
    GROUP BY i.invoice_id, i.invoice_amount
    HAVING (i.invoice_amount <> nvl(sum(d.amount),0))
    ORDER BY i.invoice_id asc
    Octavio

  • Setting mail with Cox (or other services with different servers for pop and smtp)

    My Cox mail account uses different servers for pop and smtp (my personal ISP 1&1 does too).
    The mail applet on my Blackberry Curve 8330 with Verizon does not allow to define different servers for pop and smtp, and further, for SSL smtp mail, the port is fixed at 995 and cannot be changed, while Cox (and 1&1) want to use 587 or something like that.
    As a result, I can only receive mail with these services.
    I also have yahoo mail, which works fine, so I can send mail with it and it is not a life-and-death situation, but I would like to be able to just reply to email sent to my Cox address.
    I called Verizon and they said BlackBerry provides the mail access through their servers and the applet, so there is nothing they can do.
    Is there a way to set it such that I can not only receive but also send mail through either of these services?
    Thanks in advance,
    Didier
    PS: Other than that, the Curve on Verizon rocks!!! so much better down here than AT&T it's not even funny.

    OK, thank you for the input.
    The problem I have with this solution is like the one I have now using yahoo.
    There are 2 problems:
    1) mailing lists want the mail to come from the account that is subscribed, so if the cox account is subscribed, I can't contribute from the blackberry, and if the blackberry account is subscribed, I don't get my mail in Outlook. Neither is good for me.
    2) people who send me mail to the Cox account and get replies from me from the blackberry continue responding to the account that can send from the blackberry (not Cox), and from that point on I do not have that mail on the computer.
    The issue of having two copies is no big deal, I just delete the mail I do not need. I would rather have two than none.
    Really, Blackberry should modify the email service so that they directly support mail systems like those of Cox and 1&1. I am sure there are others. They should also allow the use of another port for SSL than 995. I have not seen anyone using 995 for SSL.
    Until recently, I had a BB provided by my employer, and we had a BES, and that worked really well. I would like to emulate as much of that functionality as possible without having to pay somebody another $10 or $20 a month just for the priviledge of having an account on a private BES server.
    Anyway, thanks for the exchange and suggestions.
    Didier

  • Different result in IE and Netscape

    Hi,
    I am using JDeveloper 3.2 to create my JSP and BC4J. I deployed them into my web server, but I got different result in IE and Netscape. I amd using web bean method to create my JSP.
    When I view my JSP from IE, everything looks as expected. But when I view them from Netscape, some pages did not display correctly.
    1. For the JSTab, the Netscape displays different color(blue) in the help text area, but the IE display gray color.
    2. If I have a table with many columns (e.g.25) to be displayed and my browser is too small to display them all, the Netscape displays JSRowSetBrowser incorrectly. The top right corner, and bottom right corner did not display at the last column side, instead it displaying in the middle of my JSRowSetBrowser. It also suppressed my one button in the same page. IE displays them all properly.
    How do I fix this problem? Please help.
    I am using webapp/cabo/images/cabo_styles.css as my style sheet.
    Lisa
    null

    I'm not an expert on Netscape, but I would guess that you're problems are simply caused by the differences between IE and NS.
    It is very difficult to write (functional) JS code that works perfectly between the two of them and I bet that JSTab isn't written in such a way.
    You may want to try using your own tab object, we do this by creating a page for each tab and making the actual tabs be links to each page. This avoids the use of JavaScript.
    Good Luck!!!

  • Is it possible to play different sounds for emails and instant messages ?

    Hello,
    I was wondering if it was possible to play different sounds for emails and instant messages. I am using Thunderbird quite often with both emails and instant messages imported from Gtalk.
    I think it would be very convenient to be able to distinguish both sounds as they do not imply the same things.
    Thank you very much.
    Olivier Hubert.

    There are only six chat add-ons, three of them are about notifications. Pick one you think will do the job for you. https://addons.mozilla.org/en-US/thunderbird/extensions/chat/?sort=popular

  • I have an iphone 3g I tried to dl an app for netflix and it said i need to have ISO 5 but my phone has ISO 4.2.1 and when i try to update it I get message saying I have current version how or what can i do do to get an app the lets me watch netflix on my

    I have an iphone 3g I tried to down load  an app for netflix and it said I  need to have ISO 5 but my phone has ISO 4.2.1 and when I  try to update it on my computer through itunes  I get message saying I have current version how or what can I do do to get an app the lets me watch netflix on my  iphone 3g .Is there an sulision to my problem? I also tried another app with another name diff from netflix and I got the same message saying i need ISO 5 .Someone please help  thank you

    Thank you for your help are you aware of any apps that will work the iso 4.2.1 system that will let you watch movies on the phone. Also I tried to down load something else the other day and got message that Safari wont let you open this is ther any to see if i have the latest safari on my phone?

  • IPhoto 9.4 sliders for shadows: and highlights: only give black page. can anyone help?

    iPhoto 9.4 sliders for shadows: and highlights: only give black page. can anyone help?

    While we all have MacBooks in this forum not all of us use iPhoto. There's an iPhoto Support Community where everybody uses iPhoto. You should also post this question there to increase your chances of getting an answer.   https://discussions.apple.com/community/ilife/iphoto

  • Everytime i need to add a song in my i phone,it always ask for earse and sync option,i need to avoid that a add songs manually.

    everytime i need to add a song in my i phone,it always ask for earse and sync option,i need to avoid that and add songs manually.

    https://support.apple.com/kb/ht1535

  • I was changing my desktop screen saver in system preferences screen protection.  Now it says it is "Loading Images" and won't stop.  The Colourful wheel goes around for ever and It does not stop. Can anyone help me?

    I was changing my desktop screen saver in system preferences>screen protection.  Now it says it is "Loading Images" and won't stop.  The Colourful wheel goes around for ever and It does not stop. Can anyone help me?

    Welcome to the Apple Support Communities
    I have seen a lot of cases like your issue, and it's easy to solve.
    First, open Disk Utility, select Macintosh HD in the sidebar and repair permissions. Sometimes, a permission can be damaged and it makes that an application doesn't work properly.
    If that doesn't work, open Finder, select Go menu > Go to Folder, type ~/Library/Prefereces, delete "com.apple.desktop.plist" and "com.apple.systempreferences.plist" and restart

  • I've just downloaded a sd movie from iTunes with my ipad but the movie will only play for 13s then a msg comes up saying "could not load video! I've paid for it and downloaded the whole thing ! Can anybody help me pls?

    I've just downloaded a sd movie from iTunes with my ipad but the movie will only play for 13s then a msg comes up saying "could not load video! I've paid for it and downloaded the whole thing ! Can anybody help me pls?

    Hello Lcw2610,
    I would recommend deleting the affected movie from your iPad, and redownloading the movie.
    How to delete content you've downloaded from the iTunes Store, App Store, iBooks Store, or Mac App Store
    http://support.apple.com/kb/HT5772
    Download past purchases
    http://support.apple.com/kb/HT2519
    If the issue persists, please do report the issue to the folks in our iTunes Store.
    To report an issue with your iTunes Store, App Store, Mac App Store, or iBooks Store purchase, follow these steps:
    Find the email receipt for your purchase.
    Click Report a Problem under the app that is having the issue.
    When prompted, enter the Apple ID and password you used to purchase the item, then click Report a Problem.
    Click Report a Problem next to the item you are having an issue with.
    From the Choose Problem dropdown menu, choose the appropriate issue.
    Follow the onscreen instructions and—if prompted—type a description of the problem into the text field.
    Click Submit to have your issue reviewed.
    How to report an issue with your iTunes Store, App Store, Mac App Store, or iBooks Store purchase
    http://support.apple.com/kb/HT1933
    Cheers,
    Allen

  • Xml parsing error while selecting whole result set for sql query

    Hi All,
    I am having xml parsing error while selecting whole query result set. The data is coming fine for default result set of 50 rows.
    My exception is below.
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00234: namespace prefix "xsi" is not declared
    Error at line 1
    ORA-06512: at "SYS.XMLTYPE", line 254
    ORA-06512: at line 1
    *31011. 00000 - "XML parsing failed"*
    **Cause: XML parser returned an error while trying to parse the document.*
    **Action: Check if the document to be parsed is valid.*
    My sql query is below that is giving results for default result set of 50 rows.
    select extract(xmlType(clob_xml_colm_name), '//v2:node1//childnode/text()','xmlns:v2="namespace_url"').getStringVal()  from table_name
    My sql developer version is below.
    Java(TM) Platform     1.7.0_04
    Oracle IDE     3.1.07.42
    Versioning Support     3.1.07.42
    My database version is below.
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit
    Please could any one help me urgently as the sql query is supposed to be correct as it is returning query results, but the problem happening when i try to select whole result set.
    Thanks and regards,

    What does the XML look like? It appears that some of the supposed XML stored as a CLOB is not really valid XML. Find the row in the table that is causing your issue and review the "XML" in it.

  • To_char displays different results on sql client and server

    Hi,
    I am executing the below query on my database with 8.1.7.4 version:
    SQL> select to_char(to_date('20-OCT-07'),'D') from dual;
    The following result is displayed:
    T
    7
    When the same query is being run through sqlplus client(9.2.0.3) connecting to the same database, following result is being displayed:
    SQL> select to_char(to_date('20-OCT-07'),'D') from dual;
    T
    6
    Could anyone please explain me why is this difference and what parameter setting needs to be made to get the same result.
    Thanks in advance,
    Vishwanath

    Or from the territory part of NLS_LANG OS variable :
    oracle@xxx:/home/oracle# echo $NLS_LANG
    AMERICAN_AMERICA.UTF8
    oracle@xxx:/home/oracle# sqlplus '/ as sysdba'
    SQL*Plus: Release 9.2.0.8.0 - Production on Mon Oct 22 10:44:59 2007
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.8.0 - Production
    SQL> select to_char(to_date('20-OCT-07'),'D') from dual;
    T
    7
    SQL> quit
    Disconnected from Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.8.0 - Production
    oracle@xxx:/home/oracle# export NLS_LANG=AMERICAN_FRANCE.UTF8
    oracle@xxx:/home/oracle# sqlplus '/ as sysdba'
    SQL*Plus: Release 9.2.0.8.0 - Production on Mon Oct 22 10:45:38 2007
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.8.0 - Production
    SQL> select to_char(to_date('20-OCT-07'),'D') from dual;
    T
    6
    SQL>Check it on both sites (client and server).
    Nicolas.

Maybe you are looking for

  • How I can  enumerate objects in temporary store?

    TEMP_IN_USE_SIZE is constantly increased in my application. How i can get information about objects in temporary storage?

  • Port Issues on Ichat

    I have had problems several times I have had to log on to ichat but it displays the message "the connection could not be completed because it has timed out.try again? Now, I have tried to switch the port from 5190 to 443 but which lets me log in to m

  • How do I make the new Maps app do a turn-by-turn preview of my route?

    I'm not really bothered by the cosmetic changes to Maps, I figure those will sort themselves out. BUT. I don't want real-time turn-by-turn directions. Do not want. I want to be able to make the app move step by step through my upcoming route so I can

  • Can't open Excel File manually after MS Project has opened it via VBA

    I was testing a section of code I got from a forum that opens a Excel Workbook via MS Project VBA so that I could use it to update a Excel Workbook that I have. The macro opens the Workbook as intended but the main problem I'm encountering is that af

  • Subtracting Text From A Background Image

    Hello! I have a banner, and some text. I would like to subtract the text from the banner to create a 'cut-out' effect. What's the easiest way to do this on photoshop? Thanks. Martin