0

My types:

TYPE T_rowBalanceListForClient IS RECORD
(
    RowCode Asset.RowCode%TYPE,
    RowName Asset.RowName%TYPE
);  
TYPE T_tableBalanceListForClient IS TABLE OF T_rowBalanceListForClient;

My function:

FUNCTION F_BalanceListForClient
(
    p_ClientId Client.ClientId%TYPE
)
RETURN T_tableBalanceListForClient PIPELINED
AS
    CURSOR CUR_TABLE IS
        SELECT
                RowCode,
                RowName
            FROM Asset;
BEGIN

    FOR CUR_REC IN CUR_TABLE LOOP
        PIPE ROW(CUR_REC);
    END LOOP;

END;

Part of my stored procedure:

    sql_statement := ' SELECT * FROM TABLE(:1)';
    OPEN c_Result FOR sql_statement USING F_BalanceListForClient(11);

While building the package I reseive the Oracle error:

PLS-00457: expressions have to be of SQL types

In the common stored procedures calls like this are built and operate well (not dynamics):

PROCEDURE GET_BALANCE_STANDARD_LIST
(
    c_Result OUT SYS_REFCURSOR,
    p_ClientId Client.ClientId%TYPE DEFAULT NULL
)
AS
BEGIN
    OPEN c_Result FOR
        SELECT RowName FROM TABLE(F_BalanceListForClient(p_ClientId));
END;

Appreciate any help. Thanks.

4

1 回答 1

1
CREATE OR REPLACE TYPE T_rowBalanceListForClient IS OBJECT 
(
    RowCode NUMBER,
    RowName VARCHAR2(200)
);  


CREATE OR REPLACE TYPE T_tableBalanceListForClient AS TABLE OF T_rowBalanceListForClient;
/


CREATE OR REPLACE FUNCTION F_BalanceListForClient
(
    p_ClientId NUMBER        
)
RETURN T_tableBalanceListForClient PIPELINED
AS
CURSOR CUR_TABLE IS
        SELECT
                RowCode,
                RowName
            FROM Assets
          ;    --put a filter of the p_clientId


BEGIN

    FOR CUR_REC IN CUR_TABLE
    LOOP

       pipe row (T_rowBalanceListForClient (CUR_REC.RowCode, CUR_REC.RowName));

    END LOOP;

RETURN;

END;
/


CREATE OR REPLACE PROCEDURE GET_BALANCE_STANDARD_LIST
(
    c_Result OUT SYS_REFCURSOR,
    p_ClientId NUMBER DEFAULT NULL
)
AS
sql_statement varchar2(200);

BEGIN

 sql_statement := ' SELECT * FROM TABLE(F_BalanceListForClient(:1))';
    OPEN c_Result FOR sql_statement USING p_ClientId;

END;
/

BEGIN

GET_BALANCE_STANDARD_LIST(:cur ,11);

END;
/
于 2013-08-06T15:10:19.160 回答