我对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行受到影响,它就可以正常工作。但是当更多的行受到影响时,则不会。
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)
结果
问题是 …
我有
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)
问:如何使用AsyncController制作一个漂亮的文件下载
问:如何使Ajax.ActionLink变得更好
这是表结构
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)
这是行不通的.