int p_session_start( /* + */ value v_session, type t_session, /* + */ value v_username, type t_username, /* + */ value v_host, type t_host, /* + */ value v_password, type t_password, /* + */ value v_opts, type t_opts ) { session_t * session; Get_Typed_Object(v_session,t_session,&session_handle_tid,session); Check_String(t_username); Check_String(t_host); Check_String(t_password); Check_Structure(t_opts); if ( session_start( session, StringStart(v_username), StringStart(v_host), StringStart(v_password), v_opts) ) Bip_Error(dbi_errno); Succeed; }
int p_session_sql_dml( /* + */ value v_session, type t_session, /* + */ value v_SQL, type t_SQL, /* - */ value v_rows, type t_rows ) { session_t * session; cursor_t * cursor; char * SQL; word rows, *prows; int res; Check_String(t_SQL); Check_Output_Integer(t_rows); Get_Typed_Object(v_session,t_session,&session_handle_tid,session); cursor = session_sql_prepare(session, StringStart(v_SQL), StringLength(v_SQL), 0); if (NULL == cursor) Bip_Error(dbi_errno); if (res = cursor_sql_execute(cursor, 1)) { cursor_free(cursor); Bip_Error(Error_Code(res)); } cursor_field_value(cursor, rows_processed_count, (void **)&prows); rows = *prows; cursor_free(cursor); Return_Unify_Integer(v_rows, t_rows, rows); }
static int p_shelf_name(value vname, type tname, value vhandle, type thandle, value vmod, type tmod) { pword *prop; dident name_did; int err; Get_Functor_Did(vname, tname, name_did); prop = set_modular_property(name_did, SHELF_PROP, vmod.did, tmod, LOCAL_PROP, &err); if (prop) { t_heap_array *obj; Get_Typed_Object(vhandle, thandle, &heap_array_tid, obj); prop->tag.kernel = TPTR; prop->val.wptr = (uword *) heap_array_tid.copy(obj); Succeed_; } else if (err == PERROR) { Succeed_; } else { Bip_Error(err); } }
int p_session_close(value v_session, type t_session) { pword handle; handle.val.all = v_session.all; handle.tag.all = t_session.all; session_t * session; Get_Typed_Object(v_session,t_session,&session_handle_tid,session); session_close(session); return ec_free_handle(handle, &session_handle_tid); }
int p_session_commit( /* + */ value v_session, type t_session ) { session_t * session; Get_Typed_Object(v_session,t_session,&session_handle_tid,session); if (session_commit(session)) Bip_Error(dbi_errno); Succeed; }
int p_session_rollback( /* + */ value v_session, type t_session ) { session_t * session; int res; Get_Typed_Object(v_session,t_session,&session_handle_tid,session); if (res = session_rollback(session)) Bip_Error(Error_Code(res)); Succeed; }
int p_session_error_value( /* + */ value v_session, type t_session, /* + */ value v_code, type t_code, /* + */ value v_message, type t_message ) { int code; char * message; pword p; session_t * session; Prepare_Requests; Check_Output_Integer(t_code); Check_Output_String(t_message); Get_Typed_Object(v_session,t_session,&session_handle_tid,session); session_error_value(session, &code, &message); Make_String(&p,message); Request_Unify_Integer(v_code, t_code, code); Request_Unify_Pw(v_message, t_message, p.val, p.tag); Succeed; }