# Can someone help me with a macro to set database space

**URL:** <https://forums.toadworld.com/t/can-someone-help-me-with-a-macro-to-set-database-space/39675>\
**Category:** Toad Data Modeler\
**Created:** [July 10, 2017, 6:31pm UTC](https://forums.toadworld.com/t/can-someone-help-me-with-a-macro-to-set-database-space/39675 "2017-07-10T18:31:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![thastings](https://avatars.discourse-cdn.com/v4/letter/t/e47c2d/32.png) [@thastings](https://forums.toadworld.com/u/thastings)\
**Post date:** [July 10, 2017, 6:31pm UTC](https://forums.toadworld.com/t/can-someone-help-me-with-a-macro-to-set-database-space/39675/1 "2017-07-10T18:31:57Z")

</div>

I have reverse engineered one of our existing datbases and made a change. But now I have a validation error as the database space has not defaulted to system. Is there a way I can do this without editing every entity.

Thanks

Terry

---

<div class="post-metadata">

**Author:** ![Daril](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/daril/32/31_2.png) [@Daril](https://forums.toadworld.com/u/Daril)\
**Post date:** [July 11, 2017, 11:06pm UTC](https://forums.toadworld.com/t/can-someone-help-me-with-a-macro-to-set-database-space/39675/2 "2017-07-11T23:06:00Z")

</div>

Hi Terry,

If I understand you have a set of entities, that have assigned “DatabaseSpace1” and you want assign to all all entities which have “DatabaseSpace1” another “Database space”.

I can write to you this macro, but please I need to know what database are you use and what TDM version. I see that “database space” is in SAP Anywhere and Sybase IQ.

Daril

---

<div class="post-metadata">

**Author:** ![thastings](https://avatars.discourse-cdn.com/v4/letter/t/e47c2d/32.png) [@thastings](https://forums.toadworld.com/u/thastings)\
**Post date:** [July 13, 2017, 9:53pm UTC](https://forums.toadworld.com/t/can-someone-help-me-with-a-macro-to-set-database-space/39675/3 "2017-07-13T21:53:19Z")

</div>

SQL Anywhere and Data Modeller 6.2

---

<div class="post-metadata">

**Author:** ![thastings](https://avatars.discourse-cdn.com/v4/letter/t/e47c2d/32.png) [@thastings](https://forums.toadworld.com/u/thastings)\
**Post date:** [July 13, 2017, 9:55pm UTC](https://forums.toadworld.com/t/can-someone-help-me-with-a-macro-to-set-database-space/39675/4 "2017-07-13T21:55:44Z")

</div>

Oh and what I want to do is replace the DBSpace which hasn’t been assigned from a reverse engineered database. I want to set it to “system”

---

<div class="post-metadata">

**Author:** ![Daril](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/daril/32/31_2.png) [@Daril](https://forums.toadworld.com/u/Daril)\
**Post date:** [July 13, 2017, 11:13pm UTC](https://forums.toadworld.com/t/can-someone-help-me-with-a-macro-to-set-database-space/39675/5 "2017-07-13T23:13:17Z")

</div>

Hi Terry,

I created for you custom package, you can import it from "Main Menu - Customization - Import Custom Package" (Expert Mode must be switch on, you can switch on in Main Menu - Settings- Option - General).

Now when you have active Anywhere Model go to Main Menu - Macros. There should be new item "Assign Database Space".

![DSMenu.png](https://global.discourse-cdn.com/quest/original/2X/0/05ab5a37847fbaa3866ce8cee5ce8d2ebe346c1c.png)

You can run it, you get simply dialog, where you need to select destination Database Space (must be present in model) and click to Execute. For all entities in model will be assigned selected Database Space.

![DS.png](https://global.discourse-cdn.com/quest/original/2X/c/c47c47667cdf05c95c718625f4d6ddaf9ea866f3.png)

If you wan modify this macro, you can open "Package Explorer" from "Main Menu - Expert Mode - Customization - Package Explorer". In toolbar of Package Explorer Hide System Packages and you will see only few packages. One oft them will be "DatabaseSpaceTools", open its branch and under Macros node is only one macro. You can modify it by popup menu "Edit Source Code" or "Properties".

 ![DSPE.png](https://global.discourse-cdn.com/quest/original/2X/3/36b1ac853fc45f219f15e5604e89dcfd07a18c53.png)

I tested it on Anywhere 17, but it should works on Anywhere 11 too.

Daril  
[DatabaseSpaceTools.zip](https://forums.toadworld.com/uploads/default/original/2X/4/40f4bb02f432775eddffd35333eddd93258f60d6.zip) (1.73 KB)

---

<div class="post-metadata">

**Author:** ![thastings](https://avatars.discourse-cdn.com/v4/letter/t/e47c2d/32.png) [@thastings](https://forums.toadworld.com/u/thastings)\
**Post date:** [July 13, 2017, 11:16pm UTC](https://forums.toadworld.com/t/can-someone-help-me-with-a-macro-to-set-database-space/39675/6 "2017-07-13T23:16:34Z")

</div>

Thanks Daril

\*\*Terry Hastings \*\ ***:: Database Administrator**  
**E:** thastings@auto-it.com.au

This email may contain privileged and confidential information intended only for the use of the addressee named above. If you are not the intended recipient of this email, you are hereby notified that any use, dissemination, distribution or reproduction of this email is prohibited. No liability is accepted for the accuracy or integrity of the information contained herein or for any delays, interruptions, errors or omissions however occurring.

**From:** Daril [[mailto:bounce-Daril@toadworld.com](mailto:bounce-Daril@toadworld.com)]

**Sent:** Friday, 14 July 2017 4:14 PM

**To:** [tdmscript@toadworld.com](mailto:tdmscript@toadworld.com)

**Subject:** [Filtered] RE: [Toad Data Modeler - Scripting & Customizations Discussion Forum] Can someone help me with a macro to set database space

**[RE: Can someone help me with a macro to set database space](http://www.toadworld.com/products/toad-data-modeler/f/31/p/32838/66649#66649)**

Reply by Daril

Hi Terry,

I created for you custom package, you can import it from “Main Menu - Customization - Import Custom Package” (Expert Mode must be switch on, you can switch on in Main Menu - Settings- Option - General).

Now when you have active Anywhere Model go to Main Menu - Macros. There should be new item “Assign Database Space”.

[![](http://www.toadworld.com/resized-image/ __size/320x240/__ key/communityserver-discussions-components-files/31/DSMenu.png)](http://www.toadworld.com/cfs-file/__key/communityserver-discussions-components-files/31/DSMenu.png)

You can run it, you get simply dialog, where you need to select destination Database Space (must be present in model) and click to Execute. For all entities in model will be assigned selected Database Space.

[![](http://www.toadworld.com/resized-image/ __size/320x240/__ key/communityserver-discussions-components-files/31/DS.png)](http://www.toadworld.com/cfs-file/__key/communityserver-discussions-components-files/31/DS.png)

If you wan modify this macro, you can open “Package Explorer” from “Main Menu - Expert Mode - Customization - Package Explorer”. In toolbar of Package Explorer Hide System Packages and you will see only few packages. One oft them will be “DatabaseSpaceTools”, open its branch and under Macros node is only one macro. You can modify it by popup menu “Edit Source Code” or “Properties”.

[![](http://www.toadworld.com/resized-image/ __size/320x240/__ key/communityserver-discussions-components-files/31/DSPE.png)](http://www.toadworld.com/cfs-file/__key/communityserver-discussions-components-files/31/DSPE.png)

I tested it on Anywhere 17, but it should works on Anywhere 11 too.

Daril

**Attachments:**

[DatabaseSpaceTools.zip](http://www.toadworld.com/cfs-file/__key/telligent-evolution-components-attachments/00-31-01-00-00-06-66-49/DatabaseSpaceTools.zip)

To reply, please reply-all to this email.

[Stop receiving emails](http://www.toadworld.com/products/toad-data-modeler/f/31/t/32838?subscribe=false) on this subject.

Or [  
Unsubscribe from Toad Data Modeler - Scripting & Customizations Forum](http://www.toadworld.com/products/toad-data-modeler/f/31?subscribe=false) notifications altogether.

Toad Data Modeler - Scripting & Customizations Discussion Forum

[Flag](http://www.toadworld.com/products/toad-data-modeler/f/31/p/32838/66649?AbuseContentId=28668bd6-78db-45f1-8ce0-ba417c0b4750&AbuseContentTypeId=f586769b-0822-468a-b7f3-a94d480ed9b0&AbuseFlag=true)  
this post as spam/abuse.
