PASS1_cursor_name @brief Find a cursor. @param dsqlScratch @param name @param mask @param existence_flag **/
| 914 | |
| 915 | **/ |
| 916 | DeclareCursorNode* PASS1_cursor_name(DsqlCompilerScratch* dsqlScratch, const MetaName& name, |
| 917 | USHORT mask, bool existence_flag) |
| 918 | { |
| 919 | DeclareCursorNode* cursor = NULL; |
| 920 | |
| 921 | if (name.isEmpty()) |
| 922 | { |
| 923 | if (existence_flag) |
| 924 | { |
| 925 | ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-504) << |
| 926 | Arg::Gds(isc_dsql_cursor_err) << |
| 927 | Arg::Gds(isc_dsql_cursor_invalid)); |
| 928 | } |
| 929 | else |
| 930 | { |
| 931 | ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-502) << |
| 932 | Arg::Gds(isc_dsql_decl_err) << |
| 933 | Arg::Gds(isc_dsql_cursor_invalid)); |
| 934 | } |
| 935 | } |
| 936 | |
| 937 | for (Array<DeclareCursorNode*>::iterator itr = dsqlScratch->cursors.begin(); |
| 938 | itr != dsqlScratch->cursors.end(); |
| 939 | ++itr) |
| 940 | { |
| 941 | cursor = *itr; |
| 942 | if (cursor->dsqlName == name && (cursor->dsqlCursorType & mask)) |
| 943 | break; |
| 944 | cursor = NULL; |
| 945 | } |
| 946 | |
| 947 | if (!cursor && existence_flag) |
| 948 | { |
| 949 | ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-504) << |
| 950 | Arg::Gds(isc_dsql_cursor_err) << |
| 951 | Arg::Gds(isc_dsql_cursor_not_found) << name); |
| 952 | } |
| 953 | else if (cursor && !existence_flag) |
| 954 | { |
| 955 | ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-502) << |
| 956 | Arg::Gds(isc_dsql_decl_err) << |
| 957 | Arg::Gds(isc_dsql_cursor_exists) << name); |
| 958 | } |
| 959 | |
| 960 | return cursor; |
| 961 | } |
| 962 | |
| 963 | |
| 964 | // Extract relation and procedure context and expand derived child contexts. |