]> git.saurik.com Git - wxWidgets.git/blame - src/iodbc/catalog.c
better <HR> tag handling in wxHTML
[wxWidgets.git] / src / iodbc / catalog.c
CommitLineData
cd5bf2a6
RR
1/*
2 * catalog.c
3 *
4 * $Id$
5 *
6 * Catalog functions
7 *
8 * The iODBC driver manager.
9 *
10 * Copyright (C) 1995 by Ke Jin <kejin@empress.com>
11 *
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version.
16 *
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details.
21 *
22 * You should have received a copy of the GNU Library General Public
23 * License along with this library; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */
26
88ac883a 27#include "config.h"
cd5bf2a6 28
88ac883a
VZ
29#include "isql.h"
30#include "isqlext.h"
cd5bf2a6 31
88ac883a 32#include "dlproc.h"
cd5bf2a6 33
88ac883a
VZ
34#include "herr.h"
35#include "henv.h"
36#include "hdbc.h"
37#include "hstmt.h"
cd5bf2a6 38
88ac883a 39#include "itrace.h"
cd5bf2a6 40
69919241
KB
41#ifndef NULL
42#define NULL 0
43#endif
44
cd5bf2a6
RR
45static RETCODE
46_iodbcdm_cata_state_ok (
47 HSTMT hstmt,
48 int fidx)
1a6944fd
RR
49/* check state for executing catalog functions */
50{
cd5bf2a6
RR
51 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
52 int sqlstat = en_00000;
53
54 if (pstmt->asyn_on == en_NullProc)
55 {
56 switch (pstmt->state)
57 {
58 case en_stmt_needdata:
59 case en_stmt_mustput:
60 case en_stmt_canput:
61 sqlstat = en_S1010;
62 break;
63
64 case en_stmt_fetched:
65 case en_stmt_xfetched:
66 sqlstat = en_24000;
67 break;
68
69 default:
70 break;
71 }
72 }
73 else if (pstmt->asyn_on != fidx)
74 {
75 sqlstat = en_S1010;
76 }
77
78 if (sqlstat != en_00000)
79 {
80 PUSHSQLERR (pstmt->herr, sqlstat);
81
82 return SQL_ERROR;
83 }
84
85 return SQL_SUCCESS;
1a6944fd
RR
86}
87
cd5bf2a6
RR
88
89static RETCODE
90_iodbcdm_cata_state_tr (
91 HSTMT hstmt,
92 int fidx,
93 RETCODE result)
1a6944fd
RR
94/* state transition for catalog function */
95{
cd5bf2a6
RR
96 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
97 DBC_t FAR *pdbc;
98
99 pdbc = (DBC_t FAR *) (pstmt->hdbc);
100
101 if (pstmt->asyn_on == fidx)
102 {
103 switch (result)
104 {
105 case SQL_SUCCESS:
106 case SQL_SUCCESS_WITH_INFO:
107 case SQL_ERROR:
108 pstmt->asyn_on = en_NullProc;
109 break;
110
111 case SQL_STILL_EXECUTING:
112 default:
113 return result;
114 }
115 }
116
117 if (pstmt->state <= en_stmt_executed)
118 {
119 switch (result)
120 {
121 case SQL_SUCCESS:
122 case SQL_SUCCESS_WITH_INFO:
123 pstmt->state = en_stmt_cursoropen;
124 break;
125
126 case SQL_ERROR:
127 pstmt->state = en_stmt_allocated;
128 pstmt->prep_state = 0;
129 break;
130
131 case SQL_STILL_EXECUTING:
132 pstmt->asyn_on = fidx;
133 break;
134
135 default:
136 break;
137 }
138 }
139
140 return result;
1a6944fd
RR
141}
142
cd5bf2a6
RR
143
144RETCODE SQL_API
145SQLGetTypeInfo (
146 HSTMT hstmt,
147 SWORD fSqlType)
1a6944fd 148{
cd5bf2a6
RR
149 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
150 HPROC hproc = SQL_NULL_HPROC;
151 int sqlstat = en_00000;
152 RETCODE retcode;
153
154 if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
155 {
156 return SQL_INVALID_HANDLE;
157 }
158
159 for (;;)
160 {
161 if (fSqlType > SQL_TYPE_MAX)
162 {
163 sqlstat = en_S1004;
164 break;
165 }
166
167 /* Note: SQL_TYPE_DRIVER_START is a negative number So, we use ">" */
168 if (fSqlType < SQL_TYPE_MIN && fSqlType > SQL_TYPE_DRIVER_START)
169 {
170 sqlstat = en_S1004;
171 break;
172 }
173
174 retcode = _iodbcdm_cata_state_ok (hstmt, en_GetTypeInfo);
175
176 if (retcode != SQL_SUCCESS)
177 {
178 return SQL_ERROR;
179 }
180
181 hproc = _iodbcdm_getproc (pstmt->hdbc, en_GetTypeInfo);
182
183 if (hproc == SQL_NULL_HPROC)
184 {
185 sqlstat = en_IM001;
186 break;
187 }
188
189 sqlstat = en_00000;
190 if (1) /* turn off solaris warning message */
191 break;
192 }
193
194 if (sqlstat != en_00000)
195 {
196 PUSHSQLERR (pstmt->herr, sqlstat);
197
198 return SQL_ERROR;
199 }
200
201 CALL_DRIVER ( pstmt->hdbc, retcode, hproc, en_GetTypeInfo,
202 (pstmt->dhstmt, fSqlType))
203
204 return _iodbcdm_cata_state_tr (hstmt, en_GetTypeInfo, retcode);
1a6944fd
RR
205}
206
cd5bf2a6
RR
207
208RETCODE SQL_API
209SQLSpecialColumns (
210 HSTMT hstmt,
211 UWORD fColType,
212 UCHAR FAR * szTableQualifier,
213 SWORD cbTableQualifier,
214 UCHAR FAR * szTableOwner,
215 SWORD cbTableOwner,
216 UCHAR FAR * szTableName,
217 SWORD cbTableName,
218 UWORD fScope,
219 UWORD fNullable)
1a6944fd 220{
cd5bf2a6
RR
221 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
222 HPROC hproc = SQL_NULL_HPROC;
223 RETCODE retcode;
224 int sqlstat = en_00000;
225
226 if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
227 {
228 return SQL_INVALID_HANDLE;
229 }
230
231 for (;;)
232 {
233 if ((cbTableQualifier < 0 && cbTableQualifier != SQL_NTS)
234 || (cbTableOwner < 0 && cbTableOwner != SQL_NTS)
235 || (cbTableName < 0 && cbTableName != SQL_NTS))
236 {
237 sqlstat = en_S1090;
238 break;
239 }
240
241 if (fColType != SQL_BEST_ROWID && fColType != SQL_ROWVER)
242 {
243 sqlstat = en_S1097;
244 break;
245 }
246
247 if (fScope != SQL_SCOPE_CURROW
248 && fScope != SQL_SCOPE_TRANSACTION
249 && fScope != SQL_SCOPE_SESSION)
250 {
251 sqlstat = en_S1098;
252 break;
253 }
254
255 if (fNullable != SQL_NO_NULLS && fNullable != SQL_NULLABLE)
256 {
257 sqlstat = en_S1099;
258 break;
259 }
260
261 retcode = _iodbcdm_cata_state_ok (hstmt, en_SpecialColumns);
262
263 if (retcode != SQL_SUCCESS)
264 {
265 return SQL_ERROR;
266 }
267
268 hproc = _iodbcdm_getproc (pstmt->hdbc, en_SpecialColumns);
269
270 if (hproc == SQL_NULL_HPROC)
271 {
272 sqlstat = en_IM001;
273 break;
274 }
275
276 sqlstat = en_00000;
277 if (1) /* turn off solaris warning message */
278 break;
279 }
280
281 if (sqlstat != en_00000)
282 {
283 PUSHSQLERR (pstmt->herr, sqlstat);
284
285 return SQL_ERROR;
286 }
287
288 CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_SpecialColumns, (
289 pstmt->dhstmt,
290 fColType,
291 szTableQualifier,
292 cbTableQualifier,
293 szTableOwner,
294 cbTableOwner,
295 szTableName,
296 cbTableName,
297 fScope,
298 fNullable))
299
300 return _iodbcdm_cata_state_tr (hstmt, en_SpecialColumns, retcode);
1a6944fd
RR
301}
302
cd5bf2a6
RR
303
304RETCODE SQL_API
305SQLStatistics (
306 HSTMT hstmt,
307 UCHAR FAR * szTableQualifier,
308 SWORD cbTableQualifier,
309 UCHAR FAR * szTableOwner,
310 SWORD cbTableOwner,
311 UCHAR FAR * szTableName,
312 SWORD cbTableName,
313 UWORD fUnique,
314 UWORD fAccuracy)
1a6944fd 315{
cd5bf2a6
RR
316 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
317 HPROC hproc = SQL_NULL_HPROC;
318 RETCODE retcode;
319 int sqlstat = en_00000;
320
321 if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
322 {
323 return SQL_INVALID_HANDLE;
324 }
325
326 for (;;)
327 {
328 if ((cbTableQualifier < 0 && cbTableQualifier != SQL_NTS)
329 || (cbTableOwner < 0 && cbTableOwner != SQL_NTS)
330 || (cbTableName < 0 && cbTableName != SQL_NTS))
331 {
332 sqlstat = en_S1090;
333 break;
334 }
335
336 if (fUnique != SQL_INDEX_UNIQUE && fUnique != SQL_INDEX_ALL)
337 {
338 sqlstat = en_S1100;
339 break;
340 }
341
342 if (fAccuracy != SQL_ENSURE && fAccuracy != SQL_QUICK)
343 {
344 sqlstat = en_S1101;
345 break;
346 }
347
348 retcode = _iodbcdm_cata_state_ok (hstmt, en_Statistics);
349
350 if (retcode != SQL_SUCCESS)
351 {
352 return SQL_ERROR;
353 }
354
355 hproc = _iodbcdm_getproc (pstmt->hdbc, en_Statistics);
356
357 if (hproc == SQL_NULL_HPROC)
358 {
359 sqlstat = en_IM001;
360 break;
361 }
362
363 sqlstat = en_00000;
364
365 if (1) /* turn off solaris warning message */
366 break;
367 }
368
369 if (sqlstat != en_00000)
370 {
371 PUSHSQLERR (pstmt->herr, sqlstat);
372
373 return SQL_ERROR;
374 }
375
376 CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_Statistics, (
377 pstmt->dhstmt,
378 szTableQualifier,
379 cbTableQualifier,
380 szTableOwner,
381 cbTableOwner,
382 szTableName,
383 cbTableName,
384 fUnique,
385 fAccuracy))
386
387 return _iodbcdm_cata_state_tr (hstmt, en_Statistics, retcode);
1a6944fd
RR
388}
389
cd5bf2a6
RR
390
391RETCODE SQL_API
392SQLTables (
393 HSTMT hstmt,
394 UCHAR FAR * szTableQualifier,
395 SWORD cbTableQualifier,
396 UCHAR FAR * szTableOwner,
397 SWORD cbTableOwner,
398 UCHAR FAR * szTableName,
399 SWORD cbTableName,
400 UCHAR FAR * szTableType,
401 SWORD cbTableType)
1a6944fd 402{
cd5bf2a6
RR
403 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
404 HPROC hproc = SQL_NULL_HPROC;
405 RETCODE retcode;
406 int sqlstat = en_00000;
407
408 if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
409 {
410 return SQL_INVALID_HANDLE;
411 }
412
413 for (;;)
414 {
415 if ((cbTableQualifier < 0 && cbTableQualifier != SQL_NTS)
416 || (cbTableOwner < 0 && cbTableOwner != SQL_NTS)
417 || (cbTableName < 0 && cbTableName != SQL_NTS)
418 || (cbTableType < 0 && cbTableType != SQL_NTS))
419 {
420 sqlstat = en_S1090;
421 break;
422 }
423
424 retcode = _iodbcdm_cata_state_ok (hstmt, en_Tables);
425
426 if (retcode != SQL_SUCCESS)
427 {
428 return SQL_ERROR;
429 }
430
431 hproc = _iodbcdm_getproc (pstmt->hdbc, en_Tables);
432
433 if (hproc == SQL_NULL_HPROC)
434 {
435 sqlstat = en_IM001;
436 break;
437 }
438
439 sqlstat = en_00000;
440
441 if (1) /* turn off solaris warning message */
442 break;
443 }
444
445 if (sqlstat != en_00000)
446 {
447 PUSHSQLERR (pstmt->herr, sqlstat);
448
449 return SQL_ERROR;
450 }
451
452 CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_Tables, (
453 pstmt->dhstmt,
454 szTableQualifier,
455 cbTableQualifier,
456 szTableOwner,
457 cbTableOwner,
458 szTableName,
459 cbTableName,
460 szTableType,
461 cbTableType))
462
463 return _iodbcdm_cata_state_tr (hstmt, en_Tables, retcode);
1a6944fd
RR
464}
465
cd5bf2a6
RR
466
467RETCODE SQL_API
468SQLColumnPrivileges (
469 HSTMT hstmt,
470 UCHAR FAR * szTableQualifier,
471 SWORD cbTableQualifier,
472 UCHAR FAR * szTableOwner,
473 SWORD cbTableOwner,
474 UCHAR FAR * szTableName,
475 SWORD cbTableName,
476 UCHAR FAR * szColumnName,
477 SWORD cbColumnName)
1a6944fd 478{
cd5bf2a6
RR
479 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
480 HPROC hproc = SQL_NULL_HPROC;
481 RETCODE retcode;
482 int sqlstat = en_00000;
483
484 if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
485 {
486 return SQL_INVALID_HANDLE;
487 }
488
489 for (;;)
490 {
491 if ((cbTableQualifier < 0 && cbTableQualifier != SQL_NTS)
492 || (cbTableOwner < 0 && cbTableOwner != SQL_NTS)
493 || (cbTableName < 0 && cbTableName != SQL_NTS)
494 || (cbColumnName < 0 && cbColumnName != SQL_NTS))
495 {
496 sqlstat = en_S1090;
497 break;
498 }
499
500 retcode = _iodbcdm_cata_state_ok (hstmt, en_ColumnPrivileges);
501
502 if (retcode != SQL_SUCCESS)
503 {
504 return SQL_ERROR;
505 }
506
507 hproc = _iodbcdm_getproc (pstmt->hdbc, en_ColumnPrivileges);
508
509 if (hproc == SQL_NULL_HPROC)
510 {
511 sqlstat = en_IM001;
512 break;
513 }
514
515 sqlstat = en_00000;
516
517 if (1) /* turn off solaris warning message */
518 break;
519 }
520
521 if (sqlstat != en_00000)
522 {
523 PUSHSQLERR (pstmt->herr, sqlstat);
524
525 return SQL_ERROR;
526 }
527
528 CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_ColumnPrivileges, (
529 pstmt->dhstmt,
530 szTableQualifier,
531 cbTableQualifier,
532 szTableOwner,
533 cbTableOwner,
534 szTableName,
535 cbTableName,
536 szColumnName,
537 cbColumnName))
538
539 return _iodbcdm_cata_state_tr (hstmt, en_ColumnPrivileges, retcode);
1a6944fd
RR
540}
541
cd5bf2a6
RR
542
543RETCODE SQL_API
544SQLColumns (
545 HSTMT hstmt,
546 UCHAR FAR * szTableQualifier,
547 SWORD cbTableQualifier,
548 UCHAR FAR * szTableOwner,
549 SWORD cbTableOwner,
550 UCHAR FAR * szTableName,
551 SWORD cbTableName,
552 UCHAR FAR * szColumnName,
553 SWORD cbColumnName)
1a6944fd 554{
cd5bf2a6
RR
555 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
556 HPROC hproc = SQL_NULL_HPROC;
557 RETCODE retcode;
558 int sqlstat = en_00000;
559
560 if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
561 {
562 return SQL_INVALID_HANDLE;
563 }
564
565 for (;;)
566 {
567 if ((cbTableQualifier < 0 && cbTableQualifier != SQL_NTS)
568 || (cbTableOwner < 0 && cbTableOwner != SQL_NTS)
569 || (cbTableName < 0 && cbTableName != SQL_NTS)
570 || (cbColumnName < 0 && cbColumnName != SQL_NTS))
571 {
572 sqlstat = en_S1090;
573 break;
574 }
575
576 retcode = _iodbcdm_cata_state_ok (hstmt, en_Columns);
577
578 if (retcode != SQL_SUCCESS)
579 {
580 return SQL_ERROR;
581 }
582
583 hproc = _iodbcdm_getproc (pstmt->hdbc, en_Columns);
584
585 if (hproc == SQL_NULL_HPROC)
586 {
587 sqlstat = en_IM001;
588 break;
589 }
590
591 sqlstat = en_00000;
592
593 if (1) /* turn off solaris warning message */
594 break;
595 }
596
597 if (sqlstat != en_00000)
598 {
599 PUSHSQLERR (pstmt->herr, sqlstat);
600
601 return SQL_ERROR;
602 }
603
604 CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_Columns, (
605 pstmt->dhstmt,
606 szTableQualifier,
607 cbTableQualifier,
608 szTableOwner,
609 cbTableOwner,
610 szTableName,
611 cbTableName,
612 szColumnName,
613 cbColumnName))
614
615 return _iodbcdm_cata_state_tr (hstmt, en_Columns, retcode);
1a6944fd
RR
616}
617
cd5bf2a6
RR
618
619RETCODE SQL_API
620SQLForeignKeys (
621 HSTMT hstmt,
622 UCHAR FAR * szPkTableQualifier,
623 SWORD cbPkTableQualifier,
624 UCHAR FAR * szPkTableOwner,
625 SWORD cbPkTableOwner,
626 UCHAR FAR * szPkTableName,
627 SWORD cbPkTableName,
628 UCHAR FAR * szFkTableQualifier,
629 SWORD cbFkTableQualifier,
630 UCHAR FAR * szFkTableOwner,
631 SWORD cbFkTableOwner,
632 UCHAR FAR * szFkTableName,
633 SWORD cbFkTableName)
1a6944fd 634{
cd5bf2a6
RR
635 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
636 HPROC hproc = SQL_NULL_HPROC;
637 RETCODE retcode;
638 int sqlstat = en_00000;
639
640 if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
641 {
642 return SQL_INVALID_HANDLE;
643 }
644
645 for (;;)
646 {
647 if ((cbPkTableQualifier < 0 && cbPkTableQualifier != SQL_NTS)
648 || (cbPkTableOwner < 0 && cbPkTableOwner != SQL_NTS)
649 || (cbPkTableName < 0 && cbPkTableName != SQL_NTS)
650 || (cbFkTableQualifier < 0 && cbFkTableQualifier != SQL_NTS)
651 || (cbFkTableOwner < 0 && cbFkTableOwner != SQL_NTS)
652 || (cbFkTableName < 0 && cbFkTableName != SQL_NTS))
653 {
654 sqlstat = en_S1090;
655 break;
656 }
657
658 retcode = _iodbcdm_cata_state_ok (hstmt, en_ForeignKeys);
659
660 if (retcode != SQL_SUCCESS)
661 {
662 return SQL_ERROR;
663 }
664
665 hproc = _iodbcdm_getproc (pstmt->hdbc, en_ForeignKeys);
666
667 if (hproc == SQL_NULL_HPROC)
668 {
669 sqlstat = en_IM001;
670 break;
671 }
672
673 sqlstat = en_00000;
674
675 if (1) /* turn off solaris warning message */
676 break;
677 }
678
679 if (sqlstat != en_00000)
680 {
681 PUSHSQLERR (pstmt->herr, sqlstat);
682
683 return SQL_ERROR;
684 }
685
686 CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_ForeignKeys, (
687 pstmt->dhstmt,
688 szPkTableQualifier,
689 cbPkTableQualifier,
690 szPkTableOwner,
691 cbPkTableOwner,
692 szPkTableName,
693 cbPkTableName,
694 szFkTableQualifier,
695 cbFkTableQualifier,
696 szFkTableOwner,
697 cbFkTableOwner,
698 szFkTableName,
699 cbFkTableName))
700
701 return _iodbcdm_cata_state_tr (hstmt, en_ForeignKeys, retcode);
1a6944fd
RR
702}
703
cd5bf2a6
RR
704
705RETCODE SQL_API
706SQLPrimaryKeys (
707 HSTMT hstmt,
708 UCHAR FAR * szTableQualifier,
709 SWORD cbTableQualifier,
710 UCHAR FAR * szTableOwner,
711 SWORD cbTableOwner,
712 UCHAR FAR * szTableName,
713 SWORD cbTableName)
1a6944fd 714{
cd5bf2a6
RR
715 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
716 HPROC hproc = SQL_NULL_HPROC;
717 RETCODE retcode;
718 int sqlstat = en_00000;
719
720 if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
721 {
722 return SQL_INVALID_HANDLE;
723 }
724
725 for (;;)
726 {
727 if ((cbTableQualifier < 0 && cbTableQualifier != SQL_NTS)
728 || (cbTableOwner < 0 && cbTableOwner != SQL_NTS)
729 || (cbTableName < 0 && cbTableName != SQL_NTS))
730 {
731 sqlstat = en_S1090;
732 break;
733 }
734
735 retcode = _iodbcdm_cata_state_ok (hstmt, en_PrimaryKeys);
736
737 if (retcode != SQL_SUCCESS)
738 {
739 return SQL_ERROR;
740 }
741
742 hproc = _iodbcdm_getproc (pstmt->hdbc, en_PrimaryKeys);
743
744 if (hproc == SQL_NULL_HPROC)
745 {
746 sqlstat = en_IM001;
747 break;
748 }
749
750 sqlstat = en_00000;
751
752 if (1) /* turn off solaris warning message */
753 break;
754 }
755
756 if (sqlstat != en_00000)
757 {
758 PUSHSQLERR (pstmt->herr, sqlstat);
759
760 return SQL_ERROR;
761 }
762
763 CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_PrimaryKeys, (
764 pstmt->dhstmt,
765 szTableQualifier,
766 cbTableQualifier,
767 szTableOwner,
768 cbTableOwner,
769 szTableName,
770 cbTableName))
771
772 return _iodbcdm_cata_state_tr (hstmt, en_PrimaryKeys, retcode);
1a6944fd
RR
773}
774
cd5bf2a6
RR
775
776RETCODE SQL_API
777SQLProcedureColumns (
778 HSTMT hstmt,
779 UCHAR FAR * szProcQualifier,
780 SWORD cbProcQualifier,
781 UCHAR FAR * szProcOwner,
782 SWORD cbProcOwner,
783 UCHAR FAR * szProcName,
784 SWORD cbProcName,
785 UCHAR FAR * szColumnName,
786 SWORD cbColumnName)
1a6944fd 787{
cd5bf2a6
RR
788 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
789 HPROC hproc = SQL_NULL_HPROC;
790 RETCODE retcode;
791 int sqlstat = en_00000;
792
793 if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
794 {
795 return SQL_INVALID_HANDLE;
796 }
797
798 for (;;)
799 {
800 if ((cbProcQualifier < 0 && cbProcQualifier != SQL_NTS)
801 || (cbProcOwner < 0 && cbProcOwner != SQL_NTS)
802 || (cbProcName < 0 && cbProcName != SQL_NTS)
803 || (cbColumnName < 0 && cbColumnName != SQL_NTS))
804 {
805 sqlstat = en_S1090;
806 break;
807 }
808
809 retcode = _iodbcdm_cata_state_ok (hstmt, en_ProcedureColumns);
810
811 if (retcode != SQL_SUCCESS)
812 {
813 return SQL_ERROR;
814 }
815
816 hproc = _iodbcdm_getproc (pstmt->hdbc, en_ProcedureColumns);
817
818 if (hproc == SQL_NULL_HPROC)
819 {
820 sqlstat = en_IM001;
821 break;
822 }
823
824 sqlstat = en_00000;
825
826 if (1) /* turn off solaris warning message */
827 break;
828 }
829
830 if (sqlstat != en_00000)
831 {
832 PUSHSQLERR (pstmt->herr, sqlstat);
833
834 return SQL_ERROR;
835 }
836
837 CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_ProcedureColumns, (
838 pstmt->dhstmt,
839 szProcQualifier,
840 cbProcQualifier,
841 szProcOwner,
842 cbProcOwner,
843 szProcName,
844 cbProcName,
845 szColumnName,
846 cbColumnName))
847
848 return _iodbcdm_cata_state_tr (hstmt, en_ProcedureColumns, retcode);
1a6944fd
RR
849}
850
cd5bf2a6
RR
851
852RETCODE SQL_API
853SQLProcedures (
854 HSTMT hstmt,
855 UCHAR FAR * szProcQualifier,
856 SWORD cbProcQualifier,
857 UCHAR FAR * szProcOwner,
858 SWORD cbProcOwner,
859 UCHAR FAR * szProcName,
860 SWORD cbProcName)
1a6944fd 861{
cd5bf2a6
RR
862 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
863 HPROC hproc = SQL_NULL_HPROC;
864 RETCODE retcode;
865 int sqlstat = en_00000;
866
867 if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
868 {
869 return SQL_INVALID_HANDLE;
870 }
871
872 for (;;)
873 {
874 if ((cbProcQualifier < 0 && cbProcQualifier != SQL_NTS)
875 || (cbProcOwner < 0 && cbProcOwner != SQL_NTS)
876 || (cbProcName < 0 && cbProcName != SQL_NTS))
877 {
878 sqlstat = en_S1090;
879 break;
880 }
881
882 retcode = _iodbcdm_cata_state_ok (hstmt, en_Procedures);
883
884 if (retcode != SQL_SUCCESS)
885 {
886 return SQL_ERROR;
887 }
888
889 hproc = _iodbcdm_getproc (pstmt->hdbc, en_Procedures);
890
891 if (hproc == SQL_NULL_HPROC)
892 {
893 sqlstat = en_IM001;
894 break;
895 }
896
897 sqlstat = en_00000;
898
899 if (1) /* turn off solaris warning message */
900 break;
901 }
902
903 if (sqlstat != en_00000)
904 {
905 PUSHSQLERR (pstmt->herr, sqlstat);
906
907 return SQL_ERROR;
908 }
909
910 CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_Procedures, (
911 pstmt->dhstmt,
912 szProcQualifier,
913 cbProcQualifier,
914 szProcOwner,
915 cbProcOwner,
916 szProcName,
917 cbProcName))
918
919 return _iodbcdm_cata_state_tr (hstmt, en_Procedures, retcode);
1a6944fd
RR
920}
921
cd5bf2a6
RR
922
923RETCODE SQL_API
924SQLTablePrivileges (
925 HSTMT hstmt,
926 UCHAR FAR * szTableQualifier,
927 SWORD cbTableQualifier,
928 UCHAR FAR * szTableOwner,
929 SWORD cbTableOwner,
930 UCHAR FAR * szTableName,
931 SWORD cbTableName)
1a6944fd
RR
932{
933
cd5bf2a6
RR
934 STMT_t FAR *pstmt = (STMT_t FAR *) hstmt;
935 HPROC hproc = SQL_NULL_HPROC;
936 RETCODE retcode;
937 int sqlstat = en_00000;
938
939 if (hstmt == SQL_NULL_HSTMT || pstmt->hdbc == SQL_NULL_HDBC)
940 {
941 return SQL_INVALID_HANDLE;
942 }
943
944 for (;;)
945 {
946 if ((cbTableQualifier < 0 && cbTableQualifier != SQL_NTS)
947 || (cbTableOwner < 0 && cbTableOwner != SQL_NTS)
948 || (cbTableName < 0 && cbTableName != SQL_NTS))
949 {
950 sqlstat = en_S1090;
951 break;
952 }
953
954 retcode = _iodbcdm_cata_state_ok (hstmt, en_TablePrivileges);
955
956 if (retcode != SQL_SUCCESS)
957 {
958 return SQL_ERROR;
959 }
960
961 hproc = _iodbcdm_getproc (pstmt->hdbc, en_TablePrivileges);
962
963 if (hproc == SQL_NULL_HPROC)
964 {
965 sqlstat = en_IM001;
966 break;
967 }
968
969 sqlstat = en_00000;
970
971 if (1) /* turn off solaris warning message */
972 break;
973 }
974
975 if (sqlstat != en_00000)
976 {
977 PUSHSQLERR (pstmt->herr, sqlstat);
978
979 return SQL_ERROR;
980 }
981
982 CALL_DRIVER (pstmt->hdbc, retcode, hproc, en_TablePrivileges,
983 (pstmt->dhstmt, szTableQualifier, cbTableQualifier, szTableOwner,
984 cbTableOwner, szTableName, cbTableName))
985
986 return _iodbcdm_cata_state_tr (hstmt, en_TablePrivileges, retcode);
1a6944fd 987}