小编Bon*_*ton的帖子

如何从函数返回更新的行

我对Postgres很陌生。我想创建一个功能(如存储过程)来更新多行并选择受影响的行。

这是我的声明:

CREATE or replace FUNCTION set_val( 
                _val character varying(100) ) --5
            RETURNS setof "table_test" AS
$body$

declare results "table_test"%rowtype;

begin
    update  "table_test"
    set "value" = $1
    where   "gender" = 'm'
    returning * into results;

    if not found then 
        insert into "table_test"("value")
        values($1)
        returning * into results;
    end if;

    return next results;
end;    

$body$
LANGUAGE 'plpgsql' ;
Run Code Online (Sandbox Code Playgroud)

只要只有1行受到影响,它就可以正常工作。但是当更多的行受到影响时,则不会。

postgresql plpgsql

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

$ .get,$.postt,$ .ajax,$(elm).load to .ashx page problem

HTML页面

    // in script tag
    $(document).ready(function () {
        var url = "list.ashx";

        $.get(url + "?get", function (r1) { alert("get: " + r1); });
        $.post(url + "?post", function (r2) { alert("post: " + r2); });
        $.ajax(url + "?ajax", function (r3) { alert("ajax: " + r3); });
        $("div:last").load(url + "?load", function (r4) { alert("load: " + r4); });
    });

    // in body tag
    <div></div>
Run Code Online (Sandbox Code Playgroud)

在'list.ashx'中

public void ProcessRequest (HttpContext context) { context.Response.Write("ok"); }
Run Code Online (Sandbox Code Playgroud)

结果

  • $ .get和$ .post到达list.ashx但没有回复
  • $ .ajax未达到list.ashx
  • $ .load完全成功

问题是 …

jquery ashx

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

如何在AsyncControl下载MVC?

我有

public class FileController : AsyncController
{
  public ActionResult Download(FormCollection form)
  {
    FileContentResult file = new FileContentResult(Encoding.UTF8.GetBytes("10k file size"),"application/vnd.xls");
    file.FileDownloadName = "test.xls";

    return file;
  }
}
Run Code Online (Sandbox Code Playgroud)

当然,ajax形式

<% var form = Ajax.BeginForm(...) %>
  <input type="image" src="...gif" /> // this is my 1st attempt
  <%= Ajax.ActionLink(...) %>         // 2nd attempt
<% form.EndForm(); %>
Run Code Online (Sandbox Code Playgroud)
  1. 我尝试第一种方法(输入类型=图像).它达到了正确的行动.但客户端没有文件下载.
  2. 然后我尝试使用我真的很讨厌的Ajax.ActionLink.我想要漂亮的图像按钮,而不是链接文本.再次,它达到正确的行动,没有文件下载.但如果我在另一个窗口打开链接,那就有文件下载!!

问:如何使用AsyncController制作一个漂亮的文件下载

问:如何使Ajax.ActionLink变得更好

asp.net-mvc download asp.net-mvc-2

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

怎么办'any(:: text [])ilike :: text'

这是表结构

table1
pk int, email character varying(100)[]

data
1, {'mr_a@gmail.com', 'mr_b@yahoo.com', 'mr_c@postgre.com'}
Run Code Online (Sandbox Code Playgroud)

我试图实现的是从记录中找到任何'gmail'

query
select * from table1 where any(email) ilike '%gmail%';
Run Code Online (Sandbox Code Playgroud)

但是任何()只能在左侧,而者()可能会降低性能.有谁有任何想法?

编辑

实际上,当我第一次发帖时,我有点混淆.我尝试通过任何(array [])实现.

这是我的实际结构

pk int, 
code1 character varying(100), 
code2 character varying(100), 
code3 character varying(100), ...
Run Code Online (Sandbox Code Playgroud)

我的第一个approch是

select * from tabl1 where code1 ilike '%code%' or code2 ilike '%code%' or...
Run Code Online (Sandbox Code Playgroud)

然后我试试

select * from table1 where any(array[code1, code2, ...]) ilike '%code%'
Run Code Online (Sandbox Code Playgroud)

这是行不通的.

postgresql string-comparison any conditional-statements

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