diff --git a/src/builtin.cmod b/src/builtin.cmod
index afe9bfdcc446c31a77f4b245c7c3acd26a77f139..2b1f8dc3c1306cb40ecf24ddd494f0cde4b1d6a1 100644
--- a/src/builtin.cmod
+++ b/src/builtin.cmod
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: builtin.cmod,v 1.239 2009/11/11 14:05:58 grubba Exp $
+|| $Id: builtin.cmod,v 1.240 2009/11/12 15:10:21 grubba Exp $
 */
 
 #include "global.h"
@@ -4156,7 +4156,13 @@ PIKECLASS MasterCodec
 /*! @endmodule
  */
 
-struct object *SqlNULL_object;
+static struct object *SqlNULL_object;
+
+/* Proxy function needed for dynamic linkage on WIN32. */
+PMOD_EXPORT struct object *get_sql_null(void)
+{
+  return SqlNULL_object;
+}
 
 void init_builtin(void)
 {
diff --git a/src/builtin_functions.h b/src/builtin_functions.h
index a87cce070a33bbb0ef10353d83fa7dbb6b03c959..36ef712705638d1e775a4db2c8f1cf19f23f747d 100644
--- a/src/builtin_functions.h
+++ b/src/builtin_functions.h
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: builtin_functions.h,v 1.39 2009/11/11 12:53:49 grubba Exp $
+|| $Id: builtin_functions.h,v 1.40 2009/11/12 15:10:21 grubba Exp $
 */
 
 #ifndef BUILTIN_EFUNS_H
@@ -46,8 +46,7 @@ struct replace_many_context
   int flags;
 };
 
-extern struct object *SqlNULL_object;
-extern struct program *SqlNull_program;
+PMOD_EXPORT struct object *get_sql_null(void);
 
 PMOD_EXPORT void f_equal(INT32 args);
 PMOD_EXPORT void f_hash(INT32 args);
diff --git a/src/modules/Mysql/result.c b/src/modules/Mysql/result.c
index 693111551ea4051679e86ef406b19092b8c84e59..5a277d9cbdb42d94719941225003d3303c7c2cb9 100644
--- a/src/modules/Mysql/result.c
+++ b/src/modules/Mysql/result.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: result.c,v 1.51 2009/11/11 13:10:50 grubba Exp $
+|| $Id: result.c,v 1.52 2009/11/12 15:10:21 grubba Exp $
 */
 
 /*
@@ -627,7 +627,7 @@ static void f_fetch_row(INT32 args)
       } else {
 	/* NULL */
 	if (PIKE_MYSQL_RES->typed_mode) {
-	  ref_push_object(SqlNULL_object);
+	  ref_push_object(get_sql_null());
 	} else {
 	  push_undefined();
 	}
diff --git a/src/modules/Oracle/oracle.c b/src/modules/Oracle/oracle.c
index a97282dd5fe8b3432977e51c38ffd00a3a2bb770..41a02bee5082185df75482b40b9b96d345ff4d53 100644
--- a/src/modules/Oracle/oracle.c
+++ b/src/modules/Oracle/oracle.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: oracle.c,v 1.99 2009/11/09 14:34:02 grubba Exp $
+|| $Id: oracle.c,v 1.100 2009/11/12 15:10:21 grubba Exp $
 */
 
 /*
@@ -2728,7 +2728,7 @@ PIKE_MODULE_INIT
 
   MY_START_CLASS(dbnull); {
     struct pike_string *null_string = make_shared_string("Null");
-    low_inherit(SqlNull_program, NULL, -1, 0, 0, null_string);
+    low_inherit(get_sql_null()->prog, NULL, -1, 0, 0, null_string);
     free_string(null_string);
     add_integer_constant("is_oracle_null", 1, 0);
     ADD_FUNCTION("create", dbnull_create, tFunc(tOr(tStr, tInt), tVoid),