-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PL/SQL procedure, statement, and function are not available i have integrated the PlSqlParser.g4 and PlSqlLexer.g4 but its am facing the while running the code? #4351
Comments
The above methods have been integrated into the PlSqlParser.g4 and PlSqlLexer.g4. The grammar files have been compiled, and all necessary files have been generated. However, while running the program, I am facing an issue with logical expressions PlSqlParser.g4 /**
// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false parser grammar PlSqlParser; options { @parser::postinclude { sql_script unit_statement // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-DISKGROUP.html add_disk_clause drop_disk_clause resize_disk_clause replace_disk_clause wait_nowait rename_disk_clause disk_online_clause disk_offline_clause timeout_clause rebalance_diskgroup_clause phase check_diskgroup_clause diskgroup_template_clauses qualified_template_clause redundancy_clause striping_clause force_noforce diskgroup_directory_clauses dir_name diskgroup_alias_clauses diskgroup_volume_clauses add_volume_clause modify_volume_clause diskgroup_attributes modify_diskgroup_file disk_region_clause drop_diskgroup_file_clause convert_redundancy_clause usergroup_clauses user_clauses file_permissions_clause file_owner_clause scrub_clause quotagroup_clauses property_name property_value filegroup_clauses add_filegroup_clause modify_filegroup_clause move_to_filegroup_clause drop_filegroup_clause quorum_regular undrop_disk_clause diskgroup_availability enable_disable_volume // DDL -> SQL Statements for Stored PL/SQL Units // Function DDLs drop_function // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-FLASHBACK-ARCHIVE.html // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-HIERARCHY.html alter_function // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-JAVA.html match_string create_function_body sql_macro_body // Creation Function - Specific Clauses parallel_enable_clause partition_by_clause result_cache_clause accessible_by_clause default_collation_clause aggregate_clause pipelined_using_clause accessor relies_on_part streaming_clause // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-OUTLINE.html outline_options // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-LOCKDOWN-PROFILE.html lockdown_feature lockdown_options lockdown_statements statement_clauses clause_options option_values string_list disable_enable // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-LOCKDOWN-PROFILE.html // Package DDLs drop_package alter_package create_package create_package_body // Create Package Specific Clauses package_obj_spec procedure_spec function_spec package_obj_body // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/alter-pmem-filestore.html // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/drop-pmem-filestore.html // Procedure DDLs drop_procedure alter_procedure function_body procedure_body create_procedure_body // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-RESOURCE-COST.html // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-OUTLINE.html // Rollback Segment DDLs //https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_2011.htm#SQLRF00816 // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-RESTORE-POINT.html drop_rollback_segment drop_role // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/create-pmem-filestore.html pmem_filestore_options file_path create_rollback_segment // Trigger DDLs drop_trigger alter_trigger create_trigger trigger_follows_clause trigger_when_clause // Create Trigger Specific Clauses simple_dml_trigger for_each_row compound_dml_trigger non_dml_trigger trigger_body routine_clause compound_trigger_block timing_point_section non_dml_event dml_event_clause dml_event_element dml_event_nested_clause referencing_clause referencing_element // DDLs drop_type alter_type // Alter Type Specific Clauses compile_type_clause replace_type_clause alter_method_spec alter_method_element alter_attribute_definition attribute_definition alter_collection_clauses dependent_handling_clause dependent_exceptions_part create_type // Create Type Specific Clauses type_definition object_type_def object_as_part object_under_part nested_table_type_def sqlj_object_type type_body type_body_elements map_order_func_declaration subprog_decl_in_type proc_decl_in_type func_decl_in_type constructor_declaration // Common Type Clauses modifier_clause object_member_spec sqlj_object_type_attr element_spec element_spec_options subprogram_spec // TODO: should be refactored such as Procedure body and Function body, maybe Type_Function_Body and overriding_function_body overriding_function_spec type_procedure_spec type_function_spec constructor_spec map_order_function_spec pragma_clause pragma_elements type_elements_parameter // Sequence DDLs drop_sequence alter_sequence // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-SESSION.html alter_session_set_clause create_sequence // Common Sequence sequence_spec sequence_start_clause // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-ANALYTIC-VIEW.html classification_clause caption_clause description_clause classification_item language cav_using_clause dim_by_clause dim_key dim_ref hier_ref measures_clause av_measure base_meas_clause meas_aggregate_clause calc_meas_clause default_measure_clause default_aggregate_clause cache_clause cache_specification levels_clause level_specification level_group_type fact_columns_clause qry_transform_clause // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-ATTRIBUTE-DIMENSION.html ad_using_clause source_clause join_path_clause join_condition join_condition_item attributes_clause ad_attributes_clause ad_level_clause key_clause alternate_key_clause dim_order_clause all_clause // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-AUDIT-POLICY-Unified-Auditing.html privilege_audit_clause action_audit_clause system_actions standard_actions actions_clause object_action system_action component_actions component_action role_audit_clause // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-CONTROLFILE.html controlfile_options logfile_clause character_set_clause file_specification // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-DISKGROUP.html qualified_disk_clause // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-EDITION.html // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-FLASHBACK-ARCHIVE.html flashback_archive_quota flashback_archive_retention // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-HIERARCHY.html hier_using_clause level_hier_clause hier_attrs_clause hier_attr_clause hier_attr_name create_index cluster_index_clause cluster_name table_index_clause bitmap_join_index_clause index_expr index_properties domain_index_clause local_domain_index_clause xmlindex_clause local_xmlindex_clause global_partitioned_index index_partitioning_clause index_partitioning_values_list local_partitioned_index on_range_partitioned_table on_list_partitioned_table partitioned_table on_hash_partitioned_table on_hash_partitioned_clause on_comp_partitioned_table on_comp_partitioned_clause index_subpartition_clause index_subpartition_subclause odci_parameters indextype //https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_1010.htm#SQLRF00805 alter_index_ops_set1 alter_index_ops_set2 visible_or_invisible monitoring_nomonitoring rebuild_clause alter_index_partitioning modify_index_default_attrs add_hash_index_partition coalesce_index_partition modify_index_partition modify_index_partitions_ops rename_index_partition drop_index_partition split_index_partition index_partition_description modify_index_subpartition partition_name_old new_partition_name new_index_name // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-INMEMORY-JOIN-GROUP.html create_user // The standard clauses only permit one user per statement. drop_user alter_identified_by identified_by identified_other_clause user_tablespace_clause quota_clause profile_clause role_clause user_default_role_clause password_expire_clause user_lock_clause user_editions_clause alter_user_editions_clause proxy_clause container_names set_container_data add_rem_container_data container_data_clause // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ADMINISTER-KEY-MANAGEMENT.html keystore_management_clauses create_keystore open_keystore force_keystore close_keystore backup_keystore alter_keystore_password merge_into_new_keystore merge_into_existing_keystore isolate_keystore unite_keystore key_management_clauses set_key create_key mkid mk use_key set_key_tag export_keys import_keys migrate_keys reverse_migrate_keys move_keys identified_by_store using_algorithm_clause using_tag_clause secret_management_clauses add_update_secret delete_secret add_update_secret_seps delete_secret_seps zero_downtime_software_patching_clauses with_backup_clause identified_by_password_clause keystore_password path secret // https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_4005.htm#SQLRF01105 partition_extention_clause validation_clauses compute_clauses for_clause online_or_offline into_clause1 //Making assumption on partition ad subpartition key value clauses subpartition_key_value //https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_4006.htm#SQLRF01106 column_association function_association indextype_name using_statistics_type statistics_type_name default_cost_clause cpu_cost io_cost network_cost default_selectivity_clause default_selectivity storage_table_clause // https://docs.oracle.com/database/121/SQLRF/statements_4008.htm#SQLRF56110 policy_name // https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_4007.htm#SQLRF01107 audit_traditional audit_direct_path audit_container_clause audit_operation_clause auditing_by_clause audit_user audit_schema_object_clause sql_operation auditing_on_clause model_name object_name profile_name sql_statement_shortcut drop_index // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DISASSOCIATE-STATISTICS.html // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-INDEXTYPE.html // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-INMEMORY-JOIN-GROUP.html flashback_table restore_point // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/PURGE.html // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/NOAUDIT-Traditional-Auditing.html rename_object grant_statement container_clause // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/REVOKE.html revoke_system_privilege revokee_clause revoke_object_privileges on_object_clause revoke_roles_from_programs program_unit create_dimension // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-DIRECTORY.html directory_name directory_path // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-INMEMORY-JOIN-GROUP.html // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-HIERARCHY.html // https://docs.oracle.com/cd/E11882_01/appdev.112/e25519/alter_library.htm#LNPLS99946 // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-JAVA.html drop_library // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-JAVA.html create_library plsql_library_source credential_name library_editionable library_debug compiler_parameters_clause parameter_value library_name alter_dimension level_clause hierarchy_clause dimension_join_clause attribute_clause extended_attribute_clause column_one_or_more_sub_clause // https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_4004.htm#SQLRF01104 alter_view_editionable // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-VIEW.html editioning_clause view_options view_alias_constraint object_view_clause inline_constraint inline_ref_constraint out_of_line_ref_constraint out_of_line_constraint constraint_state xmltype_view_clause xml_schema_spec xml_schema_url element alter_tablespace datafile_tempfile_clauses tablespace_logging_clauses tablespace_group_clause tablespace_group_name tablespace_state_clauses flashback_mode_clause new_tablespace_name create_tablespace permanent_tablespace_clause tablespace_encryption_spec logging_clause extent_management_clause segment_management_clause temporary_tablespace_clause undo_tablespace_clause tablespace_retention_clause // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-TABLESPACE-SET.html permanent_tablespace_attrs tablespace_encryption_clause default_tablespace_params default_table_compression low_high default_index_compression inmmemory_clause // asm_filename is just a charater string. Would need to parse the string tempfile_specification datafile_tempfile_spec redo_log_file_spec autoextend_clause maxsize_clause build_clause parallel_clause alter_materialized_view alter_mv_option1 alter_mv_refresh rollback_segment modify_mv_column_clause alter_materialized_view_log add_mv_log_column_clause move_mv_log_clause mv_log_augmentation // Should bound this to just date/time expr // Should bound this to just interval expr synchronous_or_asynchronous including_or_excluding create_materialized_view_log new_values_clause mv_log_purge_clause create_materialized_zonemap alter_materialized_zonemap drop_materialized_zonemap zonemap_refresh_clause zonemap_attributes zonemap_name operator_name operator_function_name create_zonemap_on_table create_zonemap_as_subquery alter_operator drop_operator create_operator binding_clause add_binding_clause implementation_clause primary_operator_list primary_operator_item operator_context_clause using_function_clause drop_binding_clause create_materialized_view scoped_table_ref_constraint mv_column_alias create_mv_refresh drop_materialized_view create_context oracle_namespace //https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_5001.htm#SQLRF01201 // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-PROFILE.html resource_parameters password_parameters // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-LOCKDOWN-PROFILE.html static_base_profile dynamic_base_profile // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-OUTLINE.html // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-RESTORE-POINT.html create_role create_table xmltype_table xmltype_virtual_columns xmltype_column_properties xmltype_storage xmlschema_spec object_table object_type oid_index_clause oid_clause object_properties object_table_substitution relational_table immutable_table_clauses immutable_table_no_drop_clause immutable_table_no_delete_clause blockchain_table_clauses blockchain_drop_table_clause blockchain_row_retention_clause blockchain_hash_and_data_format_clause collation_name table_properties read_only_clause indexing_clause attribute_clustering_clause clustering_join clustering_join_item equijoin_condition cluster_clause clustering_columns clustering_column_group yes_no zonemap_clause logical_replication_clause table_name relational_property table_partitioning_clauses range_partitions list_partitions hash_partitions individual_hash_partitions hash_partitions_by_quantity hash_partition_quantity composite_range_partitions composite_list_partitions composite_hash_partitions reference_partitioning reference_partition_desc system_partitioning range_partition_desc list_partition_desc subpartition_template hash_subpartition_quantity subpartition_by_range subpartition_by_list subpartition_by_hash subpartition_name range_subpartition_desc list_subpartition_desc individual_hash_subparts hash_subparts_by_quantity range_values_clause range_values_list list_values_clause table_partition_description partitioning_storage_clause lob_partitioning_storage datatype_null_enable // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/size_clause.html table_compression // avoid to match an empty string in // avoid to match an empty string in inmemory_memcompress inmemory_priority inmemory_distribute inmemory_duplicate inmemory_column_clause physical_attributes_clause storage_clause deferred_segment_creation segment_attributes_clause physical_properties ilm_clause ilm_policy_clause ilm_compression_policy ilm_tiering_policy ilm_after_on segment_group ilm_inmemory_policy ilm_time_period heap_org_table_clause external_table_clause access_driver_type external_table_data_props opaque_format_spec row_movement_clause flashback_archive_clause log_grp supplemental_table_logging supplemental_log_grp_clause supplemental_id_key_clause allocate_extent_clause deallocate_unused_clause shrink_clause records_per_block_clause upgrade_table_clause truncate_table drop_table // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-TABLESPACE.html // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-TABLESPACE-SET.html including_contents_clause drop_view comment_on_column enable_or_disable allow_or_disallow // Synonym DDL Clauses alter_synonym create_synonym drop_synonym // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-SPFILE.html spfile_name pfile_name comment_on_table comment_on_materialized alter_analytic_view alter_add_cache_clause levels_item measure_list alter_drop_cache_clause // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-ATTRIBUTE-DIMENSION.html // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-AUDIT-POLICY-Unified-Auditing.html alter_cluster drop_analytic_view // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-ATTRIBUTE-DIMENSION.html // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-AUDIT-POLICY-Unified-Auditing.html // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-FLASHBACK-ARCHIVE.html drop_cluster // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-CONTEXT.html // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-DIRECTORY.html // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-DISKGROUP.html // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-EDITION.html truncate_cluster cache_or_nocache database_name alter_database database_clause startup_clauses resetlogs_or_noresetlogs upgrade_or_downgrade recovery_clauses begin_or_end general_recovery //Need to come back to partial_database_recovery partial_database_recovery_10g managed_standby_recovery db_name database_file_clauses create_datafile_clause alter_datafile_clause alter_tempfile_clause move_datafile_clause logfile_clauses add_logfile_clauses group_redo_logfile drop_logfile_clauses switch_logfile_clause supplemental_db_logging add_or_drop supplemental_plsql_clause logfile_descriptor controlfile_clauses trace_file_clause standby_database_clauses activate_standby_db_clause maximize_standby_db_clause register_logfile_clause commit_switchover_clause start_standby_clause stop_standby_clause convert_database_clause default_settings_clause set_time_zone_clause instance_clauses security_clause domain database edition_name filenumber filename prepare_clause drop_mirror_clause lost_write_protection cdb_fleet_clauses lead_cdb_clause lead_cdb_uri_clause property_clauses replay_upgrade_clauses alter_database_link password_value link_authentication // added by zrh database_logging_clauses database_logging_sub_clause tablespace_clauses enable_pluggable_database file_name_convert filename_convert_sub_clause tablespace_datafile_clauses undo_mode_clause default_tablespace default_temp_tablespace undo_tablespace // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/DROP-DATABASE.html // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-DATABASE-LINK.html drop_database_link // https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ALTER-TABLESPACE-SET.html alter_tablespace_attrs alter_tablespace_encryption ts_file_name_convert alter_role role_identified_clause alter_table memoptimize_read_write_clause alter_table_properties alter_table_partitioning add_table_partition drop_table_partition merge_table_partition modify_table_partition split_table_partition truncate_table_partition exchange_table_partition coalesce_table_partition alter_interval_partition partition_extended_names subpartition_extended_names alter_table_properties_1 alter_iot_clauses alter_mapping_table_clause alter_overflow_clause add_overflow_clause update_index_clauses update_global_index_clause update_all_indexes_clause update_all_indexes_index_clause update_index_partition update_index_subpartition enable_disable_clause using_index_clause index_attributes sort_or_nosort exceptions_clause move_table_clause index_org_table_clause mapping_table_clause key_compression index_org_overflow_clause column_clauses modify_collection_retrieval collection_item rename_column_clause old_column_name new_column_name add_modify_drop_column_clauses drop_column_clause modify_column_clauses modify_col_properties modify_col_visibility modify_col_substitutable add_column_clause alter_varray_col_properties varray_col_properties varray_storage_clause lob_segname lob_item lob_storage_parameters lob_storage_clause modify_lob_storage_clause modify_lob_parameters lob_parameters lob_deduplicate_clause lob_compression_clause lob_retention_clause encryption_spec tablespace varray_item column_properties lob_partition_storage period_definition start_time_column end_time_column column_definition column_collation_name identity_clause //https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/CREATE-TABLE.html#GUID-F9CE0CC3-13AE-4744-A43C-EAC7A71AAAB6 identity_options virtual_column_definition autogenerated_sequence_definition evaluation_edition_clause out_of_line_part_storage nested_table_col_properties nested_item substitutable_column_clause partition_name supplemental_logging_props column_or_attribute object_type_col_properties constraint_clauses old_constraint_name new_constraint_name drop_constraint_clause add_constraint add_constraint_clause check_constraint drop_constraint enable_constraint disable_constraint foreign_key_clause references_clause on_delete_clause unique_key_clause primary_key_clause // Anonymous PL/SQL code block anonymous_block // Common DDL Clauses invoker_rights_clause call_spec // Call Spec Specific Clauses java_spec c_spec c_agent_in_clause c_parameters_clause c_external_parameter c_property parameter default_value_part // Elements Declarations seq_of_declare_specs declare_spec // incorporates constant_declaration variable_declaration subtype_declaration // cursor_declaration incorportates curscursor_body and cursor_spec cursor_declaration parameter_spec exception_declaration pragma_declaration // Record Declaration Specific Clauses // incorporates ref_cursor_type_definition record_type_def field_spec ref_cursor_type_def type_declaration table_type_def table_indexed_by_part //https://docs.oracle.com/en/database/oracle/oracle-database/21/lnpls/collection-variable.html#GUID-89A1863C-65A1-40CF-9392-86E9FDC21BE9 // Statements seq_of_statements label_declaration statement swallow_to_semi assignment_statement continue_statement exit_statement goto_statement if_statement elsif_part else_part loop_statement // Loop Specific Clause cursor_loop_param //https://docs.oracle.com/en/database/oracle/oracle-database/21/lnpls/FORALL-statement.html#GUID-C45B8241-F9DF-4C93-8577-C840A25963DB bounds_clause between_bound lower_bound upper_bound null_statement raise_statement return_statement call_statement pipe_row_statement selection_directive error_directive selection_directive_body body // Body Specific Clause exception_handler trigger_block tps_block block // SQL Statements sql_statement execute_immediate // Execute Immediate Specific Clause dynamic_returning_clause // DML Statements data_manipulation_language_statements // Cursor Manipulation Statements cursor_manipulation_statements close_statement open_statement fetch_statement variable_or_collection open_for_statement // Transaction Control SQL Statements transaction_control_statements set_transaction_command set_constraint_command // https://docs.oracle.com/cd/E18283_01/server.112/e17118/statements_4010.htm#SQLRF01110 write_clause rollback_statement savepoint_statement // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnpls/collection-method.html#GUID-7AF1A3C4-D04B-4F91-9D7B-C92C75E3A300 // Dml /* TODO //SHOULD BE OVERRIDEN! explain_statement select_only_statement select_statement // Select Specific Clauses with_factoring_clause subquery_factoring_clause search_clause cycle_clause subav_factoring_clause subav_clause hierarchies_clause filter_clauses filter_clause add_calcs_clause add_calc_meas_clause subquery subquery_basic_elements subquery_operation_part query_block selected_list from_clause select_list_elements table_ref_list // NOTE to PIVOT clause table_ref table_ref_aux table_ref_aux_internal join_clause join_on_part join_using_part outer_join_type query_partition_clause flashback_query_clause pivot_clause pivot_element pivot_for_clause pivot_in_clause pivot_in_clause_element pivot_in_clause_elements unpivot_clause unpivot_in_clause unpivot_in_elements hierarchical_query_clause start_part group_by_clause group_by_elements rollup_cube_clause grouping_sets_clause grouping_sets_elements having_clause model_clause cell_reference_options return_rows_clause reference_model main_model model_column_clauses model_column_partition_part model_column_list model_column model_rules_clause model_rules_part model_rules_element cell_assignment model_iterate_clause until_part order_by_clause order_by_elements offset_clause fetch_clause for_update_clause for_update_of_part for_update_options update_statement // Update Specific Clauses update_set_clause column_based_update_set_clause delete_statement insert_statement // Insert Specific Clauses single_table_insert multi_table_insert multi_table_element conditional_insert_clause conditional_insert_when_part conditional_insert_else_part insert_into_clause values_clause merge_statement // Merge Specific Clauses merge_update_clause merge_element merge_update_delete_part merge_insert_clause selected_tableview lock_table_statement wait_nowait_part // Lock Specific Clauses lock_table_element lock_mode // Common DDL Clauses general_table_ref static_returning_clause error_logging_clause error_logging_into_part error_logging_reject_part dml_table_expression_clause table_collection_expression subquery_restriction_clause sample_clause seed_part // Expression & Condition condition expressions expression cursor_expression logical_operation multiset_expression relational_expression compound_expression relational_operator in_elements between_elements concatenation interval_expression model_expression model_expression_element single_column_for_loop multi_column_for_loop unary_expression // https://docs.oracle.com/en/database/oracle/oracle-database/21/lnpls/plsql-optimization-and-tuning.html#GUID-DAF46F06-EF3F-4B1A-A518-5238B80C69FA collection_expression case_statement /TODO [boolean isStatementParameter] // CASE simple_case_statement simple_case_when_part searched_case_statement searched_case_when_part case_else_part atom quantified_expression string_function standard_function //see as https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/JSON_ARRAY.html#GUID-46CDB3AF-5795-455B-85A8-764528CEC43B json_object_content json_object_entry json_table_clause json_array_element json_on_null_clause json_return_clause json_transform_op json_column_clause json_column_definition json_query_returning_clause json_query_return_type json_query_wrapper_clause json_query_on_error_clause json_query_on_empty_clause json_value_return_clause json_value_return_type json_value_on_mismatch_clause literal numeric_function_wrapper numeric_function listagg_overflow_clause other_function over_clause_keyword within_or_over_clause_keyword standard_prediction_function_keyword over_clause windowing_clause windowing_type windowing_elements using_clause using_element collect_order_by_part within_or_over_part string_delimiter cost_matrix_clause xml_passing_clause xml_attributes_clause xml_namespaces_clause xml_table_column xml_general_default_part xml_multiuse_expression_element xmlroot_param_version_part xmlroot_param_standalone_part xmlserialize_param_enconding_part xmlserialize_param_version_part xmlserialize_param_ident_part // SqlPlus sql_plus_command_no_semicolon sql_plus_command start_command whenever_command set_command timing_command // Common partition_extension_clause column_alias table_alias where_clause quantitative_where_stmt into_clause // Common Named Elements xml_column_name cost_class_name attribute_name savepoint_name rollback_segment_name table_var_name schema_name routine_name package_name implementation_type_name parameter_name reference_model_name main_model_name container_tableview_name aggregate_function_name query_name grantee_name role_name constraint_name label_name type_name sequence_name exception_name function_name procedure_name trigger_name variable_name index_name cursor_name record_name collection_name link_name local_link_name connection_qualifier column_name tableview_name xmltable char_set_name synonym_name // Represents a valid DB object name in DDL commands which are valid for several DB (or schema) objects. dir_object_name user_object_name grant_object_name column_list paren_column_list // PL/SQL Specs // NOTE: In reality this applies to aggregate functions only function_argument function_argument_analytic function_argument_modeling respect_or_ignore_nulls argument type_spec datatype precision_part native_datatype_element bind_variable general_element general_element_part table_element object_privilege //Ordered by type rather than alphabetically // $> // $<Lexer Mappings constant numeric numeric_negative quoted_string identifier id_expression inquiry_directive outer_join_sign regular_id non_reserved_keywords_in_18c non_reserved_keywords_in_12c non_reserved_keywords_pre12c string_function_name numeric_function_name create_procedure declare_statement empty_statement begin_statement end_statement expression_statement parameter_list data_type value_list value column_value_pair expression_list // Parser rules //unary_logical_expression //unary_logical_expression unary_logical_expression PlSqlLexer.g4 IDENTIFIER : 'IDENTIFIER'; //fragment LETTER : [a-zA-Z]; // Only letters, no underscore CREATE : 'CREATE'; |
|
Sample input:CREATE OR REPLACE PROCEDURE get_employee_name(p_employee_id IN NUMBER) I am not able to chunk the code with the existing listener method; I am getting the entire script. expected output: begin: end: |
Thanks. The input (x.txt) parses fine. The parse tree in Antlr's toStringTree() format is:
You should be able to get the name of the procedure from the parse tree. There's nothing wrong per se with the grammar or the generated parser. For example, using Trash, I can get the name using trparse, trxgrep, and an XPath expression to point to the sub-tree with the name, and get the text for that node.
And, you should be able to extract the two statements:
It's likely that your visitor or listener code is not working. But, as far as the grammar, it looks like the parser is working just fine. |
@OverRide |
I don't think you will want to create an override function for For example, to get the procedure_name, write a listener that overrides the enter method for regular_id. Then, given the node in the parse tree, traverse up the tree to verify that the node is contained in a "procedure_name" (look at the parse tree print out). If so, get the interval for the node and print out the text. MyList.java
You're going to need to call the tree walker in your driver.
|
Well, that's because your example doesn't contain any begin_or_end or procedure_body parse tree nodes. Try examples/alter_tablespaces.sql for
Please make sure to use block comments when giving out code that contains |
In the case of alter_tablespaces.sql, the enterBegin_or_end() function is used, but it only returns the keyword BEGIN and not the actual BEGIN and END statements. My example has BEGIN and END, but even though it is not working, it uses enterBegin_or_end() and enterProcedure_body() CREATE OR REPLACE PROCEDURE get_employee_name(p_employee_id IN NUMBER) Expected Output: Procedure: Declaration: Begin: End: |
Please use block comments around your SQL code.
Please create a file
And, do the parse, and print out the tree:
Then, please go to https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/ALTER-TABLESPACE.html, and read the railroad diagram for First, the I do not know why these refactorings were done. The person who wrote this part of the gramar is madams51703, who is a senior developer at MS. You will need to choose what to do:
|
I have used the PL/SQL grammar file https://github.com/antlr/grammars-v4/blob/451d59c5ef5ba954ffff24afdf2d367497fb9098/sql/plsql/PlSqlLexer.g4 There are several listener methods that can be used to extract the respective parts of the parsed input. In my case, I want to extract the PROCEDURE, BEGIN, END, and EXCEPTION statements separately. So, I tried to override the following listener method: @OverRide @OverRide However, I noticed that the entire script is getting captured and I am unable to capture each statement separately using this listener method. As you mentioned in the previous comment, what I understood is that we cannot extract these statements separately using the available listener methods generated from the PL/SQL grammar files. If we need to extract them separately, we would have to write custom logic on top of it to achieve that. Please correct me if I'm wrong. |
Yes, this is correct. Antlr parsers produces concrete syntax trees, not abstract syntax trees, so sometimes the information that you want may span several parse tree nodes. But, it is not hard to get the information, just tedious. You can use the Antlr Visitor or Listener to get an interval of the tokens and text of anything you are interested in. For example, suppose we want to extract out the string
|
PL/SQL procedure, statement, and function are not available. Can you please provide the PL/SQL procedure and function definitions, including the following methods?"
public void enterCreate_procedure(Create_procedureContext ctx);
public void enterDeclare_statement(Declare_statementContext ctx);
public void enterEmpty_statement(Empty_statementContext ctx);
public void enterBegin_statement(Begin_statementContext ctx);
public void enterEnd_statement(End_statementContext ctx);
The text was updated successfully, but these errors were encountered: