Last active
December 22, 2015 09:29
-
-
Save enriquemanuel/6452127 to your computer and use it in GitHub Desktop.
Change owner of folder in Blackboard database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare | |
ow varchar(200); | |
cb varchar(200); | |
counter number; | |
message varchar(200); | |
begin | |
counter := 0; | |
for uu in ( select pk1, file_id , user_id, full_path, internal_principal_id | |
from bblearn.users uu, bblearn_cms_doc.xyf_urls, bblearn_cms_doc.XYF_PRINCIPAL_LOOKUPS pp | |
where FULL_PATH = '/users/'||uu.user_id and | |
regexp_like(principal_id,'^BB:U:_[[:digit:]]*_1') and | |
substr(substr(principal_id,1, length(principal_id)-2), 7) =to_char(uu.pk1) ) | |
loop | |
select owner_principal_id, created_by into ow, cb from bblearn_cms_doc.XYF_FILES where FILE_ID = uu.file_id; | |
if(ow != uu.internal_principal_id) then | |
DBMS_OUTPUT.PUT_LINE('userid: ' ||uu.user_id || ' internal_principal_id: ' || uu.internal_principal_id || ' owner_principal_id: ' || ow); | |
counter := counter +1; | |
message := 'userid: '||uu.user_id; | |
// you will need to build this update statement as follows, | |
//please don't remove it if you don't know what you are doing. | |
//this is the point of no return. | |
//update bblearn_cms_doc.XYF_FILES set owner_principal_id = uu.internal_principal_id, created_by = uu.internal_principal_id where FILE_ID = uu.file_id; | |
end if; | |
end loop; | |
DBMS_OUTPUT.PUT_LINE(counter); | |
exception | |
when NO_DATA_FOUND THEN DBMS_OUTPUT.PUT_LINE('the exception is with the user after this one ' || message); | |
end; | |
/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment