NAMED SQL QUERY PROBLEM

I am trying to run a named read all query, which requires me to use the "AS" keyword for tables to eliminate ambiguity. This does not appear to populate my vector of object, as I assume the field names end up being different ie. FIELD1 gets T.FIELD1.
Any help with this will be greatly appreciated
Here is my query:
SELECT L.VLN_LAST_VLE_SQID, L.REC_CHANGE_DATE, L.VLN_LENDER_OE,
L.REC_CHANGE_USER, L.VLN_LG_LN_NUM, L.REC_CREATE_TIME, L.VLN_LG_LN_NUM_SEQ,
L.REC_PROGRAM, L.VLN_LG_STATUS, L.SYN_SYNC_SGT_KEY, L.VLN_LOAN_AMOUNT_ADJ,
L.SYN_SYNC_STAT_IN, L.VLN_LOAN_TYPE, L.VLN_ACADEMIC_YEAR, L.VLN_LOAN_TYPE_REQ,
L.VLN_ANTICIPATED_GRAD_DATE, L.VLN_NON_ED_BRNCH, L.VLN_APP_SOURCE,
L.VLN_NOT_USED_STAT_1, L.VLN_BORROWER_ID, L.VLN_NOT_USED_STAT_2,
L.VLN_CAPPED_INTEREST, L.VLN_NSLDS_EFFECTIVE_DATE, L.VLN_CERT_ENR_STATUS,
L.VLN_NSLDS_ID, L.VLN_CL_UNIQUE_ID, L.VLN_NSLDS_LAST_VALUE,
L.VLN_CONVERTED_DATE, L.VLN_NSLDS_SEPARATE_LOAN, L.VLN_COSIGNER_ID,
L.VLN_NSLDS_STATUS, L.VLN_CREDIT_CHECK_DATE, L.VLN_NSLDS_UPDATED_DATE,
L.VLN_CURRENT_PRINCIPAL, L.VLN_ORIG_LENDER_OE, L.VLN_DEFERMENT_REQUESTED,
L.VLN_OTHER_DEBT, L.VLN_DISB_METHOD_REQUESTED, L.VLN_PAYOFF_AMOUNT,
L.VLN_END_DATE, L.VLN_PIF_DATE, L.VLN_FAMILY_CONTRIBUTION,
L.VLN_PIF_PAYMENT_REC_DATE, L.VLN_FISCAL_YEAR, L.VLN_PIF_PRIN_AMT_DISB,
L.VLN_GALAHAD_STAT, L.VLN_PLUS_STATUS, L.VLN_GH_LOAN_SEQ,
L.VLN_PN_SIGNATURE_DATE, L.VLN_GUARANTOR, L.VLN_PRE_DISB_CANC_AMOUNT, L.VLN_ID,
L.VLN_PREV_DEFAULT, L.VLN_INT_ELIGIBILITY, L.VLN_PRIOR_ORIG_2ND_INT_RT,
L.VLN_INTERIM_MATURITY_DATE, L.VLN_PRIOR_ORIG_EXIT_DATE,
L.VLN_INTERIM_PAYMENT_DATE, L.VLN_PRIOR_ORIG_INT_RATE,
L.VLN_INT_RATE_CATEGORY,
L.VLN_PROMISSORY_NOTE, L.REC_CHANGE_TIME, L.VLN_PROM_NOTE_TYPE,
L.REC_CREATE_USER, L.VLN_REMAINING_NEED, L.SYN_SYNC_SOURCE,
L.VLN_REPORT_FFELP_LOAN, L.VLN_ADS_STATUS, L.VLN_REQ_AMT, L.VLN_BLAA,
L.VLN_RESEARCH, L.VLN_CERT_AMT, L.VLN_SALE_DATE, L.VLN_CONS_SUBSIDY,
L.VLN_SCHOOL_CERT_DATE, L.VLN_COST_OF_EDUCATION, L.VLN_SCHOOL_OE,
L.VLN_CUST_SERVICE, L.VLN_SCHOOL_REF_AMT, L.VLN_DISB_SUMMARY,
L.VLN_SCHOOL_REF_DTE, L.VLN_FINANCIAL_AID, L.VLN_SEPARATION_DATE,
L.VLN_GH_CLAIM_NUM, L.VLN_SERIAL_P_N, L.VLN_GUAR_DATE, L.VLN_SLAA,
L.VLN_INTEREST_RATE, L.VLN_SLSS_GR_ID, L.VLN_INTERIM_PMT_REC_DATE,
L.VLN_SLSS_LENDER_ID, L.REC_CREATE_DATE, L.VLN_SLSS_LG_LN_NUM,
L.SYN_SYNC_STAT_OUT, L.VLN_SLSS_LN_NUM, L.VLN_CANC_DATE, L.VLN_SLSS_STATUS,
L.VLN_CONVERTED_PRIN_AMOUNT, L.VLN_SPEC_PROGRAM, L.VLN_DENIED_DATE,
L.VLN_START_DATE, L.VLN_GALAHAD_LOAN_TYPE, L.VLN_STATUS, L.VLN_INCREASED_UNSUB,
L.VLN_STATUS_IN_SLSS, L.VLN_INT_RATE_TYPE, L.VLN_STUDENT_ID, L.VLN_APP_DATE,
L.VLN_SUB_UNSUB_SWAP, L.VLN_CURRENT_INTEREST, L.VLN_VERMONT_RELATIONSHIP,
L.VLN_GUAR_AMT, L.VSAG_AID_GROUP, L.REC_STATUS, L.VSIB_BRANCH_ID,
L.VLN_EXIT_ENR_STATUS, L.VSIN_ID, L.VLN_CLAIM_ASSIST_STATUS, L.VSLR_CODE,
L.VLN_INTERIM_PAID_AMOUNT, L.VSLS_STATUS FROM COMMONDTA.VSLN00P AS L,
COMMONDTA.VSPR00p AS P INNER JOIN COMMONDTA.VSAT00P AS A ON
L.VLN_LOAN_TYPE=A.VSAT_AID_TYPE AND A.VSAT_CONSOL_LOAN='Y' WHERE
L.VLN_BORROWER_ID = 177973 and L.VLN_CURRENT_PRINCIPAL > 0.0 AND
L.VLN_BORROWER_ID = P.VPR_PERSON_ID AND P.VPR_SSN__CHAR_ = '00XXXXXXX'

Sorry for yelling in the subject. I accidentally pasted from a text file and forgot myself.
Jason

Similar Messages

  • SQL query problem - select max (case... aggregate function)

    Hi,
    I have a problem with below sql query, it gives me problem/error message 'ORA-00937: not a single-group group function', why?
    select sag.afdeling, sag.sagsnr, to_char(sag.start_dato, 'yyyy-mm-dd'), sag.stat, BOGF_TRANS.TRANSTYPE,
    max (case when BOGF_TRANS.TRANSTYPE = 'K' then sum(bogf_trans.belobdkk) end) + -- as "TRANSTYPE K",
    max (case when BOGF_TRANS.TRANSTYPE = 'D' then sum(bogf_trans.belobdkk) end) as "TRANSTYPE K & D",
    max (case when BOGF_TRANS.TRANSTYPE = 'S' then sum(bogf_trans.belobdkk) end) as "SUM TRANSTYPE S"
    from sag
    join bogf_trans on sag.selskab = bogf_trans.selskab and sag.sagsnr = bogf_trans.sagsnr and sag.afdeling = bogf_trans.afdeling
    where SAG.SELSKAB=37 and SAG.AFDELING = 'SUS' AND SAG.SAGSNR = 10876
    group by sag.afdeling, sag.sagsnr, sag.start_dato, sag.stat, BOGF_TRANS.TRANSTYPE
    If I exclude (columns) as below it give me correct summations (max (case... sum(...)) but then I miss some important info that I need
    select
    max (case when BOGF_TRANS.TRANSTYPE = 'K' then sum(bogf_trans.belobdkk) end) + -- as "TRANSTYPE K",
    max (case when BOGF_TRANS.TRANSTYPE = 'D' then sum(bogf_trans.belobdkk) end) as "TRANSTYPE K & D",
    max (case when BOGF_TRANS.TRANSTYPE = 'S' then sum(bogf_trans.belobdkk) end) as "SUM TRANSTYPE S"
    from sag
    join bogf_trans on sag.selskab = bogf_trans.selskab and sag.sagsnr = bogf_trans.sagsnr and sag.afdeling = bogf_trans.afdeling
    where SAG.SELSKAB=37 and SAG.AFDELING = 'SUS' AND SAG.SAGSNR = 10876
    group by sag.afdeling, sag.sagsnr, sag.start_dato, sag.stat, BOGF_TRANS.TRANSTYPE
    Any ideas?

    Moved to more sutable forum, sorry.

  • Date in sql query problem

    Hi,
    I have a search form with 1 field (date picker) - the user chooses a date and a report based on a sql query is shown.
    I want the report to be based on only the month and year, and not the particular day.
    If there is a date picker (or something similar) for only month and/or year, then I can change my form, but I don't see this option.
    So, I'm trying to write my query to ignore the Day portion in the search form and just do a search based on the month and year, but i'm having trouble with this.
    This is my query...
    select d.dept, count(e.emp_id) "No. of Employees"
    from dept d, employees e
    where e.date_created = trunc(:P13_DATE, 'MONTH YYYY')
    and d.dept_id = e.dept_id
    group by dept
    order by dept
    How do I write the where clause so that the search is done only on month and year?
    Or otherwise, how can I change the search form to exclude the day from the date?
    Thanks.

    Hi,
    Oh, the invalid number is the result of :P13_DATE being a string value. all item values are actually strings (or varchar2 if you like) when you referencing them with ':Px_ITEM' format. With the pl/sql function there are 2 possible ways to reference item, namely the function: V('Px_ITEM') and NV('Px_ITEM'). Although in SQL varchar2 => number conversion can be dealed with by the SQL engine.
    Unfortunally there is no pl/sql method for getting a DATE of an date-picker item (based on its format mask etc.). Patrick Wolf has added this function in his ApExLib framework, function DV. I find this a nice extension.

  • A challenging dynamic SQL query problem

    hi All,
    I have a very interesting problem at work:
    We have this particular table defined as follows :
    CREATE TABLE sales_data (
    sales_id NUMBER,
    sales_m01 NUMBER,
    sales_m02 NUMBER,
    sales_m03 NUMBER,
    sales_m04 NUMBER,
    sales_m05 NUMBER,
    sales_m06 NUMBER,
    sales_m07 NUMBER,
    sales_m08 NUMBER,
    sales_m09 NUMBER,
    sales_m10 NUMBER,
    sales_m11 NUMBER,
    sales_m12 NUMBER,
    sales_prior_yr NUMBER );
    The columns 'sales_m01 ..... sales_m12' represents aggregated monthly sales, in which 'sales_m01' translates to 'sales for the month of january, january being the first month, 'sales_m02' sales for the month of february, and so on.
    The problem I face is that we have a project which requires that a parameter be passed to a stored procedure which stands for the month number which is then used to build a SQL query with the following required field aggregations, which depends on the parameter passed :
    Sample 1 : parameter input: 4
    Dynamically-built SQL query should be :
    SELECT
    SUM(sales_m04) as CURRENT_SALES,
    SUM(sales_m01+sales_m02+sales_m03+sales_m04) SALES_YTD
    FROM
    sales_data
    WHERE
    sales_id = '0599768';
    Sample 2 : parameter input: 8
    Dynamically-built SQL query should be :
    SELECT
    SUM(sales_m08) as CURRENT_SALES,
    SUM(sales_m01+sales_m02+sales_m03+sales_m04+
    sales_m05+sales_m06+sales_m07+sales_m08) SALES_YTD
    FROM
    sales_data
    WHERE
    sales_id = '0599768';
    So in a sense, the contents of SUM(sales_m01 ....n) would vary depending on the parameter passed, which should be a number between 1 .. 12 which corresponds to a month, which in turn corresponds to an actual field range on the table itself. The resulting dynamic query should only aggregate those columns/fields in the table which falls within the range given by the input parameter and disregards all the remaining columns/fields.
    Any solution is greatly appreciated.
    Thanks.

    Hi another simpler approach is using decode
    try like this
    SQL> CREATE TABLE sales_data (
      2  sales_id NUMBER,
      3  sales_m01 NUMBER,
      4  sales_m02 NUMBER,
      5  sales_m03 NUMBER,
      6  sales_m04 NUMBER,
      7  sales_m05 NUMBER,
      8  sales_m06 NUMBER,
      9  sales_m07 NUMBER,
    10  sales_m08 NUMBER,
    11  sales_m09 NUMBER,
    12  sales_m10 NUMBER,
    13  sales_m11 NUMBER,
    14  sales_m12 NUMBER,
    15  sales_prior_yr NUMBER );
    Table created.
    SQL> select * from sales_data;
      SALES_ID  SALES_M01  SALES_M02  SALES_M03  SALES_M04  SALES_M05  SALES_M06  SALES_M07  SALES_M08  SALES_M09  SALES_M10  SALES_M11  SALES_M12 SALES_PRIOR_YR
             1        124        123        145        146        124        126        178        189        456        235        234        789          19878
             2        124        123        145        146        124        126        178        189        456        235        234        789          19878
             1        100        200        300        400        500        150        250        350        450        550        600        700          10000
             1        101        201        301        401        501        151        251        351        451        551        601        701          10000----now for your requirement. see below query if there is some problem then tell.
    SQL> SELECT sum(sales_m&input_data), DECODE (&input_data,
      2                 1, SUM (sales_m01),
      3                 2, SUM (sales_m01 + sales_m02),
      4                 3, SUM (sales_m01 + sales_m02 + sales_m03),
      5                 4, SUM (sales_m01 + sales_m02 + sales_m03 + sales_m04),
      6                 5, SUM (sales_m01 + sales_m02 + sales_m03 + sales_m04 + sales_m05),
      7                 6, SUM (sales_m01 + sales_m02 + sales_m03 + sales_m04+sales_m05+sales_m06),
      8                 7, SUM (sales_m01 + sales_m02 + sales_m03 + sales_m04+sales_m05+sales_m06+sales_m07),
      9                 8, SUM (sales_m01 + sales_m02 + sales_m03 + sales_m04+sales_m05+sales_m06+sales_m07+sales_m08),
    10                 9, SUM (sales_m01 + sales_m02 + sales_m03 + sales_m04+sales_m05+sales_m06+sales_m07+sales_m08+sales_m09),
    11                 10,SUM (sales_m01 + sales_m02 + sales_m03 + sales_m04+sales_m05+sales_m06+sales_m07+sales_m08+sales_m09+sales_m10),
    12                 11,SUM (sales_m01 + sales_m02 + sales_m03 + sales_m04+sales_m05+sales_m06+sales_m07+sales_m08+sales_m09+sales_m10+sales_m11),
    13                 12,SUM (sales_m01 + sales_m02 + sales_m03 + sales_m04+sales_m05+sales_m06+sales_m07+sales_m08+sales_m09+sales_m10+sales_m11+sales_m12)
    14                ) total
    15    FROM sales_data
    16   WHERE sales_id = 1;
    Enter value for input_data: 08
    Enter value for input_data: 08
    old   1: SELECT sum(sales_m&input_data), DECODE (&input_data,
    new   1: SELECT sum(sales_m08), DECODE (08,
    SUM(SALES_M08)      TOTAL
               890       5663

  • PL/SQL function body returning SQL Query Problem

    I have wandered around the forums and found quite a bit of helpful information that has gotten me to the point I am now at. Unfortuntely, PL/SQL is not my strongest point and I am getting an error when I attempt to run my report.
    This is what I have for my package:
    CREATE OR REPLACE PACKAGE LIB2.report_query
    is
    function create_report2(v1 IN varchar2) RETURN VARCHAR2;
    end report_query;
    CREATE OR REPLACE PACKAGE BODY LIB2.report_query
    as
    function create_report2(v1 in varchar2) return varchar2
    is
    l_vc_format HTMLDB_APPLICATION_GLOBAL.VC_ARR2 := HTMLDB_UTIL.STRING_TO_TABLE(v1);
    l_format varchar2(255) := HTMLDB_UTIL.TABLE_TO_STRING(l_vc_format);
    q1 varchar2(32767) := ' ';
    begin
    q1 :=
    'select b.BOOK_ID, bk.book_id bkid, bkk.book_id bkkid, b.TITLE, b.SUBTITLE, b.SERIES, b.VOLUME, b.ISBN, f.FORMAT_RET, b.DESCRIPTION, .PUBLISHED,'
    ||'b.PURCHASED_FROM, b.COMMENTS, b.WEBSITE, c.LENGTH_MINS, stragg(p.last_name || '', '' || p.first_name) Author, '
    ||'stragg(p.person_id) person_id, '
    ||'pb.name PUBLISHER, decode(b.abridged, ''Y'',''Abridged'',''N'',''Unabridged'') Abridged,'
    ||'(nvl(d.disk01,0)+nvl(d.disk02,0)+nvl(d.disk03,0)+nvl(d.disk04,0)+nvl(d.disk05,0)+nvl(d.disk06,0)+nvl(d.disk07,0)+nvl(d.disk08,0)+'
    ||'nvl(d.disk09,0)+nvl(d.disk10,0)+nvl(d.disk11,0)+nvl(d.disk12,0)+nvl(d.disk13,0)+nvl(d.disk14,0)+nvl(d.disk15,0)+nvl(d.disk16,0)+nvl(d.disk17,0)+'
    ||'nvl(d.disk18,0)+nvl(d.disk19,0)+nvl(d.disk20,0)+nvl(d.disk21,0)+nvl(d.disk22,0)+nvl(d.disk23,0)+nvl(d.disk24,0)+nvl(d.disk25,0)+nvl(d.disk26,0)+'
    ||'nvl(d.disk27,0)+nvl(d.disk28,0)+nvl(d.disk29,0)+nvl(d.disk30,0)+nvl(d.disk31,0)+nvl(d.disk32,0)+nvl(d.disk33,0)+nvl(d.disk34,0)+nvl(d.disk35,0)+'
    ||'nvl(d.disk36,0)+nvl(d.disk37,0)+nvl(d.disk38,0)+nvl(d.disk39,0)+nvl(d.disk40,0)+nvl(d.disk41,0)+nvl(d.disk42,0)+nvl(d.disk43,0)+nvl(d.disk44,0)+'
    ||'nvl(d.disk45,0)+nvl(d.disk46,0)+nvl(d.disk47,0)+nvl(d.disk48,0)+nvl(d.disk49,0)+nvl(d.disk50,0)) total_tracks'
    ||'from book b, '
    ||'book bk,'
    ||'book bkk,'
    ||'person p,'
    ||'lkup_book_author la,'
    ||'lkup_book_publisher lp,'
    ||'lkup_book_format lkf,'
    ||'format f,'
    ||'publisher pb,'
    ||'conversion_info_audio c,'
    ||'lkup_book_disk_info d'
    ||'where b.book_id = la.book_id'
    ||'and b.book_id = bk.book_id'
    ||'and b.book_id = bkk.book_id'
    ||'and p.person_id = la.author_id'
    ||'and b.book_id = lp.book_id'
    ||'and b.book_id = c.book_id'
    ||'and b.book_id = d.book_id'
    ||'and b.book_id = lkf.book_id'
    ||'and lkf.format_id = f.format_id'
    ||'and pb.publisher_id(+) = lp.publisher_id'
    ||'and b.wishlist = ''N'''
    ||'and (upper(b.book_id) like ''%'' || upper(:P40_SEARCH) || ''%'''
    ||'or upper(b.title) like ''%'' || upper(:P40_SEARCH) || ''%'''
    ||'or upper(b.subtitle) like ''%'' || upper(:P40_SEARCH) || ''%'''
    ||'or upper(b.series) like ''%'' || upper(:P40_SEARCH) || ''%'''
    ||'or upper(b.volume) like ''%'' || upper(:P40_SEARCH) || ''%'''
    ||'or upper(b.isbn) like ''%'' || upper(:P40_SEARCH) || ''%'''
    ||'or upper(b.format) like ''%'' || upper(:P40_SEARCH) || ''%'''
    ||'or upper(b.description) like ''%'' || upper(:P40_SEARCH) || ''%'''
    ||'or upper(b.published) like ''%'' || upper(:P40_SEARCH) || ''%'''
    ||'or upper(b.purchased_from) like ''%'' || upper(:P40_SEARCH) || ''%'''
    ||'or upper(b.comments) like ''%'' || upper(:P40_SEARCH) || ''%'''
    ||'or upper(b.website) like ''%'' || upper(:P40_SEARCH) || ''%'''
    ||'or upper(p.last_name) like ''%'' || upper(:P40_SEARCH) || ''%'''
    ||'or upper(p.first_name) like ''%'' || upper(:P40_SEARCH) || ''%'''
    ||'or upper(pb.name) like ''%'' || upper(:P40_SEARCH) || ''%'''
    ||'or upper(:P40_SEARCH) is null)'
    ||'and ((upper(b.title) like ''%'' || upper(:P40_TITLE) || ''%'' or upper(:P40_TITLE) is null))'
    ||'and ((upper(b.series) like ''%'' || upper(:P40_SERIES) || ''%'' or upper(:P40_SERIES) is null))'
    ||'and ((upper(p.last_name) like ''%'' || upper(:P40_LASTNAME) || ''%'' or upper(:P40_LASTNAME) is null))'
    ||'and ((upper(p.first_name) like ''%'' || upper(:P40_FIRSTNAME) || ''%'' or upper(:P40_FIRSTNAME) is null))'
    ||'and ((upper(f.format_ret) in (upper(l_vc_format)) or upper(:P40_FORMAT) is null))'
    ||'group by b.BOOK_ID, bk.book_id, bkk.book_id, b.TITLE, b.SUBTITLE, b.SERIES, b.VOLUME, b.ISBN, f.FORMAT_ret, b.DESCRIPTION, '
    ||'b.PUBLISHED, b.PURCHASED_FROM, b.COMMENTS, b.WEBSITE, c.LENGTH_MINS, pb.name, b.abridged, '
    ||'(nvl(d.disk01,0)+nvl(d.disk02,0)+nvl(d.disk03,0)+nvl(d.disk04,0)+nvl(d.disk05,0)+nvl(d.disk06,0)+nvl(d.disk07,0)+nvl(d.disk08,0)+'
    ||'nvl(d.disk09,0)+nvl(d.disk10,0)+nvl(d.disk11,0)+nvl(d.disk12,0)+nvl(d.disk13,0)+nvl(d.disk14,0)+nvl(d.disk15,0)+nvl(d.disk16,0)+nvl(d.disk17,0)+'
    ||'nvl(d.disk18,0)+nvl(d.disk19,0)+nvl(d.disk20,0)+nvl(d.disk21,0)+nvl(d.disk22,0)+nvl(d.disk23,0)+nvl(d.disk24,0)+nvl(d.disk25,0)+nvl(d.disk26,0)+'
    ||'nvl(d.disk27,0)+nvl(d.disk28,0)+nvl(d.disk29,0)+nvl(d.disk30,0)+nvl(d.disk31,0)+nvl(d.disk32,0)+nvl(d.disk33,0)+nvl(d.disk34,0)+nvl(d.disk35,0)+'
    ||'nvl(d.disk36,0)+nvl(d.disk37,0)+nvl(d.disk38,0)+nvl(d.disk39,0)+nvl(d.disk40,0)+nvl(d.disk41,0)+nvl(d.disk42,0)+nvl(d.disk43,0)+nvl(d.disk44,0)+'
    ||'nvl(d.disk45,0)+nvl(d.disk46,0)+nvl(d.disk47,0)+nvl(d.disk48,0)+nvl(d.disk49,0)+nvl(d.disk50,0))';
    RETURN q1;
    EXCEPTION
    WHEN OTHERS THEN
    RETURN q1;
    end create_report2;
    end;
    And here is what I have for my Region Source on my report:
    return lib2.report_query.create_report2(v('P40_FORMAT'));
    Here is my error when I run the page:
    failed to parse SQL query:
    ORA-00936: missing expression
    I have tried the region source line in many variations, this is just my latest one. None of them have worked. I am quite obviously missing something quite important and probably extremely silly. Any ideas?
    Thanks!
    Chrissy

    Chrissy,
    This is what the package returns as a query:
    select b.BOOK_ID, bk.book_id bkid, bkk.book_id bkkid,
    b.TITLE, b.SUBTITLE, b.SERIES, b.VOLUME, b.ISBN, f.FORMAT_RET,
    b.DESCRIPTION, .PUBLISHED,b.PURCHASED_FROM, b.COMMENTS, b.WEBSITE,
    c.LENGTH_MINS, stragg(p.last_name || ', ' || p.first_name) Author,
    stragg(p.person_id) person_id, pb.name PUBLISHER, decode(b.abridged,
    'Y','Abridged','N','Unabridged') Abridged,
    (nvl(d.disk01,0)+nvl(d.disk02,0)+nvl(d.disk03,0)+nvl(d.disk04,0)+nvl(d.disk05,0)
    nvl(d.disk06,0)nvl(d.disk07,0)+nvl(d.disk08,0)+nvl(d.disk09,0)+nvl(d.disk10,0)
    nvl(d.disk11,0)nvl(d.disk12,0)+nvl(d.disk13,0)+nvl(d.disk14,0)+nvl(d.disk15,0)
    nvl(d.disk16,0)nvl(d.disk17,0)+nvl(d.disk18,0)+nvl(d.disk19,0)+nvl(d.disk20,0)
    nvl(d.disk21,0)nvl(d.disk22,0)+nvl(d.disk23,0)+nvl(d.disk24,0)+nvl(d.disk25,0)
    nvl(d.disk26,0)nvl(d.disk27,0)+nvl(d.disk28,0)+nvl(d.disk29,0)+nvl(d.disk30,0)
    nvl(d.disk31,0)nvl(d.disk32,0)+nvl(d.disk33,0)+nvl(d.disk34,0)+nvl(d.disk35,0)
    nvl(d.disk36,0)nvl(d.disk37,0)+nvl(d.disk38,0)+nvl(d.disk39,0)+nvl(d.disk40,0)
    nvl(d.disk41,0)nvl(d.disk42,0)+nvl(d.disk43,0)+nvl(d.disk44,0)+nvl(d.disk45,0)
    nvl(d.disk46,0)nvl(d.disk47,0)+nvl(d.disk48,0)+nvl(d.disk49,0)+nvl(d.disk50,0)) total_tracksfrom book b,
    book bk,book bkk,person p,lkup_book_author la,lkup_book_publisher lp,
    lkup_book_format lkf,format f,publisher pb,conversion_info_audio c,
    lkup_book_disk_info dwhere b.book_id = la.book_idand b.book_id = bk.book_idand b.book_id = bkk.book_idand p.person_id = la.author_idand
    b.book_id = lp.book_idand b.book_id = c.book_idand b.book_id = d.book_idand
    b.book_id = lkf.book_idand lkf.format_id = f.format_idand pb.publisher_id(+) = lp.publisher_idand
    b.wishlist = 'N'and (upper(b.book_id) like '%' || upper(:P40_SEARCH) || '%'
    or upper(b.title) like '%' || upper(:P40_SEARCH) || '%'or upper(b.subtitle) like '%' ||
    upper(:P40_SEARCH) || '%'or upper(b.series) like '%' || upper(:P40_SEARCH) || '%'or
    upper(b.volume) like '%' || upper(:P40_SEARCH) || '%'or upper(b.isbn) like '%' ||
    upper(:P40_SEARCH) || '%'or upper(b.format) like '%' || upper(:P40_SEARCH) || '%'or upper(b.description) like '%' || upper(:P40_SEARCH) || '%'or upper(b.published)
    like '%' || upper(:P40_SEARCH) || '%'or upper(b.purchased_from) like '%' ||
    upper(:P40_SEARCH) || '%'or upper(b.comments) like '%' || upper(:P40_SEARCH)
    || '%'or upper(b.website) like '%' || upper(:P40_SEARCH) || '%'or
    upper(p.last_name) like '%' || upper(:P40_SEARCH) || '%'or upper(p.first_name)
    like '%' || upper(:P40_SEARCH) || '%'or upper(pb.name) like '%' ||
    upper(:P40_SEARCH) || '%'or upper(:P40_SEARCH) is null)and
    ((upper(b.title) like '%' || upper(:P40_TITLE) || '%' or
    upper(:P40_TITLE) is null))and ((upper(b.series) like '%' ||
    upper(:P40_SERIES) || '%' or upper(:P40_SERIES) is null))and
    ((upper(p.last_name) like '%' || upper(:P40_LASTNAME) || '%' or
    upper(:P40_LASTNAME) is null))and ((upper(p.first_name) like '%' ||
    upper(:P40_FIRSTNAME) || '%' or upper(:P40_FIRSTNAME) is null))and
    ((upper(f.format_ret) in (upper(l_vc_format)) or upper(:P40_FORMAT) is null))
    group by b.BOOK_ID, bk.book_id, bkk.book_id, b.TITLE, b.SUBTITLE, b.SERIES, b.VOLUME,
    b.ISBN, f.FORMAT_ret, b.DESCRIPTION, b.PUBLISHED, b.PURCHASED_FROM, b.COMMENTS, b.WEBSITE,
    c.LENGTH_MINS, pb.name, b.abridged, (nvl(d.disk01,0)+nvl(d.disk02,0)+nvl(d.disk03,0)
    nvl(d.disk04,0)nvl(d.disk05,0)+nvl(d.disk06,0)+nvl(d.disk07,0)+nvl(d.disk08,0)
    nvl(d.disk09,0)nvl(d.disk10,0)+nvl(d.disk11,0)+nvl(d.disk12,0)+nvl(d.disk13,0)
    nvl(d.disk14,0)nvl(d.disk15,0)+nvl(d.disk16,0)+nvl(d.disk17,0)+nvl(d.disk18,0)
    nvl(d.disk19,0)nvl(d.disk20,0)+nvl(d.disk21,0)+nvl(d.disk22,0)+nvl(d.disk23,0)
    nvl(d.disk24,0)nvl(d.disk25,0)+nvl(d.disk26,0)+nvl(d.disk27,0)+nvl(d.disk28,0)
    nvl(d.disk29,0)nvl(d.disk30,0)+nvl(d.disk31,0)+nvl(d.disk32,0)+nvl(d.disk33,0)
    nvl(d.disk34,0)nvl(d.disk35,0)+nvl(d.disk36,0)+nvl(d.disk37,0)+nvl(d.disk38,0)
    nvl(d.disk39,0)nvl(d.disk40,0)+nvl(d.disk41,0)+nvl(d.disk42,0)+nvl(d.disk43,0)
    nvl(d.disk44,0)nvl(d.disk45,0)+nvl(d.disk46,0)+nvl(d.disk47,0)+nvl(d.disk48,0)
    nvl(d.disk49,0)nvl(d.disk50,0))
    This query will never work. I marked only couple of errors you have there. Actually,
    I meant "formating" errors rather than "syntactical" errors. You are missing spaces
    all over the place. This is why I suggested to use a CLOB column in a test table
    to return the query for debugging purposes - this is how I do it at least, when I need
    to escape and concatenate a lot of code.
    If you are referencing item values from a user session in a function or a procedure,
    then you need to use the v('ITEM') syntax instead of :ITEM syntax. However, if the
    output of this procedure will be used as a function returning SQL query, you will
    be fine with :ITEM.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • SQL query problem with sorting

    Hi,
    I have question regarding sql query . Right now I am getting the results like this if i use this sql query
    select ID,Name,Desc,Priority from emp order by Priority ;
    Priority is varchar field. I don't want to change the Priority field and cannot add a new column in the table. Because i don't have permission to do that.
    ID Name Desc Priority
    =============================================
    234 paul paul desc Highest
    3452 mike mike desc High
    4342 smith smith desc Low
    6565 kelly kelly desc Low
    9878 nate nate desc Medium
    3223 deb deb desc High
    ============================================
    I need a query to get the results like that.
    ID Name Desc Priority
    =============================================
    234 paul paul desc Highest
    3452 mike mike desc High
    3223 deb deb desc High
    9878 nate nate desc Medium
    4342 smith smith desc Low
    6565 kelly kelly desc Low
    ============================================
    If any one knows about this one, please let me know.
    Thanks,
    Bala

    You are aware that there are differences in the SQL implementation between Sqlserver and Oracle? You could try something like this, if there's a INSTR function:
    ORDER BY INSTR('Highest,High,Medium,Low,', Priority || ',')You may have to change the "Priority || ," to a "Priority + ','), if string concatenation is done differently in sqlserver. Don't know about the ('), maybe you need (").
    C.

  • Named Native Query Problem

    I am running JDev 11g patch 2 (11...3) on a windows 7 machine. JDK 1.6_18
    @NamedNativeQueries({
    @NamedNativeQuery(name = "MenuFolders.findFolderByUser",
    query = "SELECT * FROM menu_folders where mf_id is null and id in (select mf_id from userfoldervw where UPPER(user_name) = :p_user) order by display_order",
    resultClass = MenuFolders.class)
    I have entered the above code in to a entity bean - but all I get back when I run is invalid SQL statement - it works fine in a sql window.
    I tried to use just "SELECT * FROM menu_folders " and get the same problem. Many of the examples show the same format as in the namedQuery ("select o from menuFolders o") but I thought the principle of native querys was to use standard SQL - just for this reason - not everything can be done in sql expression language.
    Two things 1) mf_id is self referencing and there is no definition for the column in the regular EJB code. 2) userfoldervw is outside the bean (and yes it is a view)
    There is a secondary issue - this is a master for another table which holds the actual items (forms).
    I want to build a menu tree - normally I would do this in a backing bean and problematically build the tree menu - however - with JDeveloper this does not appear to be an option.
    I have the system working fine in the Netbeans IDE using the backing bean.
    I was looking for the adfMenuTree (the adfTree does not have the folder/node concept. I cannot find sufficient info on the adfTree to understand how it manages levels to make any sense out of it.)
    Can someone give me a hand on this (either a backing bean solution with the adfTree or a view object - or just the sql)?

    I have been developing with NetBeans and find it a much simpler IDE to work with but it is not time to move on.
    The project I have been working on has a basic splash screen -> Login -> Menu structure.
    The menu is based on a workflow and role concept. In the login I capture the users roles and the location code. These are stored in a session bean.
    The username and the location code then govern the items in the menu and a to do list that is in a split panel (menu on left and to dos on the right with a button that takes them to the appropriate page based on workflow)
    The issue I had with ADF was the lack of a data control in the page - I was using pure JSF. When I looked at the backing bean in the debugger - the input text was not being passed to the backing bean.
    I was able to solve this by a bit of editing in the jsp and some movement in the locations. What I found interesting was that the methods in the backing bean worked fine (with the NPE due to the lack of the binding of the input text to the backing bean).
    I am trying to move my skills into ADF/JDeveloper - and finding that it is a very obtuse IDE. The focus seems to be on technology rather than application development.
    I came from the Oracle Forms/Reports environment and used the Designer2000 extensively - the focus was only on the business logic - the rest was generated for you.
    With NetBeans - I found a similar focus. JDeveloper however is a different animal - I have spent hours and read tons of material - and still cannot find answers to very simple things.
    I have a good example - I have a view object that takes a parameter - it looks to me like I will have to write over 100 lines of code to get this to work and I an still not sure how I will manage it in a backing bean.
    I have no control - other than a button to execute a method (Netbeans had an abstract page bean that exposed parts of the life cycle (init, prerender, etc ...) that allowed me to execute code at specific life cycle stages - I have not found anything at all in the ADF that would guide me in doing the same.
    According to all the documentation I have read (considerable) I will have to defeat ADF and do everything programatically - what a waste of good technology and my time.
    I may be wrong - I hope I am - maybe some one can point me into a direction that can help me with this (everything in the tutorials misses these simple issues that we use every day).

  • SQL query problem using analytical/report function

    Hello there,
    I am having some problem writing my query. I have this table below:
                  create table t (priority number,
                                  plannedamount number,
                                  availablepieces number,
                                  material_id varchar2(20))
    insert into t values (1, 15, 30, 'A');
    insert into t values (2, 20, 30, 'A');
    insert into t values (3, 5, 30, 'A');
    insert into t values (4, 8, 30, 'A');
    insert into t values (5, 4, 30, 'A');
    insert into t values (1, 2, 10, 'B');     PRIORITY|     PLANNED AMOUNT|AVAILABLE PIECES |     MATERIAL_ID
         1      15     30 A     
         2      20     30 A
         3      5     30 A
         4      8 30 A
         5      4     30 A
         1      2     30 B .
    Each line is a customer order ordering a material. I am grouping by material and ordering it by priority. I want to display a new column called pieces not reserved yet. This column will show that if the order can be fully reserved for that current order ordering by priority.
    If the row can be reserved it will substract and bring it to the next row. If it cannot the pieces not reserved will remain the same.
    I've tried using sum(), lead(), first(), lag(), etc but I still cannot get the correct result.
         PRIORITY|     PLANNED AMOUNT|PIECES NOT RESERVED YET |     MATERIAL_ID
         1      15     30 A     
         2      20     15 A
         3      5     15 A
         4      8     10 A
         5      4     2 A
         1      2     30 B
    Can anyone elaborate or have any hints on what method to use to create this column?
    Thanks. .
    Edited by: 998373 on Apr 5, 2013 11:42 AM
    Edited by: 998373 on Apr 5, 2013 11:43 AM

    From 10.x on
    with t(PRIORITY, PLANNED_AMOUNT,AVAILABLE_PIECES , MATERIAL_ID) as
    select      1, 15, 30, 'A' from dual union all
    select 2, 20, 30, 'A' from dual union all
    select 3, 5, 30, 'A' from dual union all
    select 4, 8, 30, 'A' from dual union all
    select 5, 4, 30, 'A' from dual union all
    select 1, 2, 30, 'B'  from dual
    select
      MATERIAL_ID
    , PRIORITY
    , PLANNED_AMOUNT
    , AVAILABLE_PIECES PIECES_NOT_RESERVED_YET
    from t
    model
    partition by (material_id)
    dimension by (PRIORITY)
    measures (
      PLANNED_AMOUNT
    , AVAILABLE_PIECES
    rules (
    AVAILABLE_PIECES[priority>1] order by priority=
      case when PLANNED_AMOUNT[cv()-1] <= AVAILABLE_PIECES[cv()-1]
           then AVAILABLE_PIECES[cv()-1] - PLANNED_AMOUNT[cv()-1]
           else AVAILABLE_PIECES[cv()-1]
      end
    MATERIAL_ID     PRIORITY     PLANNED_AMOUNT     PIECES_NOT_RESERVED_YET
    A     1     15     30
    A     2     20     15
    A     3     5     15
    A     4     8     10
    A     5     4     2
    B     1     2     30

  • Report SQL query problem

    Hi!
    I want to create a report with the script i copied at the bottom of this message. For some reason i get the following error:
    Error: Unable to describe SQL statement. Please correct it (WWV-13010)
    (WWV-)
    ORA-01001: invalid cursor (WWV-11230)
    ORA-00937: not a single-group group function (WWV-11230)
    Critical Error in wwerr_api_error.get_errors! SQL Error Message: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-01001: invalid cursor (WWV-)
    Does anybody have a clue where this is coming from? It seems to me that there are no diffucult un-SQL like things in the script.
    Thanks in advance!
    SELECT rse.name||', '||rse.initials||' '||rse.prefix "Medewerker"
    ,dpt.name "Afdeling"
    ,sum(round(act.duration *24,2)) "Aantal uren"
    ,count(distinct(sht.begin_date)) "Aantal dagen"
    ,count(distinct(ill.begin_time)) "Aantal keer"
    FROM ros.ros_departments@ROSPROD dpt
    ,ros.ros_scenarios@ROSPROD sco
    ,ros.ros_activity_types@ROSPROD aty
    ,ros.ros_activities@ROSPROD act
    ,ros.ros_duties@ROSPROD dty
    ,ros.ros_illnesses@ROSPROD ill
    ,ros.ros_shifts@ROSPROD sht
    ,ros.ros_resources@ROSPROD rse
    WHERE rse.id = sht.rse_id
    AND sht.name = 'Z'
    AND sht.begin_date <= sysdate
    AND ill.rse_id = rse.id
    AND trunc(sht.begin_date) BETWEEN trunc(ill.begin_time) AND trunc(nvl(ill.end_time,sysdate))
    AND dty.id = sht.dty_id
    AND decode(sign(dty.begin_time)
    ,-1, sht.begin_date + 1
    ,sht.begin_date)
    >= to_date('10-01-2000 00:00','dd-mm-yyyy hh24:mi')
    AND decode(sign(dty.begin_time)
    ,-1,sht.begin_date + 1
    ,sht.begin_date)
    <= to_date('10-01-2001 23:59','dd-mm-yyyy hh24:mi')
    AND sht.begin_date >= to_date('10-01-2000 00:00','dd-mm-yyyy hh24:mi') - 1
    AND sht.begin_date <= to_date('10-01-2001 23:59','dd-mm-yyyy hh24:mi') + 1
    AND act.dty_id = dty.id
    AND aty.id = act.ate_id
    AND aty.name = 'Ziek'
    AND sco.sce_rsr_id = sht.sce_id
    AND sco.status = 'PUBLISHED' -- <> 'TRIAL' en 'PLAN'
    AND dpt.id = sco.dpt_id
    AND dpt.name NOT IN ('BEEK/VKL', 'BEEK/VLA','EELDE/VKL','EELDE/VLA','ROTTERDAM/VKL','ROTTERDAM/VLA','SIM','STO','RCN','XSurvey')
    AND rse.name = :MDWPARAM
    AND dpt.name = :AFDPARAM
    GROUP BY rse.name||', '||rse.initials||' '||rse.prefix ,dpt.name
    ORDER BY 2,1

    Hi,
    Please run this sql statement in the SQL session. This way you will get the line number where the problem is happening.
    The error seems to be because the column in the select is not in the group by clause.
    Thanks,
    Sharmila

  • Access SQL Query Problem - Pls help

    Hi,
    I'm connecting to an Access database and have a query which looks somehting like this:
    SELECT Accept.ACCEPT_NO,
         Accept.CURRENCY,
         Accept.INT_RATE,
         Accept.F_AMOUNT,
         Accept.DEALER,
         Accept.MATURITY,
         Accept.START_DATE,
         Accept.DEAL_DATE,
         Accept.DEALTICKET,
         Accept.BANK_NAME,
         Accept.CALC_DAYS,
         "2001/11/22" AS CurrentDate
    FROM Accept;
    It works fine without the line with CurrentDate so i'm sure something's wrong there. What i want to do is set CurrentDate as a constant ("2001/11/22") i dont have any experience with Access so any help you could give me would be greatly appreciated.
    Thanx in advance.

    I was able to successfully query an access 97 database using the following SQL:
    String sql = "SELECT emp.emp_fname, emp.emp_lname, '2001/11/22' AS CurrentDate FROM emp";don't know why your's wouldn't work. Was there a SQLException? Or are you trying to get it to work using the Access SQL editor?
    Jamie

  • SQL Query Problem - Please Help

    Post Author: nmellick
    CA Forum: Data Connectivity and SQL
    Hello,
    I am trying to use a query in CR9 to pull the latest date of a DREXAM for each patient.  The patient can have one item or several items.  When I run this query, it only pulls back one record, the latest DREXAM from the whole table, not by patients.  I need it by patients (tracking_id is the patient_id).  Any ideas on what I'm doing wrong?
    Here is the query:select t.tracking_id, t.tracking_group_cd, t.track_event_id, t.requested_dt_tm, t.complete_dt_tm, te.display_keyfrom V500.TRACKING_EVENT t, v500.track_event tewhere t.track_event_id = te.TRACK_EVENT_IDand te.display_key = 'DREXAM'and t.complete_dt_tm = (select max(complete_dt_tm) "MaxDate" from V500.TRACKING_EVENT t, v500.track_event te                        where t.track_event_id = te.TRACK_EVENT_ID                        and te.display_key = 'DREXAM');
    Note:  The tracking_id field shows by patient.  When I run everything up to the last "and" (the complete date), it pulls all rows, which may be more than one per patient.  Basically, I just want the latest DREXAM row per patient.
    Thanks!

    Try to escape the special character '%' using '\%'.

  • Urgent Sql Query Problem - -Very Urgent

    Hi Guys,
    I need a urgent solution for a problem.I am
    using the following query
    select ename from emp where deptno =10
    Now I will declare a bind variable and if user passes 'A'
    then the query will run as it is and if he passes B
    then it should run the above query with this additional clause -> birthdate - hiredate >15.
    Please can any one help its very urgent

    Assuming that you have a birthdate column in your emp table, the following will do what you are asking for:
    VARIABLE bind_var VARCHAR2(1)
    EXECUTE :bind_var := '&bind_variable'
    SELECT ename FROM
    (SELECT 'A' AS selection, ename FROM emp WHERE deptno = 10
    UNION ALL
    SELECT 'B' AS selection, ename FROM emp WHERE deptno = 10 AND birthdate - hiredate > 15)
    WHERE selection = :bind_var
    However, the clause "birthdate - hiredate > 15" will only retrieve rows for employees who were born more than 15 days after they were hired. I doubt that this is what you really want, since this is impossible.

  • SQL Query Problems

    Hello,
    I am trying to query a database column containing xml. How my problem is when I display my query on the page the data is not being shown properly.
    The data in the database is like this:
    <P><tag1>2003/05/22 11:01:34</tag1><tag2>2003/05/22</tag2><tag3>11:01:34</tag3><tag4></tag4>.......
    However all that is returned is on the jsp page
    2003/05/22 11:01:34<tag2>2003/05/22<tag3>11:01:34..............
    i.e closing tags missing and empty pairs not shown at all.
    My query is a simple
    String sqlQuery="select * from table;
    rs = stmt.executeQuery (sqlQuery);
    rs.next();
    out.print(rs.getString(1));
    Can anyone suggest why the data stored in the column is being truncated and how I can prevent this.
    Many thanks in advance
    Les,

    Hi,
    For your problem, the solutions i thought is put your output between <pre></pre> tags in HTML
    means
    out.print("<pre>" + rs.getString("") + "</pre>")
    hope this willl work.
    have fun!!!

  • SQL query problem while combining two values.

    Hi,
    I am having a table test with columns X and Y. X is not nullable where as Y is nullable.
    I had a requirement where I have to get these two values seperated by '-' (Hyphen).
    So I wrote the query like :
    Select X||'-'|| Y from test.
    But now Y is nullable. So I'm getting some values ended by hypen if y is null. So is there any way to append these two only if Y is present and not to join if Y is null or empty.
    Help me out in resolving this issue.
    Regards,
    Venky.

    There are several ways to avoid/remove that hypen
    1. select RTRIM(X||'-'||Y,'-') from test
    2. select X||decode(Y,null,null,'-'||Y) from test
    HTH,
    Mohana

  • SQL Query problem (PL/SQL function returning SQl query)

    I am using 3.1.2 Apex. When I create the region source with the following code.
    DECLARE
    l_sql VARCHAR2(32767);
    X1 VARCHAR2(9);
    X2 VARCHAR2(9);
    X3 VARCHAR2(9);
    X4 VARCHAR2(9);
    X5 VARCHAR2(9);
    X6 VARCHAR2(9);
    X7 VARCHAR2(9);
    X8 VARCHAR2(9);
    BEGIN
    SELECT decode(:P3_FAILED_CDD,'0','0','1','1', '2','2' ) INTO X2
    FROM DUAL;
    SELECT decode(:P3_Order_status,'J','J','1','1','2') INTO X3
    FROM DUAL;
    SELECT decode(:P3_FAILED_STAGE,'0','0','1','1','2') INTO X4
    FROM DUAL;
    SELECT decode(:P3_ORDER_TYPE,'TYPE1','TYPE1','TYPE2','TYPE2','2') INTO X5
    FROM DUAL;
    SELECT decode(:P3_INCLUDE_SFIN,'NO','NO','YES','YES') INTO X6
    FROM DUAL;
    SELECT decode(:P3_CDD_MATCH,'0','0','1','1', '2','2' ) INTO X7
    FROM DUAL;
    SELECT decode(:P3_FIELD,'0','0','1','1', '2','2' ) INTO X8
    FROM DUAL;
    l_sql := 'SELECT
    ORDER_NR,
    FNN,
    ST,
    SOT,
    STAGE,
    CUST_NAME,
    STG_DAYS,
    ZONE,
    P1.OWNER,
    QUEUE_A,
    STG_LFD,
    LFD_LEFT,
    CIJ_FLAG,
    FST_FLAG,
    CCD_COUNT,
    TCD_COUNT,
    LATEST_RET_CODE,
    CRD,
    CDD_DATE,
    CRD_LEFT CDD_LEFT,
    TCD_DATE RTCD_DATE,
    PROP_TCD_DATE TCD_DATE,
    PROJECT_ID,
    APPLN_TBO,
    CO_ORD_ID,
    CON_WSTN,
    P1.STATE,
    A_DTB,
    B_DTB,
    DESIGN_NO,
    CREATE_DATE,
    DATE_APPLN,
    CUSTOMER_ID,
    SALES_QUEUE,
    TRACKING_NR,
    WORK_REQUIRED,
    SFIN_STAGE_ENTERED_DATE,
    APPLN_CONTACT_OFFICER,
    A_LOCATION_ADDRESS,
    B_LOCATION_ADDRESS,
    SO_CREATE_USERID,
    OP_SEP,
    WMC_CODE
    FROM RASS_TICKET_VIEW P1
    WHERE WMC_CODE like :p3_wmc_code
    AND ST in (SELECT SYSTEM_ID from PRDRF where PRODUCT_CATEGORY like :p3_product_cat)';
    IF X2 = '0' then
    l_sql := l_sql || ' and CRD_LEFT < 0';
    END IF;
    IF X2 = '1' then
    l_sql := l_sql || ' and CRD_LEFT >= 0';
    END IF;
    IF X3 = 'J' then
    l_sql := l_sql || ' and CIJ_FLAG = ''J''';
    END IF;
    IF X3 = '1' then
    l_sql := l_sql || ' and CIJ_FLAG is null';
    END IF;
    IF X4 = '0' then
    l_sql := l_sql || ' and LFD_LEFT < 0';
    END IF;
    IF X4 = '1' then
    l_sql := l_sql || ' and LFD_LEFT >= 0';
    END IF;
    IF X5 = 'TYPE1' then
    l_sql := l_sql || ' and SOT in (''NEW'',''NET'',''ERT'',''UGP'')';
    END IF;
    IF X5 = 'TYPE2' then
    l_sql := l_sql || ' and SOT not in (''NEW'',''NET'',''ERT'',''UGP'')';
    END IF;
    IF X6 = 'NO' then
    l_sql := l_sql || ' and STAGE in (''DSAL'',''DPLO'',''OISS'',''TRPB'',''OTST'',''TEQP'',''DSPS'')';
    END IF;
    IF X7 = '0' then
    l_sql := l_sql || ' and PROP_TCD_DATE <= CDD_DATE';
    END IF;
    IF     X7 = '1' then
    l_sql := l_sql || ' and PROP_TCD_DATE > CDD_DATE';
    END IF;
    RETURN l_sql;
    END;
    The query returns data.
    If I add some more code just after the where clause.
    AND decode(CUST_CODE,'TW','TW','RET') like (select decode(OPS_SEP,'TS','%',OPS_SEP) from T_U_CDW_BU_OP_SEP where upper(USER_ID) = upper(:APP_USER))
    The query just stops working and no error message is returned.
    I thought there was an issue prior to version 3.1.2 that was fixed in version 3.1.2
    Othwerwise is there a better way to write the code? As I have 7 radio btn's that control the condition within the where clause.
    Thanks
    Ron

    >
    bug in APEX 3.0
    >
    Are you sure?
    Do as Paul has suggested and post the code that doesn't work (including your extra line) using the {noformat}{noformat} tags +exactly+ as you had it in the region source.
    Cheers
    Ben                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for

  • BPM 11g - FYI task to send a copy to each member of a group

    In BPM 11g I am trying to send an FYI task to each member of a group. They should each get their own copy of the task so that it does not get removed from their inbox when the first person dismisses it. I was not successful in getting multiple copies

  • Oracle Collaboration Suite Slow Performance

    Hi, I have encountered with problem with OCS 10.1.2 with following information: Hardware : DL-380G5 Operating System : OEL 4 update 5 64 bit Oracle Product : Collaboration Suite 10.1.2 The installation has been done in three server as follow: Server

  • Is it bettter to download apps from your ipod rather than sync through computer

    when i sync app through my computer i always says backing up step 1 of 2 so will the problem stop if i use wifi and download apps from my ipod

  • How to insert Time alone

    i got time alone if i insert this in datetime field while selecting will return with default date as 1st date of current month ... is there any other option other than varchar field....

  • Problem opening a browser using applet

    I am trying to open a browser window with the following applet. The applet executes fine with no exception and even prints out the debug statement "Browser Opened" I put, but does not actually open the browser. I am using 1.3.1_05 version of plugin a