# Wrong Key Type in Globals Relation?

**URL:** <https://forum.servoy.com/t/wrong-key-type-in-globals-relation/10021>\
**Category:** Classic Servoy\
**Created:** [December 14, 2008, 3:05pm UTC](https://forum.servoy.com/t/wrong-key-type-in-globals-relation/10021 "2008-12-14T15:05:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kahuna](https://avatars.discourse-cdn.com/v4/letter/k/8491ac/32.png) [@Kahuna](https://forum.servoy.com/u/Kahuna)\
**Post date:** [December 14, 2008, 3:05pm UTC](https://forum.servoy.com/t/wrong-key-type-in-globals-relation/10021/1 "2008-12-14T15:05:53Z")

</div>

I created a Global Var (comp\_id = null;) its an PK integer cd\_id and a servoy sequence on a table. I then tried to create a relation with that Global on the same column name in another table where its a FK integer cd\_id.

When I try to save the relation I get:

Key type of globals.comp\_id does not match with type from cd\_id

These columns are the same as far as I can see. Any suggestions on how I might track down this issue?

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [December 14, 2008, 3:32pm UTC](https://forum.servoy.com/t/wrong-key-type-in-globals-relation/10021/2 "2008-12-14T15:32:01Z")

</div>

Hi Kahuna,

Seems the global is not of the type integer. What happens when you set the default value to 0 instead of null ?

---

<div class="post-metadata">

**Author:** ![Kahuna](https://avatars.discourse-cdn.com/v4/letter/k/8491ac/32.png) [@Kahuna](https://forum.servoy.com/u/Kahuna)\
**Post date:** [December 14, 2008, 5:10pm UTC](https://forum.servoy.com/t/wrong-key-type-in-globals-relation/10021/3 "2008-12-14T17:10:59Z")

</div>

> ROCLASI:  
> Hi Kahuna,
> 
> Seems the global is not of the type integer. What happens when you set the default value to 0 instead of null ?

That did the trick Robert - thanks.

I had’nt realised that a variable would be set to any specific type before it was declared in running code. I see now that since the comp\_id had a Not Null property then of course I would need to set it to something!

Its a learning Curve ![:shock:]( "Shocked")

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [December 15, 2008, 8:52am UTC](https://forum.servoy.com/t/wrong-key-type-in-globals-relation/10021/4 "2008-12-15T08:52:41Z")

</div>

Note that you can also set the type of a global via the properties view.  
Select the global via -\>Globals (in the solution explorer tree) and select the variable in the bottom list.  
Now you can change the variableType of the global via the properties view.

Rob

---

<div class="post-metadata">

**Author:** ![Kahuna](https://avatars.discourse-cdn.com/v4/letter/k/8491ac/32.png) [@Kahuna](https://forum.servoy.com/u/Kahuna)\
**Post date:** [December 15, 2008, 9:46am UTC](https://forum.servoy.com/t/wrong-key-type-in-globals-relation/10021/5 "2008-12-15T09:46:54Z")

</div>

> rgansevles:  
> Note that you can also set the type of a global via the properties view.  
> Select the global via -\>Globals (in the solution explorer tree) and select the variable in the bottom list.  
> Now you can change the variableType of the global via the properties view.
> 
> Rob

Nice one - thanks Rob.
