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 #.

Tags: ColdFusion

Similar Questions

  • 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.

  • How to store the result of a query in a variable in the data model

    In a model of date I want to do something like this

    < name of dataTemplate = than one dataSourceRef "HURDetail" = "BRM_DATA_SOURCE" >
    < Parameters >
    < parameter name = "PARAM_THRESHOLD_VALUE" dataType = "number", defaultValue = "0" / >
    < / Parameter >

    < SQLStatement instance name = "Q1" >
    <! [CDATA]
    SELECT count (*) FROM TABLE_NAME
    []] >
    < / sqlStatement >

    -I want to assign the output of the above query to PARAM_THRESHOLD_VALUE so I can use it in future requests...
    -My query is complex, for reason of performance I want to store the output of the query.

    Please suggest how do...
    Made a package with the PARAM_THRESHOLD_VALUE parameter and the function value entry assigns the done variable to work?

    Thank you
    Shiva

    Hey Shiva,

    If you want to use the value of the counter in the other queries in the data model, you can have an alias for the extraction of County and use it as a bind variable in other queries as


    SELECT count (*) PARAM_THRESHOLD_VALUE
    FROM TABLE_NAME
    ]]>

    and can use it in another query as


    SELECT XYZ
    FROM TABLE_NAME2
    WHERE XXX = *: PARAM_THRESHOLD_VALUE *.
    ]]>

    Hope this is what you want.
    Thank you.

  • 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;
    
  • 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
    
  • 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.

  • 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.

  • 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.

  • 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 to define the result of a call sequence of pass/fail

    Hi all

    in my application, I have a pass/fail with the adapter of the test sequence. The Source of data for the stage is Step.Result.PassFail.

    Is it possible to tell the appellant (the stage of appeal for success/failure sequence) the result within the sequence? I've experimented with the RunState.Caller, but did not find any property that applies to the PassFail result.

    Madottati

    This link is not very useful and, in my view, is not the right solution for you.

    It makes not sense why you need to change the Step.Result.PassFail inside your sequence.  It is not evaluated until after that sequence is returned to the caller.  So why not just pass back a parameter and and set the Step.Result.PassFail parameter.  I've attached a picture that shows.

    However, if it is essential that you change in the subsequence Fail pass then use this expression:

    RunState.Caller.Step.Result.PassFail = here, a Boolean expression

    It won't evaluate at time of publishing, but will work during runtime.

    The reason why you use Pass/Fail card combination and sequence is to create a modularized test.  Let's say you need to call several code modules in order to obtain pass/fail status.  Think of it as a function or a Subvi.  It just creates a clean, maintainable code.

    Hope this helps,

  • 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)

  • Store the result of a function in a variable

    Hello
    I have an interface where I do some transformations (get Oracle COST of the corresponding values of PeopleSoft). For research, I have a PL/SQL function in place. This function takes the values of the columns in my input in the runtime source data store. I want to store the result of the function in a variable, use the variable instead of calling the function again later. Any help is appreciated.

    Hello

    I had the problem...

    Gotta 'keep' the same order value to execute the PL/SQL only once...

    In this case, a first suggestion is:

    (1) create an interface to load a temporary table (yellow interface). The target table will be the PK and a field with the PL/SQL returned returns. The source will have the same tables as the real interface.
    Remember, IKM, to set the create table and options to truncate to 'yes '.

    2) add the temporary table to the real interface (drag / move the yellow interface itself in the source of real interface box) and create a join by PK.

    (3) just to map the column transformed (from the temporary table) for columns 4 targets...

    This help you?

    Published by: Cezar Santos on 02/12/2008 13:52

  • Divide the result from a query

    Hello

    I want to split/Group (I'm not sure about terms) a result of the query. Suppose I get a query with 50 results. I would like to show only 4 then the next 4 etc.. I have the following code that displays arrows active and inactive.
    I imagine the create a loop around my results of the 4 games and place each of these sets in a DIV. Images of related arrow would then show hide resp. the DIVs.

    The code below, I've prepared this day but I can't continue because can not resolve the above question and then find an effective idea of showing each result set.

    Someone has a good entry? It would be great!

    Thank you very much

    Here is the solution to my problem:
    http://www.Adobe.com/cfusion/webforums/Forum/MessageView.cfm?CATID=3&ThreadId=1402501

  • define the result

    Hi all

    I just want to know how to create a result that is displayed as a result of the State:

    example is similar to

    If the output equal to 1 = good
    2 = better
    3 = excellent

    someone at - he had the idea how I can do?
    Thank you

    Nadège azym
    UTHM
    Malaysia


Maybe you are looking for