关于postgre创建视图的语句中字段使用大写导致select失败的问题
现场使用的postgre版本忘记查了,但是不影响,只需要知道postgre有些版本大小写是不敏感的就行
关于大小写不敏感
1、创建视图语句
CREATE OR REPLACE VIEW public.v_approval_results AS
select
a.uidRecordID “uidRecordID”,
a.uidApplyID “uidApplyID”,
b.strUserName “strUserName”,
b.strUserDesc “strUserDesc”,
b.uiddeptid “uiddeptid”,
b.strRoleName “strRoleName”,
b.strDevName “strDevName”,
b.strDevIP “strDevIP”,
b.strMac “strMAC”,
b.dtTime “dtTime”,
b.strInfo1 “strInfo1”,
b.strInfo2 “strInfo2”,
b.strInfo3 “strInfo3”,
b.iInfo1 “iInfo1”,
b.strLVFSConfigName “strLVFSConfigName”,
b.strFileDownloadPath “strFileDownloadPath”,
a.iApprovalResult “iApprovalResult”,
a.dtEndTime “dtEndTime”,
b.itype “iType”,
b.strapplicationreason “strapplicationreason”,
iSubType “iSubType”,
strSubType “strSubType”,
case
when a.strentrustoperatorname is not null
and a.strentrustoperatorname != ‘’ then a.strentrustoperatorname
else a.strAuditName
end “strAuditName”,
case
when a.strentrustoperatorname is not null
and a.strentrustoperatorname != ‘’ then (
select
strdesc
from
Tbl_Operator
where
strOperatorName = a.strentrustoperatorname)
else (
select
strdesc
from
Tbl_Operator
where
strOperatorName = a.strAuditName)
end “strAuditDesc”,
b.uidsecpolicyid “uidsecpolicyid”,
b.uidlvfsserverid “uidlvfsserverid”,
b.uiddomainid “uiddomainid”,
b.imatchkw “imatchkw”,
b.strkwclass “strkwclass”,
b.strkwlevel “strkwlevel”,
b.strkwdetail “strkwdetail”,
b.strkwabstract “strkwabstract”,
a.strremark “strremark”
from
Tbl_AgentActionApplyResult a
left join Tbl_AgentActionApply b on
a.uidApplyID = b.uidApplyID
where
a.uidApplyID <> ‘’
and a.uidApplyID is not null
and ( 1 = 1 )
order by
dtEndTime desc
这里的字段名都使用了大写,导致查询失败再代码里查询结果相同也是失败的(otlv4)

这里将字段名带上双引号是可以查询的。
ex:
select “strUserName,strUserDesc,…” from v_approval_results where …;
或者我们直接将创建视图的语句中的字段名称全部修改为小写,也可以解决问题
以上现场已验证通过
浙公网安备 33010602011771号