将文件加载到2D阵列时出现CSV错误

时间:2017-03-26 17:38:56

标签: java arrays csv

我有一个CSV文件,我的任务涉及获取该文件并将其加载到2D数组中。我已经计算了那里有多少行以及man列如何,但是当我将它加载到数组中时我得到了错误

  

“无法从静态引用非静态变量filetable   上下文中,“

但如果我这样做import Data.List main = putStrLn(aRow 4) aRow :: Int -> String aRow n = "+" ++ take (4*n) (intercalate "" (repeat "---+")) ++ "\n|" ++ take (4*n) (intercalate "" (repeat " |"))

我收到错误

  

非法引用转发使用静态非最终变量   intialization

代码:

    create or replace FUNCTION AGG_NC8B_FN (
    FACTORY_ID       NUMBER,
    REPORTING_PERIOD NUMBER,
    GRANULARITY_TYPE_TXT  VARCHAR2,
      GRANULAROTY_LEVEL_TXT VARCHAR2,
    CONDITION_ID     NUMBER)
  RETURN NUMBER
IS
  CAL_VALUE OCT_DMA_MOMIS.FCT_KSTACK_AGGREGATION.AGGREGATE_VALUE_DEC%TYPE;
  -- temporary variables --not sure why this is required?
  A number;
  B number;
  C varchar2(100);
  D varchar2(100);
  E number;
BEGIN
A:=FACTORY_ID;
B:=REPORTING_PERIOD;
C:=GRANULARITY_TYPE_TXT;
D:=GRANULAROTY_LEVEL_TXT;
E:=CONDITION_ID;

  SELECT DECODE(B.AGGREGATE_VALUE_DEC,0,0,((A.AGGREGATE_VALUE_DEC/B.AGGREGATE_VALUE_DEC)*100))
    INTO CAL_VALUE
    FROM (SELECT AGGREGATE_VALUE_DEC
            FROM OCT_DMA_MOMIS.FCT_KSTACK_AGGREGATION
           WHERE FK_FIGURE_ID      =30121
             AND FK_FACTORY_ID       =A
             AND LK_REPORTING_PERIOD =B
             AND GRANULARITY_TYPE_TXT=C
                   AND GRANULAROTY_LEVEL_TXT=D
             AND FK_CONDITION_ID     =E) A ,
         (SELECT AGGREGATE_VALUE_DEC
            FROM OCT_DMA_MOMIS.FCT_KSTACK_AGGREGATION
           WHERE FK_FIGURE_ID      =30122
             AND FK_FACTORY_ID       =A
             AND LK_REPORTING_PERIOD =B
             AND GRANULARITY_TYPE_TXT=C
                   AND GRANULAROTY_LEVEL_TXT=D
             AND FK_CONDITION_ID     =E
             ) B ;


  RETURN CAL_VALUE;
END AGG_NC8B_FN;

1 个答案:

答案 0 :(得分:1)

public static void  method 

如果方法是静态的,只有当局部变量也是静态的时才可以引用局部变量

public SomeClass {
  private static String var1;
  private String var2;

  public void someMethod(){
     this.var2 // is allowed 
     this.var1 // is allowed
   }

   public static void someMethod(){
     this.var2 // is allowed 
     this.var1 // is not allowed
   }



}

我建议你在类中创建一个方法,而不是在main()方法中创建一个新的类实例,而不是调用方法

 SomeClass test = new SomeClass():
  test.someMethod()// copy the code of the main to this method