Query Design/Implementation Question

Hi,
I have to query the database based on different input values from a JSP page. So, A user can query the database based on one or more fields. My question to you is what would be an efficient way to write the queries or implement this using JDBC. Should I write PreparedStatements for every possible combination of the query fields. Should I write stored procedures ? I had problems with the PreparedStatement earlier and I still do, so just to keep my developement going I wrote a stored procedure. If you read my previous post you can read the whole story.
So, this is more of a design question. Let the ideas flow.
Any help or suggestion will be appreciated.
Thanks,
Prasoon

Hi Justin,
This I got from an earlier post on this forum and you said that doing this was a very bad idea. Why ? I am doing this just as a workaround to my current problem.
So, basically I would have a temporary table for every query field in my JSP page. This table I would create in separate stored procedures and then finally do an AND to get the result ?
This feels dirty to me too but can u suggest a better way ?
Thanks,
Prasoon
stored procedure, temporary table, and result sets Nov 6, 2003 6:39 PM
Reply
Pls, Help me with the folloing questions:
1. Is it possible to declare and use temporary tables in a stored procedure? How?
2. Is it possible to return a result set, or recordset from a stored procedure? How?
These might be a very basic one, but as a beginer in Oracle Databse, I am having hard time to find out good source of technical materials.
Justin Cave
Posts: 5,786
OTN Member Since: Oct, 1999
Re: stored procedure, temporary table, and result sets ( In Reply To : stored procedure, temporary table, and result sets ) Nov 6, 2003 7:17 PM
Reply
1) You certainly can declare and use temporary tables in a stored procedure. On the other hand, doing so strikes me as a manifestly bad idea, so I would strongly caution you not to. If you explain a bit about what you're trying to accomplish, I'm sure there are better ways.
If you did want to create temporary tables in a stored procedure, you'd have to use dynamic sql, i.e.
execute immediate 'create temporary table foo...'
2) You can return resultsets from a stored procedure by declaring an OUT parameter which is a REF CURSOR.
Justin
Distributed Database Consulting, Inc.
www.ddbcinc.com/askDDBC

Similar Messages

  • BEx Query Designer - Simple Question - Will Give Points Promptly

    I have this query designed and looks like I have personalized the variables from the parameter screen. how do I undo it. I am running this report from query designer itself and not th web. Kindly assist.

    Hi,
    It may be helpful to know that ODS 0PERS_VAR stores all the entries. We have used this in the past to see who had turned this on & for what kind of objects. You can also selectively delete out of the ODS if you had to, for some reason.
    OR
    <b>(Better one)</b>
    Start transaction SM31 (table maintenance)
    Enter table RSPERSHEAD and click on [maintain]
    It is not necessary to open the BW system for maintenance in SCC4.
    Search for the line:
    application component = VAR
    version = A (active)
    now un-check the checkbox in the table field "boolean" and save the changes.
    As a result the BEX analyzer will show all the personalized variables in the selection screens again, you don't have to delete the data in the ODS 0PERS_VAR.
    You can undo the changes by ticking the checkbox again.
    I have implemented this solution on BW release 3.1
    We only use BEX reporting so I don't know if this solution has any effect on WEB reports.
    please let me know if one of you encounters any problem with this solution.
    Regards,
    San!

  • Query Design - Hierarchy Question

    Hi guys,
    I am making a query with Cost and Profitaccounts. All the accounts are listed up in a hierarchy.
    6>61>610, 6>61>611,6>62>621 etc
    Under each 3digit account we have vendor information.
    Now one users wants me to create a query that only shows the 1digit accounts with directly the vendor information underneath it.
    How do you do this?
    Thank you,
    Filip

    Hi Filip,
    if you want to display the 1 digit accounts then give the restriction by selecting it in the filter and give the range of fixed values.and if you want to display the heirarchial values then select the particualr dimension and right click and go to properties and select the hierarchy level and give for the display which node you want to display and hide the other fields by hiding them and you can gieve the selction also on hierarchy nodes by creating the hierarchy node variables.if this is not you are looking for exactly then post your question more clear way then we will help in resolving your issue.
    assign points if it helps.
    Regards,
    ashok.

  • BI 7 - BEX Query Designer variable question

    Hi all,
    If I have an Entry Variable in the selection screen of a query,  is it possible to populate another variable based on the user input.
    e.g.
    If I have a Report Date with a mandatory input, and I want a CalMonth variable to be populated based on this.
    Is the only way of achieving this through customer exits???
    Many thanks,
    Shane.

    Hi Shane,
    You would need to write a code in the CMOD for the variable, something like below:
    Declare internal table IT_RANGE with type same as I_T_VAR_RANGE.
    Also declare work area WA_RANGE like line of IT_RANGE
    when 'variable_name'.
         IF i_step = 2.
         REFRESH e_t_range.
         data: v_date type sy-datum.
         data: v_date1 type sy-datum.
         data: v_month type I length 2.
         data: v_year type I length 4.
         read I_T_VAR_RANGE into WA_RANGE where VNAM = 'variable_name' and IOBJNM = '0cal_day'.
         if sy-subrc = 0.
              v_date = WA_RANGE-LOW. "Date Entered by user     
         endif.
         WA_RANGE-SIGN = 'I'.
         WA_RANGE-OPT = 'EQ'.
         * here we will write our logic to populate the 7 dates as required.
         * and populate the date into v_date1.
            WA_RANGE-LOW = v_date1. "Similar procedure to derive all 7 dates
         append wa_range to e_t_range. "We append all the 7 derived dates to e_t_range
            "(i.e. 7 append statements)
         You should be careful while writing the logic for previous month to handle year ends.
         you can use sample code like below for that:
         v_month = v_date4(2). "month
         v_year = v_date+0(4). "Year
         if v_month = '01'.
              v_month = '12'.
              v_year = v_year - 1.
         endif.
    You will probably need an ABAPers help to write the logic for deriving the dates as required.
    Here your logic will be like finding end date of previous months which can be done using function module LAST_DAY_OF_MONTHS
    similarly you will have to get last dates of 3 quarters, which can be done by determining which quarter the input date falls in.
    and same for the year end date.
    Hope this helps
    Regards,
    Joe
    Edited by: lazarus_joey on Feb 15, 2012 6:45 PM

  • 2013 Design implementation-two sites

    Hi!
    I have a design implementation question. We are a small firm with 80 AD users, 100 mailboxes, DB store is 200 gigs and all on Exchange 2007 (Virtualized connecting to a SAN), but growing rapidly. Also, we currently have two sites in Chicago and New York(Exchange
    2007 server in NY). We would like to upgrade from 2007(all roles installed on a VM server ESX 5.5 server) to 2013. Should we virtualized the Exchange 2013 or should they be physical servers? Also, since the servers will be in separate sites will I need a Load
    Balancer in both location? Also, should I split up the roles since we have two locations running the both roles on both servers. For example below:
    1 Chicago server-CAS/Mailbox Role
    1 New York server-CAS/Mailbox Role
    Should I have the Chicago users connect to the Chicago Server? And the New York users pointed to the New York Server? Currently everyone connects to the mail sever in NY. Any advice or comments would be appreciated.
    Thanks!

    Hi,
    Yes, if you need proxy or redirection settings on OWA and other Exchange web services, one CAS in each site is must.
    Thanks,
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Simon Wu
    TechNet Community Support

  • Bi Query Design Question

    Hi,
                I have a question regarding a query design issue I was faced with today. I was asked to designed a Query, however all the fields required are all defined as characteristics but I would like to display one as a key figure. I would have a characteristic for a row, the column also for a characteristic and have another characteristic displayed instead of the key figured…… Is that possible?
    Thanks for any feedback

    Hi Serge,
    This question would be more appripriate -- and you will get a quicker answer -- in the BI Forums.  Please open your question there.
    Best Regards,
    Matt

  • Please help how to design query to implement this requirement.

    Dear Expert,
    Here is what I have and what the requirement is:
    I have a InfoCube:
    Dimensions:
    1. Material
    2. Currency
    Key Figures:
    1. Qty
    2. Amount
    We want to get the Qty and Amount by Material, but use Currency to be the filter.
    It means for example, if the Currency have CNY for one material, we need to show all the Qty/Amount, not only Qty/Amount in CNY.
    So please help give some idea about how to design the query to implement this requirement.
    Thank you,
    Andy

    Hi Andy:
    To accomplish your requirement you need to do 2 things:
    1. Create a Variable for the Currency (to be used as the Target Currency not as a filter for the Characteristic itself).
    2. Use the Standard Currency Conversion for the Amount Key Figure (Conversion Tab).
    This way, while executing the report you can select any currency you want and all the amounts will be converted to that currency.
    Take a look at this paper:
    "How to... Use Variables for Currency Conversion"
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/287bab90-0201-0010-f48e-cc55b0cd13d0?quicklink=index&overridelayout=true
    A more detailed explanation can be found on this article provided by Ramakrishna Gattikoppula:
    "Currency Conversion in BI 7.0"
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a0d5bf96-b19b-2c10-e3b6-e2f12a3de99a?quicklink=index&overridelayout=true
    In summary, to work with the Standard Currency Conversion you need to define 4 things:
    - Exchange Rate Type.
    - Source Currency.
    - Target Currency.
    - Time Reference.
    Regards,
    Francisco Milán.
    Edited by: Francisco Milan on May 31, 2010 11:19 AM

  • Query designer in EXCEL question

    Hi!
    I have a question about query designer in excel.
    I want SQL query to have in WHERE clause OR instead of AND (which is default), so the query would be like these:
    <b>ORIGINAL:</b>
    SELECT
    D1~SID_ZKAZALNIK AS S____590
    COUNT( * ) AS 1ROWCOUNT
    SUM( F~/BIC/ZPLANKA2 ) AS ZPLANKA2
    SUM( F~/BIC/ZVREDKA2 ) AS ZVREDKA2
    FROM
    FROM
    /BIC/FZKAZAL AS F
    JOIN
    /BIC/DZKAZAL1 AS D1
    ON
    F~KEY_ZKAZAL1
    = D1~DIMID
    JOIN
    /BIC/DZKAZALT AS DT
    ON
    F~KEY_ZKAZALT
    = DT~DIMID
    JOIN
    /BIC/DZKAZALP AS DP
    ON
    F~KEY_ZKAZALP
    = DP~DIMID
    WHERE
    <b>WHERE
    DT~SID_0CALQUARTER
    = 20044
    ) ) AND  ( (
    DP~SID_0RECORDTP
    = 0
    ) ) AND  ( (
    DP~SID_0REQUID
    <= 1060
    ) ) ) )</b>*** GROUP BY
    GROUP BY
    D1~SID_ZKAZALNIK
    DB-SPECIFIC HINTS
    &SUBSTITUTE LITERALS&
    <b>WHAT I WANT:</b>
    SELECT
    D1~SID_ZKAZALNIK AS S____590
    COUNT( * ) AS 1ROWCOUNT
    SUM( F~/BIC/ZPLANKA2 ) AS ZPLANKA2
    SUM( F~/BIC/ZVREDKA2 ) AS ZVREDKA2
    FROM
    FROM
    /BIC/FZKAZAL AS F
    JOIN
    /BIC/DZKAZAL1 AS D1
    ON
    F~KEY_ZKAZAL1
    = D1~DIMID
    JOIN
    /BIC/DZKAZALT AS DT
    ON
    F~KEY_ZKAZALT
    = DT~DIMID
    JOIN
    /BIC/DZKAZALP AS DP
    ON
    F~KEY_ZKAZALP
    = DP~DIMID
    WHERE
    <b>WHERE
    DT~SID_0CALQUARTER
    = 20044
    ) ) <b>OR</b> ( (
    DP~SID_0RECORDTP
    = 0
    ) ) <b>OR</b>  ( (
    DP~SID_0REQUID
    <= 1060
    ) ) ) )</b>*** GROUP BY
    GROUP BY
    D1~SID_ZKAZALNIK
    DB-SPECIFIC HINTS
    &SUBSTITUTE LITERALS&<b></b><b></b>
    Is there a way to change filter from AND to OR where u need that in visual query designer in Excel????
    I need these becouse i want to say smth. like that ... SELECT data FROM some cube WHERE date = 10/2004 OR date_q = 3/2004 OR month = 11 OR year = 2003

    Thanks for reply Roberto!
    Do u think with that? :
    Create 3 different queries on worksheet and than copy values in excel to another worksheet manualy?
    If that, then this is not an option for me, becouse i need joust one query.
    Is there another option?

  • Question about calculation example with Query Designer

    Hi guys,
    I have to calculate within columns and rows and I am not familiar with the settings in Query Designer that could be done to achieve the results.
    For example:
    Payments----
    Delay -
    Weighted Delay
    1000USD--10 days--
    10000
    2000USD--20 days--
    40000
    3000USD--xxx--
    50000 (this is the sum row)
    The column marked with the xxx is calculated with the sum of weighted delay divided by the sum of payments (50000 / 3000).
    Has anybody an idea how the sum row can be calculated separately?
    Thank you for suggestions!
    Edited by: saplaz on Jul 13, 2010 8:47 AM
    Edited by: saplaz on Jul 13, 2010 9:08 AM

    Hi,
    Assuming you have the Payments Infoobject in the rows and WD Infoobject in the columns; Delay as a formula object.
    > Payments----
    Delay -
    Weighted Delay
    > 1000USD--10 days--
    10000
    > 2000USD--20 days--
    40000
    > 3000USD--xxx--
    50000 (this is the sum row)
    > The column marked with the xxx is calculated with the sum of weighted delay divided by the sum of payments (50000 / 3000).
    You may try this workaround of using
    NODIM( SUMCT(WEIGH_DELAY) / SUMCT(PAYMENTS) )
    on a formula variable. (In this case, the assumption is you have not static type-restricted the rows/cols) If you find any hinderances in the default approach, you may check this out as a formula & insert this at the cell editor level.
    If not, use a simple formula variable; here define the replacement path as 0(N) for your Payments. (N being the # of digits)
    Use a simple calculation:
    SUMGT(WD)/FV
    But you may not get an result o/p in the last row, as the values are not linked (sans relation with Payments). as it will return a X for the delay in the Result row.
    Pls. let me know know if this works or some sample o/p if the initial assumption was wrong.
    Thanks,
    Arun Bala

  • Webi: BW Query design best practice question

    The scenario is as follows:
    SAP NetWeaver BW 7.01 SPS3
    Business Objects Enterprise XI 3.1 Fix Pack 1.2
    SAP Integration Kit XI 3.1
    Webi report built off of a BW Query. Based on the versions listed above, the MDX statement generated should only pick up only the fields listed in the query panel in Webi, not necessarily every field in the underlying BW query.  Having said that, does it matter what fields are in the Free CHAR or in the rows in the underlying BW Query??  I heard a suggestion that all fields should be put in the Free CHAR panel of the BW Query Designer but I don't see the value add of that approach.  Any thoughts?
    -Brad

    Hi,
    it does not matter if the items are Free Characteristics or rows or columns.
    for best practices here some material:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/008d15dc-f76c-2b10-968a-fafe5a121129
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b0320722-741c-2c10-afab-93b5c0fc7e96
    Ingo

  • Query design question (NW04s)

    In query designer, how do I hide a column that has no data. I know how to suppress zero result columns, but these columns are not zero because they had no data.
    Can this be done using a local formula?

    Hi Raynald,
    Yes you can do this by restriction. I mean you restrict the report only display for the column that has a data.
    How you do this :
    1. Open your query.
    2. Right click for the characteristic (column), choose restrict.
    3. Choose for fix values, and singles value for selection type.
    4. (there will be 2 area) You restrict it by choose no-data / symbolized by # (move it from left to right pane).
    5. (After moving it to right pane) You right click to that symbol then choose exclude from selection in the context menu.
    If you have already made it, the column that has no data will be hidden.
    Hopefully it can help you.
    Regards,
    Niel.
    award points if it helps you.

  • Some question about the query designer

    hello, dear all,
    I am a new comer of here, and I am intersting in BI, but I have no basic knowledge about it.
    so I just want someone could give me some advice about it.
    our boss need I do the developer about the query designer,  I just have searched in this forum. but nothing founded for I am a new comer here,
    I heard there are some training document of the query designer, could someone give me the URL, thanks.

    Hi,
    Query desinger is used to develop a Query, Query can be created on following data targets
    -Info Cube
    -DSO
    Virtual data target
    -MultiCube
    -Infoset
    -Multiprovider
    We have 5 section in query designer
    - Infoprovider : where we select the data target , on which report to be created
    -Filter : to restrict value at infoprovider level ( if you want data for year 2008, for example)
    -Free Characterstic : this allow you to drill down
    -Columns : char/keyfigs to be display in columns can be added here
    Row: key/char to be display in Rows can be added here
    gv me ur mailid i will let u have Bex manual,
    I would suggest , if you have any IDES ( training ) system , where you can log in and then go to RRMX,
    and try to create new query and add any data target ( which is already created ) and then drag and drop the char/key fig to the required section ,
    save it and execute it .....
    if you play arround and see the output , that would help u to understand how to work with query designer.
    Hope this helps
    Sukhi
    Edited by: Sukhvidner Singh on Nov 4, 2009 5:36 PM

  • Settings for SAP Portal start page from BEx Query Designer

    Hi!
    In order to see queries I would like to use SAP Enterprise Portal from BEx Query Designer.
    When I push "execute" button within BEx Query Designer a wrong page will be shown in browser.
    I changed the settings in table RSPOR_T_PORTAL, but still get the wrong Portal page shown in browser.
    Question:
    What is the transaction/table/report to customize the portal start page using by BEx Query Designer?
    Thank you very much!
    regards
    Jürgen

    Hi Anton?
    Many thanks for your reply.
    But I mentioned that I changed the URL within table RSPOR_T_PORTAL and this does not help...
    Do you speak Russian? Me too
    Can you also help me with the following problem?
    Hi!
    I am about to implement SAP Best Practices scenario "B34: Accounts Receivable Analysis".
    Therefore I load the data from SAP ERP IDES system into SAP NetWeaver 2004s system.
    My problems are:
    when I try to load the transaction data for Infosources 0FI_AR_4 and 0FI_AR_6 from SAP ERP system the following happens:
    - the status is getting u201Cyellowu201D (194 from 0 records)
    - at the next day the status is getting u201Credu201D and I received the following error:
    Errors while sending packages from OLTP to BI
    Diagnosis
    No IDocs could be sent to BI using RFC.
    System Response
    There are IDocs in the source system ALE outbox that did not arrive in the ALE inbox of BI.
    Further analysis:
    Check the TRFC log.
    You can access this log using the wizard or the menu path "Environment -> Transact. RFC -> In source system".
    Error handling:
    If the TRFC is incorrect, check whether the source system is fully connected to BI. In particular, check the authorizations of the background user in the source system.
    Comment:
    I did not find any entries on "Environment -> Transact. RFC -> In source system"
    The Source system connection EC6CLNT100 is OK
    Can some one help me to solve this problem?
    Edited by: Jgen Pfeiffer on Feb 5, 2009 12:48 PM

  • Difference between  aggregation and calculation tab in BEx Query Designer

    HI,
    I am using BEx Query Designer for my report, for the key figures in the coloumn area i slected one numeric key figures, in  the properties tab i found aggregation tab and calculation tab.
    I need to sum up the total values for that particualar coloumn, when i used calculation tab i found to sum all the values for a particular coloumn, then what is the use the aggreagation tab?
    I not able to used that Aggregation tab it is showing as a hidden fields...
    can any one tell me whats the exact difference between these tabs and when we need to use which tab?
    With Regards,
    Thanesh Kumar.

    Hi Thanesh Kumar,
    I moved this thread from forum Data Warehousing to Business Explorer since it is a query related question (as SDN moderator).
    I could explain to you the difference between these two tabs.
    For "calculation" tab, it changes the display of result and does not change the calculation logic.
    It means that, if this key figure is used further in formula, still the original number (without "calculation" tab setting)  is used for further formula calculation.
    For "aggregation" tab, it changes the real calculation logic.
    The system takes the setting as the aggregation rule for records.
    The most common aggregation rule is of course summation. If you set to e.g. Average here, the system does the
    Average instead of summation when aggregating records. And the Average value will be taken for calculation
    in further formulas or other calculations.
    For "aggregation" tab, you could only use it for CKF (calculated key figure) or formula and you could not use it for
    a basic key figure. That should be the reason why you see it greyed-out.
    Regards,
    Patricia

  • Doubt on Rows and Coloums in BEx Query Designer.

    Hello, Experts.
    I have a Doubt in BEx Query Designer.
    In the Rows I have a Fiscal year Period,  if the user enters the Fiscal year period for e.g. : 001/2006  .  
    in the columns i have  forecast for the Fiscal year period which user entered ( 001/2006 ),   and we have another column pervious ( Prior )fiscal year period ( 001/2005 ). 
    My Questions is ,  as we are Restricting with 001/2006 will the query retrieve the values of 2005 or not?
    Thanks in Advance .
    Sharp

    yes i am  Doing Offest.
    I moved this Fiscal year Period to Free char,   and i Restricted with Pervious Fical Year period and Fical year period .  it worked.  but
    when i kept this in Rows and deleted Previous Fiscal Year period .  it is displaying blanks.   in prior years forecast.
    is it because i am Ristricting it to only fical year period  which user entered
             Colums-->  Forcast ( User Entered year )          Prior year
    Rows
    Fiscal year period
      Fiscal year period( user enterd )
    Thanks

Maybe you are looking for

  • Row level security in Hyperion System 9 - 9.3.1

    Hi Gurus, I have a requirement where the users get to see records in a table based on their localization code. This is currently implemented using views. The view has a set of conditions which checks the localization table with te employee table. For

  • Dragging files out of iPhoto

    I was uploading photos to fotki out of iPhoto and I noticed that even though I dragged the modified photos out of iPhoto only the original file got uploaded. Is there any way of dragging the photo out of iPhoto, but still retain the modifications mad

  • WAD Javascript  to return system id

    hi In WAD , is there a javascript API call to return system id?  eg SAPPRD or SAPDEV thanks.

  • Multiple planned orders for a requirement

    Hi,        We have PPDS MRP with NEW shelflife w/ lot size profle run for product and produces multiple planned orders for the the requirements. I have a requirement of 4,750 and 14,976 in the system and available stock 86,966. The system creates two

  • Oracle 11g RAC hp-unix 11.31安装

    在linux安装11g RAC的时候需要在 /etc/security/limits.conf 对oracle,grid进行设置. HP-UNIX有没有类似的地方进行设置?