小编use*_*380的帖子

Oracle SQL插入With子句

我是sql的新手,所以也许这是一个愚蠢的问题,但有没有可能在Insert Into中使用With子句?或者有任何常见的解决方法吗?我的意思是这样的:

With helper_table As (
Select * From dummy2
)
Insert Into dummy1 Values (Select t.a From helper_table t Where t.a = 'X' );
Run Code Online (Sandbox Code Playgroud)

谢谢!

我的例子太虚拟了,所以我添加了一些扩展代码(到目前为止答案是thx).

INSERT
INTO    dummy values (a,b)  //more values
WITH    helper_table AS
    (
    SELECT  *
    FROM    dummy2
    )
WITH    helper_table2 AS   //from more tables
    (
    SELECT  *
    FROM    dummy3
    )         
SELECT  t.value as a, t2.value as b
FROM    helper_table t 
join helper_table t2 on t.value = t2.value //some join
WHERE   t.value = 'X' and t2.value …
Run Code Online (Sandbox Code Playgroud)

sql oracle with-statement

22
推荐指数
3
解决办法
8万
查看次数

MessageFormat中的嵌套选择子句?

我正在尝试用java.text.MessageFormat做一个简单的逻辑:

MessageFormat cf = new MessageFormat(
"{0,choice, 1<hello|5<{1,choice,1<more than one|4<more than four}}");

 Object[] array = {3, 1};
 System.out.println(cf.format(array));
Run Code Online (Sandbox Code Playgroud)

使用单词:如果第一个参数大于1,则打印"hello",如果大于5则比第二个参数大于1打印"多于一个"如果第二个参数大于4打印"超过4个" ".

我发现没有人说这是不可能的,但我得到一个IllegalArgumentException:

Choice Pattern incorrect: 1<hello|5<{1,choice,1<more than one|4<more than four}

有没有办法可以做到这一点?谢谢!

整个堆栈跟踪:

Exception in thread "main" java.lang.IllegalArgumentException: Choice Pattern incorrect:  1<hello|5<{1,choice,1<more than one|4<more than four}
at java.text.MessageFormat.makeFormat(Unknown Source)
at java.text.MessageFormat.applyPattern(Unknown Source)
at java.text.MessageFormat.<init>(Unknown Source)
at test.Test5.main(Test5.java:18)
Caused by: java.lang.IllegalArgumentException
    at java.text.ChoiceFormat.applyPattern(Unknown Source)
    at java.text.ChoiceFormat.<init>(Unknown Source)
    ... 4 more
Run Code Online (Sandbox Code Playgroud)

java messageformat

7
推荐指数
1
解决办法
1677
查看次数

java复合赋值运算符和赋值运算符

我在java中理解复合赋值运算符和赋值运算符时遇到了一些问题.有人可以向我解释这两个运营商如何运作的吗?(Somwhere我发现了一个非常好的示例代码,使用临时变量来解释工作,但遗憾的是我已经失去了它.)非常感谢你的优势.这是我的小例子代码(我已经知道前缀和后缀运算符之间的区别):

       int k = 12;
       k += k++;   
       System.out.println(k);  // 24 -- why not (12+12)++ == 25?

       k = 12;
       k += ++k; 
       System.out.println(k); // 25 -- why not (1+12)+(1+12) == 26?               

       k = 12;
       k = k + k++; 
       System.out.println(k); // 24 -- why not 25? (12+12)++?

       k = 12;
       k = k++ + k; 
       System.out.println(k); // 25 -- why not 24 like the previous one?

       k = 12;
       k = k + ++k; 
       System.out.println(k); // 25 …
Run Code Online (Sandbox Code Playgroud)

java variable-assignment operator-keyword

3
推荐指数
1
解决办法
1865
查看次数