| 3077 | // |
| 3078 | |
| 3079 | static act* act_fetch() |
| 3080 | { |
| 3081 | // Handle dynamic SQL statement, if appropriate |
| 3082 | |
| 3083 | dyn* cursor = par_dynamic_cursor(); |
| 3084 | if (cursor) |
| 3085 | { |
| 3086 | dyn* statement = (dyn*) MSC_alloc(DYN_LEN); |
| 3087 | statement->dyn_statement_name = cursor->dyn_statement_name; |
| 3088 | statement->dyn_cursor_name = cursor->dyn_cursor_name; |
| 3089 | if (MSC_match(KW_USING) || MSC_match(KW_INTO)) |
| 3090 | { |
| 3091 | MSC_match(KW_SQL); // optional for backward compatibility |
| 3092 | |
| 3093 | if (MSC_match(KW_DESCRIPTOR)) |
| 3094 | statement->dyn_sqlda = PAR_native_value(false, false); |
| 3095 | else |
| 3096 | statement->dyn_using = (gpre_nod*) SQE_list(SQE_variable, NULL, false); |
| 3097 | if (statement->dyn_using) |
| 3098 | PAR_error("Using host-variable list not supported."); |
| 3099 | } |
| 3100 | act* action = (act*) MSC_alloc(ACT_LEN); |
| 3101 | action->act_type = ACT_dyn_fetch; |
| 3102 | action->act_object = (ref*) statement; |
| 3103 | action->act_whenever = gen_whenever(); |
| 3104 | return action; |
| 3105 | } |
| 3106 | |
| 3107 | // Statement is static SQL |
| 3108 | |
| 3109 | gpre_req* request = par_cursor(NULL); |
| 3110 | |
| 3111 | if (request->req_flags & REQ_sql_blob_create) |
| 3112 | PAR_error("Fetching from a blob being created is not allowed."); |
| 3113 | |
| 3114 | act* action = MSC_action(request, ACT_fetch); |
| 3115 | action->act_whenever = gen_whenever(); |
| 3116 | |
| 3117 | if (request->req_flags & REQ_sql_blob_open) |
| 3118 | { |
| 3119 | if (!MSC_match(KW_INTO)) |
| 3120 | CPR_s_error("INTO"); |
| 3121 | action->act_object = (ref*) SQE_variable(NULL, false, NULL, NULL); |
| 3122 | action->act_type = ACT_get_segment; |
| 3123 | } |
| 3124 | else if (MSC_match(KW_INTO)) |
| 3125 | { |
| 3126 | action->act_object = (ref*) SQE_list(SQE_variable, request, false); |
| 3127 | gpre_rse* select = request->req_rse; |
| 3128 | into(request, select->rse_fields, (gpre_nod*) action->act_object); |
| 3129 | } |
| 3130 | |
| 3131 | return action; |
| 3132 | } |
| 3133 | |
| 3134 | |
| 3135 | //____________________________________________________________ |
no test coverage detected