Пример #1
0
/* --------------------------------------------------------------------------------------------- *
* test_ref
* --------------------------------------------------------------------------------------------- */
void test_ref(void)
{
    ocout << otext("\n>>>>> TEST REF FETCHING \n\n");

    Statement st(con);

    st.Execute(otext("select ref(e) from test_table_obj e"));

    Resultset rs = st.GetResultset();
    while (rs++)
    {
        Reference ref = rs.Get<Reference>(1);
        Object   obj = ref.GetObject();

        ocout << obj.Get<int>(otext("ID")) << otext(" - ") << obj.Get<ostring>(otext("NAME")) << oendl;
    }

    ocout << otext("\n>>>>> TEST REF PL/SQL BINDING \n\n");

    Reference ref(TypeInfo(con, otext("type_t"), TypeInfo::Type));

    st.Prepare(otext("begin ")
        otext("  select ref(e) into :r from test_table_obj e where e.id = 1; ")
        otext("end; "));

    st.Bind(otext(":r"), ref, BindInfo::InOut);
    st.ExecutePrepared();

    Object obj = ref.GetObject();
    ocout << obj.Get<int>(otext("ID")) << otext(" - ") << obj.Get<ostring>(otext("NAME")) << oendl;
}