Skip to content

Instantly share code, notes, and snippets.

@Tracnac
Created September 23, 2022 16:57
Show Gist options
  • Select an option

  • Save Tracnac/3805380aceaea36393a788b0b98193ff to your computer and use it in GitHub Desktop.

Select an option

Save Tracnac/3805380aceaea36393a788b0b98193ff to your computer and use it in GitHub Desktop.
Execute any sql from another session #oracle #sql
declare

nUid number;
vSqltext varchar2(100) := 'alter user <username> profile personal';
iCursor integer;
iResult integer;

begin
select user_id into nUid from all_users where username like 'SYS';
iCursor:=sys.dbms_sys_sql.open_cursor();
sys.dbms_sys_sql.parse_as_user(iCursor,vSqltext,dbms_sql.native,nUid);
iResult := sys.dbms_sys_sql.execute(iCursor);
sys.dbms_sys_sql.close_cursor(iCursor);
end ;
/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment