我在Oracle中调用了一个流水线函数,我得到了一个"不支持的列数据类型"错误,不知道如何解决这个问题。
这里是代码,这比现实中的更简单,但它的工作方式完全相同:
CREATE OR REPLACE FUNCTION CIC3.F_SUG_PUBS_BY_DESIGS(p_desigs in VARCHAR2)
RETURN SUG_PUBS_TBL PIPELINED IS
BEGIN
FOR r IN (
SELECT invid, title, desc, price, fin, desig FROM v_sugpubs WHERE desig = p_desigs
)
LOOP
PIPE ROW(SUG_PUBS_T(r.invid, r.title, r.desc, r.price, r.fin, r.desig));
END LOOP;
RETURN;
END F_SUG_PUBS_BY_DESIGS;
/
这里有两种类型:
CREATE OR REPLACE TYPE SUG_PUBS_TBL AS TABLE OF SUG_PUBS_T
/
CREATE OR REPLACE TYPE CIC3.SUGGESTED_PUBS_T AS OBJECT
(
invid VARCHAR2(15),
title VARCHAR2(300),
desc VARCHAR2(500),
price VARCHAR2(5),
fin NUMBER(15),
desig VARCHAR2(5)
)
/
这是我的服务电话:
public object Get(SugPubsRequest request)
{
if (QryPidFromLT(request.LT) == request.PID)
{
List<SugPubsResponse> p = GetSugPubs(request.Desigs);
return p;
}
else
{
throw new AuthenticationException("Invalid LT");
}
}
private List<SugPubsResponse> GetSugPubs(string Desigs)
{
var db = new PetaPoco.Database("Settings.Oracle");
var sql = "SELECT F_SUG_PUBS_BY_DESIGS('" + Desigs + "') FROM DUAL";
List<SugPubsResponse> _sc = db.Fetch<SugPubsResponse>(sql);
return _sc;
}
以下是模特:
[Route("/SugPubs/{LT}/{PID}/{Desigs}")]
public class SugPubsRequest
{
public string LT { get; set; }
public int PID { get; set; }
public string Desigs { get; set; }
}
public class SugPubsResponse
{
[PetaPoco.Column("invid")]
public string InvId { get; set; }
[PetaPoco.Column("title")]
public string Title { get; set; }
[PetaPoco.Column("desc")]
public string Desc { get; set; }
[PetaPoco.Column("price")]
public string Price { get; set; }
[PetaPoco.Column("fin")]
public int Fin { get; set; }
[PetaPoco.Column("desig")]
public string Desig { get; set; }
}
答案 0 :(得分:0)
为了让其他人能够使用它,我这样做是为了得到结果: 您所要做的就是更改服务调用中的SQL:
var sql = "SELECT * FROM TABLE(F_SUG_PUBS_BY_DESIGS('" + Desigs + "'))";