小编And*_*ine的帖子

如何在Postgres中使用数组作为变量?

我有这个.sql脚本:

DO $$
  DECLARE 
    user_list integer[] = (select user_id from user where state = 'ACTIVE');
BEGIN
    CREATE CREATE MATERIALIZED VIEW accounts_with_active_users AS
    select * from accounts where user_account IN (user_list);
    ...

    CREATE CREATE MATERIALIZED VIEW accounts_without_active_users AS
    select * from accounts where user_account NOT IN (user_list);
    ...
END $$;
Run Code Online (Sandbox Code Playgroud)

但是我总是有这个错误:

ERROR: cannot cast type integer to integer[]
Run Code Online (Sandbox Code Playgroud)

我也尝试过用这个词array之前有相同的结果:

user_list integer[] = array(...)
Run Code Online (Sandbox Code Playgroud)

postgresql postgresql-9.6

5
推荐指数
1
解决办法
3397
查看次数

Spring 中没有注解的 Java 对象验证

我正在与 mybatis 合作执行所有数据库操作。我也在使用 Angular 前端,因此客户端中的验证是使用angular-validation-ghiscoding原生 HTML5 验证进行的。我想验证银行端的数据,但我不想使用注释。

以下是代码示例:

    @RequestMapping(value = SecureApiResources.URI_UPDATE_ACCOUNT, method = RequestMethod.POST, produces = "application/json")
    public @ResponseBody Account updateAccount(
            @RequestBody final AccountRequestUpdate accountRequest) { // Object to be validated (accountRequest)

        Account account = accountMapper.getAccountOfMerchant(authContextHolder.getMerchantId(), authContextHolder.getDefaultAccountId());

        if (account == null) {
            HttpErrors httpErrors = new HttpErrors(
                    SecureApiResources.ERROR_ACCOUNTS_NOT_FOUND);
            throw new EntityNotFoundException(httpErrors);
        }
        int resultUpdate;
        try {
            // In this point I should validate the accountRequest object
            account.setAccountName(accountRequest.getAccountName());
            account.setCommercialName(accountRequest.getCommerciaName());
            account.setCountry(accountRequest.getCountry());
            account.setCity(accountRequest.getCity());
            resultUpdate = accountMapper.updateMerchant(account);
            if (resultUpdate == 0) { …
Run Code Online (Sandbox Code Playgroud)

java validation spring spring-mvc bean-validation

2
推荐指数
1
解决办法
3991
查看次数

Java使用JSTL c标记设置字符串值

我正在尝试从会话中设置String值.我想要这样的东西:

<%
    String getReactive = <c:out value="${result}"></c:out>;
%>
Run Code Online (Sandbox Code Playgroud)

我知道它不会奏效.但是我需要类似的东西:

<%
    String getReactive =  ics.GetVar("result");
%>
Run Code Online (Sandbox Code Playgroud)

java jsp jstl

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

Postgres:获取哪一部分是一组中的记录

我试图获取或计算一组(分期付款和部分价值)中每条记录的信息,我在下面举例说明:

| pay        |  date       | value |
|:-----------|------------:|:-----:|
| 910006603  | 2017-04-19  | 30    |
| 910006603  | 2017-04-21  | 30    |
| 910006603  | 2017-04-23  | 30    |
| 910006603  | 2017-04-25  | 30    |  
| 910006604  | 2017-04-14  | 45    | 
| 910006604  | 2017-04-18  | 45    |
Run Code Online (Sandbox Code Playgroud)

有了这些信息,我必须添加另外两列,指示它的安装和部分值,以便结果:

| pay        |  date       | value | insta | partial|
|:-----------|------------:|:-----:|:-----:|:------:|
| 910006603  | 2017-04-19  | 30    | 1     | 30     |
| 910006603  | 2017-04-21  | 30 …
Run Code Online (Sandbox Code Playgroud)

sql postgresql

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