Could the following requests be merged or an internal procedure be made



  • I have several tables in the annex, and 5 DBComboBox filled out (with several tables) with the following requests:

    1st and 2nd DBComboBox

    select distinct * 
        from (
            select distinct(KEEP_ORGANIZATION) 
                from GOV_ETALON
                where KEEP_ORGANIZATION is not null 
            union all select distinct(STORED_ETALON) 
                from REGISTER_ETALON
                where STORED_ETALON is not null ) O, (
                    select min(YEAR_ETALON) as MIN_YEAR, max(YEAR_ETALON) as MAX_YEAR
                        from GOV_ETALON
        ) Y
    

    3rd DBComboBox

    select distinct *
        from (
            select distinct(KEEP_POSITION)
                from GOV_ETALON
                where KEEP_POSITION is not null
            union all select distinct(POSITION_PEOPLE)
                from USERS_DATA
                where POSITION_PEOPLE is not null
        ) P
    

    4th DBComboBox

    select distinct *
        from (
            select distinct(KEEP_DEGREE)
                from GOV_ETALON
                where KEEP_DEGREE is not null
            union all select distinct(DEGREE)
                from USERS_DATA
                where DEGREE is not null
        ) D
    

    5th DBComboBox

    select distinct *
        from (
            select distinct(KEEP_RANK)
                from GOV_ETALON
                where KEEP_RANK is not null
            union all select distinct(RANK)
                from USERS_DATA
                where RANK is not null 
        ) R
    

    I was wondering if they could be merged into one request?
    Or to speed up the internal procedure, and to put these requests in there, and the answer to the procedure will be only the relevant sets?



  • Try that.

    create procedure vsezaprosi
    as
    begin
      // Zapros №1
    

    // Zapros №2

    // Zapros №3

    // Zapros №4

    // Zapros №5
    end

    full text

    create procedure vsezaprosi
    as
    begin
    // Zapros №1 и №2
    select distinct *
    from (
    select distinct(KEEP_ORGANIZATION)
    from GOV_ETALON
    where KEEP_ORGANIZATION is not null
    union all select distinct(STORED_ETALON)
    from REGISTER_ETALON
    where STORED_ETALON is not null ) O, (
    select min(YEAR_ETALON) as MIN_YEAR, max(YEAR_ETALON) as MAX_YEAR
    from GOV_ETALON
    ) Y;

    // Zapros №3

    select distinct *
        from (
            select distinct(KEEP_POSITION)
                from GOV_ETALON
                where KEEP_POSITION is not null
            union all select distinct(POSITION_PEOPLE)
                from USERS_DATA
                where POSITION_PEOPLE is not null
        ) P;
    

    // Zapros №4

    select distinct *
        from (
            select distinct(KEEP_DEGREE)
                from GOV_ETALON
                where KEEP_DEGREE is not null
            union all select distinct(DEGREE)
                from USERS_DATA
                where DEGREE is not null
        ) D;
    

    // Zapros №5

    select distinct *
        from (
            select distinct(KEEP_RANK)
                from GOV_ETALON
                where KEEP_RANK is not null
            union all select distinct(RANK)
                from USERS_DATA
                where RANK is not null 
        ) R;
    

    end




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2