Constant expression required

(Original thread http://forum.java.sun.com/thread.jsp?forum=31&thread=428634)
Hello all,
in the following class, if the comment is removed, the compiler complains that a constant expression is required.
class Test {
final static int A;
final static int B=5;
static {
A=5;
public static void main(String args[]) {
switch(1) {
//case A:
case B:
Is this a bug? Is this a feature? How could A not be a constant expression?
Is it good coding style to initialize constant variables at declaration time and not in the static block?
7Kami

(Original thread
http://forum.java.sun.com/thread.jsp?forum=31&thread=42
634)
Hello all,
in the following class, if the comment is removed, the
compiler complains that a constant expression is
required.
class Test {
final static int A;
final static int B=5;
static {
A=5;
public static void main(String args[]) {
switch(1) {
//case A:
case B:
Is this a bug? Is this a feature? How could A not be a
constant expression?JLS goes to a lot of detail explaining why this is a language feature. It is required to support Java's requirement to never have unreachable code. In order to do that, the compiler need to have compile-time const expressions in case labels (otherwise it can never detect at static compilation time whether a case branch is reachable or not [e.g., because it clashes with another case label]). Those expressions could be either literals or static finals etc.
This, BTW, explains why inlining of static finals is not just an optimization but an essential language requirement.
The relevant JLS sections to read are 14.20 and 13.4.8.

Similar Messages

  • Error #: 409 : constant expression required at line 342

    hi all,
    switch( nodeClicked.hashCode() ) {
    case "Devices".hashCode(): showPanel_Devices();
    break;
    case "Clusters".hashCode(): showPanel_Clusters();
    break;
    case "General".hashCode(): showPanel_General();
    scan.nas.executeNTP(scan.getIPFromHash(parentNUSNode));
    scan.nas.executeSystemInfo(scan.getIPFromHash(parentNUSNode));
    scan.setValuesInNTP();
    scan.setValuesInSystemInfo();
    break; default: showPanel_LHNScreen();
    break;
    i am getting error at
    "Devices".hashCode()
    its saying that "constant expression required" at that place.......
    can anyone help me plz.....its urgent..............
    Thanks,
    Kalpana

    Case statements need integer literals or constant integer expressions. No runtime expressions are allowed.
    Do this instead:
    if(nodeClicked.equals("Devices")) ...;
    else if(nodeClicked.equals("Clusters")) ...;
    else if(nodeClikcked.equals("General")) ...;
    else ...;It's not a good idea to use hash codes like this, because two objects with different values can have the same hash code.

  • BUG: constant expression required

    Hello,
    the attached code fragment compiles with javac but produces a "constant expression required" with internal compiler (Version 10.1.3.0.4 (SU2))
    Regards
    Michael
    package bug.repro;
    public class Class1 {
    protected final int TYPE_LH = 1;
    package bug.repro;
    public class Class2 extends Class1 {
    protected void checkRule(int iStatus)
    switch (iStatus) {
    case TYPE_LH:
    break;
    -------

    Hi,
    thanks, i filed a bug.
    Frank

  • Switch: constant expression required

    Hi,
    i initialize some integer constants with the hash code of some strings. However, i cannot use these constants in "case"s of "switch". How can i deal with this?
    Here's the code:
        public void parseHeader()
            char[] headerChars=header_.toCharArray(); //the array representation of the XML header tag
            StringBuffer sBuffer=new StringBuffer();  //the String
            char c=' ';
            int fieldCode=0;
            for (int i=0; i<headerChars.length; i++)
                c=(char)headerChars;
    if (c=='\n')
    switch(fieldCode)
    case ACCEPT:
    sAccept_=new String(sBuffer);
    break;
    case ACCEPT_CHARSET:
    sAcceptCharset_=new String(sBuffer);
    break;
    case ACCEPT_ENCODING:
    sAcceptEncoding_=new String(sBuffer);
    break;
    case ACCEPT_LANGUAGE:
    sAcceptLanguage_=new String(sBuffer);
    break;
    case AUTHORIZATION:
    sAuthorization_=new String(sBuffer);
    break;
    case CACHE_CONTROL:
    sCacheControl_=new String(sBuffer);
    break;
    case CLIENT_IP:
    sClientIp_=new String(sBuffer);
    break;
    case INT_CONNECTION:
    sConnection_=new String(sBuffer);
    break;
    case CONTENT_LANGUAGE:
    sContentLanguage_=new String(sBuffer);
    break;
    case CONTENT_LOCATION:
    sContentLocation_=new String(sBuffer);
    break;
    case CONTENT_MD5:
    sContentMD5_=new String(sBuffer);
    break;
    case WARNING:
    sWarning_=new String(sBuffer);
    break;
    case X_FORWARDED_FOR:
    sXForwardedFor_=new String(sBuffer);
    break;
    case X_SERIAL_NUMBER:
    sXSerialNumber_=new String(sBuffer);
    break;
    default:
    System.err.println("Header field with hash code: "+fieldCode+" detected");
    else if (c==':')
    fieldCode=new String(sBuffer).hashCode();
    sBuffer=new StringBuffer();
    else
    sBuffer.append(c);
    private static final int ACCEPT= "Accept".hashCode();
    private static final int ACCEPT_CHARSET="Accept-Charset".hashCode();
    private static final int ACCEPT_ENCODING="Accept-Encoding".hashCode();
    private static final int ACCEPT_LANGUAGE="Accept-Language".hashCode();
    private static final int AUTHORIZATION="Authorization".hashCode();
    private static final int CACHE_CONTROL="Cache-Control".hashCode();
    private static final int CLIENT_IP="Client-ip".hashCode();
    private static final int CONNECTION="connection".hashCode();
    private static final int CONTENT_LANGUAGE="Content-Language".hashCode();
    private static final int CONTENT_LOCATION="Content-Location".hashCode();
    private static final int CONTENT_MD5="Content-MD5".hashCode();
    private static final int WARNING="Warning".hashCode();
    private static final int X_FORWARDED_FOR="X-Forwarded-For".hashCode();
    private static final int X_SERIAL_NUMBER="X-Serial-Number".hashCode();
    Message was edited by:
    uig

    the labels in a switch-case statement have to be compile-time constant. Anything that involves calling a method is not.
    you could make an enumerated type
    http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html

  • Error: An integer constant expression is required within the array subscrip

    hello all,
    here is a small piece of code which compile well with g++:
    #include <iostream>
    using namespace std;
    int main () {
    int i= 0, j=4 ;
    cout <<" i=" ; cin >> i ;
    cout  << "i="<<i<< endl;
    if ( i > 1) {
       double xx [i+5];
       int n= i+5;
       for (int k =0 ; k < n ; k++) xx[k] =k;
      cout << "xx[2]=" << xx[2] << " xx[4]=" << xx[4] <<" xx["<<i<<"]="<< xx[i] <<en
    dl;
      cout << "xx[1]=" << xx[3] << " xx[5]=" << xx[4] <<" xx["<<n-1<<"]="<< xx[n-1]
    <<endl;
    }with Sun Studio 12 CC, the error is:
    "x.C", line 12: Error: An integer constant expression is required within the array subscript operator.
    1 Error(s) detected.Is there an option to force CC to accept it? i read that CC has some gnu extensions (http://docs.sun.com/source/820-4155/c++.html)
    Thanks in advance for help,
    gerard

    This works:
    #include <iostream>
    #include <alloca.h>
    using namespace std;
    int main () {
    int i= 0, j=4 ;
    cout <<" i=" ; cin >> i ;
    cout  << "i="<<i<< endl;
    if ( i > 1) {
       double *xx = ( double * ) alloca( sizeof( *xx ) * ( i + 5 ) );
       int n= i+5;
       for (int k =0 ; k < n ; k++) xx[k] =k;
      cout << "xx[2]=" << xx[2] << " xx[4]=" << xx[4] <<" xx["<<i<<"]="<< xx[i] <<en
    dl;
      cout << "xx[1]=" << xx[3] << " xx[5]=" << xx[4] <<" xx["<<n-1<<"]="<< xx[n-1]
    <<endl;
    }

  • NI USB 6008: expected constant expression

    I am using NI USB 6008 device. Looking at NI-DAQ\Examples\DAQmx ANSI C\Analog In\Measure Voltage\Acq-Int Clk\
    So I want to modify the line that has
    DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,1000,10.0,DAQmx_Val_GroupByChannel,data,1000,&read,NULL));
    as
        DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,numsamps,TimeouT,DAQmx_Val_GroupByChannel,data,numsamps,&read,NULL));
    where the corresponding variables have been defined before like:
      Int_t xx=2;
      const Int_t numsamps = const_cast<Int_t&>(xx);
        int32       error=0;
        TaskHandle  taskHandle=0;
        int32       read;
        float64     data[numsamps];
        float64 RatE = float64(raTE);
        float64 TimeouT = float64(numsamps)/RatE;
    But when I try to compile I get this error message:
    $ nmake -f makefile.mak
    Microsoft (R) Program Maintenance Utility Version 8.00.50727.42
    Copyright (C) Microsoft Corporation.  All rights reserved.
            cl  -D_MT -D_DLL -MDd -EHsc  -nologo -G5 -GR -MD -DWIN32  -DVISUAL_CPLUS
    PLUS -D_WINDOWS -IC:\ROOT/include -O2 -c SNatInDAQ.cpp
    cl : Command line warning D9025 : overriding '/MDd' with '/MD'
    cl : Command line warning D9002 : ignoring unknown option '-G5'
    SNatInDAQ.cpp
    SNatInDAQ.cpp(261) : error C2057: expected constant expression
    SNatInDAQ.cpp(261) : error C2466: cannot allocate an array of constant size 0
    SNatInDAQ.cpp(261) : error C2133: 'data' : unknown size
    NMAKE : fatal error U1077: '"c:\Program Files\Microsoft Visual Studio 8\VC\BIN\c
    l.EXE"' : return code '0x2'
    Stop.
    What does it mean 'expected constant expression'? How can I get around this?
    What I want to do is pass the size of that data array from another function.

    Hi novaiscool,
    I think the issue is that you are declaring numsamps as a constant and the DAQmxReadAnalogF64 function wnats a non constant parameter.  Have you tried calling the function with a regular int or a value?  Give that a try and see if you get the same error. 
    You will also need to initialize numsamps to something since you are allocating an array using that variable. 
    Give those things a try and let me know how it works.
    Thank You,
    Nick F.
    Applications Engineer

  • ORA-56901: non-constant expression is not allowed for pivot|unpivot values

    Getting following errors
    ORA-56901: non-constant expression is not allowed for pivot|unpivot values
    ORA-06512: at "APPS.PIVOT_AWARD", line 16
    ORA-06512: at line 5
    when i run the following function it is giving error as above.
    can you please help me
    create or replace
    Function Pivot_award return sys_refcursor
    IS
       v_dept    VARCHAR2 (20000);
       v_query   VARCHAR2 (1000);
       op_rs sys_refcursor;
    BEGIN
      SELECT LISTAGG(award_number,',') WITHIN GROUP (ORDER BY award_id)
      INTO V_DEPT FROM xxdl.XXDL_CD_SCHEDULE_K_GTT ;
       v_query :=
          'SELECT *
            FROM (
            select award_name, award_id,award_number from xxdl.XXDL_CD_SCHEDULE_K_GTT)
            PIVOT(max(VAL) for award_number in  ('||v_dept||'))';
       OPEN op_rs FOR v_query;
       return op_rs;
    END;
    SELECT LISTAGG(award_number,',') WITHIN GROUP (ORDER BY award_id)
      INTO V_DEPT FROM xxdl.XXDL_CD_SCHEDULE_K_GTT ;
    Result of 1st query is PPE_T_CAPITAL,XIBNG,XIABP,XIABQ,XIABR,XIABS,XIABT,XIABU,XIABV,XIABW,XIAAE,XIAAF,XIAAG,XIAAH,XIAAI,XIAAJ,XIAAK,XIAAL,XIAAM,XIAAN,XIAAO,XIAAP,XIAAQ,XIAAR,XIAAS,XIAAU,XIAAU,XIAAV,XIAAZ,XIABD,XIABE,XIABF,XIABG,XIABH,XIABI,XIABJ,XIABK,XIABL,XIABM,XIABN,XIAAA,XIAAB,XIAAC,XIAAD,XIABY,XIABZ,XIACA,XIACB,XIACC,XIACD,XIACE,XIACF,XIACG,XIACH,XIACI,XIABA,XIAAW,XIAAX,XIAAY,XIACN,XIACT,XIACU,XIACP,AAAEX,XIACW,XIADC

    Hi Frank,
    Here is the create table and insert script. This is needed for me to show in report rows to columns.
    create table award_test(
      AWARD_NUMBER                            VARCHAR2 (15) ,                                                                                                                                                                                
    AWARD_NAME                              VARCHAR2(30)  ,                                                                                                                                                                               
    TOTAL_PROCEEDS                          NUMBER    ,                                                                                                                                                                                   
    EARNING_PROCS                           NUMBER    ,                                                                                                                                                                                   
    TOT_PROCS_EARNINGS                      NUMBER   ,                                                                                                                                                                                    
    GROSS_PROCS                             NUMBER   ,                                                                                                                                                                                    
    PROC_REF_DEF_ESCR                       NUMBER   ,                                                                                                                                                                                    
    OTH_UNSP_PROCS                          NUMBER  ,                                                                                                                                                                                     
    ISSUANCE_COST                           NUMBER   ,                                                                                                                                                                                    
    WORK_CAP_EXP                            NUMBER 
    --insert script
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIAAE','CEFA CP',300000000,200,300000200,300,500,600,0,700);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIABG','CEFA K',0,null,0,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIAAS','Escondido Village #3',0,null,0,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('AAAEX','SU2009A',801806000,null,801806000,null,null,null,1806000,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIABI','CEFA L-6',17815000,null,17815000,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIAAP','CEFA R',115050508.15,null,115050508.15,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIACG','CEFA D',53150000,null,53150000,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIAAB','Stu Union-1962',0,null,0,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIAAA','Notes Payable-Commercial Paper',350000000,null,350000000,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIABZ','CEFA L-3',9840000,null,9840000,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIAAV','CEFA B',18106540,null,18106540,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIAAI','Medium Term Notes - Tranche 3',50000000,null,50000000,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIAAZ','Recycling Pool',473379904.44,null,473379904.44,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIAAY','CEFA T2',187550000,null,187550000,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIAAM','GMAC',0,null,0,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIAAU','CEFA A/K',16922982,null,16922982,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIAAC','SU TB 2002A - PARS',50000000,null,50000000,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIABL','CEFA L-9',15490000,null,15490000,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIABY','CEFA L-2',8775000,null,8775000,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIAAJ','Frat 1&2',0,null,0,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIAAW','CEFA S',180727500,null,180727500,null,null,null,-472500,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIAAQ','Escondido Village #1',0,null,0,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIACW','CEFA U',0,null,0,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIACF','CEFA E',19753227.34,null,19753227.34,null,null,null,-106772.66,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIACN','CEFA T3',27562758.96,null,27562758.96,null,null,null,-47941.04,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIAAG','Medium Term Notes - Tranche 1',50000000,null,50000000,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('PPE_T_CAPITAL','PPE_T_CAPITAL',0,null,0,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIAAK','Frat 3',0,null,0,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIAAF','Tresidder',0,null,0,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIABH','CEFA L',5055000,null,5055000,null,null,null,0,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIAAU','CEFA A/K',6605655,null,6605655,null,null,null,-74345,null);
    Insert into "award_test" (AWARD_NUMBER,AWARD_NAME,TOTAL_PROCEEDS,EARNING_PROCS,TOT_PROCS_EARNINGS,GROSS_PROCS,PROC_REF_DEF_ESCR,OTH_UNSP_PROCS,ISSUANCE_COST,WORK_CAP_EXP) values ('XIAAD','SU 2024 Bonds',150000000,null,150000000,null,null,null,0,null);Expected output rows to columns (i took first two insert statements)
    'XIAAE','CEFA CP',300000000,200,300000200,300,500,600,0,700
    'XIABG','CEFA K',0,null,0,null,null,null,0,null
    I need to have awardnumber and corresponding details below
    'XIAAE'       'XIABG'
    'CEFA CP'    'CEFA K'
    300000000   0
    200             null
    300000200   0
    This way i need to get all the information vertically with awardnumber. I have written following code but it is not working.
    create or replace
    Function Pivot_award return sys_refcursor
    IS
       v_dept    VARCHAR2 (20000);
       v_query   VARCHAR2 (1000);
       op_rs sys_refcursor;
    BEGIN
      SELECT LISTAGG('''' || award_number || '''',',') WITHIN GROUP (ORDER BY award_number)
      INTO V_DEPT FROM award_test ;
       v_query :=
          'SELECT *  from award_test
            UNPIVOT(VAL for operator in(                                                                                                                                                                                                       
    AWARD_NAME,                                                                                                                                                                                                              
    TOTAL_PROCEEDS,                                                                                                                                                                                                             
    EARNING_PROCS ,                                                                                                                                                                                                              
    TOT_PROCS_EARNINGS ,                                                                                                                                                                                                           
    GROSS_PROCS    ,                                                                                                                                                                                                               
    PROC_REF_DEF_ESCR ,                                                                                                                                                                                                        
    OTH_UNSP_PROCS ,                                                                                                                                                                                                              
    ISSUANCE_COST ,                                                                                                                                                                                                            
    WORK_CAP_EXP ))
            PIVOT(max(VAL) for award_number in  ('||v_dept||'))';
       OPEN op_rs FOR v_query;
       return op_rs;
    END;throwing an error ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-06512: at "APPS.PIVOT_AWARD", line 11
    ORA-06512: at line 5
    also when i run simple query
    SELECT *  from award_test
            UNPIVOT(VAL for operator in(                                                                                                                                                                                                       
    AWARD_NAME,                                                                                                                                                                                                              
    TOTAL_PROCEEDS,                                                                                                                                                                                                             
    EARNING_PROCS ,                                                                                                                                                                                                              
    TOT_PROCS_EARNINGS ,                                                                                                                                                                                                           
    GROSS_PROCS    ,                                                                                                                                                                                                               
    PROC_REF_DEF_ESCR ,                                                                                                                                                                                                        
    OTH_UNSP_PROCS ,                                                                                                                                                                                                              
    ISSUANCE_COST ,                                                                                                                                                                                                            
    WORK_CAP_EXP ))
            PIVOT(max(VAL) for award_number in  ('PPE_T_CAPITAL','XIBNG','XIABP')) Throwing an error
    ora-01790 Expression must have same datatype as correspoding expression
    Edited by: 893185 on Nov 10, 2011 2:00 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Using constant expression in query

    When I write a query, if I use a bind variable that could be null as for example:
    select *
    from table
    where :variable is null or column = :variable
    the performance drops significantly.
    I can't find any reason, so if you can help me...
    I also tried something simpler, and something I thought it shoud be faster.
    select *
    from table
    where 1=1 or column = :variable
    this query should return all the table, since 1=1 is allways true. It should be easier to evaluate, since it's the same as before, but it does not need to bind the variable. It takes five times longer than before.
    What I am looking for is to understand what the database does when I run this queries.
    Thankyou very much
    Edited by: user4823534 on 27-abr-2010 9:16

    I think I didn't explain myself.
    I have several very complex querys that use bind variables as optional parameters.
    What I noticed is that it's much slower (100 times maybe) to have a constant expression which is true in an or than evaluating something else. For example
    select * from table where :a is null or column1 in (select column1 from table2 where a = :a) should be faster than
    select * from table where column1 in (select column1 from table2 where a = :a) since the last one has to evaluate the in clause, and the first one is allways true.
    Thankyou for your patience and sorry for my bad english.

  • Does an Airport Express require a wired connection to boost a Wi-Fi signal if I already have a wired Airport Time Capsule on the Network?

    I want to boost the Wi-Fi signal around my house. I have a 3TB Airport Time Capsule connected to my Virgin Media modem via a WLAN connection but wonder if an Airport Express device can be used at a remote location purely wirelessly - apart from a power connection obviously?

    Does AirPort Express require a wired connection.......if I already have a wired AirPort Time Capsule on the Network?
    No, but you will have much better network performance if you do wire the AirPort Express.
    The reason for this is that when you try to extend a network using wireless, you will typically lose about a half of the potential speed capability on the network.
    There is no network speed loss when you wire the Express.
    Here is what Apple's support document says about this:
    In the case of a wirelessly extended network, throughput may be reduced to less than 60 percent of that of a single device. The general rule is to keep the Wi-Fi network as simple as possible. You can accomplish this by using the minimum number of Wi-Fi base stations required to service the physical network area and by using Ethernet wherever possible.
    Extending the range of your Wi-Fi network by connecting Wi-Fi base stations together using Ethernet is always the best option, and will provide the best throughput

  • WebTest - VS2013 - Extract Regular Expression - Required=False

    I have an "Extract Regular Expression" that may or may not be able to extract a value. I set the property value of Required to False. The next block checks for the existence of that Context Parameter. If the Context Parameter is there, it does
    some work, if the Context Parameter is not there, it skips the condition.
    When I run my WebTest, it tells me that it passes the extraction rule but it never created the Context Parameter so the condition is skipped.
    If I set Required=True, everything works as expected.
    I remembered that there was a defect in VS2010 with the Required=False, so I added this Extraction Plug-In 
    [DisplayName("Extract Regular Expression Not Required")]
    [Description("Extract text matching a regex and add it to the test context. If no match is found, do not fail webtest. This gets around a VSTS bug where 'Required' property of the Extract Regular Expression rule is not honored.")]
    public class ExtractRegularExpressionNotRequired : ExtractRegularExpression
    public override void Extract(object sender, ExtractionEventArgs e)
    base.Extract(sender, e);
    e.Success = true;
    That too passes the regular expression but fails to create the Context Parameter.

    By setting the Required parameter to False, I am expecting that a Context Parameter does not get created if the regular expression is not found and that is does get created if the regular expression is found.
    So when I run my test, it tells me that the regular expression was found but my Context Parameter was not created. 
    When I created this webtest in VS2010, I found that there was a bug with the Extract Regular Expression when the Required property was False. This
    thread showed the code for a custom Extraction rule to fix the problem. When I run this webtest in VS2013, both the built-in Extract Regular Expression and the custom Extract Regular Expression Not Required are not creating the Context Parameter if the
    regex is found.
    Try this yourself:
    Create a webtest
    Add "Extract Regular Expression"
    Set the Regular expression to . (this will match any one character)
    Set the Requiredto False
    Set the Context Parameter Name to TEST
    Run the webtest
    Although the result from the extraction rule will be Passed, there is no Context Parameter TEST created. 
    If you create the custom Extract Regular Expression Not Required plugin, the same problem occurs.

  • Does AirPort Express require better Internet than Ethernet?

    Wondering since I was having intermittent problems w my Linksys router &amp; trouble updating it so thought switching to Airport Express would give me a simple way to get things working.
    Very disappointed that noes it's worse than before. Yesterday after a # of tries I did get it partly set up &amp; although amber blinking lights, I was able to use Internet.
    Called Set up AppleCare call online to resolve amber light issue. She had me reset modem &amp; when we were done, I again had green light on Airport BUT NO INTERNET CONNECTION. She said to call my ISP cox.
    I did try after a reset to connect MacbookPro directly to Ethernet &amp; got it to connect. Then I unplugged Ethernet from Mac &amp; plugged into airport &amp; no connection again.
    So instead of Airport Express making things better, they are worse. I'm typing this on my iPhone 4S which for some reason has really slowed down.
    I learned that my old Motorola Surfboard modem is Docsis 2.0 &amp; cox is switching to 3.0.
    But it was working better, although frequent brief loss of connection.
    So does Airport require a better modem or better connection than just Ethernet or via my Linksys E1200?
    Not happy also that functionally worse off after calling AppleCare. I know she didn't cause the issue but her suggestion while standard tipped it over to not be connecting.
    &amp; typing all this on my iPhone is not fun although it did just now get back temporarily there for just a bit to its usual speed but now back to having to wait for it.

    Well I did the power down reset. But I think you missed the import of my question.
    I'm talking about an older modem that may be marginal. Not positive about the 2 Ethernet cables I have used either.
    So yes if the modem is working as it should I guess it should make a difference.
    But something is weird when I can can next via Ethernet &amp; then I just unplug the the rent from my Mac &amp; plug it into the wan port on the AirPort Express &amp; no connection.
    To look at the modem &amp; Airport across the room the lights make it look like they are fine.
    I just done have Internet connection to my Mac. I did yesterday w the amber lights flashing.
    &amp; I was connecting w the Linksys but had frequent loss of connection.
    So wondering if maybe Airport has slightly greater requirements that act as a tipping point so it connected without it but doesn't connect w it. But the green light supposedly shows its working fine.
    Well I did put out a wanted request on FreeOC for a compatible Docsis 3.0 cable modem. Supposedly they work better &amp; that might just make the difference.
    Don't really want to buy a new modem when I'm about to move to a new area where requirements might be different.

  • Regular Expression Required for Checksum variable

    I am wanting to create a regular expression that extracts a variable checksum value (cs=) which is unique to a given server response string.
    The issue I am having is that a simple regex being name="cs" value="(.+?)" just does not work because there are 18 different checksum values being returned per session id/server response.
    So a simple regex just picks up any "cs" value and I guess gets confused since there are 18 different ones contained within the server response (all user related)
    What i need is a regex to use say this value from the server response (JONHONEYMAN%40YAHOO.COM) or any other unique value which is contained within the string response from the server then extract the cs (Checksum) value from that string and make it variable :)
    Here is the server response string:-
    "fp=220:1200:2977638312763704:: NO::P1200_EMAIL_ADDRESS,P1200_ORGANISATION_NAME,P1200_UCRN,P1200_ORG_ID,P1200_CALLING_PAGE:JONHONEYMAN%40YAHOO.COM%2C john%20Honeyman%2C260%2C220%2C1190&cs=336788D01EC6E80B1877B3EE982E8B2D8" >Select</td></tr
    can anyone help?
    Thanks

    You need an XML Parser.

  • Cisco Unity Express requirement (license,package files,application)

    Hi everyone,
    I am about to install CUE on my c2911 router and I am confused with the license needed. Currently I have these license:
    1.     SL-29-UC-K9           : Unified Communication License
    2.     FL-CUE-MBX-5        : Unity Express License - 5 Mailbox -CUCM and CUCME
    3.     FL-CUE-PORT-2      : Unity Express License - Non Re-hostable-2 Port
    4.     VWIC2-1MFT-T1/E1 : 1-Port 2nd Gen Multiflex Trunk Voice/Wan Int. Card - T1/E1
    Is there any license/package files/application that I need in order to get this service running?
    Regards.

    This should help:
    http://www.cisco.com/en/US/docs/voice_ip_comm/unity_exp/rel7_1/Licensing/Using_CSL.html
    Chris

  • Does the airport express require an AirPort Extreme?

    Can it run its own wifi network? Can it extend my current system? Does it only work with a higher grade network?

    The AirPort Express is a router, so it just needs a modem to get the Internet connection (the WAN port of the AirPort Express is used to connect it to the modem), not another AirPort Extreme or router.
    It creates its own network, but you can configure it to extend an existing network. See > http://support.apple.com/kb/HT4145

  • Does American Express require any extra coding to work in BC?

    last week, we took our client online with their shop and have experienced our first issue with the Registration Buy form. The client received a call from a customer that our form would not take American Express as a card. I checked the form and yes, Amex is listed as a card option. (I did not change that).  I did not change the script at the bottom of the page either.  The client is using Authorize.net (US only) as the gateway.
    Any thoughts? Anybody? Beuller?
    www.shoplechameau.com is the site.
    Thanks
    Chuck

    Thanks Liam,
    In the interim, we were informed that the site rejected a VISA as well, the client was able to provide an error message and we have narrowed it down to an Authorize.net issue. My boss has submitted a case to BC, but I think he will get the same answer I gave him (and that you have confirmed). Just in case, here is a screen cap of the error message.
    I have the client checking their information and looking into an issue I discovered on another site. Here is the gist of it from Authorize.net:
    The confusion has to do with the two options, Transaction Server (Live or Test) and Transaction Mode (Live or Test).
    From the Authorize.net developer site:
    Quote
    If you are posting your transaction requests to the gateway URLs https://test.authorize.net/gateway/transact.dll or https://certification.authorize.net/gateway/transact.dll and you are using an account given to you by an Authorize.Net Reseller or from Authorize.Net Sales, you may encounter this error. The gateway URLs mentioned above only work with specific test accounts, available upon request by completing the form at http://developer.authorize.net/testaccount/
    Try posting your transaction request to https://secure.authorize.net/gateway/transact.dll instead. If you need to submit a test transaction, you may do so by setting the field x_test_request to "TRUE". You may then remove x_test_request or set it to "FALSE" when you have completed your testing.
    Since we can only access the type of server (regular or test) and not the Mode on BC, I am at a standstill.
    But thanks anyhow,
    Chuck

Maybe you are looking for

  • What cable do I need to connect a 30in Cinema Display to a 2013 Mac Pro

    what cable do I need to connect a 30in Cinema Display to a 2013 Mac Pro

  • Video plays on iPhone 3G, but not iPhone 2G or iPod Touch 1st Gen

    Hi all, We're creating videos to be played on iPhones and iPod touch's. The videos are working fine on my iPhone 3Gs but won't play on my iPod touch 1st gen or a 2G iPhone. I've had a look and the supported video list is exactly the same on all iPhon

  • Can't open file in Imovie 09

    Hello there. I was working with a friend on a video project. She has a newer macbook then I and when she emailed me the file to finish editing I could not open it. When I tried to import it into Imovie it said that 'This file is not comaptible with I

  • DNS + do I need a diradmin account?

    I have a 10.5.8 server currently being used as a file server for 8 Macs. It is behind a NAT router so is not accessible from the Internet, and doesn't need to be. E-mail and website is handled by a hosting company. All computers have manually-set IP

  • IPhone. Email issue.

    With the new iOS 7.0 all the messages in my email account are on the phone. Can I limit the number?  It's eating up all the memory on my phone.