Dynamic query name

Hello,
I sure home someone can help me with this.
I am trying to run dynamic loops and am stumped with how to
call a variable name.
As you can see, calling the variable names just isnt going to
work out the way I am trying to do this. Can someone steer me in
the correct direction?
thanks,
Matt

quote:
fyrehed wrote:
I pulled out a ton of code, trying to simplify
That's appreciated. But it was not obvious that the omission
was deliberate and truthfully your code sample is confusing because
few of the variables and query names match up.
For example, you're storing a list of the ID's from the
"getnums" query here
........<cfset leaguelist=valuelist(getnums.id)>
Then you're looping through a 2nd query named "GetInfo".
Where does that query come from?
........<cfloop query="Getinfo">
Inside the loop the code references a 3rd query named
"getLeagues"
........<cfquery datasource="#my.dsn#"
name="get#getLeagues.id#">
Then a 4th query is used in the where clause
........Where leagueID='#Getinums.leagueid#'
So its unclear how many you have and which ones you're
actually using. Honestly, the cfloops seem like an over
complication. Unless you have another reason for using them, you
could probably do the same thing more simply by using one cfquery
with a JOIN and <cfoutput> with "group". That said, one
problem that jumps out at me is here
quote:
<cfloop from"1" to="#listlen(leaguelist)#" index="i">
<table>
<cfloop query="get#i#">
<cfif get#i# currentrow mod 2 eq 0>
The queries were named using #getLeagues.id#. So you must use
the
id value, not the list index #i#. Also, you don't need to
use the query name inside your query loop.
<cfloop list="#leagueList#" index="currentID">
<table>
<cfoutput query="get#currentID#">
<cfif currentrow mod 2 eq 0>

Similar Messages

  • How to find table name(s) in a dynamic query

    In one of our (9iAS PORTAL)applications, any user can able to run their query statment and get output. All queries will be executed as dynamic SQL thru' a common shema/user who has 'SELECT' privilege on all tables but all users don't have this privilege on all tables. Now, before executing any query I need to find out what are the table name(s) used in this query to check the privilege for the respective user. How do I extract all table names being used in a dynamic query?.
    Thanks
    -Krishnamurthy

    I guess that his users log in to application first, then application uses one account to log in to database, so application are not direct database user since all users share the same account to database. If so, when a user lgins in, you may write it down from application to a database audit table, and you need to write down the dynamic query to the database audit table too, then you may query that audit table to find out. up to here, it looks that your application has to do more to assign what role to a user running the application, since database does not know what user is assessing it.

  • How to set dynamic table name in sql query?

    I want set dynamic table name by parameter in sql query,just like:
    select * from :tbname
    but run report is error,BI P report table name is invalidation.
    What can i do? Thanks!

    Hi,
    that's only possible inside a data template with a lexical parameter.
    Regards
    Rainer

  • Dynamic table name, how to query?

    Hi!
    There is a table name that is decided dynamically. the name is:
    someNameYYY where YYY denotes the client number.
    I get the client number by sy-mandt and concatenate it with someNameYYY to lc_table_name but then comes the problem:
    I cannot do
    SELECT *
    FROM  lc_table_name
    because I get compiler error "lc_table_name" is not defined in ABAP dictionary.
    How do I query a table with the name decided dynamically?
    regards
    Baran

    You can have do something like this :
    REPORT ZTABLE_DOWNLOAD .
    tables :
    dd02l,    "SAP Tables
    dd03l,    "Table fields
    dd04t.    "R/3 DD: Data element texts
    constants : c_activation_status(1)  value 'A',
               c_tabclass(6) type c    value 'INTTAB',
               c_language(2) type c    value 'EN'.
    type-pools : slis.
    selection-screen begin of block b1 with frame title text-003.
    *parameters :p_mandt like t001-mandt obligatory default '560'.
    parameters :p_table like dd03l-tabname obligatory.
    selection-screen end of block b1.
    data:
    table_desc(70) type c,
    table_field like dd03l-fieldname,
    total_rows type i,
    t_rows(20) type c.
    field-symbols:
    <fs_line> type any,
    <fs_field> type any.
    at selection-screen.
    *Check for the existence of the table
    select single * from dd02l where tabname  = p_table
                                and   as4local = c_activation_status.
    if sy-subrc ne 0.
    *Table is not active in dictionary
       message e999(zs) with 'Table is not active in dictionary'.
    elseif dd02l-tabclass = c_tabclass.
    *It is a structure not a table
       message e999(zs) with 'This is a structure not a table'.
    endif.
    start-of-selection.
    perform table_data_display.
    end-of-selection.
    form table_data_display.
    data:
    l_long_type type i,
    lx_struct   type ref to data,
    lt_table    type ref to data,
    lcl_sdescr  type ref to cl_abap_structdescr,
    lx_lvc_cat  type lvc_s_fcat,
    lt_lvc_cat  type lvc_t_fcat,         "Field catalog
    lx_fieldcat type slis_fieldcat_alv,
    lt_fieldcat type slis_t_fieldcat_alv,
    lx_layout   type slis_layout_alv,
    lt_sort     type slis_t_sortinfo_alv, "Sort table
    ls_sort     type slis_sortinfo_alv.
    field-symbols :
    <fieldcat>    type slis_fieldcat_alv,
    <lt_table>    type table,
    <fs>          type any,
    <components>  type abap_compdescr.
    *Dynamic creation of a structure
    create data lx_struct type (p_table).
    assign lx_struct->* to <fs>.
    *Get the field structure
    lcl_sdescr ?= cl_abap_typedescr=>describe_by_data( <fs> ).
    loop at lcl_sdescr->components assigning <components>.
    *Do not display field "MANDT"
       IF sy-tabix = 1 AND <components>-name = 'MANDT'.
         CONTINUE. "next loop
       ENDIF.
    *Build fieldcatalog
       lx_lvc_cat-fieldname = <components>-name.
       lx_lvc_cat-ref_table = p_table.
       append lx_lvc_cat to lt_lvc_cat.
       lx_fieldcat-fieldname   = <components>-name.
       lx_fieldcat-ref_tabname = p_table.
       append lx_fieldcat to lt_fieldcat.
    endloop.
    *Create an internal table
    call method cl_alv_table_create=>create_dynamic_table
    exporting it_fieldcatalog = lt_lvc_cat
    importing ep_table        = lt_table.
    assign lt_table->* to <lt_table>.
    *Read the data
        select * from (p_table)
       into corresponding fields of table <lt_table>
       order by primary key.
      loop at <lt_table> assigning <fs_line>.
      assign component 'MANDT' of
             structure <fs_line> to <fs_field>.
          <fs_field> = p_mandt.
      endloop.
    if <lt_table>[] is initial.
    *No table enties are existing
       message e003(zdynamictable) with p_table.
       exit.
    else.
       describe table <lt_table>[] lines total_rows.
       t_rows = total_rows.
       shift t_rows left deleting leading space.
    endif.
    *Specify the layout
    lx_layout-zebra = 'X'.
    lx_layout-colwidth_optimize = 'X'.
    *Display the ALV List
    select single ddtext into table_desc from dd02t
    where tabname eq p_table and ddlanguage eq c_language.
    check not table_desc is initial.
    concatenate  'Entries from table:'
    p_table '(' table_desc ')' '-:' t_rows 'Entries Found' into
    table_desc
    separated by space.
    *Start - Download the data to excel sheet by validating the file path.
    data:
    *lv_filename type string,
    lv_fname_validate like rlgrap-filename.
    *CONCATENATE 'C:\ZTABLE_DWN\' P_TABLE '.Xls' INTO LV_FILENAME.
    *CONCATENATE '
    Pc-p31061\Harman\Tasks\ZTABLE_DWN\' P_TABLE '.xls' INTO
    CONCATENATE 'C:\ZTABLE_DWN\' P_TABLE '.xls' INTO
    LV_FNAME_VALIDATE.
    call function 'WS_FILE_DELETE'
    exporting
       file          = lv_fname_validate
    IMPORTING
      RETURN        =
    CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
      BIN_FILESIZE                  = ' '
      CODEPAGE                      = ' '
      FILENAME                      =  LV_FNAME_VALIDATE
      FILETYPE                      = 'DAT'
    IMPORTING
      FILELENGTH                    =
    TABLES
       DATA_TAB                      = <lt_table>.
    *call function 'GUI_DOWNLOAD'
    exporting
      BIN_FILESIZE                  =
       filename                      = lv_fname_validate
      filetype                      = 'ASC'
      write_field_separator           =  'X'
    IMPORTING
      FILELENGTH                    =
    tables
       data_tab                      = <lt_table>.
    End of Download.
    call function 'REUSE_ALV_GRID_DISPLAY'
      exporting
        i_background_id                   = 'ALV_BACKGROUND'
        i_grid_title                      = table_desc
        is_layout                         = lx_layout
        it_fieldcat                       = lt_fieldcat
       tables
         t_outtab                          = <lt_table>
      exceptions
        program_error                     = 1
        others                            = 2
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    clear table_desc.
    endform.                    " table_data_display

  • Dynamic alias name in query

    Is it possible to use dynamic alias name in query for interactive report?
    I have this SELECT and I would like to use the parameters used in alias request to build a dynamic crosstab report:
    SELECT p.annee AS "Ann&eacute;e", p.desc_rls AS "RLS",
    SUM(CASE WHEN p.age BETWEEN :P2_AGE1 AND :P2_AGE2 THEN p.pop END) "0-4 ANS",
    SUM(CASE WHEN p.age BETWEEN :P2_AGE3 AND :P2_AGE4 THEN p.pop END) "5-9 ANS",
    SUM(CASE WHEN p.age BETWEEN :P2_AGE5 AND :P2_AGE6 THEN p.pop END) "10-14 ANS"
    FROM pop_rls_isq_111 p
    GROUP BY ROLLUP(p.annee, p.desc_rls);
    Instead of coding "0-4 ANS" as alias, I would like for example use the parameters ":P2_AGE1 - :P2_AGE2 ANS".

    Hi,
    to make your column headings dynamic you can use the substitution syntax in the "Column Heading" property of your IR columns. For example:
    &P2_AGE1. - &P2_AGE2. ANSHope that helps
    Patrick
    My blog: http://www.oracleapex.info/
    New Check out the Oracle APEX Essentials!

  • Dynamic table name in native sql query

    Can i pass a dynamic table name in this query ---
                EXEC SQL PERFORMING APPEND_MTO.
                  SELECT          
                               LTOG_QUANTITY_TYPE,
                               FCONO,
                              WBSELEMENT,
                             PROJECT
                  INTO   :IMTO
                  FROM  RWORKS.MTO_ISO_V2
                  WHERE LTOD_DATE > TO_DATE(:MAXD,'YYYYMMDDHH24MISS')
                ENDEXEC.
    How can i pass this table name RWORKS.MTO_ISO_V2  dynamically in the query
    Edited by: Madhukar Shetty on Nov 26, 2009 2:40 PM

    Can i pass a dynamic table name in this query ---
                EXEC SQL PERFORMING APPEND_MTO.
                  SELECT          
                               LTOG_QUANTITY_TYPE,
                               FCONO,
                              WBSELEMENT,
                             PROJECT
                  INTO   :IMTO
                  FROM  RWORKS.MTO_ISO_V2
                  WHERE LTOD_DATE > TO_DATE(:MAXD,'YYYYMMDDHH24MISS')
                ENDEXEC.
    How can i pass this table name RWORKS.MTO_ISO_V2  dynamically in the query
    Edited by: Madhukar Shetty on Nov 26, 2009 2:40 PM

  • Dynamic change in the query name based on user input

    Hi Gurus,
    In a scenario, country appears as a user input variable.When the user specifies his country, the same query displays <b>Business trends</b>' data pertaining to his own country and rest of the world(international) in two tables.The reports are developed using Web application designer.
    Can the name(description) of the query be changed  so that the user input value for country gets dynamically reflected in the query name like <b>Business trends:Selected country vs International</b>?
    Regards,
    Balaji

    Hi Bala,
      ya this can be done by text variables. create a text variable( replacement path on the country infoobject) by going to the query properties on the description.
    if the user enters country value then it will be displaed on the description of the query .
    assign points if useful .
    regards
    santosh

  • Giving dynamic sheet name while importing data from Excel in OPENROWSET query

    I want to import data from Excel to table in SQL server. Sheets in Excel file can have any name. I want to get data from first sheet of the excel file. 
    CREATE PROC CopyExcelDataToTempTable
    @ExcelPath VARCHAR(1000)
    AS
    BEGIN
    EXEC sp_configure 'show advanced options', 1;
    RECONFIGURE;
    EXEC sp_configure 'ad hoc distributed queries', 1;
    RECONFIGURE;
    EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1;
    EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1;
    INSERT INTO TempData
    SELECT *
    FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
    SELECT CONCAT('Excel 12.0 Xml;HDR=YES;Database=', @ExcelPath),
    'SELECT * FROM [Sheet1$]');
    END;
    Currently I am giving Sheet1 as static name in Select statement. But my sheet name is not fixed. I want to create a dynamic query. If getting Sheet name is not possible then can we put sheet with its index in Select query? There is no front end. Whatever I
    want to do is in SQL server 2012. Is there any solution for this problem?

    Hi Ajinkya,
    To get the sheet names from an excel, you can use the Stored Procedure
    SP_TABLES_EX. See the below code.
    EXEC sp_addlinkedserver 'ExcelSource', '',
    'Microsoft.ACE.OLEDB.12.0',
    'c:\worksheet.xls',
    NULL,
    'Excel 8.0'
    EXEC sp_addlinkedsrvlogin 'ExcelSource', 'false'
    GO
    EXECUTE SP_TABLES_EX 'ExcelSource'
    the names in the worksheet.xls and execute result are like below.
    Table name
    a
    b
    c
    d
    Regarding your description, you need the first sheet of your excel. As the result shows, the sheet names are sorted, so there’s no guarantee to get the first one. The SP can work as a workaround when there’s only one sheet in your excel or the required sheet’s
    name is customized to be sorted at the top first.
    If you have any question, feel free to let me know.
    Best regards,
    Eric Zhang

  • Get alias name from dynamic query

    Hi All,
    I would make a plsql function using dynamic query.
    And the function takes a whole sql query as a parameter.
    The main issue is that the function should get what alias or columns were queried.
    For example,
    FUNCTION_GET_QUERY_ALIAS('SELECT 1 AS col1, 2 AS col2 FROM DUAL')
    Inside the function, it should find the alias name COL1 and COL2.
    I'd appreciate for any help.

    I have modified print_table as function and made it to satisfy your needs.
    SQL> CREATE OR REPLACE TYPE my_column_object AS OBJECT(ruw_number integer, column_name VARCHAR2(1000), column_val VARCHAR2(1000))
      2  /
    Type created.
    SQL> CREATE OR REPLACE TYPE my_table_type AS TABLE OF my_column_object
      2  /
    Type created.
    SQL> CREATE OR REPLACE FUNCTION print_table( p_query in varchar2 ) RETURN my_table_type PIPELINED
      2  AS
      3      l_theCursor     INTEGER DEFAULT DBMS_SQL.OPEN_CURSOR;
      4      l_columnValue   VARCHAR2(4000);
      5      l_status        INTEGER;
      6      l_descTbl       DBMS_SQL.DESC_TAB;
      7      l_colCnt        NUMBER;
      8      l_rcount           INTEGER := 0;
      9  BEGIN
    10      DBMS_SQL.PARSE(  l_theCursor,  p_query, dbms_sql.native );
    11
    12      DBMS_SQL.DESCRIBE_COLUMNS( l_theCursor, l_colCnt, l_descTbl );
    13
    14      FOR i IN 1 .. l_colCnt
    15      LOOP
    16          DBMS_SQL.DEFINE_COLUMN(l_theCursor, i, l_columnValue, 4000);
    17      end loop;
    18
    19      l_status := DBMS_SQL.EXECUTE(l_theCursor);
    20
    21      WHILE ( DBMS_SQL.FETCH_ROWS(l_theCursor) > 0 )
    22      LOOP
    23             l_rcount := l_rcount + 1;
    24          FOR i IN 1 .. l_colCnt
    25          LOOP
    26              DBMS_SQL.COLUMN_VALUE( l_theCursor, i, l_columnValue );
    27
    28              PIPE ROW(my_column_object(l_rcount,l_descTbl(i).col_name,l_columnValue));
    29          END LOOP;
    30      END LOOP;
    31
    32     RETURN;
    33  end;
    34  /
    Function created.
    SQL> select * from table(print_table('select * from emp'))
      2  /
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
             1 EMPNO                7369
             1 ENAME                SMITH
             1 JOB                  CLERK
             1 MGR                  7902
             1 HIREDATE             17-DEC-80
             1 SAL                  800
             1 COMM
             1 DEPTNO               20
             1 DIV                  10
             2 EMPNO                7499
             2 ENAME                ALLEN
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
             2 JOB                  SALESMAN
             2 MGR                  7698
             2 HIREDATE             20-FEB-81
             2 SAL                  1600
             2 COMM                 300
             2 DEPTNO               30
             2 DIV                  10
             3 EMPNO                7521
             3 ENAME                WARD
             3 JOB                  SALESMAN
             3 MGR                  7698
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
             3 HIREDATE             22-FEB-81
             3 SAL                  1250
             3 COMM                 500
             3 DEPTNO               30
             3 DIV                  10
             4 EMPNO                7566
             4 ENAME                JONES
             4 JOB                  MANAGER
             4 MGR                  7839
             4 HIREDATE             02-APR-81
             4 SAL                  2975
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
             4 COMM
             4 DEPTNO               20
             4 DIV                  10
             5 EMPNO                7654
             5 ENAME                MARTIN
             5 JOB                  SALESMAN
             5 MGR                  7698
             5 HIREDATE             28-SEP-81
             5 SAL                  1250
             5 COMM                 1400
             5 DEPTNO               30
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
             5 DIV                  10
             6 EMPNO                7698
             6 ENAME                BLAKE
             6 JOB                  MANAGER
             6 MGR                  7839
             6 HIREDATE             01-MAY-81
             6 SAL                  2850
             6 COMM
             6 DEPTNO               30
             6 DIV                  10
             7 EMPNO                7782
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
             7 ENAME                CLARK
             7 JOB                  MANAGER
             7 MGR                  7839
             7 HIREDATE             09-JUN-81
             7 SAL                  2450
             7 COMM
             7 DEPTNO               10
             7 DIV                  10
             8 EMPNO                7788
             8 ENAME                SCOTT
             8 JOB                  ANALYST
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
             8 MGR                  7566
             8 HIREDATE             19-APR-87
             8 SAL                  3000
             8 COMM
             8 DEPTNO               20
             8 DIV                  10
             9 EMPNO                7839
             9 ENAME                KING
             9 JOB                  PRESIDENT
             9 MGR
             9 HIREDATE             17-NOV-81
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
             9 SAL                  5000
             9 COMM
             9 DEPTNO               10
             9 DIV                  10
            10 EMPNO                7844
            10 ENAME                TURNER
            10 JOB                  SALESMAN
            10 MGR                  7698
            10 HIREDATE             08-SEP-81
            10 SAL                  1500
            10 COMM                 0
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
            10 DEPTNO               30
            10 DIV                  10
            11 EMPNO                7876
            11 ENAME                ADAMS
            11 JOB                  CLERK
            11 MGR                  7788
            11 HIREDATE             23-MAY-87
            11 SAL                  1100
            11 COMM
            11 DEPTNO               20
            11 DIV                  10
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
            12 EMPNO                7900
            12 ENAME                JAMES
            12 JOB                  CLERK
            12 MGR                  7698
            12 HIREDATE             03-DEC-81
            12 SAL                  950
            12 COMM
            12 DEPTNO               30
            12 DIV                  10
            13 EMPNO                7902
            13 ENAME                FORD
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
            13 JOB                  ANALYST
            13 MGR                  7566
            13 HIREDATE             03-DEC-81
            13 SAL                  3000
            13 COMM
            13 DEPTNO               20
            13 DIV                  10
            14 EMPNO                7934
            14 ENAME                MILLER
            14 JOB                  CLERK
            14 MGR                  7782
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
            14 HIREDATE             23-JAN-82
            14 SAL                  1300
            14 COMM
            14 DEPTNO               10
            14 DIV                  10
    126 rows selected.
    SQL>Thanks,
    Karthick.
    Edited by: Karthick_Arp on Sep 23, 2008 12:11 AM

  • How to use three part name with using dynamic query.

    Dear all, (sqlserver 2008 express r2)
    q1)following is showing error, is it possible to accomplish the task with out using dynamic query.
    DECLARE @A VARCHAR(100)
    DECLARE @A1 VARCHAR(100)
    SET @A='DB1'
    SET @A1='DBO'
    SELECT * FROM @[email protected]
    q2) table value function is not accepting dynamic query , is there any way to do this task.
    yours sincerley

    Certain parts in an SQL query like FROM tablename cannot be local variables. In such a case, dynamic SQL can be applied:
    http://www.sqlusa.com/bestpractices/dynamicsql/
    As noted above, more information needed to decide if dynamic SQL the correct solution in this instance.
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • How to change recordset bahaviour to accept dynamic column names in the where clause

    Hi
    im using php-mysql and i make a recordset and i want to make the column names in the where clause to be dynamic like
    "select id,name from mytable where $tablename-$myvar";
    but when i do this my i break the recordset and it disappear
    and when i use variables from advanced recordset it only dynamic for the value of the column not for the column name
    and when i write the column name to dynamic as above by hand it truns a red exclamation mark on the server behaviour panel
    so i think the only way is to change the recordset behaviour is it? if so How to make it accept dynamic column names?
    thanks in advance.

    As bregent has already explained to you, customizing the recordset code will result in Dreamweaver no longer recognizing the server behavior. This isn't a problem, but it does mean that you need to lay out your dynamic text with the Bindings panel before making any changes. Once you have changed the recordset code, the Bindings panel will no longer recognize the recordset fields.
    Using a variable to choose a column name is quite simple, but you need to take some security measures to ensure that the value passed through the query string isn't attempting SQL injection. An effective way of doing this is to create an array of acceptable column names, and check that the value matches.
    // create array of acceptable values
    $valid = array('column_name1', 'column_name2', 'column_name3');
    // if the query string contains an acceptable column name, use it
    if (isset($_GET['colname']) && in_array($_GET['colname'], $valid)) {
      $col = $GET['colname'];
    } else {
      // set a default value if the submitted one was invalid
      $col = 'column_name1'
    You can then use $col directly in the SQL query.

  • How to get dynamic query results from an array/structure

    I have an edit page that is set up to display phone number fields from the user stored in our database. The properties for the phone number fields are set by a structure of arrays. My problem is that when a user has more than 1 phone number in my database, my structures correctly show this on the form by displaying 2 phone numbers. The problem I am having is that when it shows multiple phone numebrs, it always shows the first result and just repeats it as opposed to dropping the 2nd or 3rd phone number in their respective fields.
    array and structure code below:
          <!--- Mobile --->
          <cfset mobile = StructNew()>
          <cfset mobile.dynamic = false>
          <cfset mobile.dynamicLabel = '+ Add'>
          <cfset mobile.fields = ArrayNew(1)>
    <cfif #checkuserv.recordcount# GT '0'>   
          <cfset mobile.fields[1] = StructNew()>
          <cfset mobile.fields[1].required = false>
          <cfset mobile.fields[1].label = 'Phone Number 1'>
          <cfset mobile.fields[1].displayIcon = false>
          <cfset mobile.fields[1].voice = true>
          <cfset mobile.fields[1].voiceChecked = true>
          <cfset mobile.fields[1].toolTip = "Please choose if you would like to receive a text or voice call on this number">
    </cfif>
    <cfif #checkuserv.recordcount# IS '2'>    
          <cfset mobile.fields[2] = StructNew()>
          <cfset mobile.fields[2].required = false>
          <cfset mobile.fields[2].label = 'Phone Number 2'>
          <cfset mobile.fields[2].displayIcon = false>
          <cfset mobile.fields[2].toolTip = "Please choose if you would like to receive a text or voice call on this number">
          <cfset mobile.fields[2].voice = true>
          <cfset mobile.fields[2].voiceChecked = true>
    </cfif>
    <cfif #checkuserv.recordcount# IS '3'>     
          <cfset mobile.fields[3] = StructNew()>
          <cfset mobile.fields[3].required = false>
          <cfset mobile.fields[3].label = 'Phone Number 3'>
          <cfset mobile.fields[3].displayIcon = false>
          <cfset mobile.fields[3].toolTip = "Please choose if you would like to receive a text or voice call on this number">
          <cfset mobile.fields[3].voice = true>
          <cfset mobile.fields[3].voiceChecked = true>
    </cfif>
    Here is the code for my fields that call the array info:
    <!--- Voice 1 --->      
            <cfloop index="i" from="1" to="#ArrayLen(mobile.fields)#">
                <cfif i EQ 1 OR NOT mobile.dynamic OR form.mobileDisplayed GTE i>
                    <cfparam name="form.areacode_#i#" default="">
                    <cfparam name="form.prefix_#i#" default="">
                    <cfparam name="form.suffix_#i#" default="">
                <div class="fieldBlock phoneBlock" id="phoneBlock#i#">
                    <label for="areacode_#i#">
                        <cfif mobile.fields[i].required><span>*</span></cfif>
                        <cfif mobile.fields[i].displayIcon><img src="/images/sm_phone.jpg" /></cfif>
                        #mobile.fields[i].label#:
                    </label>
                    <div class="inputBlock">
                        <input type="text" maxlength="3" onKeyUp="numTyped(this, 'prefix_#i#', 3, event)" name="areacode_#i#" id="areacode_#i#" class="areacode" value="#trim(left(checkuserv.sub_user_number, '3'))#" />
                        <input type="text" maxlength="3" onKeyUp="numTyped(this, 'suffix_#i#', 3, event)" name="prefix_#i#" id="prefix_#i#" class="prefix" value="#trim(mid(checkuserv.sub_user_number, "4", '3'))#" />
                        <input type="text" maxlength="4" name="suffix_#i#" id="suffix_#i#" class="suffix"  value="#trim(mid(checkuserv.sub_user_number, "7", '4'))#" />
                        <cfif StructKeyExists(mobile.fields[i], "voice") and mobile.fields[i].voice>
                            <div class="voice" id="voice#i#">
                                <input type="radio" value="0" name="voice_#i#"<cfif Not StructKeyExists(mobile.fields[i], "voiceChecked") or Not mobile.fields[i].voiceChecked> checked="checked"</cfif> />
                                <label>Text</label>
                                <input type="radio" value="1" name="voice_#i#"<cfif StructKeyExists(mobile.fields[i], "voiceChecked") and mobile.fields[i].voiceChecked> checked="checked"</cfif> />
                                <label>Voice</label>
                            </div>
                        </cfif>
                        <cfif StructKeyExists(mobile.fields[i], "toolTip") and mobile.fields[i].toolTip neq "">
                            <div class="toolTip" id="toolTip_#i#" title="#mobile.fields[i].toolTip#" onClick="alert('#mobile.fields[i].toolTip#')">?</div>
                        </cfif>
                    </div>
    <!--- This number was invalid or if geocoding failed, and they've picked a carrier to override, display the carrier override dropdown--->
                    <cfif ListFindNoCase(invalidMobileIndexList, i) or ( showMap and IsDefined("form.carrierOverride" & i) )>
                        <div id="carrierOverrideBox#i#" class="carrierOverrideBlock">
                            <label>Carrier:</label>
                            <div class="inputBlock">
                                <select name="carrierOverride#i#" id="carrierOverride#i#">
                                    <option value="-1">-- Pick your carrier --</option>
                                    <cfloop query="carriers">
                                        <!--- 1111 is voice, 0 is NONE, don't display  --->
                                        <cfif Not ListFindNoCase("0,1111", carriers.carrier_id)>
                                            <option value="#Trim(carriers.carrier_id)#"<cfif IsDefined("form.carrierOverride" & i) and form["carrierOverride" & i] eq Trim(carriers.carrier_id)> selected="selected"</cfif>>#Trim(carriers.carrier_title)#</option>
                                        </cfif>
                                    </cfloop>
                                </select>
                                <a href="http://www.inspironlogisticscontact.cfm?account_id=#account_id#&carrierOverride=1"
                                       title="Carrier help"
                                       onClick="window.open('http://www.inspironlogisticscontact.cfm?account_id=#account_id#&carrierOverride=1','#accou nt_id#','width=500,height=800,scrollbars=no,screenX=100,screenY=100,top=100,left=100,resiz able=1'); return false;"
                                      >?</a>
                            </div>
                        </div>
                    </cfif>
                    <cfif mobile.dynamic AND i EQ form.mobileDisplayed AND i LT ArrayLen(mobile.fields)>
                    <div class="dynamicAddBlock dynamicAddMobileBlock" id="dynamicAddmobile_#i#">
                          <a href="javascript: submitAddField('mobile')">#mobile.dynamicLabel#</a>
                    </div>
                    </cfif>
                </div>
                </cfif>
            </cfloop>
            <cfif mobile.dynamic>
                <input name="mobileDisplayed" id="mobileDisplayed" value="#form.mobileDisplayed#" type="hidden" />
            </cfif>
            <input name="carrierOverrideActive" id="carrierOverrideActive" value="<cfif carrierOverrideActive>1<cfelse>0</cfif>" type="hidden" />
    I have been stuck on this for days, finally turning to the forum today with a few different issues. I hate trying to work within the framwork of other peoples code.
    I use coldfusion 8

    I broke the chunk of code away from the page and am now getting teh phone numbers in the right spots, but I am still getting a coldfusion error.
    Element 2 is undefined in a Java object of type class coldfusion.runtime.Array.
    Here is my code...
    <cfset invalidMobileIndexList = "">
    <cfset showMap = false>
    <cfset carrierOverrideActive = false>
    <!--- Voice 1 --->       
            <cfloop index="i" from="1" to="#ArrayLen(mobile.fields)#">
    <!------>            <cfif i EQ 1 OR NOT mobile.dynamic OR form.mobileDisplayed GTE i>
                    <cfparam name="form.areacode_#i#" default="">
                    <cfparam name="form.prefix_#i#" default="">
                    <cfparam name="form.suffix_#i#" default="">
                <div class="fieldBlock phoneBlock" id="phoneBlock#i#">
                <label for="areacode_#i#">
                        <cfif mobile.fields[i].required><span>*</span></cfif>
                        <cfif mobile.fields[i].displayIcon><img src="/images/sm_phone.jpg" /></cfif>
                        #mobile.fields[i].label#:
                    </label>
                    <cfoutput query="checkuserv" ><div class="inputBlock">
                        <input type="text" maxlength="3" onKeyUp="numTyped(this, 'prefix_#i#', 3, event)" name="areacode_#i#" id="areacode_#i#" class="areacode" value="#trim(left(checkuserv.sub_user_number, '3'))#" />
                        <input type="text" maxlength="3" onKeyUp="numTyped(this, 'suffix_#i#', 3, event)" name="prefix_#i#" id="prefix_#i#" class="prefix" value="#trim(mid(checkuserv.sub_user_number, "4", '3'))#" />
                        <input type="text" maxlength="4" name="suffix_#i#" id="suffix_#i#" class="suffix"  value="#trim(mid(checkuserv.sub_user_number, "7", '4'))#" />
                        <cfif StructKeyExists(mobile.fields[i], "voice") and mobile.fields[i].voice>
                            <div class="voice" id="voice#i#">
                                <input type="radio" value="0" name="voice_#i#"<cfif Not StructKeyExists(mobile.fields[i], "voiceChecked") or Not mobile.fields[i].voiceChecked> checked="checked"</cfif> />
                                <label>Text</label>
                                <input type="radio" value="1" name="voice_#i#"<cfif StructKeyExists(mobile.fields[i], "voiceChecked") and mobile.fields[i].voiceChecked> checked="checked"</cfif> />
                                <label>Voice</label>
                        </cfif></div></cfoutput>
                        <cfif StructKeyExists(mobile.fields[i], "toolTip") and mobile.fields[i].toolTip neq "">
                            <div class="toolTip" id="toolTip_#i#" title="#mobile.fields[i].toolTip#" onClick="alert('#mobile.fields[i].toolTip#')">?</div>
                        </cfif>
                    </div>
                    <!--- This number was invalid or if geocoding failed, and they've picked a carrier to override, display the carrier override dropdown--->
                    <cfif ListFindNoCase(invalidMobileIndexList, i) or ( showMap and IsDefined("form.carrierOverride" & i) )>
                        <div id="carrierOverrideBox#i#" class="carrierOverrideBlock">
                            <label>Carrier:</label>
                            <div class="inputBlock">
                                <select name="carrierOverride#i#" id="carrierOverride#i#">
                                    <option value="-1">-- Pick your carrier --</option>
                                    <cfloop query="carriers">
                                        <!--- 1111 is voice, 0 is NONE, don't display  --->
                                        <cfif Not ListFindNoCase("0,1111", carriers.carrier_id)>
                                            <option value="#Trim(carriers.carrier_id)#"<cfif IsDefined("form.carrierOverride" & i) and form["carrierOverride" & i] eq Trim(carriers.carrier_id)> selected="selected"</cfif>>#Trim(carriers.carrier_title)#</option>
                                        </cfif>
                                    </cfloop>
                                </select>
                                <a href="http://www.inspironlogistics.com/wens/contact.cfm?account_id=#account_id#&carrierOverride= 1"
                                       title="Carrier help"
                                       onClick="window.open('http://www.inspironlogistics.com/wens/contact.cfm?account_id=#account_id#&carrierOverride= 1','#account_id#','width=500,height=800,scrollbars=no,screenX=100,screenY=100,top=100,left =100,resizable=1'); return false;"
                                      >?</a>
                            </div>
                        </div>
                    </cfif>
                    <cfif mobile.dynamic AND i EQ form.mobileDisplayed AND i LT ArrayLen(mobile.fields)>
                    <div class="dynamicAddBlock dynamicAddMobileBlock" id="dynamicAddmobile_#i#">
                          <a href="javascript: submitAddField('mobile')">#mobile.dynamicLabel#</a>
                    </div>
                    </cfif>
                </div>
                </cfif>
            <cfif mobile.dynamic>
                <input name="mobileDisplayed" id="mobileDisplayed" value="#form.mobileDisplayed#" type="hidden" />
            </cfif>
            <input name="carrierOverrideActive" id="carrierOverrideActive" value="<cfif carrierOverrideActive>1<cfelse>0</cfif>" type="hidden" /><!------>
           </cfloop>

  • Dynamic Query to display a page of records at a time

    I need some help creating procedure with a dynamic query that will query a table and pass out a certain number of records (like records 101 - 200 of 20,000). This procedure will receive the column names, table name, where clause, page number and number of records per page. It will then pass back the requested records to be displayed on a PHP page.
    Pseudo Code:
    Select Dynamic_Columns, ROWNUM
    Into Dynamic_Pl_Sql_Table
    From Dynamic_Table
    Where Dynamic_Where_Clause
    Total_Records_Out := Dynamic_PL_Sql_Table.Count
    Modulus := Mod(Total_Records_Out, Total_Records_Per_Page_In)
    Total_Pages_Out := (Total_Records_Out - Modulus) / Total_Records_Per_Page_In
    If Modulus > 0 Then
    Total_Pages_Out + 1
    End If
    Row_Start = Page_Number_In * Total_Records_Per_Page_In
    Row_End = Row_Start + Total_Records_Per_Page_In
    Results_Out = Dynamic_Pl_Sql_Table(Row_Start ... Row_End)
    Any help with this will be appreciated!

    Maybe this will help you
    1) If the Serial is 0 then page break
    2) total_rows gives you total number of rows selected.
    3) you can apply where clause to this and it will give you appropriate records.
    select empno, ename, sal, 
    mod(row_number() over (order by null),5) serial,
    count(*) over () tot_rows from emp ed
         EMPNO ENAME             SAL     SERIAL   TOT_ROWS
          7369 SMITH             800          1         14
          7499 ALLEN            1600          2         14
          7521 WARD             1250          3         14
          7566 JONES            2975          4         14
          7654 MARTIN           1250          0         14
          7698 BLAKE            2850          1         14
          7934 MILLER           1300          2         14
          7788 SCOTT            3000          3         14
          7839 KING             5000          4         14
          7844 TURNER           1500          0         14
          7876 ADAMS            1100          1         14
          7900 JAMES             950          2         14
          7902 FORD             3000          3         14
          7782 CLARK            2450          4         14
    14 rows selected.SS

  • Saving result from sp_executesql into a variable and using dynamic column name - getting error "Error converting data type varchar to numeric"

    Im getting an error when running a procedure that includes this code.
    I need to select from a dynamic column name and save the result in a variable, but seem to be having trouble with the values being fed to sp_executesql
    DECLARE @retval AS DECIMAL(12,2)
    DECLARE @MonthVal VARCHAR(20), @SpreadKeyVal INT
    DECLARE @sqlcmd AS NVARCHAR(150)
    DECLARE @paramdef NVARCHAR(150)
    SET @MonthVal = 'Month' + CAST(@MonthNumber AS VARCHAR(2) );
    SET @SpreadKeyVal = @SpreadKey; --CAST(@SpreadKey AS VARCHAR(10) );
    SET @sqlcmd = N' SELECT @retvalout = @MonthVal FROM dbo.CourseSpread WHERE CourseSpreadId = @SpreadKeyVal';
    SET @paramdef = N'@MonthVal VARCHAR(20), @SpreadKeyVal INT, @retvalout DECIMAL(12,2) OUTPUT'
    --default
    SET @retval = 0.0;
    EXECUTE sys.sp_executesql @sqlcmd,@paramdef, @MonthVal = 'Month4',@SpreadKeyVal = 1, @retvalout = @retval OUTPUT;
    SELECT @retval
    DECLARE @return_value DECIMAL(12,2)
    EXEC @return_value = [dbo].[GetSpreadValueByMonthNumber]
    @SpreadKey = 1,
    @MonthNumber = 4
    SELECT 'Return Value' = @return_value
    Msg 8114, Level 16, State 5, Line 1
    Error converting data type varchar to numeric.

    Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need
    to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. And you need to read and download the PDF for: 
    https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
    >> I need to select from a dynamic column name and save the result in a variable, but seem to be having trouble with the values being fed to sp_executesql <<
    This is so very, very wrong! A column is an attribute of an entity. The idea that you are so screwed up that you have no idea if you want
    the shoe size, the phone number or something else at run time of this entity. 
    In Software Engineering we have a principle called cohesion that says a model should do one and only one task, have one and only one entry point, and one and only one exit point. 
    Hey, on a scale from 1 to 10, what color is your favorite letter of the alphabet? Yes, your mindset is that level of sillyity and absurdity. 
    Do you know that SQL is a declarative language? This family of languages does not use local variables! 
    Now think about “month_val” and what it means. A month is a temporal unit of measurement, so this is as silly as saying “liter_val” in your code. Why did you use “sp_” on a procedure? It has special meaning in T-SQL.  
    Think about how silly this is: 
     SET @month_val = 'Month' + CAST(@month_nbr AS VARCHAR(2));
    We do not do display formatting in a query. This is a violation of at the tiered architecture principle. We have a presentation layer. But more than that, the INTERVAL temporal data type is a {year-month} and never just a month. This is fundamental. 
    We need to see the DDL so we can re-write this mess. Want to fix it or not?
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Dynamic query in where clause while looping in an internal table.

    Hi,
    Had a small question : How can i make a dynamic query for the WHERE clause while looping at an internal table.
    i want to implement a dynamic where clause query for the below example.
    it_cfx_col is an internal table and wa_cfx_col is a work area for it_cfx_col
      DATA :
      i_cfx_col TYPE TABLE OF cfx_col,
      wa_cfx_col LIKE LINE OF i_cfx_col.
    DATA : count TYPE i VALUE 0.
    DATA : l_where_clause TYPE string,
             l_where_clause2 TYPE string,
             l_name type string.
    l_name = 'NANDANOM'.
    l_scenario = 'collaboration'.
    LOOP AT it_cfx_col INTO wa_cfx_col
    WHERE CREATED_BY = l_name
    AND SCENARIO = l_scenario.
    count = count + 1.
    some business logic implemented using the work area wa_cfx_col
    endloop.
    Now i want to write a dynamic query for the where clause.
    DATA : count TYPE i VALUE 0.
      DATA : l_where_clause TYPE string,
             l_where_clause2 TYPE string,
             l_name type string.
    l_name = 'NANDANOM'.
    l_scenario = 'collaboration'.
      l_where_clause = 'CREATED_BY = l_name'.
      l_where_clause2 = 'AND SCENARIO = l_scenario'.
    if l_scenario is not initial.
      CONCATENATE  l_where_clause l_where_clause2
      INTO l_where_clause SEPARATED BY space.
    endif.
    LOOP AT i_cfx_col INTO wa_cfx_col
    WHERE (l_where_clause).
    count = count + 1.
    some business logic implemented using the work area wa_cfx_col
    endloop.
    when i compile this i get an error message as { Statement concluding with "...(l_where_clause)" ended unexpectedly}
    Even i changed the initilization of the variable  l_where_clause2 to [ l_where_clause2 = 'AND SCENARIO = l_scenario.'. ]
    added the end of line demarkation ".", but still i got the same error message.
    Is it a limtation in ABAP that i cannot write a dynamic query for the where clause while looping at an internal table?
    Regards,
    om

    Hi savita,
    there in no such 1 limitaion in abap for dynamic query .. i think the  error meassge is only beacuse of your synatx delcartaion.
    >> LOOP AT i_cfx_col INTO wa_cfx_col
       WHERE (l_where_clause).
       count = count + 1.
    some business logic implemented using the work     area    wa_cfx_col
       endloop.
    afted delclarataion also , in the where statement you should specify both the field name and value bname
       LOOP AT i_cfx_col INTO wa_cfx_col
       WHERE l_where_clause = 'CREATED_BY = l_name' .
       count = count + 1.
    hope it helps.
    regads
    priya.

Maybe you are looking for

  • Generated a report which gives PR(Purchase Requisition) analysis using ALV.

    hi experts, please give me tables and fields for following report, and also exlain me briefly, Generated a report which gives PR(Purchase Requisition) analysis using ALV. thanks in advance, radhakrishna

  • Dual 2,5GHz G5 with startup problems

    Hi, I have a Dual 2,5GHz (June 2004 model) G5 with the following problem: When I try to turn it on, the screen sometimes stays dark. This is often the case the first time in the morning. Occasionally when this happens the front power LED is off. I ha

  • How to Replicate Standard Alternating Colors using XSL-FO??

    Hi All I am using Apex_3.1, Apache fop and Standard Report Printing to produce PDF reports. We would like to replicate the theme 12 (Blue) standard alternating colors in our PDF output. I do realise that this involves modifying the xsl-fo and have tr

  • How to eliminate "Edit in Progress" lock when Photoshop used as external editor?

    I have read several responses to questions on this but nothing has worked when I use Photoshop CS5 as the external editor. I am using PSE 10. To get to Photoshop CS5 I select a file and then have to click on the Fix tab where, at the bottom of the po

  • Maintaining Status

    Hi, While am maintaining status, there are some default function keys assigned like F2, F9, SHIFT-F2.. I could not remove the default values assigned to them.. I wud like them to be  empty. How to do that? Regards, Kalai