Select from sys.all_ind_columns works in sql*plus but not in stored proc

I'm writing a query to find duplicate rows in a temporary table which has no unique index defined before I insert the data into the real table. I'm trying to query the sys.all_ind_columns view for the target table which belongs to a different schema:
SELECT column_name colnm
FROM sys.all_ind_columns i
WHERE i.table_owner = 'SUSDB'
AND i.index_name LIKE '%LUK'
AND i.table_name = &tbnm
ORDER BY i.column_position;
This works from my GUI interface and returns five rows but when I put it into a stored procedure I get now data returned. I have granted my userid SELECT ANY DICTIONARY authority. What else do I need?

CREATE OR REPLACE FUNCTION bog_elsa2_leslie.diag_msg_1000_cursor(i_rept_inst IN VARCHAR2,
i_rept_time_frame IN VARCHAR2,
i_table_name IN VARCHAR2,
i_column_name IN VARCHAR2,
i_domain_table IN VARCHAR2,
i_domain_column IN VARCHAR2,
i_domain_code IN VARCHAR2,
i_trace_flg IN NUMBER := 0)
RETURN VARCHAR2 IS
cursor_stg VARCHAR2(4000);
|| File name: diag_msg_1000_cursor.fnc
|| Created by: ELSA.LESLIE
|| Created on: 20071215 4:08:20 AM
|| Purpose: Build the string that will retrieve PRIKEY and CONTENTS
|| from the target table, university, time frame, submission
|| and table passed as parameters for the 1000 dignostic.
|| Diagnostic 1000:
|| Validate that the table's logical unique key constraint
|| is not violated.
|| In: ***
|| *** ALL INPUT VARIABLES MUST BE DECLARED EVEN IF THEY ARE
|| *** NOT USED IN THIS PARTICULAR FUNCTION BECAUSE THE
|| *** EDIT_ANY_TABLE PROCEDURE CALLS THE FUNCTION IN AN
|| *** EXECUTE IMMEDIATE STATEMENT THAT REQUIRES THE 'USING'
|| *** PHRASE BE PART OF THE CALLING PROGRAM RATHER THAN BEING
|| *** INCLUDED IN THE RETURNED CURSOR_STG.
|| ***
|| i_rept_inst = reporting institution (eg. UF, FSU)
|| i_rept_time_frame = reporting time frame (eg., 200608, 20062007)
|| i_table_name = target table to be edited (eg. BUILDINGS, ENROLLMENTS)
|| i_trace_flg is optional and is used for debugging (values: TRUE/FALSE)
|| [not used] i_column_name = eg. ALTER_YR, BASE_YR
|| [not used] i_domain_table = the name of the domain table containing valid values
|| [not used] (eg. DOMAIN_MAIN_VALUES, DOMAIN_UNIV)
|| [not used] i_domain_column = the name of the column in the domain table that
|| [not used] contains the valid values (eg. CODE, OPEID_CD)
|| [not used] i_domain_code = the 5-digit domain code (eg. 10021, 01045)
|| Out: cursor_stg = executable SQL to return error row information
|| Dependencies: Logical Unique Key for tables must be have the string 'LUK'
|| postpended to it's name.
|| Exceptions: none
|| Copyright: BOG 2007
|| ***************************************************
|| Modifications:
|| Userid - Date - Modification description
-- Constants and special assignments
rept_inst VARCHAR2(4) := upper(i_rept_inst);
rept_time_frame VARCHAR2(8) := i_rept_time_frame;
table_name VARCHAR2(30) := upper(i_table_name);
column_name VARCHAR2(30) := upper(i_column_name);
domain_table VARCHAR2(30) := upper(i_domain_table);
domain_column VARCHAR2(30) := upper(i_domain_column);
domain_code VARCHAR2(5) := upper(i_domain_code);
trace_flg NUMBER := i_trace_flg;
file_name VARCHAR2(100) := 'diag_msg_1000_cursor: ';
unq_cols VARCHAR2(1000) := NULL;
unq_contents VARCHAR2(4000) := NULL;
unq_where VARCHAR2(4000) := NULL;
-- Accounting of process n/a all contained in the for loop
row_num NUMBER := 0;
-- Object types - n/a
-- Cursors
CURSOR ix_cols_curr(tbnm VARCHAR2 := table_name) IS
SELECT column_name colnm
FROM sys.all_ind_columns i
WHERE i.table_owner = 'SUSDB'
AND i.index_name LIKE '%LUK'
AND i.table_name = tbnm
ORDER BY i.column_position;
-- Cursor variables n/a
-- errors and exceptions
sql_code NUMBER;
sql_errm VARCHAR2(255);
BEGIN
-- output trace information if requested
IF trace_flg = 1
THEN
dbms_output.put_line(file_name || 'rept_inst = ' || rept_inst);
dbms_output.put_line(file_name || 'rept_time_frame = ' || rept_time_frame);
dbms_output.put_line(file_name || 'table_name = ' || table_name);
dbms_output.put_line(file_name || 'column_name = ' || column_name);
dbms_output.put_line(file_name || 'domain_table = ' || domain_table);
dbms_output.put_line(file_name || 'domain_column = ' || domain_column);
dbms_output.put_line(file_name || 'domain_code = ' || domain_code);
END IF;
-- ix_cols_loop builds a string of the columns contain in the
-- logical unique key which is then later incorporated into the
-- select cursor returned to the calling program.
FOR this_col IN ix_cols_curr(table_name)
LOOP
<<ix_cols_loop>>
-- output trace information if requested
IF trace_flg = 1
THEN
row_num := ix_cols_curr%ROWCOUNT;
dbms_output.put_line(file_name || 'row=' || row_num ||
'column_name=' || this_col.colnm);
END IF;
IF unq_cols IS NOT NULL
THEN
unq_cols := unq_cols || ', ';
unq_contents := unq_contents || ', ';
END IF;
unq_cols := unq_cols || this_col.colnm;
unq_contents := unq_contents || q'[']' || this_col.colnm ||
q'['=]' || this_col.colnm;
unq_where := unq_where || 'AND tbl.' || this_col.colnm ||
' = dups.' || this_col.colnm;
END LOOP ix_cols_loop;
IF trace_flg = 1
THEN
dbms_output.put_line(file_name || 'unq_cols =' || unq_cols);
dbms_output.put_line(file_name || 'unq_contents =' || unq_contents);
dbms_output.put_line(file_name || 'unq_where =' || unq_where);
END IF;
cursor_stg := 'SELECT prikey, ' || unq_contents || ' AS contents ' ||
'FROM univdb.' || table_name || ' tbl, (SELECT ' ||
unq_cols || ', COUNT(*) FROM univdb.' || table_name ||
q'[ WHERE rept_inst = ']' || rept_inst || q'[']' ||
q'[AND rept_time_frame = ']' || rept_time_frame || q'[']' ||
' GROUP BY ' || unq_cols || ' HAVING COUNT(*) > 1) dups' ||
q'[ WHERE tbl.rept_inst = ']' || rept_inst || q'[']' ||
q'[ AND tbl.rept_time_frame = ']' || rept_time_frame ||
q'[']' || unq_where;
-- output trace information if requested
IF trace_flg = 1
THEN
dbms_output.put_line(file_name || 'cursor_stg = ' || cursor_stg);
END IF;
RETURN(cursor_stg);
EXCEPTION
-- block exception
WHEN OTHERS THEN
sql_code := SQLCODE;
sql_errm := SQLERRM;
IF trace_flg = 1
THEN
dbms_output.put_line(file_name || ' ROW NUM ' || row_num || ' sql code ' ||
sql_code || ' sql message ' || sql_errm);
END IF;
END diag_msg_1000_cursor;

Similar Messages

  • SQL statement works with SQL/Plus - but not with ODBC

    Hi all,
    I have a rather copmplex SQL statement:
    BEGIN
    UPDATE ContentDataTable
    SET SYMBOLIC_PATH_PARENT = N'/Test',
    SYMBOLIC_NAME = N'HAWK01.GIF',
    VERSION_NUMBER = 1 +
    SELECT MAX(VERSION)
    FROM
    (SELECT MAX(VERSION_NUMBER) AS VERSION
    FROM ContentDataTable WHERE
    SYMBOLIC_PATH_PARENT = N'/Test' AND
    SYMBOLIC_NAME = N'HAWK01.GIF'
    UNION
    SELECT MAX(VERSION_NUMBER) AS VERSION
    FROM RevisedContentDataTable WHERE
    SYMBOLIC_PATH_PARENT = N'/Test' AND
    SYMBOLIC_NAME = N'HAWK01.GIF'))
    WHERE SYMBOLIC_PATH_PARENT = N'/Test' AND SYMBOLIC_NAME = N'HAWK02.GIF' AND VERSION_NUMBER = 1;
    END;
    It works fine in SQL/Plus or SQL Worksheet and does what it should do ;-)
    But when using it via ADO (ODBC Driver) I get the following error:
    PLS-00103 found 'string' but expected one of the following: 'string'"}
    Any idaes?
    Thanx,
    Christian
    null

    Pardon my ignorance, but what's the significance of the N'<string>' construction? That's not one I'm familar with.
    Justin

  • Able to connect to database from SQL plus but not from Oracle SQL developer

    Hi
    I have two database editions in my system Oracle XE and Oracle EE. I am able to connect to EE database through SQL plus but not through SQL developer.Please tell me how to do it.
    All settings are good.I am able to connect to the database before installing XE.I need both for my work(different projects).
    And the default listener started is XE's.Please tell me how to change the default one to EE or tell me how to connect through SQL developer??
    Regards
    Harsha

    I Solved it.
    I copied the text from listener.ora for EE
    and added it in the other one.
    It works after restart.

  • Procedure runs in SQL Plus, but not when called from my Oracle Form

    Hi. I have this code to send an email alert as the user updates a record on my base table from my Oracle Form. I use dbms_scheduler so that it's submitted as a background job and so the email processing does not delay my Oracle Form from saving quickly. If I submit this code in SQL Plus it executes and I receive the email as expected.
    begin
    dbms_scheduler.create_job ( 
         job_name            => 'IMMEDIATE_JOB', 
         job_type            => 'PLSQL_BLOCK', 
         job_action          => 'begin TTMS.dropperVacationConflict_Notify (62547, ''01-SEP-11'', ''02-SEP-11''); end;', 
         number_of_arguments => 0, 
         start_date          => sysdate +1/24/59, -- sysdate + 1 minute 
         enabled             => TRUE, 
         auto_drop           => TRUE, 
         comments            => 'Immediate, one-time run');
    end;However if I submit this code from a Post-Update trigger in my form the code runs without error, but my email is never received (the same parameter values would be passed to this trigger):
    begin
    -- Submit the email notification in the background so as to not slow down the screen while saving.   
    dbms_scheduler.create_job ( 
         job_name            => 'IMMEDIATE_JOB', 
         job_type            => 'PLSQL_BLOCK', 
         job_action          => 'begin TTMS.dropperVacationConflict_Notify (:dropper_vacations.dropper_id, :dropper_vacations.begin_dt, :dropper_vacations.end_dt); end;', 
         number_of_arguments => 0, 
         start_date          => sysdate +1/24/59, -- sysdate + 1 minute 
         enabled             => TRUE, 
         auto_drop           => TRUE, 
         comments            => 'Immediate, one-time run');
    end;     Any ideas why this might be happening?

    Wow, so I changed the two procedures so that I'm only passing in one number parameter and one char parameter...
    CREATE OR REPLACE procedure TTMS.job_vacationconflict_notify (p_dropper_id number, p_other char) IS
    CREATE OR REPLACE PROCEDURE TTMS.dropperVacationEmailURL_new (in_dropper_id number, in_other char) ISIf I execute it like this it works and I get the email:
    TTMS.job_vacationconflict_notify(62547, 99999);or like this it works and I get the email:
    TTMS.job_vacationconflict_notify(62547, '99999');But if I execute it like this (I get no errors) the email is not sent:
    TTMS.job_vacationconflict_notify(62547, 'ababa');So this problem really has nothing to do with date formats. It seems to have to do with whether parameter two has characters in it!!! What the heck.
    Any ideas on this?
    Here is the procedure I'm calling:
    CREATE OR REPLACE procedure TTMS.job_vacationconflict_notify (p_dropper_id number, p_other char) IS
    begin
      dbms_scheduler.create_job ( 
         job_name            => 'IMMEDIATE_JOB', 
         job_type            => 'PLSQL_BLOCK', 
         job_action          => 'begin TTMS.dropperVacationemailurl_new ('||p_dropper_id||','||p_other||'); end;', 
         number_of_arguments => 0, 
         start_date          => sysdate +1/24/59, -- sysdate + 1 minute 
         enabled             => TRUE, 
         auto_drop           => TRUE, 
         comments            => 'Immediate, one-time run');
    end;
    /And the above procedure is calling this procedure which should be sending the email alert:
    CREATE OR REPLACE PROCEDURE TTMS.dropperVacationEmailURL_new (in_dropper_id number, in_other char) IS
          myguid varchar2(15):=null;
          pcm_contact varchar2(3):=null;
          guid_contact varchar2(15):=null;
          conflict_cnt number(8):=0;
          -- Various declarations
          PSENDER VARCHAR2(200);            --  From
          PRECIPIENT VARCHAR2(200);         --  To
          P_CC_RECIPIENT VARCHAR2(200);     --  CC
          P_BCC_RECIPIENT VARCHAR2(200);    --  BCC
          PSUBJECT VARCHAR2(200);           --  Subject
          PMESSAGE VARCHAR2(6000);          --  Message Body
          PPARAMETER NUMBER;                --  Parameter Value
          guid_valid varchar2(15);          --  Used to grab the validation value of
          -- Grab name details of e-mail targets
          cursor targets is
          select guid, initcap(first_name) first_name, initcap(first_name)||' '||initcap(last_name) fullname
          from pwc_employee
          where upper(guid) = upper(guid_contact);
    BEGIN
            select count(*)
            into conflict_cnt
            from dropper_bundle_assign
            where
                dropper_sched = in_dropper_id and
                trunc(sched) <> '31-DEC-29' AND        
                trunc(sched) between '01-SEP-11' and '02-SEP-11' and
                trunc(sched) > trunc(sysdate);
            select distinct pcm
            into pcm_contact
            from dropper_bundle_assign
            where
                  dropper_sched = in_dropper_id and
                  trunc(sched) <> '31-DEC-29' AND        
                  trunc(sched) between '01-SEP-11' and '02-SEP-11' and
                  trunc(sched) > trunc(sysdate);
            select guid
            into guid_contact
            from pwc_employee
            where initials = pcm_contact;
        -- Ensure required parameters have been passed
        if guid_contact is not null
           and in_dropper_id is not null then
               Begin
                    select guid
                    into guid_valid
                    from pwc_employee
                    where upper(guid) = upper(guid_contact);
               Exception
                    when no_data_found then
                    raise_application_error(-20000,'Invalid Recipient.  Please check the employee table.  Please try again.');
               End;
               -- In the event there are multiple targets then we will loop thru and send individual emails
               for thisone in targets loop
                    PSENDER := lower(user)||'@us.ibm.com';
                    PRECIPIENT := lower(thisone.guid)||'@us.ibm.com';
                    P_CC_RECIPIENT := lower(thisone.guid)||'@us.ibm.com';
                    P_BCC_RECIPIENT := 'ssbuechl'||'@us.ibm.com';
                    PPARAMETER := TO_NUMBER(lower(in_dropper_id));
                    PSUBJECT := 'TEST: Dropper Vacation '||in_other||' Conflict Notification for dropper '||in_dropper_id||' - Action Required';
                    PMESSAGE := thisone.first_name||'-<br><br>There is an induction conflict due to a new or updated dropper vacation.<br><br>Click here to the dropper''s vacation conflicts: <u><a href="http://9.35.32.205:7777/forms/frmservlet?config=TTMSMENU&form=dropper_vacations&otherparams=p_dropper='||PPARAMETER||'">Dropper Id: '||PPARAMETER||'</a></u> (note: use your Oracle credentials when prompted for log-on information).<br><br>Thanks.';
                    SEND_MAIL ( PSENDER, PRECIPIENT, P_CC_RECIPIENT, P_BCC_RECIPIENT, PSUBJECT, PMESSAGE );  -- Procedure to physically send the e-mail notification
               end loop;
        else
              raise_application_error(-20001,'Recipient and Parameter Value are required. Please try again.');
        end if;
    exception
        when no_data_found then
             raise_application_error(-20002,'Note: Email will not be sent because no PCM was identified as the manager or the PCM does not have a record in the Employee table.  See ITS for assistance.');
         when too_many_rows then
             raise_application_error(-20003,'Note: Email will not be sent because multiple PCMs manage this dropper. Please notify each PCM manually.');
    END dropperVacationEmailURL_new;
    /Edited by: sharpe on Aug 17, 2011 4:38 PM
    Edited by: sharpe on Aug 17, 2011 5:03 PM

  • Executing a procedure - Works on Isql Plus but not SQL Developer??

    Hi folks.
    I am playing around with some design and structure stuff, mostly just passing values around procedures. I have one procedure (procedure1) which takes a sysdate and then passes it to another procedure (procedure2) which takes the parameter and does a dbms_output.put_line.
    Both objects are valid, and compile correctly. I use
    exec procedure1;
    in iSql Plus and it works perfectly. It prints the dates out and all.
    However if I use the exact same command in SQL Developer it gives me error "ORA-00900: invalid SQL statement"
    I don't understand why this happens?? The code executes perfectly in one but not the other...

    Remember that SQL*Plus commands don't work in the worksheet. So, this would fail
    exec my_procIn the worksheet you have to declare an anonymous block....
    begin
        my_proc;
    end;
    /If you right-click on the procedure in the Navigator and select Run then SQL*Dev will throw up a harness for you. Very handy if you want to get DBMS_OUTPUT, set variables, etc.
    Cheers, APC
    http://radiofreetooting.blogspot.com

  • Select works with SQL Server but not with Oracle!

    Hello
    this select works on SQL Server correct, but it don't work on Oracle!
    Can someone help me?
    Select * from Tabelle, Tabelle as XXX Where Tabelle.ID=XXX.IDTabelle
    Thanks
    Thomas

    Hi,
    These are the things which I have noticed, which wont work in Oracle ..
    Table As XXX ?? Are you giving alias name for the table .. The syntax which you have givne doesnt work in Oracle
    Regards

  • 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.

  • 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

  • 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

  • Select works in SQL Workshop, but not as an LOV

    I want all venues to appear in my LOV
    With their affiliated Performing Arts Center, if one exists.
    I get the perfect results when I run it in SQL Workshop.
    When I try to create the LOV, I'm told it's invalid, because it includes an in-line query and the first FROM clause must not belong in the in-line query.
    Not quite sure what it means, but I'm sure I don't know how to fix it...
    SELECT
    v.VENUE_NAME, p.pac_name d,
    v.VENUE_ID r
    from pac p, VENUES v
    where v.venue_pacid = p.pac_id(+)
    thanks
    Marion

    I'm told it's invalid, because it includes an in-line query and the first FROM clause must not belong in the in-line query.Think that's just an example of why a query might be invalid, as this query clearly doesn't have that.
    Jari's right, it has to only return 2 columns, so the venue and PAC values need merged somehow, like:
    SELECT
             v.VENUE_NAME || nvl2(p.pac_name, ' (', null) || p.pac_name || nvl2(p.pac_name, ')', null) d,
             v.VENUE_ID r
    from     pac p, VENUES v
    where    v.venue_pacid = p.pac_id (+)

  • 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

  • SQL works in SQL workshop but not in APEX

    Hi All,
    I'm trying some sample sql to get around the 32k limit in APEX and even though the sql works in SQLWorkshop, when I use it as a source for textarea object in APEX I get an error. Here's the SQL:
    declare
    l_code clob := empty_clob;
    l_clob_source2 clob;
    offset int:=1;
    begin
         select replace("CHNL_PRTNR_XML_TRAN"."XML_TRAN", '<', '<') into l_code from "CHNL_PRTNR_XML_TRAN" where "CHNL_PRTNR_XML_TRAN"."VITRIA_DROP_OFF_SEQ_ID" = :P2_TRAN_ID;
    loop
    l_clob_source2 := dbms_lob.substr(l_code,4000,offset);
    htp.prn(l_clob_source2);
    exit when offset + 4000 >= nvl(dbms_lob.getlength (l_code),0);
    offset := offset + 4000;
    end loop;
    end;
    Here's the error message I get APEX:
    ORA-06550: line 13, column 17: PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: ; The symbol ";" was substituted for "end-of-file" to continue.
    Error ERR-1019 Error computing item default value: page=2 name=P2_XMLTRAN.

    Try to set it to SQL Query (PL/SQL-Functions Body), then it should work

  • 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

  • Upload files from my app works fine in JDev but NOT on app server???

    i guys,
    I'm using jdeve 10.1.2. and adf bc's. So here's my problem:
    In my application i need to allow for the upload of files from user's computers. This works perfectly fine from jdeveloper but when i deploy my application on the application server i get the following error:
    JBO-26041: Failed to post data to database during "Insert": SQL Statement "D:\TrademarkTestData\TrademarkunitTestData.xls (The system cannot find the path specified)".
    D:\TrademarkTestData\TrademarkunitTestData.xls (The system cannot find the path specified)
    For some reason the system cannot find the path. This is most frustrating as it works perfectly fine when run from jdeveloper.
    Any ideas would be most welcome.
    Thanks in advance,
    Newbe

    Hi Frank,
    Thanks for the response. I've consulted with our server guy and he says that there are no read/write privileges. Jdev is not on the server.
    I'm really stumped by this so if you have any ideas, I'd really appreciate it.
    Happr New Year to you,
    Newbe.

Maybe you are looking for

  • Joining 2 related records using PL SQL in Apex - Problems when there are more than 2 related records?

    Hi I am combining 2 related records of legacy data together that make up a marriage record.  I am doing this in APEX using a before header process using the following code below which works well when there are only 2 related records which joins the b

  • Place a button on a report

    Hi All, I need to set a button called Back at the top right of my report and after clicking that button it should be redirect to the specified page, say page 1. How can i do this? Arif

  • How do I install Window 7 64 bits onto IMac A1312

    I read that I should hv bought Window 7 32-bit instead of 64-bit version. I am not convince that there isn't a patch for the 64-bit version. Any suggestion? On installation, a blue screen appears with system32 system error.

  • Some Yahoo pages do not load. Error msg says "oops something went wrong. Help

    I have the latest version of Firefox. My isp uses Yahoo.com for it's home page. For the past few weeks, whenever I try to read a news or sports article, I get a message that says "oops, something went wrong". I tried reloading several times but no he

  • Traverse on object graph

    Hey, I want to implement a diff engin that compare two graph of objects. I mean that it get an object and run on its references and compare them to the other object graph. The objects are not from the same type , so i have a problem to know how to ru