Able to connect via Oracle SQL Developer, but not sql plus

Using Oracle 10.2.0.
I can connect using the TNS connection type in SQL Developer, but cannot do so in SQL PLUS. SQL Plus gives me the error -- could not resolve the connect identifier.
When I do tnsping USPO_ADHOC, I get:
C:\oracle\product\10.2.0\client_1\network\admin\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION =
TNS-12533: TNS:illegal ADDRESS parameters
So here is my tnsnames.ora file:
INTL_ADHOC =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.239.162.108)(PORT = 1521))
(CONNECT_DATA =
(SID = intl1)
USSYN_ADHOC =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.239.162.109)(PORT = 1521))
(CONNECT_DATA =
(SID = USSYN)
USPO_ADHOC =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.239.162.107)(PORT = 1521))
(CONNECT_DATA =
(SID = uspo)
Any assistance gratefully appreciated. Thanks.

I actually did not have that environmental variable, so I added it, but nothing changed.
I would note that if I do tnsping foo, I get: failed to resolve name.
If I do tnsping USPO_ADHOC, I get: illegal address parameter.
In both cases, the output correctly identified the path to my sqlnet.ora file, which is in the same directory as my tnsnames.
So I would conclude from that, that the system was already able to find my tnsnames file.
Anyway, here's my sqlnet.ora:
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
Thanks again for any ideas!

Similar Messages

  • Code runs correctly when compiled by SQL developer but not SQL Plus

    I have a rather large package body I need to deploy and compile ... It's big and complex (I inherited the project). Our it dept is huge and scripts are deployed by the dba team and they seem to only use sql plus. My code deploys and runs fine when compiled in sql developer. Once I compile it from SQL plus it stops working. It runs and using debug statements I can see the values are correct but it no longer inserts the data into the proper tables. I get ZERO errors or warnings when this is compiled in SQL Plus and no errors are generated from the code at run time. I've diffed the extracts of the code from the DB after each deployment and the only difference is the blank lines which SQL Plus strips out when you load the file. Has anyone run into anything remotely similar and if so how did you solve it? I've tried modifying the code to no avail, adding in comments to preserve the white space makes no difference. The thing that really kills me is that there is no error at all.

    Ok this is the problem area.... vReplyMessage is a clob. I've replaced it in this section of processing with a varchar2(32000). And now it works. I still would like to know why though. Nothing is changed when I load it though sqlplus or sql developer but this line " update swn_recip_response_t set SWN_RECIP_RESPONSE = vTextReply where notification_id = v_notification_id; " would never execute with the clob. Logging showed that the clob had the correct value though. I am puzzled.
    begin
    call_SWNPost('http://www.sendwordnow.com/usps/getNotificationResults',vMessageText, vReplyMessage, v_status_code, v_status_phrase, '');
    exception
    when others then
    raise eJavaException;
    end;
    vTextReply := dbms_lob.substr( vReplyMessage, 32000, 1 );
    if (vDebug) then
    update PEMS_PROD_2.SWN_POST_LOG set response = 'notif_id == '|| v_notification_id || 'status code == '|| v_status_code|| ' '||vTextReply where log_pk = vLogPK;
    commit;
    end if;
    IF v_status_code = 200 then
    v_has_error := 'N';
    ELSE
    v_has_error := 'Y';
    END IF;
    -- we handle all exceptions below in case something goes wrong here.
    -- this area can die silently.
    vTextReply := replace(vTextReply,'<getNotificationResultsResponse xmlns="http://www.sendwordnow.com/usps">', '<getNotificationResultsResponse xmlns:xyz="http://www.sendwordnow.com/usps">');
    begin
    insert into swn_recip_response_t(notification_id) values (v_notification_id);
    exception
    when others then
    if (vDebug) then
    err_num := SQLCODE;
    err_msg := SUBSTR(SQLERRM, 1, 100);
    insert into PEMS_PROD_2.SWN_POST_LOG (LOG_PK, create_date, REQUEST, notification_id) values(pems_prod_2.swn_post_log_seq.nextval,sysdate,
    'err_num - '||to_char(err_num)|| ' error_msg - '|| err_msg, v_notification_id);
    commit;
    else
    null;
    end if;
    end;
    commit;
    begin
    update swn_recip_response_t
    set SWN_RECIP_RESPONSE = vTextReply
    where notification_id = v_notification_id;
    exception
    when others then
    if (vDebug) then
    err_num := SQLCODE;
    err_msg := SUBSTR(SQLERRM, 1, 100);
    insert into PEMS_PROD_2.SWN_POST_LOG (log_pk, create_date, REQUEST, notification_id) values(pems_prod_2.swn_post_log_seq.nextval,sysdate,
    'err_num - '||to_char(err_num)|| ' error_msg - '|| err_msg, v_notification_id);
    commit;
    else
    null;
    end if;
    end;
    commit;
    -- parse through the XML document and update the notification and recipient records
    -- parse the clob into an xml dom object
    begin
    vReplyMessage := vTextReply;
    ...

  • Connection ... able to connect using sql developer, but not sqlplus or toad too

    Hi folks, having this issue, with only one of my so many databases, what might be the reason and how to fix/correct this, please assist.
    Able to connect using sql developer, but not sqlplus or toad too; sqlplus error: ORA-12154: TNS:could not resolve the connect identifier specified
    thanks in advance.

    SQLDEVELOPER works since it use JDBC Thin & does not use tnsnames.ora
    ORA-12154 ALWAYS only occurs on SQL Client & no SQL*Net packets ever leave client system
    ORA-12154 [B]NEVER[/B] involves the listener, the database itself or anything on the DB Server.
    ORA-12154 occurs when client requests a connection to some DB server system using some connection string.
    TNS-03505 is thrown by tnsping & is same error as ORA-12154 thrown by sqlplus or others.
    The lookup operation fails because the name provided can [B]NOT[/B] be resolved to any remote DB.
    The analogous operation would be when you wanted to call somebody, but could not find their name in any phonebook.
    The most frequent cause for the ORA-12154  error is when the connection alias can not be found in tnsnames.ora.
    The lookup operation of the alias can be impacted by the contents of the sqlnet.ora file; specifically DOMAIN entry.
    TROUBLESHOOTING GUIDE: ORA-12154 & TNS-12154 TNS:could not resolve service name [ID 114085.1]
    http://edstevensdba.wordpress.com/2011/02/26/ora-12154tns-03505/

  • Just hooked up new apple tv for first time. able to connect to internet (netflix, youtube) but not able to connect to my itunes account via home sharing. apple tv tells me to make sure computer's itunes has home-sharing enabled, which it does. any advice?

    Just hooked up new apple tv for first time. able to connect to internet (netflix, youtube) but not able to connect to my itunes account via home sharing. apple tv tells me to make sure computer's itunes has home-sharing enabled, which it does. any advice?

    Have done both suggestions, still not working. Could it have somehting to do with my local network? I am using a wireless Internet provided by my apartment building so not sure if apple tv and my computer are not technically on the same "local network?"
    apple tv and main computer are connecting to Internet fine. Just cannot see my itunes on apple tv.
    any other advice? My itunes is turned on to home sharing. i entered the same apple itunes account into aple tv. but appletv keeps saying my computer's home sharing is not turned on...but it is.

  • Query works in SQL Developer but not in Oracle APEX

    The query below runs and produces the correct result in SQL Developer, but when I try to put it into a PL/SQL process in Apex I get the error shown. There is no semi-colon at the end of the query in APEX.
    The error is:
    ORA-06550: line 10, column 54: PL/SQL: ORA-00933: SQL command not properly ended ORA-06550: line 2, column 1: PL/SQL: SQL Statement ignored ORA-06550: line 11, column 21: PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: ( begin case declare end exception exit for goto if loop mod null pragma raise return select update while with.
    The query is:
    SELECT *
    FROM
    (SELECT *
    from T3_LEADS
    WHERE
    (SYSDATE - Last_Mailed_Date) > 60 OR Last_Mailed_Date is null
    WHERE MARKET_ID = 'Salt_Lake_City' AND rownum <= 100

    That is because when you run a SQL in SQL*Plus or SQLDeveloper the output is displayed on the screen, but in Apex you need to select those values into variables so you can do something with the data.
    delcare
      v_emp_id    employee.emp_id%type;
    begin
      select emp_id
        into v_emp_id
        from employee
      where lname = 'JOHNSON' and fname = 'BILLY';
      -- Then do something with that data
      if v_emp_id between 1 and 10 then
      end if;
    end;Probably a bad SQL for an example. For your SQL though, you are selecting * which you would be able to select into a rowtype variable, but you are probably going to start having problems like "Exact fetch returns more that one row" since your query will probably return more that one value. In those cases you want to use cursors, and loop through the data one record at a time. You can Google all of that.

  • Query returns record in SQL Developer but not in iSQLPlus

    ... back in a minute, I may not have done a commit at the end of the insert.
    The problem I was having was I hadnt commited the record in SQL Developer but the queries where returning records in this environment but not in iSQLPlus or Apex and it was confusing me.
    Message was edited by:
    Benton
    Message was edited by:
    Benton

    Finally got to know the reason why Timezone Abbr woudn't show up in SQL Plus.
    I ran below query in SQL PLUS
    SELECT SESSIONTIMEZONE, CURRENT_TIMESTAMP, systimestamp, LOCALTIMESTAMP FROM DUAL;
    SESSIONTIMEZONE CURRENT_TIMESTAMP SYSTIMESTAMP LOCALTIMESTAMP
    -05:00 08-SEP-12 12.00.31.575228 AM -05:00 08-SEP-12 12.00.31.575223 AM -05:00 08-SEP-12 12.00.31.575228 AM
    Now executed the same query in SQL Developer:
    SESSIONTIMEZONE CURRENT_TIMESTAMP SYSTIMESTAMP LOCALTIMESTAMP
    America/Chicago     08-SEP-12 12.08.32.072424000 AM AMERICA/CHICAGO     08-SEP-12 12.08.32.072420000 AM -05:00     08-SEP-12 12.08.32.072424000 AM
    The difference between the 2 outputs is the way in which time_zones were respresented. In SQL PLUS, it is shown as an offset whereas in SQL Developer as a time zone region name. Now there are many "time sone regions" that follow an offset of -5:00. This confuses Oracle and a "UNK"(Unknown) for a query like the one below when trying to execute in SQL PLUS:
    select extract(timezone_abbr from from_tz(cast(sysdate as timestamp),SESSIONTIMEZONE)) from dual;
    EXTRACT(TI
    UNK
    Therefore we need to specify the exact Time Zone Region(TZR) in order to obtain the corresponding TZD(Daylight Savings Format i.e. CDT or CST). This we do by altering the session environment vaiable time_zone
    alter session set time_zone='America/Chicago';
    Now executing the queries to find the abbreviated time zone( in TZD format) will finally work to return a non-null char value.
    select extract(timezone_abbr from from_tz(cast(sysdate as timestamp),SESSIONTIMEZONE)) from dual;
    EXTRACT(TI
    CDT
    select to_char(CURRENT_TIMESTAMP, 'TZD') from dual;
    TO_CHA
    CDT

  • Why will a query work in SQL Developer but not in Apex?

    Here's a good one. I created a dynamic LOV with the following query.
    select
    e.DESCR d,
    ee.ENTRD_EVNT_SK r
    from
    PT_EVNT_IN_DIV eid,
    PT_ENTRD_EVNT ee,
    PT_EVNT e
    where ee.PGNT_SK = :PGNT_SK
    and ee.CNTSNT_SK = :CNTSNT_SK
    and ee.EVNT_IN_DIV_SK = eid.EVNT_IN_DIV_SK
    and eid.EVNT_SK = e.EVNT_SK
    and ee.ENTRD_EVNT_SK not in
    (select js.ENTRD_EVNT_SK
    from PT_JDG_SCR js
    where js.JDG_SK = :JDG_SK
    and js.PGNT_SK = :ai_pgnt_sk
    and js.CNTSNT_SK = :CNTSNT_SK)
    order by 1
    The query works fine in SQL Developer, but Apex gives the following error when compiling it in the LOV editor.
    "1 error has occurred
    - LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query."
    I tried rearranging the entries in the From clause, but that didn't do any good.
    Do you see what I can do to make Apex accept it?
    Thanks,
    Kim

    Kim
    Kim2012 wrote:
    select
    e.DESCR d,
    ee.ENTRD_EVNT_SK r
    from
    PT_EVNT_IN_DIV eid,
    PT_ENTRD_EVNT ee,
    PT_EVNT e
    where ee.PGNT_SK = :PGNT_SK
    and ee.CNTSNT_SK = :CNTSNT_SK
    and ee.EVNT_IN_DIV_SK = eid.EVNT_IN_DIV_SK
    and eid.EVNT_SK = e.EVNT_SK
    and ee.ENTRD_EVNT_SK not in
    (select js.ENTRD_EVNT_SK
    from PT_JDG_SCR js
    where js.JDG_SK = :JDG_SK
    and js.PGNT_SK = :ai_pgnt_sk
    and js.CNTSNT_SK = :CNTSNT_SK)
    order by 1
    The column named ENTRD_EVNT_SK is used twice in a select. Once in the main select and once in the inline query.
    The validation maybe choking on that.
    Try giving the column in the inline query an alias and see if that helps.
    Nicolette

  • Can we keep APEX open? Query works in SQL Developer but not Oracle APEX

    Hi Sirini,
    Just my thoughts -- but if one of these is closed, I think it should be the other one {thread:id=2496751} where he's getting the run-around. This one {thread:id=2496754} (APEX!) should be the one kept open. Don't you think?
    My 2 cents,
    Howard

    ..where he's getting the run-around...What runaround? The posters there determined that he needed a semi-colon at the end of the statement and then that he had forgotten the INTO clause. Both are beginner errors. OP has closed the thread as answered and has gone 'off to Google' to learn more about creating SQL queries in PL/SQL. This seems resolved -- at least until he comes back from his Googlequest with another question.

  • Inner Query is excuting properly in 10g SQL developer, but not in Form 6i

    Hi All,
    I am able to excute below query in Oracle SQL developer in 10g , but when I tried to excute it in Forms 6i on WHEN-NEW-FORM_INSTANCE trigger, it is giving me below error message
    SELECT okl2.line_number subline_number, okl2.sts_code subline_status,
    okl2.start_date subline_start_date, okl2.end_date subline_end_date,
    okl2.date_terminated,oks.cognomen line_ref,okl2.ID subline_id,okl2.lse_id,
    (SELECT orig_model_no
    FROM apps.emcoks_msh_subst_models sm
    WHERE okh.contract_number = sm.contract_number
    AND okl.line_number = record_line_id) orig_model_no,
    (SELECT orig_model_qty
    FROM apps.emcoks_msh_subst_models sm
    WHERE okh.contract_number = sm.contract_number
    AND okl.line_number = record_line_id) orig_model_qty
    FROM apps.okc_k_lines_b okl2,
    apps.okc_k_headers_b okh,
    apps.okc_k_lines_b okl,
    apps.okc_k_items oki ,
    apps.okc_k_lines_tl oks
    WHERE 1 = 1
    AND okl2.dnz_chr_id = okl.chr_id
    AND okl.lse_id = 1
    AND okl2.lse_id IN (7, 9)
    AND okl.ID = okl2.cle_id
    AND okl.ID = oki.cle_id
    AND okl2.ID = oks.ID
    AND okl.chr_id = okh.ID
    AND okl2.dnz_chr_id = okh.ID
    AND okl.ID = 130246066126590818122526020119476052469
    order by subline_id;
    Error 103 : Encountered the symbol "Select" when expecting one of the following
    ( - + mod not null others <an identifier>

    I am new to Oracle Forms. Could you please guide me, how to create this statement as a view in the database ?
    I have tried to rewrite it using OUTER JOIN, but I am not getting same results.
    SELECT okl.line_number subline_number, okl.sts_code subline_status,
    okl.start_date subline_start_date, okl.end_date subline_end_date,
    okl.date_terminated,oks.cognomen line_ref,okl.ID subline_id,okl.lse_id,
    sm.orig_model_no orig_model_no,
    sm.orig_model_qty orig_model_qty
    FROM apps.okc_k_lines_b okl2,
    apps.okc_k_headers_b okh,
    apps.okc_k_lines_b okl,
    apps.okc_k_items oki ,
         apps.okc_k_lines_tl oks
    , apps.emcoks_msh_subst_models sm
    WHERE 1 = 1
    AND okl2.dnz_chr_id = okl.chr_id
    AND okl.lse_id = 1
    AND okl2.lse_id IN (7, 9)
    AND okl.ID = okl2.cle_id
    AND okl.ID = oki.cle_id
    AND okl2.ID = oks.ID
    AND okl.chr_id = okh.ID
    AND okl2.dnz_chr_id = okh.ID
    AND okl.ID = 130246066126590818122526020119476052469
    AND okh.contract_number (+) = sm.contract_number
    AND okl.line_number (+) = sm.record_line_id
    order by subline_id;
    Edited by: Swarup_C on May 8, 2013 6:46 AM

  • Generate DDL works in old version of SQL Developer, but not in new versions

    Hello all,
    How to generate DDL in new versions of Oracle SQL Developer for production Oracle database?
    For production database, the generate DDL feature works fine in old versions (version 1.5.5) of Oracle SQL Developer, SQuirrel, Toad and many other similar tools, but not the new versions of Oracle SQL Developer (such as 2.1.1.64.45).
    The SQL tab for a table is blank for me in production databases. Of course, it works fine in development Oracle database.
    I did some research that many articles describe SELECT_CATALOG_ROLE as the required read-only role in production database. Our DBA did a test to grant me this role temporarily, and it worked for me to generate DDL using new Oracle SQL Developer. It is pain for me to ask for this role.
    Is there a plug-in or work-around, so the new versions of Oracle SQL Developer can have this generate DDL feature in production without the mentioned SELECT_CATALOG_ROLE?
    I could not find the answer in older forum threads.
    For now, I will have to install older versions of Oracle SQL Developer.
    Thanks

    I've seen a couple posts about people not being able to generate DDL for other users. To date, I've never seen a anybody post a workaround, nor have I seen one of the developers post a response, nor have I seen anybody say they've submitted a SR.
    I think I remember reading somewhere that the new version of SQL Developer uses dbms_metadata.get_ddl to generate DDLS, rather than some custom query built on top of catalog views...which could explain why it use to work, but no longer does. But whether or not this is true, I don't know.
    You could try submitting a SR and see if Oracle responds saying that it's a known bug and will be fixed in the next release. Until then, unless you get the role, you're stuck using something else for DDL generation.

  • SQL script works in SQL Developer but not when scheduled

    I have a script that I can run, logged onto my server as a user with full permissions and into my database as SYSDBA, that produces a CSV file on the server when I run it from SQL Developer ON the server. HOWEVER, when I set it up as a scheduled job, using those SAME CREDENTIALS (same Windows/network user; same database user), I get no output. The job indicates that it's running successfully, but no file gets created.
    Any advice is greatly appreciated.
    Here's the script:
    WHENEVER SQLERROR EXIT FAILURE;
         set serveroutput on
         DECLARE
         my_query varchar2(5000);
         BEGIN
         my_query := q'[
    SELECT client_id, JOB_NAME, SCHEDULE_TYPE, TO_CHAR(START_DATE,'MM/DD/YYYY HH24:MM') AS START_DATE,
    REPEAT_INTERVAL, ENABLED, STATE, RUN_COUNT,
    TO_CHAR(LAST_START_DATE,'MM/DD/YYYY HH24:MM') AS LAST_START, LAST_RUN_DURATION,
    TO_CHAR(NEXT_RUN_DATE,'MM/DD/YYYY HH24:MM') AS NEXT_RUN
    FROM DBA_SCHEDULER_JOBS
    WHERE instr(client_id,'10.') is not null
    ORDER BY LAST_START_DATE DESC
         p2k.ccsd_any_query_to_csv('HRISEDB_E_OUTPUT_MK', 'dbserver_job_output.csv',my_query);
         end;
    =================================================================
    Here's the called procedure (I don't really understand it -- I gleaned it from others on the internet):
    -- DDL for Procedure CCSD_ANY_QUERY_TO_CSV
    set define off;
    CREATE OR REPLACE PROCEDURE "CCSD_ANY_QUERY_TO_CSV" (p_dir in varchar2, p_filename in varchar2, p_query in varchar2) AUTHID CURRENT_USER
    is
    l_output utl_file.file_type;
    l_theCursor integer default dbms_sql.open_cursor;
    l_columnValue varchar2(4000);
    l_status integer;
    l_query long;
    l_colCnt number := 0;
    l_separator varchar2(1);
    l_col_desc dbms_sql.desc_tab;
    l_col_type varchar2(30);
    l_datevar varchar2(8);
    BEGIN
    l_query := 'SELECT SYSDATE FROM DUAL; ';
    dbms_sql.parse(l_theCursor, p_query, dbms_sql.native);
    dbms_sql.describe_columns(l_theCursor, l_colCnt, l_col_desc);
    l_output := utl_file.fopen( p_dir, p_filename, 'w' );
    dbms_sql.parse( l_theCursor, p_query, dbms_sql.native );
    for i in 1..l_col_desc.count LOOP
    utl_file.put( l_output, l_separator || '"' || l_col_desc(i).col_name || '"' );
    dbms_sql.define_column( l_theCursor, i, l_columnValue, 4000 );
    l_separator := ',';
    end loop;
    utl_file.new_line( l_output );
    l_status := dbms_sql.execute(l_theCursor);
    while ( dbms_sql.fetch_rows(l_theCursor) > 0 ) loop
    l_separator := '';
    for i in 1 .. l_colCnt loop
    dbms_sql.column_value( l_theCursor, i, l_columnValue );
    utl_file.put( l_output, l_separator || '"' || l_columnValue || '"');
    l_separator := ',';
    end loop;
    utl_file.new_line( l_output );
    end loop;
    dbms_sql.close_cursor(l_theCursor);
    utl_file.fclose( l_output );
    execute immediate 'alter session set nls_date_format=''dd-MON-yy'' ';
    exception
    when others then
    execute immediate 'alter session set nls_date_format=''dd-MON-yy'' ';
    raise;
    end;
    /

    hello,
    does oracle showing any errors in user_scheduler_job_run_details for this job ? I would advise try inserting some debug statement to identify where exactly its stuck. Also please check sample configurations syntax for user_scheduler_jobs.
    Cheers
    Sush

  • SQL Query works in SQL Developer, but not always in MII

    Hi all,
    I encountered a strange behaviour with a query in MII 12.0.2. Maybe someone has a guess what happens.
    I have created a SQL query which runs against Oracle 10g tables. I have tested the query using SQL Developer, and it throws a couple of lines, depending on the contents of the where clause.
    Next I have copied the query to a MII SQL Query (FixedQuery). However, the output is empty most of the time, without showing any errors. After some testing I got the impression that older data are not displayed, but there is no time or date setting in MII.
    As the SQL Developer always returns rows, I am unsure where to search for the error.
    Regards
    Michael

    Michael,
    I would imagine that you have sub-select statements in your FixedQuery, all which will fall subject to the RowCount property of the query template (SQL defaults to 100), which is issued through the driver and typically honored by the database when returning the data from your request.
    Most of the native database query tools allow you to make unbound query requests with no limit on rows, which would probably account for the difference between SQL Developer and the query template.
    For SQLServer it's ROWCOUNT:  http://msdn.microsoft.com/en-us/library/ms188774.aspx
    For Oracle it's ROWNUM:  http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html
    So the answer would be not to make the query template row count some rediculous number, but more appropriately refine the way that the database request is issued.
    Regards,
    Jeremy

  • Getting values in SQL Developer, but not in answers

    Hi,
    I joined the fact table with the other table and when i pull the columns from these tables in Answers, I am getting the result set dint result in any data. But, I am able to get the data/result in sql developer, did the same join there. Please suggest me what might be the reason. How to achieve this.This is very very urgent. Thanks for teh help!!
    Thanks
    SR

    Please take the SQL from OBIEE Manage Sessions and run on SQL Developer
    Make sure you are running on correct environment.
    Make sure you dont have filters in rpd.
    Update me
    Thanks
    NK

  • Query works in SQL Developer but not in APEX

    The query below runs fine in SQL Developer. I have tried entering it both as a Report Region based on SQL Query and in a Dynamic PL/SQL Region. I get different error messages in each. In the Dynamic PL/SQL Region I get the error that an INTO clause is expected in the select
    statement. When I place it in a Report based on SQL query I get an error that there is an invalid column and to use column alias. What I am attempting to do is add the first query result to the second query result.
    Select (select count(lead_id) from t3_leads
    WHERE
    t3_leads.market_id = 'Gurnee'
    AND (T3_Leads.Last_Campaign = 'Hand Addressed' OR T3_Leads.Last_Campaign is null)
    AND
    ((TRUNC(sysdate) - TRUNC(T3_Leads.LAST_MAILED_DATE)) > 60
    OR T3_Leads.Last_Mailed_Date is null))
    +
    (select count(lead_id)from t3_leads where zip in (select zip from t3_overlap where t3_leads.zip = t3_overlap.zip)
    and
    market_id <> 'Gurnee'
    and ((TRUNC(sysdate) - TRUNC(T3_Leads.LAST_MAILED_DATE)) > 60
    OR T3_Leads.Last_Mailed_Date is null))
    from dual

    Hi,
    you need a column alias for your "result" before the final 'from dual':
    Select (select count(lead_id) from t3_leads
    WHERE
    t3_leads.market_id = 'Gurnee'
    AND (T3_Leads.Last_Campaign = 'Hand Addressed' OR T3_Leads.Last_Campaign is null)
    AND
    ((TRUNC(sysdate) - TRUNC(T3_Leads.LAST_MAILED_DATE)) > 60
    OR T3_Leads.Last_Mailed_Date is null))
    +
    (select count(lead_id)from t3_leads where zip in (select zip from t3_overlap where t3_leads.zip = t3_overlap.zip)
    and
    market_id 'Gurnee'
    and ((TRUNC(sysdate) - TRUNC(T3_Leads.LAST_MAILED_DATE)) > 60
    OR T3_Leads.Last_Mailed_Date is null)) result
    from dualPlease let me know if this works.
    Thanks
    Sandro

  • Why does the query work in SQL Developer, but not in APEX?

    Hi, guys:
    I have a silly question. I have a complicated query, and I tested it successfully with SQL developer, and result is correct. However, when I put it into APEX to generate a report, it always reports no data found. I also know the condition related to "other marks" select list in the where clause part causes this problem. It also looks strange: before I add this condition, everything works OK; after I add this condition, even I do not choose the "other marks" select list, other components do not work neither. I always got no data found result. Could anyone help me on this problem? You can also visit our developing site as http://lsg-solutions.com:8888/apex/f?p=206 to check the problem.
    Thanks a lot
    Sam
    select distinct 'MAP','Detail',so.doc_number as "DOC Number", so.offender_id as "Offender ID", so.first_name||' '|| so.middle_name||' '||so.last_name as "Offender Name",
    so.date_of_birth as "Date of Birth",
    (select sc1.description from sor_code sc1 where sc1.code_id=so.race) as "Race",
    (select sc2.description from sor_code sc2 where sc2.code_id=so.sex) as "Sex",
    (select sc8.description from sor_code sc8 where sc8.code_id=so.hair_color) as "Hair Color",
    (select sc9.description from sor_code sc9 where sc9.code_id=so.eye_color) as "Eye Color",
    replace(replace(nvl2(sl.address1, sl.address1||' '||sl.address2 ||' '||sl.city ||' '||sl.county||' '||(select sc3.description from sor_code sc3 where sc3.code_id=sl.state)||' '||sl.zip, 'No Known Address'),'#'),',') as "Address",
    replace(replace(nvl2(sl.physical_address1,sl.physical_address1||' '||sl.physical_city ||' '||sl.physical_county||' '||(select sc4.description from sor_code sc4 where sc4.code_id=sl.physical_state)||' '||sl.physical_zip, 'No Known Address'),'#'),',') as "Physical Address",
    sl.status as "Status",
    sl.jurisdiction as "Jurisdiction",
    to_char(sl.ADDRESS_LATITUDE) as "Address Latitude",to_char(sl.address_longitude) as "Address Longitude",
    to_char(sl.physical_address_latitude) as "Physical Latitude",to_char(sl.physical_address_Longitude) as "Physical Longitude",
    decode(rox.habitual, 'Y', 'Habitual', '') as "Habitual",
    decode(rox.aggravated, 'Y', 'Aggravated', '') as "Aggravated",
    rox.status as "Registration Status",
    rox.registration_date as "Registration Date",
    rox.end_registration_date as "End Registration Date"
    from sor_location sl, sor_offender so, registration_offender_xref rox, sor_last_locn_v sllv
    where rox.offender_id=so.offender_id
    and sllv.offender_id(+)=so.offender_id
    and sl.location_id(+)=sllv.location_id
    and rox.status not in ('Merged')
    and rox.reg_type_id=1
    and upper(rox.status)='ACTIVE'
    and nvl(rox.admin_validated, to_date(1,'J'))>=nvl(rox.entry_date, to_date(1,'J'))
    and (((select sc11.description from sor_code sc11 where sc11.code_id=so.race and sc11.description=:P5_SL_RACE) is not null ) or (:P5_SL_RACE is null))
    and (((select sc12.description from sor_code sc12 where sc12.code_id=so.sex and sc12.description=:P5_SL_SEX) is not null ) or (:P5_SL_SEX is null))
    and (((select sc13.description from sor_code sc13 where sc13.code_id=so.hair_color and sc13.description=:P5_SL_HAIR_COLOR) is not null ) or (:P5_SL_HAIR_COLOR is null))
    and (((select sc14.description from sor_code sc14 where sc14.code_id=so.eye_color and sc14.description=:P5_SL_EYE_COLOR) is not null ) or (:P5_SL_EYE_COLOR is null))
    and (( so.offender_id in(select sm.offender_id from sor_code sc15, sor_mark sm, sor_offender so1 where sm.offender_id=so1.offender_id and sc15.code_id=sm.code and sc15.description=:P5_SL_OTHER_MARKS and sm.description is not null)) or (:P5_SL_OTHER_MARKS is null))

    My suggestion would be to put some instrumentation into your query and see what values you are using.. Or even simpler take out ALL the where clauses you can until data starts to sho wup and then add them back in one at a time until you find the culprit..
    My bet would be on any date comparisons you are doing between page items and database columns..
    Thank you,
    Tony Miller
    Dallas, TX

Maybe you are looking for

  • Ipad software updates states 5.1.1 is latest version

    I have recently inherited an ipad from a friend and restored if after connecting it to my laptop, using itunes. I have tried to download a few apps but many state that they need IOS 6. I have tried checking for updates via both methods - using itunes

  • Error in applying patch 6241631

    Platform: "MS Win 32-bit 2003 R2" EBS: "11.5.10.2" DB Version: "10.2.0.4" Java Version: "1.5.0_22" While applying patch 6241631 got the below error: ATTENTION: All workers either have failed or are waiting: FAILED: file afcmgr.odf on worker 1. ATTENT

  • Problem viewing flex in Safari

    I'm new to Flex and unable to view my Flex work in Safari... Firefox works fine. Here's one simple example: http://www.papaya.net/test/flex/1/firstAnimation.html You should see a red ball moving across the screen like this screen cap from Firefox: ht

  • HT4461 How to load a copy of Lion on to disk to boot from and install OS onto MacBook after replacing HD with SSD?

    Hello, All. I am replacing the Hard Drive (HD) in my MacBook with a Solid State Drive (SSD) to improve reliability and speed.  How do I go about getting the Lion OS, which only came as a web download, onto a disk to boot from and load onto the SSD?

  • Installing CCM 5.0(4)

    When iam installing CCM 5.0(4) on a MCS 7815, after providing all the information like(IPs, timezones, selecting it as a publisher, NTP, DNS)installation process keeps on restarting the server and starting from the begining of the installation. What