0

xqj でクエリを実行しようとすると、このエラーが発生します。

Exception in thread "main" javax.xml.xquery.XQException:
  XQJQS001 - Invalid XQuery syntax, syntax does not pass static validation.
  Root Cause:
  XQueryParseException: Encountered "$" at line 1, column 36.
Was expecting one of:
    "=" ...
    "order" ...

public static void Consultar(XQConnection connexio) throws XQException { Scanner sc = new Scanner(System.in);

    System.out.println(">>>>Please select a mminim stock :)");

    int selec = sc.nextInt();

    String squery = "for $prod  in /productos/produc"
            + "for $zone in $prod/cod_zona"
            + "let $stock :=$prod/stock_minimo"
            + "let $deno :=$prod/denominacion"
            + "let $codi_prod :=$prod/cod_prod"
            + "let $cod:=/zonas/zona[cod_zona = $zone]/cod_zona"
            + "let $nomzona:=/zonas/zona[cod_zona = $zone]/nombre"
            + "let $direc:=/zonas/zona[cod_zona = $zone]/director"
            + "where $prod/$stock < " + selec + ""
            + "return concat('Denominacio:',$deno,'&#xa;' ,"
            + "'Codi producte:',$codi_prod,'&#xa;' ,"
            + "'Stock mínim:',$stock,'&#xa;' ,"
            + "'Codi zona:',$cod,'&#xa;' ,"
            + "  'Nom zona:',$nomzona),'&#xa;'";

    XQPreparedExpression consulta = connexio.prepareExpression(squery);

    XQResultSequence resultat = consulta.executeQuery();

    while (resultat.next()) {
        System.out.println(resultat.getItemAsString(null));
        System.out
                .println("...................................................................");
    }

    connexio.close();

}

同じヘルプ。ありがとう。

4

1 に答える 1

1

文字列連結式

  "for $prod  in /productos/produc"
+ "for $zone in $prod/cod_zona"

文字列を生成します

for $prod  in /productos/producfor $zone in $prod/cod_zona

producとの間にある種の空白を追加する必要がありforます+

String squery = "for $prod  in /productos/produc "
            + "for $zone in $prod/cod_zona "
            + "let $stock :=$prod/stock_minimo "
            + "let $deno :=$prod/denominacion "
            // etc etc.
于 2014-04-10T17:26:47.050 に答える