The Variable value based on the results of SQL query

With the help of OBIEE 11.1

Is it possible to set the value of a variable presentation of the results of a SQL statement?

Scenario:

I have 2 topics.

SubjectArea1

Text1

Date1

SubjectArea2

Field1

Field2

UpdateDate

I have an analysis that uses only the SubjectArea2.

Using a dashboard quickly, the user must be able to select Text1 in the other topic area (SubjectArea1).

Assuming that selection will be stored in a variable of presentation (SelectedText),

The filter in the analysis should be something like

Upper UpdateDate to @{SelectedDate}

How can I set a variable (SelectedDate) using a SQL statement?

Something like this:

SELECT "Date1" TO "SubjectArea1" WHERE "Text1" = @{SelectedText}

So the command prompt text selection should give a date that is used to filter the second review?

If so:

The prompt on SA1.textCol

hidden analysis who is invited on SA1.texCol has SA1.dateCol in the criteria

Analysis SA2.dateCol is filetered on basis of the results of another analysis (any value analysis hidden SA1.dateCol)

Tags: Business Intelligence

Similar Questions

  • defining the results of a query to a variable

    Hi all

    I'm having a problem affecting the results of a query to a variable. What I'm trying to do, is to do an AJAX call to a .cfc file and pass back the results of the function. The main problem is, I'm again moving a block of HTML (resulting from a cfquery in a cfoutput) stored in a variable. My code is something like...

    < name cffunction = "getText" access = "remote" returntype = 'Cancel' >

    < datasource = "" #request.dsn # cfquery "name ="queryTable">"
    SELECT kort, infoB

    Of infoTable

    < / cfquery >


    < cfset result = ' <!-this is the part I'm stuck, I want the table go here. -> ">"

    < table >
    < cfoutput query = "tablequery" >
    < b >
    < td > #infoA # < table > < td > #infoB # < table >
    < /tr >
    < / cfoutput >
    < /table >


    < cfwddx action = "cfml2js" input = "" # result # ' toplevelvariable 'o' = > "

    < / cffunction >

    It is a simplified version of what I want to do, but you get the idea...

    Is it still the right way to go about this?  Thank you

    That's what I get for trying the E-mail response feature!  Are you not happy, that I double checked my post.

    You could do a lot of string concatenation here to do stuff like"& Kort &""& infoB &""> time and time again."  But in reality the tags is so much easier to use.



      

        
      

    #infoA #.#infoB #.

  • I need to return the result of a query on a stored procedure

    I need to return the result of a query to a stored procedure, I mean when I run a stored procedure it returns a result set in a select statement.
    Best regards...

    Hello.

    Do you really want a stored procedure for this?
    Why not just a script that contains the query?

    Assuming that you don't really want a stored procedure, you'll have to decide what to do with the results.
    An option is a slider.

    For example, you can write a procedure of this type to hold the query:

    CREATE OR REPLACE PROCEDURE USP_TEST
    (     out_cursor     OUT     SYS_REFCURSOR
    )
    IS
    BEGIN
         OPEN  out_cursor
         FOR     SELECT     *
              FROM     scott.emp;
    END  USP_TEST;
    /
    SHOW ERRORS
    

    You can move the cursor to another procedure for handling.

    You could test this in SQL * more by creating a variable blond:

    VARIABLE     usp_test_cursor     REFCURSOR;
    
    EXEC  usp_test (:usp_test_cursor);
    
    PRINT     :usp_test_cursor
    
  • Need to print the results of a query in a CASE statement

    I want to print the results of a query in a CASE statement:

    SELECT RUN_STATUS

    Of

    (select check BOX WHEN COUNT (ROW_WID) = 0 THEN 'NO JOBS RAN AFTER' |) (select sysdate - XXAFL_MINUTES MINUTE)

    END RUN_STATUS

    of W_ETL_RUN_SDTL

    where START_TS >

    (sélectionnez sysdate-MINUTES de XXAFL_MINUTES)) where RUN_STATUS is not null; e

    The query above subtracted 5 minutes from SYSDATE and he shoots XXAFL_MINUTES. I am doing this because we could change the number of minutes in the future. I want to print the number of minutes in the case statement.

    If I execute this statement, it throws an error stating:

    ORA-00937: not a single group group function

    00937 00000 - 'not a single-group function.

    * Cause:

    * Action:

    Error on line: 1 column: 96

    How can I include "select sysdate - MINUTES of XXAFL_MINUTES" in the CASE that it calculates the number of minutes and it prints with the results.

    Thanks in advance!

    Hey guys,.

    I found the solution:

    SELECT

    RUN_STATUS | TO_CHAR ((sélectionnez sysdate-MINUTES de XXAFL_MINUTES), 'HH24:MI:SS')

    Of

    (select check BOX WHEN COUNT (ROW_WID) = 0

    THEN "NO JOB RAN.

    END RUN_STATUS

    of W_ETL_RUN_SDTL

    where

    START_TS > (select sysdate - XXAFL_MINUTES MINUTE))

    where

    RUN_STATUS is not null;

    The output:

    NO JOBS RAN AFTER 09:07:54

    Thanks to you all!

  • Insert the result of a query select in another table

    Hello

    I have a strange problem when I try to insert all the results of a query select in another table, using the declaration of the order.

    With the declaration of COMMAND it works fine
    Work:
    ------------------------------
    INSERT INTO ADART01 (SELECT (codart)
    "STOCK". "" CODART_STO ".
    Of
    "DB". ' ' 'ACTIONS');
    ------------------------------

    But if I try to sort the result using the declaration of the ORDER, I have the following error:
    Error: ORA-00907 missing right parenthesis
    ------------------------------
    INSERT INTO ADART01 (SELECT (codart)
    "STOCK". "" CODART_STO ".
    Of
    "DB". "" "ACTIONS"
    ORDER BY
    "STOCK". ("' CODART_STO ASC ');
    ------------------------------

    Any idea?

    Thank you for your help,
    Angel.

    delete "()" to select

    create table test1 (a number, b varchar2(100));
    
    insert into test1
        (a, b)
        select level, 'level ' || level from dual connect by level < 101;
    
    insert into test1
        (a, b)
        select level, 'level ' || level from dual connect by level < 101 order by to_char(sysdate - level, 'D');
    
    select * from test1;
    
    drop table test1;
    
  • Store the result of SQL in the local file?

    Hello
    Is it possible to store the results of SQL (executed from ksh scripts) in the file on the local client (server not DB), I know how to do in SQLPlus, but want to simpify process using existing script .ksh calling Oracle and exec any SQL.

    Is this possible?

    TX
    M

    Well, you always need SQL * more:

    #!/bin/sh
    sqlplus -s username/password@tnsentry << EOF
    set trimout on trimspool on tab off echo off feed off verify off pages 0 lines 20000
    spool result.txt replace
    select * from emp;
    spool off
    exit
    EOF
    exit
    

    NOTE: code not tested, not Linux/Unix to play with for now

  • Export the results of a query to a CSV file

    Hello

    My requirement is that I need to export the results of a query to a CSV file. Can someone please suggest a way to also include the names of columns in the CSV file?

    Thanks in advance.

    Annie

    Following code comes from asktom. I changed to include the column header. This will get your CSV file desired for a given query.

    create or replace function  dump_csv( p_query     in varchar2,
                                          p_separator in varchar2
                                                        default ',',
                                          p_dir       in varchar2 ,
                                          p_filename  in varchar2 )
    return number
    AUTHID CURRENT_USER
    is
        l_output        utl_file.file_type;
        l_theCursor     integer default dbms_sql.open_cursor;
        l_columnValue   varchar2(2000);
        l_status        integer;
        l_colCnt        number default 0;
        l_separator     varchar2(10) default '';
        l_cnt           number default 0;
    
         l_colDesc          dbms_sql.DESC_TAB;
    begin
        l_output := utl_file.fopen( p_dir, p_filename, 'w' );
    
        dbms_sql.parse(  l_theCursor,  p_query, dbms_sql.native );
    
        for i in 1 .. 255 loop
            begin
                dbms_sql.define_column( l_theCursor, i,
                                        l_columnValue, 2000 );
                l_colCnt := i;
            exception
                when others then
                    if ( sqlcode = -1007 ) then exit;
                    else
                        raise;
                    end if;
            end;
        end loop;
    
        dbms_sql.define_column( l_theCursor, 1, l_columnValue, 2000 );
    
        l_status := dbms_sql.execute(l_theCursor);
    
         dbms_sql.describe_columns(l_theCursor,l_colCnt, l_colDesc);
    
         l_separator := '';
    
         for lColCnt in 1..l_colCnt
         loop
                utl_file.put( l_output, l_separator ||  '"' || Upper(l_colDesc(lColCnt).col_name) || '"');
                   l_separator := p_separator;
         end loop;
    
         utl_file.new_line( l_output );
    
        loop
            exit when ( dbms_sql.fetch_rows(l_theCursor) <= 0 );
            l_separator := '';
            for i in 1 .. l_colCnt loop
                dbms_sql.column_value( l_theCursor, i,
                                       l_columnValue );
                utl_file.put( l_output, l_separator ||  '"' ||
                                        l_columnValue || '"');
                l_separator := p_separator;
            end loop;
            utl_file.new_line( l_output );
            l_cnt := l_cnt+1;
        end loop;
        dbms_sql.close_cursor(l_theCursor);
    
        utl_file.fclose( l_output );
        return l_cnt;
    end dump_csv;
    

    The original link is below.

    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:95212348059

    Thank you
    Knani.

  • assign the value to a selection of the result of a query control

    I want to assign a value to my controls with the result of the query.

    It works for CFINPUT TEXT, but it does not work to SELECT

    I want to know are there any way tp affect my drop-down list value based on the result of questy.

    I have CFSTOREPROC as follows:

    < cfstoredproc procedure = "PSP" >

    < cfprocparam value = '#form. "IDNumber #" CFSQLTYPE = "cf_sql_integer" >

    < name cfprocresult = resultset "spResult" = "1" >

    < / cfstoredproc >

    < type CFINPUT = 'text' id = "txtIDNumber" value = "" #spResult.IDNumber # "/ >"

    I am able to name a TEXT of ENTRY CF as above the code value,

    < select id = "lstNumber" value = "#spResult.lstNumber #" > < / select >

    but it does not affect the value of my result of the query to SELECT entry.

    Is it possible to assign a value to the query result SELECTION control?

    I tried to use JavaScript that works if I pass a number, but it does not work if I pass a query result,

    Your help is very appreciated,

    Kind regards

    Iccsi,

    @Iccsi,

    My bad!  Yes, you will either need to the CFOUTPUT tag (that you commented out in your code) but without specifying a query or change the CFLOOP query CFOUTPUT = "Notes".  If one of these should work:

    OR

    -Carl V.

  • Is it possible to put the results of a query in a variable to use in the bean class?

    Hello, I am using JDeveloper 12.1.2.0.0

    I like to keep the result of my queries (the method that I created in the AppModule) in a richeTableau or another type of variable, so I can get results and I don't have to make unnecessary after queries. I don't think that the query is the problem but keeping the results.

    I tried to do in using this:

    public String testVFactSales (String conditions) {}

    PreparedStatement query = getDBTransaction () .createPreparedStatement ("" + "select * from v_fact_sales"+ conditions, 0 ");

    ResultSet rs;

    Outcome of the result set;

    Result of the richeTableau;

    String result = null;

    try {}

    query.setString (1, conditions);

    Query.Execute ();

    Query.Execute ();

    result = query.getGeneratedKeys ();

    Query.Close ();

    System.out.println ("result:" + result.toString ());

    return result.toString ();

    } catch (SQLException e) {}

    e.printStackTrace ();

    }

    Return ' ';

    }

    As you can see, I have already tried a few solutions, but so far I have only errors (cannot convert or null exception, when I try to put the result in a richeTableau in my bean class)

    Any ideas?

    It is very important for me, because it would improve the performance of my project a lot.

    Kind regards

    Frederico.

    Although the issue is not 100% responded, I used the idea that Shay told me, where you can create a method in your AppModule to set your where clause!

    Good luck to everyone who has the same problem.

    As an attack similar to what I wanted in the first place, you can check this:

    https://community.Oracle.com/thread/2619669

    Kind regards

    Frederico.

  • Cannot display the results in SQL Developer

    Hello Experts - I installed Oracle SQL Developer, just ran simple query. Nothing appears in the results window. Can you please let me know why?

    Select * of the double

    Done «I installed...» "mean you use 4.1.0? Or is it an older version, perhaps even an Early Adopter version? Have you installed in an empty folder? Were there no migration of user settings step?  Did you run the SQL statement (even if it is technically incorrect, as posted here, I guess the Oracle manages Analyzer) using the declaration of implementation (Ctrl + Enter) or run (F5) Script?

    So, you do not have much to do, but...

    1. try to use the latest version of production, installed in an empty folder.  In fact, the 4.1.1 patch comes out.

    2. try to click on the little black down, arrow down to the left of the box of the spreadsheet to see if that exposes a results pane.

    3. try window > Windows reset factory settings if you think that the layout of fenestration of the product is somehow screwed up.

    4. try view > log to see which makes its appearance in the statements of the Log pane tab when you run the SQL (version 4.1.0 & upward).

  • The results of F1-QUERY-how to restrict or to SQL with the role of access to the data?

    Hello

    With the help of CC & B 2.3.1.

    I'm configuration of a Zone of F1-OF-QUERY to get and display customer information as level account; the filter criteria will be Geo val SP.

    With our application, we use access to accounts and groups access to the data on users roles to restrict access to sensitive accounts, such as VIP.

    What keywords should I use in the SQL statement to limit the results only for group accounts to which access is included in the Dar of the user?

    Example: If the user has DAR 'STANDARD', it won't see accounts with group access 'VIP '.

    I tried unsucessfully: USER: USER ID,: USER_ID.

    Unsucessfull example:

    Select dar_cd, user_id, expire_dt
    of ci_dar_usr
    Where user_id =: USER_ID
    and expire_dt > =: F1

    Thks,

    Fabien

    Hi, Fabien,

    If you are looking to determine the current user in the box,
    the keyword to use is: USERID

    You can check the zone of F1 "F1-FAVSCR" for its use.

  • Compare the result of a query with a number and return a message

    Hello
    I have the following query in oracle 9i:

    SELECT COUNT (*)
    OF hourly_files
    WHERE date_received = TO_DATE ((SELECT TO_CHAR (SYSDATE - INTERVAL '1' DAY, 'DDMMYYYY')
    (THE DOUBLE), 'DDMMYYYY');

    This will produce a number of lines required

    I need to compare the number of output with another number hardcoded (threshold) and print an appropriate example message

    If the result of the query above is 18000 and the number of threshold is fixed at 20000, then output a meesage:

    Number of files received less than 2000

    Any help will be very appreciated!

    Thank you.
    SQL> ed
    Wrote file afiedt.buf
    
      1  SELECT CASE WHEN COUNT(*) >5 THEN 'Number is > than 5'
      2              WHEN COUNT(*) <1 THEN 'Its less than 1'
      3  ELSE 'Its in between'
      4  END
      5  FROM emp
      6* WHERE deptno=20
    SQL> /
    
    CASEWHENCOUNT(*)>5
    ------------------
    Its in between
    
    SQL> SELECT COUNT(*) FROM emp
      2  WHERE deptno=10;
    
      COUNT(*)
    ----------
             3
    
  • How can I parse the XML file using the Oracle's Sql query.

    Hi all
    I have an XML file that must analyze and display the result according to the following example
    Can you please recommend me an approach to get the result.

    For example, here is my XML:

    <? XML version = "1.0" encoding = "UTF-8"? >
    < xmlns:pi = "urn:com.workday / picof pi: Extract_Employees" >
    < IP: employee >
    < Additional_Information: pi > < pi: pi function: PriorValue = "" > Intern - masteri¿½s < / pi: function >
    < / pi: Additional_Information >
    < / pi: employee >
    < / pi: Extract_Employees >

    Databases:

    Oracle Database 10 g Enterprise Edition release 10.2.0.3.0 - production

    SQL > SELECT * FROM NLS_DATABASE_PARAMETERS;

    NLS_LANGUAGE AMERICAN
    NLS_TERRITORY AMERICA
    NLS_CURRENCY $
    NLS_ISO_CURRENCY AMERICA
    NLS_NUMERIC_CHARACTERS.,.
    WE8ISO8859P1 NLS_CHARACTERSET
    NLS_CALENDAR GREGORIAN
    NLS_DATE_FORMAT DD-MON-RR
    NLS_DATE_LANGUAGE AMERICAN
    NLS_SORT BINARY
    NLS_TIME_FORMAT HH.MI. SSXFF AM
    NLS_TIMESTAMP_FORMAT-DD-MON-RR HH.MI. SSXFF AM
    NLS_TIME_TZ_FORMAT HH.MI. SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI. SSXFF AM TZR
    NLS_DUAL_CURRENCY $
    BINARY NLS_COMP
    NLS_LENGTH_SEMANTICS BYTES
    NLS_NCHAR_CONV_EXCP FAKE
    NLS_NCHAR_CHARACTERSET AL16UTF16
    NLS_RDBMS_VERSION 10.2.0.3.0



    The Xml file above with UTF-8 character sets which is multi bytes.

    But in my character database is WE8ISO8859P1 for example ISO-8859-1 (single-byte character set)

    SQL > SELECT extractValue (Value (x) ', ' / pi:Employee/pi:Additional_Information/pi:Job_Title','xmlns:pi="urn:com.workday/picof ' ')
    TABLE (XMLSequence (extract (XMLType (bfilename('XMLDIR','XML_Issue_227176.xml'), nls_charset_id ('AL32UTF8')),'/ pi: Employee ',' xmlns:pi="urn:com.workday/picof"'))) x;)))


    which gives the following error:

    Error:
    ORA-31011: XML parsing failed
    ORA-19202: an error has occurred in the processing of XML
    LPX-00200: could not convert from UTF-8 encoding to ISO-8859-1
    Error on line 1
    ORA-06512: at "SYS." XMLTYPE", line 295
    ORA-06512: at line 1

    Also I tried with this
    SQL > SELECT convert (extractValue (Value (x), ' / pi:Employee/pi:Additional_Information/pi:Job_Title','xmlns:pi="urn:com.workday/picof"'),'WE8ISO8859P1 ', 'UTF8'))
    TABLE (XMLSequence (extract (XMLType (bfilename('XMLDIR','XML_Issue_227176.xml'), nls_charset_id ('AL32UTF8')),'/ pi: Employee ',' xmlns:pi="urn:com.workday/picof"'))) x;)))

    The same error is according to the above error message.

    Please help in this regard.

    Thank you and best regards,
    Sandrine

    You know the code of real character behind "" or you receive the file like that?

    For the record, "" is the wildcard of UTF-8 (0xEFBFBD), so that the original character of the means has already been replaced and that very probably the file was not coded properly in the first place.

    With respect to the resolution of the problem, try another method to read the file:

    SQL> select value from nls_database_parameters where parameter = 'NLS_CHARACTERSET';
    
    VALUE
    ----------------------------------------
    WE8ISO8859P15
    
    SQL> SELECT x.*
      2  FROM XMLTable(
      3         XMLNamespaces(default 'urn:com.workday/picof')
      4       , '/Extract_Employees/Employee'
      5         passing xmltype(
      6                   dbms_xslprocessor.read2clob(
      7                     'COP_DIR'
      8                   , 'XML_Issue_227176.xml'
      9                   , nls_charset_id('AL32UTF8')
     10                   )
     11                 )
     12         columns job_title varchar2(30) path 'Additional_Information/Job_Title'
     13       ) x
     14  ;
    
    JOB_TITLE
    ------------------------------
    Intern -  Master¿s
     
    
  • between the clause of sql query?

    Hi all

    After sql query using a report.
    ------------------------------------------------

    Select trunc (m.spc_doc_date) prod_date, sum (nvl(d.req_qty,0)) order_qty, sum (nvl(d.spc_item_qty,0)) prod_qty
    of spc_ppc_daily_m m, spc_ppc_daily_d d
    where m.spc_doc_ # in (select spc_doc_ # to spc_ppc_daily_m)
    - and d.blce_qty > 0
    and m.spc_locn_code =: locn_code
    and m.spc_doc_date between: TO_date and: FROM_date
    and m.spc_locn_code = d.spc_locn_code
    and m.spc_doc_ #= d.spc_doc_ #.
    and (m.obu =: obu OR: OLGA IS NULL)
    and (m.customer =: customer OR: CUSTOMER IS NULL)
    Trunc Group (m.spc_doc_date)
    order of trunc (m.spc_doc_date)

    -----------------------------------------

    "When I use to_date = 22 February 2012 ' from_date = February 22, 2012"
    There is no pick up. (acually documents are there on February 22, 2012)

    "When I use to_date = 22 February 2012 ' from_date = February 23, 2012"
    now shows data of February 22, 2012.

    I have replace between it of > = & < =, same result two cases respectively.

    Why?

    Thank you
    Yoann

    date you hours minutes and seconds
    then

    use
    trunc (m.spc_doc_date)

    or to: from_date in the parameter after form convert to February 23, 2012 23:59:59 '

  • The analysis of SQL query

    Hi all

    In addition to the discussion of yesterday (https://community.oracle.com/message/11317343#11317343)

    For a list of the table used in the SQL query, there is another way.

    If we plan to explain for the query command, table plan we will be able to get all the table names.

    But in the query, if we used all the views, the tables used in the underlying views are also the list.

    I don't know how to do to get the name of view only, not the names of the underlying tables.

    Thank you

    Manon...

    Dint you pick me up I guess. If you see the plan for performance that I posted you will find oracle have not all table EMP scan. There is therefore no reference to the EMP table in the PLAN_TABLE.

    SQL > delete from plan_table;

    0 rows deleted.

    SQL > explain the plan for
    2. Select empno in emp;

    He explained.

    SQL > select * from plan_table where object_type = "TABLE";

    no selected line

Maybe you are looking for