DBA Data[Home] [Help]

PACKAGE BODY: APPS.HZ_GEO_STRUCTURE_VALIDATE_PVT

Source


1 PACKAGE BODY HZ_GEO_STRUCTURE_VALIDATE_PVT AS
2 /*$Header: ARHGSTVB.pls 120.10 2005/10/18 21:03:02 baianand noship $ */
3 
4 
5 --------------------------------------
6 -- declaration of private global varibles
7 --------------------------------------
8 
9 --------------------------------------------------
10 -- declaration of private procedures and functions
11 ---------------------------------------------------
12 
13 -- validate uniqueness of geography type within a parent_geography type in relationship type
14 PROCEDURE validate_geo_type_unique (
15   p_geography_type        IN VARCHAR2,
16   p_parent_geography_type IN VARCHAR2,
17   x_return_status         IN OUT NOCOPY VARCHAR2
18   );
19 
20 -- validate relationship_type_id FK
21 PROCEDURE validate_relationship_type_id (
22  p_relationship_type_id     IN NUMBER,
23  x_return_status            IN OUT NOCOPY VARCHAR2
24  );
25 
26 
27 ------------------------------------------
28 -- body of public procedures and functions
29 ------------------------------------------
30 
31 /**
32  * PROCEDURE validate_geography_type
33  *
34  * DESCRIPTION
35  *     Validate Geography Type based on the Unique flag.
36  *
37  * EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
38  *
39  * ARGUMENTS
40  *   IN:
41  *     p_geography_type               Geography Type you want to validate.
42  *     p_master_ref_flag              Geography Use flag.
43  *
44  *   IN/OUT:
45  *     x_return_status                Return status.
46  *
47  * NOTES
48  *
49  *
50  * MODIFICATION HISTORY
51  *
52  *   11-05-2002    Rekha Nalluri      o Created.
53  *
54  */
55 
56  PROCEDURE validate_geography_type (
57        p_geography_type       IN VARCHAR2,
58        p_master_ref_flag      IN VARCHAR2,
59        x_return_status        IN OUT NOCOPY VARCHAR2
60  ) IS
61 
62        l_count           NUMBER;
63 
64    BEGIN
65           SELECT count(*)
66           INTO   l_count
67           FROM   hz_geography_types_b
68           WHERE  GEOGRAPHY_TYPE = UPPER(p_geography_type)
69             AND  GEOGRAPHY_USE = decode(p_master_ref_flag,'Y','MASTER_REF',GEOGRAPHY_USE);
70 
71           IF l_count = 0 THEN
72           fnd_message.set_name('AR', 'HZ_API_INVALID_FK');
73           fnd_message.set_token('FK', 'geography_type');
74           fnd_message.set_token('COLUMN', 'geography_type');
75           fnd_message.set_token('TABLE', 'hz_geography_types_b');
76           fnd_msg_pub.add;
77           x_return_status := fnd_api.g_ret_sts_error;
78          END IF;
79 
80   END validate_geography_type;
81 
82   /**
83  * PROCEDURE validate_geography_id
84  *
85  * DESCRIPTION
86  *     Validate Geography id.
87  *
88  * EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
89  *
90  * ARGUMENTS
91  *   IN:
92  *     p_geography_id               Geography id you want to validate.
93  *
94  *   IN/OUT:
95  *     x_return_status                Return status.
96  *
97  * NOTES
98  *
99  *
100  * MODIFICATION HISTORY
101  *
102  *   11-05-2002    Rekha Nalluri      o Created.
103  *
104  */
105 
106 
107  PROCEDURE validate_geography_id (
108        p_geography_id         IN NUMBER,
109        p_master_ref_flag      IN VARCHAR2,
110        x_return_status        IN OUT NOCOPY VARCHAR2
111  ) IS
112 
113        l_count           NUMBER;
114 
115    BEGIN
116           SELECT count(*)
117           INTO   l_count
118           FROM   HZ_GEOGRAPHIES
119           WHERE  GEOGRAPHY_ID = p_geography_id
120             AND  GEOGRAPHY_USE = decode(p_master_ref_flag,'Y','MASTER_REF',GEOGRAPHY_USE);
121 
122          IF l_count = 0 THEN
123 
124           fnd_message.set_name('AR', 'HZ_GEO_NO_RECORD');
125           fnd_message.set_token('TOKEN1', 'geography');
126           fnd_message.set_token('TOKEN2', 'geography_id '||p_geography_id);
127           fnd_msg_pub.add;
128           x_return_status := fnd_api.g_ret_sts_error;
129         END IF;
130 
131         EXCEPTION
132           WHEN NO_DATA_FOUND THEN
133               NULL;
134   END validate_geography_id;
135 
136   --------------------------------
137   ---- body of public procedures
138   --------------------------------
139 
140   -- PROCEDURE validate_geo_rel_type
141   --
142   -- DESCRIPTION
143   --     Validates geography relationship type record. Checks for
144   --
145   --         uniqueness
146   --         lookups
147   --         mandatory columns
148   --
149   --
150   -- EXTERNAL   PROCEDURES/FUNCTIONS ACCESSED
151   --
152   -- ARGUMENTS
153   --   IN:
154   --     p_create_update_flag        Create update flag. 'C' = create. 'U' = update.
155   --     p_geo_rel_type_rec geography relationship type record.
156   --
157   --   IN/OUT:
158   --     x_return_status         Return status after the call. The status can
159   --                             be FND_API.G_RET_STS_SUCCESS (success),
160   --                             FND_API.G_RET_STS_ERROR (error),
161   --                             FND_API.G_RET_STS_UNEXP_ERROR (unexpected error).
162   --
163   -- NOTES
164   --
165   -- MODIFICATION HISTORY
166   --
167   --   11-11-2002    Rekha Nalluri       o Created.
168   --
169 
170 
171   PROCEDURE validate_geo_rel_type(
172      p_create_update_flag           IN  VARCHAR2,
173      p_geo_rel_type_rec    IN  HZ_GEOGRAPHY_STRUCTURE_PUB.geo_rel_type_REC_TYPE,
174      x_return_status                IN OUT NOCOPY VARCHAR2
175    ) IS
176 
177    BEGIN
178 
179      IF p_create_update_flag='C' THEN
180          -- validate mandatory columns
181         hz_utility_v2pub.validate_mandatory(
182           p_create_update_flag     => 'C',
183           p_column                 => 'geography_type',
184           p_column_value           => p_geo_rel_type_rec.geography_type,
185           x_return_status          => x_return_status
186           );
187 
188 
189         hz_utility_v2pub.validate_mandatory(
190           p_create_update_flag     => 'C',
191           p_column                 => 'parent_geography_type',
192           p_column_value           => p_geo_rel_type_rec.parent_geography_type,
193           x_return_status          => x_return_status
194           );
195 
196         hz_utility_v2pub.validate_created_by_module(
197           p_create_update_flag     => 'C',
198           p_created_by_module      => p_geo_rel_type_rec.created_by_module,
199           p_old_created_by_module  => null,
200           x_return_status          => x_return_status);
201       END IF;
202 
203         -- check if geography_type and parent_geography_type are same . If yes , raise error
204         -- because a geography_type can not be parent of the same geography_type.
205          IF p_geo_rel_type_rec.geography_type = p_geo_rel_type_rec.parent_geography_type THEN
206 
207           fnd_message.set_name('AR', 'HZ_GEO_DUPL_GEO_TYPE');
208           fnd_msg_pub.add;
209           x_return_status := fnd_api.g_ret_sts_error;
210 
211          END IF;
212       --dbms_output.put_line('In validate after mandatory validation '||x_return_status);
213 
214       IF p_create_update_flag='C' THEN
215          -- validate parent geography type
216          validate_geography_type (
217           p_geography_type       => p_geo_rel_type_rec.parent_geography_type,
218           p_master_ref_flag      => 'N',
219           x_return_status        => x_return_status
220           );
221 
222           -- validate geography type
223          validate_geography_type (
224           p_geography_type       => p_geo_rel_type_rec.geography_type,
225           p_master_ref_flag      => 'N',
226           x_return_status        => x_return_status
227           );
228       END IF;
229 
230       --dbms_output.put_line('In validate after geography types validation '||x_return_status);
231 
232       IF p_create_update_flag='C' THEN
233           -- validate geography type uniqueness within parent geography type
234           validate_geo_type_unique(
235            p_geography_type          => p_geo_rel_type_rec.geography_type,
236            p_parent_geography_type   => p_geo_rel_type_rec.parent_geography_type,
237            x_return_status           => x_return_status
238            );
239       END IF;
240       --dbms_output.put_line('In validate after geo unique validation '||x_return_status);
241 
242       /*IF p_create_update_flag ='C' THEN
243         -- validate whether geography_type is below parent_geography_type
244         HZ_GEOGRAPHY_VALIDATE_PVT.validate_structure(
245             p_geography_type        => p_geo_rel_type_rec.geography_type,
246             p_parent_geography_type => p_geo_rel_type_rec.parent_geography_type,
247             p_country_code          => p_geo_rel_type_rec.country_code,
248             x_return_status         => x_return_status
249             );
250       END IF; */
251 
252 
253 
254 END validate_geo_rel_type;
255 
256  -- PROCEDURE validate_geo_structure
257   --
258   -- DESCRIPTION
259   --     Validates geography structure record. Checks for
260   --
261   --         uniqueness
262   --         lookups
263   --         mandatory columns
264   --
265   --
266   -- EXTERNAL   PROCEDURES/FUNCTIONS ACCESSED
267   --
268   -- ARGUMENTS
269   --   IN:
270   --     p_create_update_flag        Create update flag. 'C' = create. 'U' = update.
271   --     p_geo_structure_rec         geography structure type record.
272   --
273   --   IN/OUT:
274   --     x_return_status         Return status after the call. The status can
275   --                             be FND_API.G_RET_STS_SUCCESS (success),
276   --                             FND_API.G_RET_STS_ERROR (error),
277   --                             FND_API.G_RET_STS_UNEXP_ERROR (unexpected error).
278   --
279   -- NOTES
280   --
281   -- MODIFICATION HISTORY
282   --
283   --   11-15-2002    Rekha Nalluri       o Created.
284   --
285   --
286 
287   PROCEDURE validate_geo_structure(
288   p_create_update_flag        IN VARCHAR2,
289   p_geo_structure_rec         IN HZ_GEOGRAPHY_STRUCTURE_PUB.geo_structure_rec_type,
290   x_return_status             IN OUT NOCOPY VARCHAR2
291   ) IS
292 
293     l_geography_type          VARCHAR2(30);
294     l_addr_val_level          VARCHAR2(30);
295     l_count                   NUMBER;
296     l_geo_count               NUMBER;
297     l_pgeo_count              NUMBER;
298 
299   BEGIN
300 
301   -- validate mandatory columns
302   IF p_create_update_flag = 'C' THEN
303     hz_utility_v2pub.validate_mandatory(
304           p_create_update_flag     => 'C',
305           p_column                 => 'geography_id',
306           p_column_value           => p_geo_structure_rec.geography_id,
307           x_return_status          => x_return_status
308           );
309 
310     hz_utility_v2pub.validate_mandatory(
311           p_create_update_flag     => 'C',
312           p_column                 => 'geography_type',
313           p_column_value           => p_geo_structure_rec.geography_type,
314           x_return_status          => x_return_status
315           );
316 
317     hz_utility_v2pub.validate_mandatory(
318           p_create_update_flag     => 'C',
319           p_column                 => 'parent_geography_type',
320           p_column_value           => p_geo_structure_rec.parent_geography_type,
321           x_return_status          => x_return_status
322           );
323 
324    /* commented per bug : 2911108
325    hz_utility_v2pub.validate_mandatory(
326           p_create_update_flag     => 'C',
327           p_column                 => 'geography_element_column',
328           p_column_value           => p_geo_structure_rec.geography_element_column,
329           x_return_status          => x_return_status
330           );*/
331 
332     hz_utility_v2pub.validate_created_by_module(
333       p_create_update_flag     => 'C',
334       p_created_by_module      => p_geo_structure_rec.created_by_module,
335       p_old_created_by_module  => null,
336       x_return_status          => x_return_status);
337 
338   END IF;
339 
340 
341   -- validate geography_id
342   IF p_create_update_flag = 'C' THEN
343 
344     validate_geography_id(
345        p_geography_id    => p_geo_structure_rec.geography_id,
346        p_master_ref_flag => 'Y',
347        x_return_status   => x_return_status
348        );
349 
350         -- validate whether geography_type of the above geography_id is 'COUNTRY'
351         SELECT geography_type
352           INTO l_geography_type
353           FROM HZ_GEOGRAPHIES
354          WHERE geography_id = p_geo_structure_rec.geography_id;
355 
356          IF l_geography_type <> 'COUNTRY' THEN
357           FND_MESSAGE.SET_NAME( 'AR', 'HZ_GEO_INVALID_TYPE' );
358            FND_MESSAGE.SET_TOKEN( 'GEO_ID', p_geo_structure_rec.geography_id);
359            FND_MSG_PUB.ADD;
360           x_return_status := fnd_api.g_ret_sts_error;
361          END IF;
362   END IF;
363 
364   IF p_create_update_flag = 'C' THEN
365 
366       validate_geography_type(
367         p_geography_type  => p_geo_structure_rec.geography_type,
368         p_master_ref_flag => 'Y',
369         x_return_status   => x_return_status
370          );
371       validate_geography_type(
372          p_geography_type  => p_geo_structure_rec.parent_geography_type,
373          p_master_ref_flag => 'Y',
374          x_return_status   => x_return_status
375          );
376   END IF;
377 
378   -- Below if conditions is added for bug # 4656717
379   -- Should check for duplicate geography type being entered in the same structure
380   -- We should check the uniqueness of  geography_id geography_type and geography_id and parent_geography_type.
381   IF p_create_update_flag = 'C' THEN
382     BEGIN
383 
384       SELECT count(*) INTO l_geo_count
385       FROM   hz_geo_structure_levels
386       WHERE  geography_id = p_geo_structure_rec.geography_id
387       AND    geography_type = p_geo_structure_rec.geography_type;
388 
389       IF l_geo_count > 0 THEN
390         fnd_message.set_name('AR', 'HZ_GEO_TYPE_EXISTS_IN_STRUCT');
391         fnd_message.set_token('P_GEO_TYPE', p_geo_structure_rec.geography_type);
392         fnd_msg_pub.add;
393         x_return_status := fnd_api.g_ret_sts_error;
394         RAISE FND_API.G_EXC_ERROR;
395       END IF;
396 
397       SELECT count(*) INTO l_pgeo_count
398       FROM   hz_geo_structure_levels
399       WHERE  geography_id = p_geo_structure_rec.geography_id
400       AND    parent_geography_type = p_geo_structure_rec.parent_geography_type;
401 
402       IF l_pgeo_count > 0 THEN
403         fnd_message.set_name('AR', 'HZ_GEO_PTYPE_EXISTS_IN_STRUCT');
404         fnd_message.set_token('P_PGEO_TYPE', p_geo_structure_rec.parent_geography_type);
405         fnd_msg_pub.add;
406         x_return_status := fnd_api.g_ret_sts_error;
407         RAISE FND_API.G_EXC_ERROR;
408       END IF;
409 
410     END;
411   END IF;
412 
413   IF p_create_update_flag = 'C' THEN
414      -- Added the below if condition and error message for bug # 4596440
415      -- Address validation level should not be populated all the geography types.
416      -- It should be populated only for parent_geography_type = 'COUNTRY'.
417      IF p_geo_structure_rec.addr_val_level is NOT NULL then
418         IF p_geo_structure_rec.parent_geography_type = 'COUNTRY' then
419            BEGIN
420               SELECT lookup_code
421               INTO   l_addr_val_level
422               FROM   ar_lookups
423               WHERE  lookup_type = 'HZ_ADDRESS_VALIDATION_LEVEL'
424               AND    lookup_code = p_geo_structure_rec.addr_val_level;
425            EXCEPTION WHEN NO_DATA_FOUND THEN
426               x_return_status := FND_API.G_RET_STS_ERROR;
427               FND_MESSAGE.SET_NAME('AR', 'HZ_GEO_INVALID_VAL_LEVEL');
428               --  The Address Validation Level is invalid. Please pass a valid Address Validation Level
429               FND_MSG_PUB.ADD;
430               RAISE FND_API.G_EXC_ERROR;
431            END;
432         ELSE
433            x_return_status := FND_API.G_RET_STS_ERROR;
434            FND_MESSAGE.SET_NAME('AR', 'HZ_GEO_VAL_LEVEL_INVALID_GEO');
435            --  Address validation level can be set only for parent geography type, 'COUNTRY'
436            FND_MSG_PUB.ADD;
437            RAISE FND_API.G_EXC_ERROR;
438         END IF;
439      END IF;
440   END IF;
441 
442         -- validate geography_element_column to be one of geography_element1..10 columns of hz_geographies
443 -- commented as per the bug fix: 2911108
444    /*   IF UPPER(p_geo_structure_rec.geography_element_column) NOT IN (
445       'GEOGRAPHY_ELEMENT2','GEOGRAPHY_ELEMENT3','GEOGRAPHY_ELEMENT4','GEOGRAPHY_ELEMENT5',
446       'GEOGRAPHY_ELEMENT6','GEOGRAPHY_ELEMENT7','GEOGRAPHY_ELEMENT8','GEOGRAPHY_ELEMENT9','GEOGRAPHY_ELEMENT10')
447       THEN
448            FND_MESSAGE.SET_NAME( 'AR', 'HZ_GEO_ELEMENT_COL_INVALID');
449            FND_MESSAGE.SET_TOKEN( 'GEO_ID', p_geo_structure_rec.geography_id);
450            FND_MSG_PUB.ADD;
451         x_return_status := fnd_api.g_ret_sts_error;
452       END IF;*/
453 
454 
455   IF p_create_update_flag = 'U' THEN
456 
457   -- validate mandatory for relationship_type_id
458   hz_utility_v2pub.validate_mandatory(
459           p_create_update_flag     => 'U',
460           p_column                 => 'geography_id',
461           p_column_value           => p_geo_structure_rec.geography_id,
462           x_return_status          => x_return_status
463           );
464 
465   hz_utility_v2pub.validate_mandatory(
466           p_create_update_flag     => 'U',
467           p_column                 => 'geography_type',
468           p_column_value           => p_geo_structure_rec.geography_type,
469           x_return_status          => x_return_status
470           );
471    hz_utility_v2pub.validate_mandatory(
472           p_create_update_flag     => 'U',
473           p_column                 => 'parent_geography_type',
474           p_column_value           => p_geo_structure_rec.parent_geography_type,
475           x_return_status          => x_return_status
476           );
477 
478 
479      END IF;
480 
481 
482 END VALIDATE_GEO_STRUCTURE;
483 
484 --------------------------------------------
485 --- body of private procedures and functions
486 --------------------------------------------
487 
488 --- validate geography type uniqueness within parent geography type
489 
490 PROCEDURE validate_geo_type_unique (
491   p_geography_type       IN VARCHAR2,
492   p_parent_geography_type IN VARCHAR2,
493   x_return_status         IN OUT NOCOPY VARCHAR2
494  ) IS
495 
496    l_count       NUMBER;
497 
498  BEGIN
499    SELECT count(*) INTO l_count
500      FROM hz_relationship_types
501     WHERE SUBJECT_TYPE = p_parent_geography_type
502       AND OBJECT_TYPE = p_geography_type
503       AND FORWARD_REL_CODE = 'PARENT_OF'
504       AND BACKWARD_REL_CODE = 'CHILD_OF';
505 
506       IF l_count > 0 THEN
507 
508         fnd_message.set_name('AR', 'HZ_API_DUPLICATE_COLUMN');
509           fnd_message.set_token('COLUMN', 'geography_type');
510           fnd_msg_pub.add;
511         x_return_status := fnd_api.g_ret_sts_error;
512 
513       END IF;
514 
515       EXCEPTION
516          WHEN NO_DATA_FOUND THEN
517               NULL;
518  END validate_geo_type_unique;
519 
520 
521  --- validate Relationship Type ID FK
522 
523  PROCEDURE validate_relationship_type_id (
524  p_relationship_type_id     IN NUMBER,
525  x_return_status            IN OUT NOCOPY VARCHAR2
526  ) IS
527 
528        l_count           NUMBER;
529 
530    BEGIN
531           SELECT 1
532           INTO   l_count
533           FROM   HZ_RELATIONSHIP_TYPES
534           WHERE  RELATIONSHIP_TYPE_ID = p_relationship_type_id;
535 
536         EXCEPTION
537           WHEN NO_DATA_FOUND THEN
538               fnd_message.set_name('AR', 'HZ_API_INVALID_FK');
539           fnd_message.set_token('COLUMN', 'relationship_type_id');
540           fnd_msg_pub.add;
541           x_return_status := fnd_api.g_ret_sts_error;
542   END validate_relationship_type_id;
543 
544 
545   /**
546  * PROCEDURE validate_zone_type
547  *
548  * DESCRIPTION
549  *     Validate Zone type.
550  *
551  * EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
552  *
553  * ARGUMENTS
554  *   IN:
555  *     p_geography_type               Geography Type to validate
556  *     p_geography_use                Geography Usage
557  *     p_limited_by_geography_id
558  *     p_incl_geo_type                Included geography type
559  *
560  *   IN/OUT:
561  *     x_return_status                Return status.
562  *
563  * NOTES
564  *
565  *
566  * MODIFICATION HISTORY
567  *
568  *   01-09-2003    Rekha Nalluri      o Created.
569  *
570  */
571 
572 PROCEDURE validate_zone_type (
573     p_zone_type_rec                         IN  HZ_GEOGRAPHY_STRUCTURE_PUB.zone_type_rec_type,
574     p_create_update_flag                    IN     VARCHAR2,
575     x_return_status                         IN OUT NOCOPY VARCHAR2
576   ) IS
577 
578    l_count         NUMBER;
579 
580   BEGIN
581 
582      -- validate for mandatory columns
583 
584       IF p_create_update_flag = 'C' THEN
585       hz_utility_v2pub.validate_mandatory(
586           p_create_update_flag     => 'C',
587           p_column                 => 'geography_type',
588           p_column_value           => p_zone_type_rec.geography_type,
589           x_return_status          => x_return_status
590           );
591 
592       hz_utility_v2pub.validate_mandatory(
593           p_create_update_flag     => 'C',
594           p_column                 => 'geography_use',
595           p_column_value           => p_zone_type_rec.geography_use,
596           x_return_status          => x_return_status
597           );
598 
599       hz_utility_v2pub.validate_created_by_module(
600         p_create_update_flag     => 'C',
601         p_created_by_module      => p_zone_type_rec.created_by_module,
602         p_old_created_by_module  => null,
603         x_return_status          => x_return_status);
604       END IF;
605 
606 
607         HZ_UTILITY_V2PUB.validate_lookup(
608        p_column         => 'postal_code_range_flag',
609        p_lookup_type    => 'HZ_GEO_POSTAL_CODE_RANGE_FLAG',
610        p_column_value   => p_zone_type_rec.postal_code_range_flag,
611        x_return_status  => x_return_status
612         );
613 
614       IF p_create_update_flag = 'C' and
615          p_zone_type_rec.limited_by_geography_id is not null
616         and p_zone_type_rec.limited_by_geography_id <> fnd_api.g_miss_num THEN
617       -- check for the mandatory columnm included_geography_type
618          IF p_zone_type_rec.included_geography_type.count = 0 THEN
619            FND_MESSAGE.SET_NAME( 'AR', 'HZ_API_MISSING_COLUMN' );
620            FND_MESSAGE.SET_TOKEN( 'COLUMN', 'included_geography_type' );
621            FND_MSG_PUB.ADD;
622            x_return_status := FND_API.G_RET_STS_ERROR;
623           END IF;
624        END IF;
625 
626 
627        IF p_create_update_flag = 'C' THEN
628          HZ_UTILITY_V2PUB.validate_lookup(
629        p_column         => 'geography_use',
630        p_lookup_type    => 'HZ_RELATIONSHIP_TYPE',
631        p_column_value   => p_zone_type_rec.geography_use,
632        x_return_status  => x_return_status
633         );
634 
635        -- check for the uniqueness of geography_type
636 
637        SELECT count(*) INTO l_count
638          FROM hz_geography_types_b
639         WHERE geography_type=p_zone_type_rec.geography_type;
640 
641        IF l_count > 0 THEN
642         fnd_message.set_name('AR', 'HZ_API_DUPLICATE_COLUMN');
643            fnd_message.set_token('COLUMN', 'geography_type');
644            fnd_msg_pub.add;
645            x_return_status := fnd_api.g_ret_sts_error;
646        END IF;
647        END IF;
648 
649        IF (p_zone_type_rec.limited_by_geography_id IS NOT NULL AND p_zone_type_rec.limited_by_geography_id <> fnd_api.g_miss_num) THEN
650         SELECT count(*) INTO l_count
651           FROM hz_geographies
652          WHERE geography_id = p_zone_type_rec.limited_by_geography_id;
653 
654           IF l_count = 0 THEN
655            fnd_message.set_name('AR', 'HZ_API_INVALID_FK');
656            fnd_message.set_token('FK', 'limited_by_geography_id');
657            fnd_message.set_token('COLUMN','limited_by_geography_id');
658            fnd_message.set_token('TABLE','hz_geographies');
659            fnd_msg_pub.add;
660           x_return_status := fnd_api.g_ret_sts_error;
661          END IF;
662        END IF;
663 
664 
665        IF  p_zone_type_rec.included_geography_type.count > 0 THEN
666          FOR i in 1 .. p_zone_type_rec.included_geography_type.count LOOP
667            validate_geography_type (
668             p_geography_type         =>   p_zone_type_rec.included_geography_type(i),
669             p_master_ref_flag        =>   'Y',
670             x_return_status          =>   x_return_status
671              );
672            END LOOP;
673         END IF;
674 
675  END validate_zone_type;
676 
677 END HZ_GEO_STRUCTURE_VALIDATE_PVT;