我有很多我的简单查询返回的记录,但是当我使用函数时,它只给了我第一条记录,
首先,我使用以下方法创建自己的数据类型,
CREATE TYPE my_type (usr_id integer , name varchar(30));
Run Code Online (Sandbox Code Playgroud)
我的功能是,
CREATE OR REPLACE function test() returns my_type as $$
declare rd varchar := '21';
declare personphone varchar := NULL;
declare result my_type;
declare SQL VARCHAR(300):=null;
DECLARE
radiophone_clause text = '';
BEGIN
IF rd IS NOT NULL then
radiophone_clause = 'and pp.radio_phone = '|| quote_literal(rd);
END IF;
IF personphone IS NOT NULL then
radiophone_clause = radiophone_clause|| 'and pp.person_phone = '|| quote_literal(personphone);
END IF;
radiophone_clause = substr(radiophone_clause, 5, length(radiophone_clause)- 4);
EXECUTE …Run Code Online (Sandbox Code Playgroud) sql postgresql plpgsql postgresql-9.1 set-returning-functions
我试图在我的查询中添加列,如下,
SELECT Name as [holiday_name] FROM tableMonth t UNPIVOT (ID for Name in (m1,m2,m3,sf1,sf2)) u WHERE ID != 0.0 and D_No ='0700'
Run Code Online (Sandbox Code Playgroud)
这个查询运行正常,但是当我添加"sf1"和"sf2"时,它给了我错误
"The type of column "sf1" conflicts with the type of other columns specified in the UNPIVOT list."
Run Code Online (Sandbox Code Playgroud)
我将如何运行上面提到的查询列我想更新像"sf1"和"sf2"
希望你的建议
谢谢
我是 python 新手,并尝试使用 ast.literal_eval 获取请求数据,导致“语法无效”错误。
它打印我发送的数据,格式如下,
192.156.1.0,8181,database,admin,12345
Run Code Online (Sandbox Code Playgroud)
在python中我显示它但在阅读它时出错我的代码是,
print str(request.body.read())
datas = request.body.read()
data=ast.literal_eval(datas)
dbname = data['dbname']
username = data['uname']
ip = data['ip']
port = data['port']
pwd = data['pwd']
Run Code Online (Sandbox Code Playgroud)
行data=ast.literal_eval(datas)上的无效语法错误
如何解决它的建议将是可观的
谢谢
asp.net ×1
c# ×1
http ×1
httprequest ×1
json ×1
parsing ×1
plpgsql ×1
postgresql ×1
python ×1
sql ×1
sql-server ×1
unpivot ×1