Physical Tables based on select with parameters

I have a database query that receives some input parameters and it worked fine when I run this query from any sql tool, The query is very complex and the input parameters are not associated in the sql to a specific column, they are associated in the subqueries that the query has.
Is it possible create a view using the sys_context function and establish the parameters at runtime from business intelligence 10.1.3.4.1 ?
Thanks!
Ramiro Ortiz

I believe this is what you are trying to get at:
SELECT DECODE(m.pref_type, 1, (SELECT result FROM a
                               WHERE a.pref_value = m.pref_value),
                           2, (SELECT result FROM b
                               WHERE b.pref_value = m.pref_value)
FROM my_table mAlthough, if the tables are large, that might be pretty slow. Better than an outer join, but one of those correlated queries is going to be run for each row in my_table. You could lso try something like:
SELECT m.pref_type, r.result
FROM my_table m,
     (SELECT 'A' tbl, pref_value, result
      FROM a
      UNION ALL
      SELECT 'B', pref_value, result
      FROM b) r
WHERE DECODE(m.pref_type, 1, 'A', 'B') = r.tbl and
      m.pref_value = r.pref_valueHTH
John

Similar Messages

  • Conditionaly select the physical table based on selection from prompt.

    Hi expert.
    we have one logical table with two LTS(LTS A and LTS B). LTS A is at day level and LTS B is at week level.
    So i have created a dashboard prompt which returns as day and week in drop down(SQL Result).
    So when we select Day it should run from the day table and when we select Week it should run from week table.
    How to do that...

    Amotoj,
    This scenario is exactly what the Cascade parent is meant for.   You would define your screen to have multiple fields where if you select a value in field 1, field 2 will be automatically filtered based on the first selection.
    You will need the appropriate indexes on the Complex Table to support it but it is fairly straight forward.
    If there a reason you don't want to use multiple fields?
    --Bill

  • Using variable in physical table of type "select"

    Hello!
    I have to use query as physical table (in Administration tool - http://file.qip.ru/file/120930377/8713693/1_online.html):
    SELECT ID, CODE
    FROM TABLE (pkg.output('1','2')) This code works well. I need to insert instead of parameters '1' and '2' session variables, which will be set from Dashboard.
    How to put variable in this query? Variants like @{test} don't work.

    Hi
    I have a working example:
    select * from table(get_emps('VALUEOF(NQ_SESSION.USER)'))
    where
    CREATE OR REPLACE FUNCTION GET_EMPS(P_USER VARCHAR2:='SUPPLIER2')
    RETURN EMP_TYPE_LIST
    IS
    EMPS EMP_TYPE_LIST:=EMP_TYPE_LIST();
    R EMP_TYPE:=EMP_TYPE(NULL,NULL,NULL,NULL,NULL);
    i pls_integer:=0;
    CURSOR C_EMP(C_USER EMPLOYEES.USER_ID%TYPE) IS
    SELECT EMPLOYEE_ID,FIRST_NAME,LAST_NAME,SALARY ,USER_ID
    FROM EMPLOYEES WHERE upper(USER_ID)=upper(C_USER);
    BEGIN
    OPEN C_EMP(P_USER);
    LOOP
    FETCH C_EMP INTO R.EMPLOYEE_ID,R.FIRST_NAME,R.LAST_NAME,R.SALARY,R.USER_ID;
    EXIT WHEN C_EMP%NOTFOUND;
    i:=i+1; emps.extend; EMPS(i):=R;
    END LOOP;
    RETURN EMPS;
    END;
    and
    CREATE OR REPLACE TYPE EMP_TYPE AS OBJECT
    EMPLOYEE_ID NUMBER(6),
    FIRST_NAME VARCHAR2(20),
    LAST_NAME VARCHAR2(25),
    SALARY NUMBER(8,2),
    USER_ID VARCHAR2(30));
    and
    CREATE OR REPLACE TYPE EMP_TYPE_LIST AS TABLE OF EMP_TYPE;
    My employees table contains an extra column, called user_id, which has different values: 'Administrator','SUPPLIER2' and so on
    Best regards
    Laszlo

  • How to variable exit read table based on selected row on weblayout ??

    Hi All,
    Greeting,
    I have a question regarding IP.
    I have report where I can choose the line. I've already been able to catch the selected row there using ABAP Planning Function.
    The requirement is to change some value from other customized table ( not info cube ) based on selected row.
    So when user's selecting data and pressing a button, the idea is to prompt a variable where they can see the old value, and they can entry the new value. But to query that value, I need to select based on the values the row.
    My Question is how user-exit in variable can read selected row in web planning layout especially it happens when I_step = 1 ?
    Or the other idea is to get the value on that customized table and put it in text web item as the old value. How can I fetch data from table and put it in text web item ?
    Thanks a lot and have a good day,

    Hi.
    My Question is how user-exit in variable can read selected row in web planning layout especially it happens when I_step = 1 ?
    I think there is no way to do it. I_STEP=1 called before the report shows the data.
    But may be the next approach could help you:
    1. when you select line you can use command for populating variables according to selected line. let's say yohave selected line with costcenterr XXX so you can populate variable (let's say Z_CC) with selected value.
    2. create FOX that reads variable Z_CC value and calls any function module with customized table and variable value (you can use CALL FUNCTION statement within FOX and pass to it variable value).
    This is just an idea of some direction - may be you can take it and develope to required result.
    Regards.

  • Javascrip call sqldatasource select with parameters

    It is possible call sqldatasource select with setting parameters in javascript function?

    Hello JoneCunha,
    It is much better for you to post javescript related question to ASP.NET forum or other related forum, this forum topic is C# language not for JaveScript.
    Best regards,
    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Need Table for BOM selection with qunatity

    Hi experts,
    I'm unable to get the table for Alternate BOM, BOM component and Component qty in one table. Plz help me if any body having idea about this inform me.
    Thanking you,
    Narendra

    Hi,
    Please find below tables for BOM
                          STKO                    BOM - header
         STPO                    BOM - item
         STAS                    BOMs - Item Selection
         STPN                    BOMs - follow-up control
         STPU                    BOM - sub-item
         STZU                    Permanent BOM data
         PLMZ                    Allocation of BOM - items to operations
         MAST                    Material to BOM link
         KDST                    Sales order to BOM link
    I think use MAST,STKO ,STPO for your use
    Regards
    SANIL

  • Using case when statement in the select query to create physical table

    Hello,
    I have a requirement where in I have to execute a case when statement with a session variable while creating a physical table using a select query. let me explain with an example.
    I have a physical table based on a select table with one column.
    SELECT 'VALUEOF(NQ_SESSION.NAME_PARAMETER)' AS NAME_PARAMETER FROM DUAL. Let me call this table as the NAME_PARAMETER table.
    I also have a customer table.
    In my dashboard that has two pages, Page 1 contains a table with the customer table with column navigation to my second dashboard page.
    In my second dashboard page I created a dashboard report based on NAME_PARAMETER table and a prompt based on customer table that sets the NAME_ PARAMETER request variable.
    EXECUTION
    When i click on a particular customer, the prompt sets the variable NAME_PARAMETER and the NAME_PARAMETER table shows the appropriate customer.
    everything works as expected. YE!!
    Now i created another table called NAME_PARAMETER1 with a little modification to the earlier table. the query is as follows.
    SELECT CASE WHEN 'VALUEOF(NQ_SESSION.NAME_PARAMETER)'='Customer 1' THEN 'TEST_MART1' ELSE TEST_MART2' END AS NAME_PARAMETER
    FROM DUAL
    Now I pull in this table into the second dashboard page along with the NAME_PARAMETER table report.
    surprisingly, NAME_PARAMETER table report executes as is, but the other report based on the NAME_PARAMETER1 table fails with the following error.
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 16001] ODBC error state: S1000 code: 1756 message: [Oracle][ODBC][Ora]ORA-01756: quoted string not properly terminated. [nQSError: 16014] SQL statement preparation failed. (HY000)
    SQL Issued: SET VARIABLE NAME_PARAMETER='Novartis';SELECT NAME_PARAMETER.NAME_PARAMETER saw_0 FROM POC_ONE_DOT_TWO ORDER BY saw_0
    If anyone has any explanation to this error and how we can achieve the same, please help.
    Thanks.

    Hello,
    Updates :) sorry.. the error was a stupid one.. I resolved and I got stuck at my next step.
    I am creating a physical table using a select query. But I am trying to obtain the name of the table dynamically.
    Here is what I am trying to do. the select query of the physical table is as follows.
    SELECT CUSTOMER_ID AS CUSTOMER_ID, CUSTOMER_NAME AS CUSTOMER_NAME FROM 'VALUEOF(NQ_SESSION.SCHEMA_NAME)'.CUSTOMER.
    The idea behind this is to obtain the data from the same table from different schemas dynamically based on what a session variable. Please let me know if there is a way to achieve this, if not please let me know if this can be achieved in any other method in OBIEE.
    Thanks.

  • OBIEE generated SQL differs if it's a Physical Table or Select Table...

    Hi!
    I have some tables defined in the Physical Layer, which some are Physical Tables and others are OBIEE "views" (tables created with a Select clause).
    My problem is that the difference in the generated SQL for the same table, differs (as expected) whether it is a Physical Table or a "Select Table". And this difference originates problems in the returned data. When it a Physical Table, the final report returns the correct data, but when it is a Select Table it returns incorrect/incomplete data. The report joins this table with another table from a different Database (it is a join between Sybase IQ and SQL Server).
    This is the generated SQL in the log:
    -- Physical Table generated SQL
    select T182880."sbl_cust_acct_row_id" as c1,
    T182880."sbl_cust_acct_ext_key" as c2,
    T182880."sbl_cust_source_sys" as c3
    from
    "SGC_X_KEY_ACCOUNT" T182880
    order by c2, c3
    -- "Select Table" generated SQL
    select
         sbl_cust_acct_ext_key,
         ltrim(rtrim(sbl_cust_source_sys)) as sbl_cust_source_sys,
         sbl_cust_acct_row_id,
         sbl_cust_acct_camp_contact_row_id,
         ods_date,
         ods_batch_no,
         ods_timestamp
    from dbo.SGC_X_KEY_ACCOUNT
    As you may notice, the main difference is the use of Aliases (which I think that it has no influence in the report result) and the use of "Order By" (which I start to think that it its the main cause to return the correct data).
    Don't forget that OBIEE server is joining the data from this table, with data from another table from a differente database. Therefore, the join is made in memory (OBIEE Engine). Maybe in the OBIEE Engine the Order by is essential to guarantee a correct join...but then again, I have some other tables in the Physical Layer that are defined as "Select" and the generated SQL uses the aliases and the Order by clause...
    In order to solve my problem, I had to transform the "Select Table" into a "Physical Table". The reason it was defined as a "Select Table" was because it had a restriction in the Where Clause (which I eliminated already, althouth the performance wil be worse).
    I'm confused. Help!
    Thanks.
    FPG

    Hi FPG,
    Not sure if this is a potential issue for you at all, but I know it caused me all kinds of headaches before I figured it out. Had to do with "Features" tab Values in the database object's settings in the Physical Layer:
    Different SQL generated for physical table query vs. view object query?
    Mine had to do with SQL from View objects not being submitted as I would expect, sounds like yours has more to do with "Order By"? I believe I remembered seeing some Order By and Group By settings in the "Features" list. You might make a copy of your RPD and experiement around with setting some of those if they aren't already selected and retesting your queries with the new DB settings.
    Jeremy

  • Creating Physical table as select in the .rpd

    When creating a physical table as a select we can write the SQL statement like SELECT A,B,C... FROM xxx etc.
    Trouble is that we then have to go the tab COLUMNS and define each column... This is kind of very error prone and lots of work...
    Pls. is there a way to somehow leverage the columns alreaday defined in the PHYSICAL TABLE ?
    Txs. for any help.
    Antonio

    Hi Antonio,
    You didnt catch me..
    1)Open actual rpd and create a view using select query, do not add any columns.
    2) Create view in dev db.
    3) Create a new rpd file import the view into the physical layer.
    4) Select columns from step3 and copy
    5) paste in the actual rpd on selecting the 'select query' object
    you are good to go.
    This wold help you with all columns and their datatypes.
    Hope this helps.
    Cheers,
    SVee

  • Calling stored procedures with parameters with the Database Connectivi​ty Toolkit

    Hi all,
    I am new to the forum and am having difficulty finding a solution to a particular problem I am having regarding using the LabVIEW Database Connectivity Toolkit on a project I am currently working on at my job.  I have a database in which I have tables and stored procedures with parameters.  Some of these stored procedures have input, output, and return parameters.
    I have been trying to follow this example but to no avail:  http://digital.ni.com/public.nsf/allkb/07FD1307460​83E0686257300006326C4?OpenDocument
    One such stored procedure I am working on implementing is named "dbo.getAllowablePNs", which executes "SELECT * from DeviceType" (DeviceType is the table).  In this case, it does not require an input parameter, it has an output parameter that generates the table [cluster], and has a return parameter which returns an integer value (execution status code) to show if an error occurred.  The DeviceType table has 3 columns; ID (PK, int, not null), PN (nvarchar(15), null), and NumMACAddresses (int, null).  I have gone over many examples and have talking to NI support to try to implement this and similar stored procedures in LabVIEW but have not been successful.  I am able to connect to the database with the Open Connection VI without error, but am running into some confusion following this step.  I am then trying to use the Create Parameterized Query VI to call the stored procedure and set the parameters.  I assume I would then use the Set Parameter Value VI for each parameter that is wired into the parameters input on the previous Parameterized Query VI?  I am also having some confusion during and following these steps as well.  I would greatly appreciate any advice or suggestions anyone might have in regards to this situation as I am not a SQL expert.  Also, I would be happy to provide any more information that would be helpful.
    Regards,
    Jon
    Solved!
    Go to Solution.

    Also, I don't know if this would be helpful but here is the actual stored procedure in SQL:
    CREATEPROCEDURE [dbo].[getLastSequenceNumber]
    @p1 nvarchar(10)='WO-00000'
    AS
    BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SETNOCOUNTON;
    -- Insert statements for procedure here
    selectmax(SequenceNumber)from Devices where WorkOrderNumber= @p1
    END
    GO

  • Could not able to join physical tables in obiee using a dataconversion func

    Hi,
    i am trying to join physical tables wc_perf_ratings_d and w_wrkfc_evt_month_f with condition as
    "Oracle Data Warehouse"."Catalog"."dbo"."Dim_WC_PERF_RATINGS_D"."RATING_CD" = to_char(round( "Oracle Data Warehouse"."Catalog"."dbo"."Fact_W_WRKFC_EVT_MONTH_F"."ORIG_PERF_RATING",2)). But i am getting the below syntax error while applying this.
    [nQSError:27002] Near <(>: Syntax error [nQSError:26012]
    i used the same condition on database and i got results.
    select rating_cd,
    to_char(round(orig_perf_rating,2)) as orig_perf_rating,
    headcount,
    fte,
    salary_annl,
    total_service_days
    from wc_perf_ratings_d, w_wrkfc_evt_month_f
    where wc_perf_ratings_d. rating_cd= to_char(round(w_wrkfc_evt_month_f.orig_perf_rating,2));
    Here i am trying to convert the format of ORIG_PERF_RATING field and trying to join with RATING_CD in physical layer.
    so my question is, is it possible to join in obiee using such conditions? i do not want to convert the field format in ETL and i wanted to do that at obiee level. Could anybody please suggest how to do it?

    Hi,
    Thanks for the link. i was trying another method in joining the two fields (rating_cd, orig_perf_rating) at database level. As i said both these fields are of varchar datatype. Earlier i tried to convert orig_perf_rating field from number to string. But i want to convert string data in (rating_cd) to number. so i have values in it like (1,2,3,4,bep, ep, vp, nr). Actually i have a requirement to create a database view for the dimension table (wc_perf_ratings_d) having rating_cd field with new datatype (number) instead of string and then join this field with orig_perf_rating in fact table which already has numbers. Along with the number rating fields, there are four particular string fields in rating_cd (bep, ep, vp, nr) as i mentioned. so while converting, i also have to convert these specific string fields in to partcular numbers. (bep=1, ep=5, nr=0, vp=3). Now, all this requirement is at database level as i am creating a db view. so my question is how to apply the to_number conversion function for converting the rating_cd field values (bep, ep, vp, nr) from string to specific mentioned numbers. Could you please help?
    for eg: create or replace view as select to_number(rating_cd....................
    Thank you.

  • To retrieve physical tables used in SP

    Hi all,
    Can anyone help me to get result for Retrieving list of physical tables used in Stored Procedure.
    Thanks in advance.
    Regards, Muthukumar Balu

    You need to run via loop to traverse all physical tables and issue
    SELECT * FROM sys.sql_modules
    WHERE definition LIKE '%'+@table_name+'%'
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Problem with parameters and non table based items

    Hi,
    I have a situation where I have some not table based items on a page (shuttles and select lists). It is parameters that the end user inputs. I have another page with the same items just here they are Display Only and also not table based. When the user press a button I branch from page 1 to page 2 and set the items on page 2. My problem is that the input the user keys in are not copied to the items on page 2. I can see the data in the session state.
    I assume that this is a silly question and I have just set Source Used or Source Type wrong one one of the items but I can not get it working. Can anybody help?
    It works fine if I use a Application Item and creates a process on page 1 where I copy the item value from the session state but that should be needed right?
    Regards Pete

    Thanks Scott,
    I think I got it working. If I remove all the colons from the data it works. I select several entries in a Shuttle and the result is a colon delimited string of values. If I remove these in a process it works fine. Is there a way of escaping the output from a Shuttle?
    Regards Pete

  • Querying a table based on a selection criteria

    Hi Gurus,
    Could you please help me in creating a function module that picks records from the table based on certain selection criteria.For eg, If contract number(a primary field) is an import parameter and I want the Function module to export all the records with contract number starting with 1 or may be ending with 303.How could I query this??
    Thanks,
    Ashwini

    Hello,
    Creation of Function Module
    Goto TCode SE37
    Click on the Menu Goto->Create Function Group
    Create Z (ZPTP) function group and Activate Function Group even if the error occurs
    Create Function module Namely Z (ZTEST) assign to the function group (ZPTP)
    Go to the Import parameters (EBLEN TYPE EKKO-EBELN)
    Go to the Tables ( itab type ekpo)
    Goto the Source code
    tables ekpo.
    Select * from ekpo into table itab
    where ebeln eq ebeln.
    Activate the function module and run the function
    regards
    suresh nair

  • How can i update rows  in a table based on a match from a select query

    Hello
    How can i update rows in a table based on a match from a select query fron two other tables with a update using sqlplus ?
    Thanks Glenn
    table1
    attribute1 varchar2 (10)
    attribute2 varchar2 (10)
    processed varchar2 (10)
    table2
    attribute1 varchar2 (10)
    table3
    attribute2 varchar2 (10)
    An example:
    set table1.processed = "Y"
    where (table1.attribute1 = table2.attribute1)
    and (table1.attribute2 = table3.attribute2)

    Hi,
    Etbin wrote:
    Hi, Frank
    taking nulls into account, what if some attributes are null ;) then the query should look like
    NOT TESTED !
    update table1 t1
    set processed = 'Y'
    where exists(select null
    from table2
    where lnnvl(attribute1 != t1.attribute1)
    and exists(select null
    from table3
    where lnnvl(attribute2 != t1.attribute2)
    and processed != 'Y'Regards
    EtbinYes, you could do that. OP specifically requested something else:
    wgdoig wrote:
    set table1.processed = "Y"
    where (table1.attribute1 = table2.attribute1)
    and (table1.attribute2 = table3.attribute2)This WHERE clause won't be TRUE if any of the 4 attribute columns are NULL. It's debatable about what should be done when those columns are NULL.
    But there is no argument about what needs to be done when processed is NULL.
    OP didn't specifically say that the UPDATEshould or shouldn't be done on rows where processed was already 'Y'. You (quite rightly) introduced a condition that would prevent redo from being generated and triggers from firing unnecessarily; I'm just saying that we have to be careful that the same condition doesn't keep the row from being UPDATEd when it is necessary.

Maybe you are looking for