0
我正在寻找一种方法来更新一般的行类型,以便我可以为不同的表插入相同的数据组。动态更新通用行?
我的要求是采取具有非常相似的列像下面的表格。
create table storedNumber(myNumber number, userName varchar2(4000), userId number, birthDate date);
/
create table storedVarchar(myVarchar varchar2(4000), userName varchar2(4000), userId number, birthDate date);
从那里我想创建一个通用的解决方案,将更新与三个相同的列有(用户名,用户id,生日)rowtypes。想象一个解决方案和用例看起来如下所示。
procedure UpdateRowWithUserInfo(in_tableName varchar2, in_rowType in out generic_row(?), in_userInfo userInfo) is
begin
in_rowType('userName') := in_userInfo.userName;
in_rowType('userId') := in_userInfo.userId;
in_rowType('birthDate') := in_userInfo.birthDate;
end;
/
declare
l_userInfo userInfo;
l_numberRow storedNumber%rowtype;
l_varcharRow storedVarchar%rowtype;
begin
-- This returns a userInfo object from the id with the userName, userId, and birthDate populated
l_userInfo := get_userInfo(123);
-- Getting some data for the rows
l_numberRow.myNumber := 42;
l_varcharRow.myVarchar := 'Hello World';
-- This function should update the input row's columns with the input user info
UpdateRowWithUserInfo('storedNumber', l_numberRow, l_userInfo);
UpdateRowWithUserInfo('storedVarchar', l_varcharRow, l_userInfo);
end;
这样的事情对Oracle来说可能吗?