Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8130767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:50:45+00:00 2026-06-06T08:50:45+00:00

— ——————————————————————————– — Routine DDL — ——————————————————————————– DELIMITER $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `storage_choices_according_to_criteria`( IN

  • 0
-- --------------------------------------------------------------------------------
-- Routine DDL
-- --------------------------------------------------------------------------------
DELIMITER $$

CREATE DEFINER=`root`@`localhost` PROCEDURE `storage_choices_according_to_criteria`( 
                                        IN storage_calc_usage BIGINT,
                                        IN all_provider_considered BOOLEAN,
                                        IN provider_LIST varchar(200),
                                        IN has_requests BOOLEAN
                                        )
BEGIN

    IF storage_calc_usage > 0 THEN
        drop table if exists `storage_choices_expanded`;
        CREATE TEMPORARY TABLE `storage_choices_expanded` AS
        (select *, 
             usage_each_plan * standard_storage as price_storage, 
             concat_ws(' ',`Provider Name`,`Name`,`region_name`) as group_name
        from 
           (SELECT *, 
                ( 
                    if( 
                    (quota_band_high is not NULL) and storage_calc_usage>quota_band_high, 
                    quota_band_high, 
                    storage_calc_usage
                    ) - quota_band_low
                ) as usage_each_plan
            FROM `storage_service_price`
            where storage_calc_usage > quota_band_low
        and if(all_provider_considered, 1, find_in_set(`Provider Name`,provider_LIST))
           ) as storage_usage_each_plan
        );

        drop table if exists `request_options_for_storage`;

        if has_requests then

            CREATE TEMPORARY TABLE `request_options_for_storage` as
            SELECT 
                price_storage_requests.*,
                n,
                (n / per_unit_amount)*request_price as cost
            FROM `storage_request_criterias`
            right join price_storage_requests
            on price_storage_requests.storage_request_name = storage_request_criterias.name
            ;

        else

            CREATE TEMPORARY TABLE `request_options_for_storage` as
            select *, 
                0 as cost,
                0 as n
            from `price_storage_requests`
            where 0=1
            ;

        end if;

        drop table if exists `choices_storage_summed`;
        CREATE TEMPORARY TABLE `choices_storage_summed` AS

        select 
            summed.*,
            total_storage_cost + if(total_requests_cost is NULL,0,total_requests_cost) as 'Total Price',
            total_requests_cost,
            request_type_id_list
        from 
            (
                select *, 
                  sum(price_storage) as total_storage_cost, 
                  count(group_name) as count 
                from storage_choices_expanded
                group by group_name
            ) as summed
        left join
        (
            select 
            sum(cost) as total_requests_cost,
            GROUP_CONCAT(request_options_for_storage.id) as request_type_id_list,
            resource_type_id 
            from `request_options_for_storage`
            group by resource_type_id       
        ) as requests
        on requests.resource_type_id = summed.resource_type_id      
        where 
            (   
                count=1 
                and 
                if(quota_band_high is NULL,1,storage_calc_usage<=quota_band_high) 
            ) 
            or count>1 
        order by 'Total Price' asc
        ;

    END IF;

END

Above is the PROCEDURE I called, but when I try to select from the table choices_storage_summed, it gives me a Table doesn't exist error.

I called the PROCEDURE programatically via jdbc connection, I’m using the same connection.
The following code shows how I called the procedure:

private static void calcChoicesStorageSummed(Map<String, Integer> requests, boolean consider_all_provider, String provider_list, Integer storage_calc_usage, Integer daysInUse) throws SQLException {

    storage_calc_usage = storage_calc_usage * (daysInUse / DAYS_PER_MONTH);
    Boolean has_requests = insertIntoStorageRequestCriterias(requests); 

    CallableStatement cs = conn.prepareCall("call "+db+".storage_choices_according_to_criteria(?,?,?,?);"); 
    cs.setInt("storage_calc_usage", storage_calc_usage);
    cs.setBoolean("all_provider_considered", consider_all_provider);
    cs.setString("provider_LIST", provider_list); 
    cs.setBoolean("has_requests", has_requests);
    cs.executeQuery();
    cs.close();
} 

And here is the code trying to access the temporary table, conn is a global variable which remains the same during the related operations.

    calcChoicesStorageSummed(requests,(provider_name_list == null),provider_name_list,storage_usage,duration);
    /**
     * debug
     */
    sql = "select * from choices_storage_summed ";
    sql += ";";

    prest = conn.prepareStatement(sql);     
    rs = prest.executeQuery();
    while (rs.next()) {
        System.out.println(rs.getString("standard_storage")); 
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T08:50:48+00:00Added an answer on June 6, 2026 at 8:50 am

    I have figured our what was wrong.
    I have defined the input storage_calc_usage as BIGINT but in the java code I used setInt to pass in the value and in the sql I have IF storage_calc_usage > 0 THEN this condition failed so the temporary table wasn’t created.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a chrome extension and im doing this by parsing an
&mdash; or &#8212; Is there a difference between these? Is one better-supported than the
I am trying to create a modal window for my application, but unfortunately I
I'm using a DatePicker ( org.apache.wicket.extensions.yui.calendar.DatePicker — Javadoc ) in a form. The form
I'm trying to create a parser (with parsec), that parses tokens, delimited by newlines,
string formIdList = 8256, 8258, 8362, 8120, 8270, 8271, 8272, 8273, 8257, 8279, 8212,
So to start, I have an array of XML files. These files need to
I'm using some of Firefox's specially-defined values for cursor, in particular -moz-zoom-in -moz-zoom-out -moz-grab
Basically, is there a way to write a.children('.outer').children('.inner') without the intermediate selector? I can't
I recently ran against a very interesting site that expresses a very interesting idea

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.