select 'update collaborationspace set cscourseid = '||c.classcontextid||' where collaborationspaceid = '||c.classid||';' from csclass c

this sql produces these sql statements:

update collaborationspace set cscourseid = 1059836 where collaborationspaceid = 1059844;

update collaborationspace set cscourseid = 1059836 where collaborationspaceid = 1059895;

i want to use the top statement in a database script and run the update statements dynamically. is it any way of doing this? I know you can run packages with the perform command. anything like
perform (select 'update' ...)

please help ;/