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);
そこから私はそこに3つの同一の列(ユーザー名は、ユーザーID、たbirthDate)で行型を更新する汎用的なソリューションを作成します。ソリューションとユースケースを想像すると、次のようになります。
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ではこれが可能でしょうか?