Linq to sql return dynamic table

Hi,
I am looking to use linq to sql like I did with ADO and return a dynamic table like I did with a datatable.
I will not know what table/fields will return until runtime.  I later want to loop through the return table and get the field names and values.
if this was a datatable it would look something like
System.Data.
DataTable
dt = new
DataTable();
foreach
(DataRow
dr in
dt.Rows )
string
fieldName = dt.Columns[0].ColumnName;
string
values = dr[0].ToString();
Here is my linq to sql but dynamic will not work
var
recordSet = (db.ExecuteQuery<dynamic>(sql,

Andrew;
You seem to be having the same issue I am (for which, by the way, no one seems to have the answers);
1.  A data object being passed to your class/methods
2.  Another object being passed containing the "fields"/properties the user wants returned from the data
I've been trying to make something like this work
List
IQueryable
subset = from
a in
rawdata select
(<<dataFields>>);
... Tantamount to passing a fields list into an SQL query (macro expansion?).  Unfortunately, LINQ wants to treat whatever is passed in the select
as a literal.
If you come up with an answer, please let me know.  I have solved every other issue in my code (including a rather clever GroupByMany cobbled
together from various leads from other posts), but am stuck at this one.
<string>
dataFields = datapoints.ToList<string>();

Similar Messages

  • SQL script: dynamic table creation

    Hello,
    I should write a sql script to do the following (simplified):
    - Create a table if it doesn't exist yet
    - Select something from the newly created table and do further conditional actions
    I've tried something like that:
    DECLARE
    lv_count INTEGER;
    BEGIN
    DBMS_OUTPUT.enable();
    SELECT COUNT(*) INTO lv_count FROM user_tables WHERE table_name = 'DATABASEINFO';
    IF(lv_count = 0)
    THEN
         DBMS_OUTPUT.PUT_LINE('Create DatabaseInfo');
    EXECUTE IMMEDIATE
         'CREATE TABLE DATABASEINFO(
              ZDatabaseInfoId RAW(16) NOT NULL,
              ZInfo VARCHAR2(30) NOT NULL,
              ZValue VARCHAR2(100) NOT NULL,
    CONSTRAINT DatabaseInfo_U_NC_PK PRIMARY KEY
    ZDatabaseInfoId
    END IF;
    SELECT COUNT(*) INTO lv_count FROM DatabaseInfo WHERE ZInfo = 'anything';
    The select statement fails with error message "Table or view cannot be found". As far as I know, this is because the table is created dynamically and validation of the sql script fails because the table doesn't exist on compile time.
    How to solve that?
    Best Regards
    Andreas

    866121 wrote:
    Hello,
    I should write a sql script to do the following (simplified):
    - Create a table if it doesn't exist yet
    - Select something from the newly created table and do further conditional actions
    I've tried something like that:
    DECLARE
    lv_count INTEGER;
    BEGIN
    DBMS_OUTPUT.enable();
    SELECT COUNT(*) INTO lv_count FROM user_tables WHERE table_name = 'DATABASEINFO';
    IF(lv_count = 0)
    THEN
         DBMS_OUTPUT.PUT_LINE('Create DatabaseInfo');
    EXECUTE IMMEDIATE
         'CREATE TABLE DATABASEINFO(
              ZDatabaseInfoId RAW(16) NOT NULL,
              ZInfo VARCHAR2(30) NOT NULL,
              ZValue VARCHAR2(100) NOT NULL,
    CONSTRAINT DatabaseInfo_U_NC_PK PRIMARY KEY
    ZDatabaseInfoId
    END IF;
    SELECT COUNT(*) INTO lv_count FROM DatabaseInfo WHERE ZInfo = 'anything';
    The select statement fails with error message "Table or view cannot be found". As far as I know, this is because the table is created dynamically and validation of the sql script fails because the table doesn't exist on compile time.
    How to solve that?
    why, oh why, are you dynamically making table?
    DDL should be done only once via static SQL.
    dig a deeper hole & EXECUTE IMMEDIATE the SELECT.

  • Dynamic SQL substituting dynamic table name with slct statement having date

    Hello,
    I just wanted some help with the following PL block. My problem is whenever I try to run this block it ask for invoking values for 2 substitute variables, though no substitute variables present in the code. Please find the code below:
    Declare
    cursor C_1 is
    select unique table_name from gsi_daily_count;
    table_names varchar2(240);
    Begin
    Open C_1;
    Loop
    Fetch C_1 into table_names;
    EXIT WHEN C_1%NOTFOUND;
    EXECUTE IMMEDIATE' select last_extract_date,
    to_char(min(greatest(nvl(last_update_date,'||01-Jan-10||'),nvl(program_update_date,'||01-Jan-10||'))),'||DD-MON-YY HH24:MI:SS||') mi,
    to_char(max(greatest(nvl(last_update_date,'||01-Jan-10||'),nvl(program_update_date,'||01-Jan-10||'))),'||DD-MON-YY HH24:MI:SS||') ma
    from' || table_names ||'
    group by last_extract_date
    order by last_extract_date desc';
    End Loop;
    Close C_1;
    COMMIT;
    End;
    Please help.
    Thanks in advance.

    You cannot specify your dates the way you have since they are being intepreted as bind variables:
    Try this:
    Declare
      cursor C_1 is
        select unique table_name
        from gsi_daily_count;
        table_names varchar2(240);
    Begin
      Open C_1;
      Loop
        Fetch C_1 into table_names;
        EXIT WHEN C_1%NOTFOUND;
        EXECUTE IMMEDIATE' select last_extract_date,
                                  to_char(
                                          min(
                                                greatest(
                                                          nvl(last_update_date,to_date('''|| '01-Jan-10' ||''',''dd-Mon-yy''))
                                                         ,nvl(program_update_date,to_date('''|| '01-Jan-10' ||''',''dd-Mon-yy''))
                                             ),''DD-MON-YY HH24:MI:SS''
                                         ) mi
                                  to_char(
                                          max(
                                                greatest(
                                                          nvl(last_update_date,to_date('''|| '01-Jan-10' ||''',''dd-Mon-yy''))
                                                         ,nvl(program_update_date,to_date('''|| '01-Jan-10' ||''',''dd-Mon-yy''))
                                             ),''DD-MON-YY HH24:MI:SS''
                                         ) ma
                          from ' || table_names ||'
                          group by last_extract_date
                          order by last_extract_date desc';
      End Loop;
      Close C_1;
      COMMIT;
    End;
    / There is not way for me to test this, so you may have to play around with all the quotes!

  • PL/SQL using dynamic table names

    I want to create a procedure in which i want to pass a parameter which after concatenation with a string gives me a variable which is the tablename in my SELECT query in the procedure.
    How to do it?

    See here for an example using ref cursor.
    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/11_dynam.htm#10037
    If this is not what you need, come back and give us more details

  • A Simple Linq Query to return a Record from SQL Server

    I have a table named Customers which contain columns like
    Id   Col1   Col2   Col3   Col4   Col5
    How do I write a Linq query to return the value of Col2 where Id=999

    Hello,
    It depends on what method you use to read data i.e. Data Context class, Entity Framework for SQL-Server we can get data directly from the database easily.
    The following has two very simply examples using data context classes and the same came be done with Entity Framework which has an even more powerful version of data context implementation under 6 and above
    Dim db As New DataClasses1DataContext
    Dim theCustomer As Customer = db.Customers.Where(Function(c) c.CustomerID = 999).FirstOrDefault
    If theCustomer IsNot Nothing Then
    ' use theCustomer which contains all columns
    Else
    ' do not use, customer not located
    End If
    Dim theCustomer1 As Customer =
    From c In db.Customers
    Where c.CustomerID = 999
    Select New Customer With
    .CompanyName = c.CompanyName,
    .ContactName = c.ContactName,
    .Orders = c.Orders
    ).FirstOrDefault
    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

  • 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 pulled from SQL database, Need to Search

    My table results are not static, they are pulled into a
    dynamic table from a SQL database. Each table displays 10 records
    with an option at the bottom to display additional records
    (next/previous), for my query. I also have an option set up to
    allow users to click for a detail view of a record in the table. If
    the table data was static, I would be able to set up a search
    option and a results page for it, but I'm dealing with dynamic data
    on an .ASP page. I'd like to set up a search box to limit the
    records displayed in the table. I haven't found any code samples
    that are designed for dynamic data.
    Here is a copy of the code from my table.

    Hi,
    I think the code on this URL will get you the solution
    http://www.asp.happycodings.com/Array/code3.html
    Cheers,
    ~Maneet

  • Dynamic table name in native SQL

    Hi,
    How can i use dynamic table name in native SQL?
    My req is to select data from a external database table , but the table name will be only poulated during runtime.
    How can i acheive this?
    Regards,
    Arun.

    It should work OK - see demo below.
    Jonathan
    report zsdn_jc_adbc_test.
    start-of-selection.
      perform demo_lookup.
    form demo_lookup.
      data:
        l_error_msg          type string,
        ls_t001              type t001, "Company
        ls_t003              type t003. "Doc types
      perform dynamic_lookup
        using
          'T001'
        changing
          ls_t001
          l_error_msg.
      write: / l_error_msg.
      perform dynamic_lookup
        using
          'T003'
        changing
          ls_t003
          l_error_msg.
      write: / l_error_msg.
    endform.
    form dynamic_lookup
      using
        i_tabname            type tabname
      changing
        os_data              type any
        o_error_msg          type string.
    * Use ADBC to select data
      data:
        l_mandt_ref          type ref to data,
        l_result_ref         type ref to data,
        l_mandt              type symandt,
        l_tabname            type tabname,
        l_sql_statement      type string,
        lo_cx_root           type ref to cx_root,
        lo_cx_sql            type ref to cx_sql_exception,
        lo_connection        type ref to cl_sql_connection,
        lo_statement         type ref to cl_sql_statement,
        lo_result_set        type ref to cl_sql_result_set.
      clear: os_data, o_error_msg.
      get reference of l_mandt into l_mandt_ref.
      get reference of os_data into l_result_ref.
      l_mandt   = '222'.   "i.e. select from client 222
      l_tabname = i_tabname.
      try.
          lo_connection = cl_sql_connection=>get_connection( ).
          lo_statement  = lo_connection->create_statement( ).
    * Set criteria for select:
          lo_statement->set_param( l_mandt_ref ).
          concatenate
            'select * from' l_tabname
            'where mandt = ?'
            into l_sql_statement separated by space.
    * Execute
          call method lo_statement->execute_query
            exporting
              statement   = l_sql_statement
              hold_cursor = space
            receiving
              result_set  = lo_result_set.
    * Get the data from the resultset.
          lo_result_set->set_param_struct( l_result_ref ).
          while lo_result_set->next( ) > 0.
            write: / os_data.
          endwhile.
    * Tidy up:
          lo_result_set->close( ).
          lo_connection->close( ).
        catch cx_sql_exception into lo_cx_sql.
          o_error_msg = lo_cx_sql->get_text( ).
        catch cx_root into lo_cx_root.
          o_error_msg = lo_cx_root->get_text( ).
      endtry.
    endform.

  • 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

  • Calling a PL/SQL function returning Netsed Table Rows

    Hi,
    I am trying to call a Function which returns Nested Table rows (as Out Parameter) in Java .
    When I am trying to use
    pstmt.registerOutParameter(3, OracleTypes.OTHER);
    to capture the Out parameter in Java code , I get the follwoing error :
    java.sql.SQLException: Invalid column type
    I have even tried using OracleTypes.JAVA_OBJECT ,but I get the same error.
    If I use OracleTypes.JAVA_STRUCT I get
    java.sql.SQLException: Parameter Type Conflict: sqlType=2008
    error.
    Please help .
    Am I doing the right thing ?
    Thanks in advance.
    Ninad

    http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/jdbc20/jdbc20.html

  • Error while insert data using execute immediate in dynamic table in oracle

    Error while insert data using execute immediate in dynamic table created in oracle 11g .
    first the dynamic nested table (op_sample) was created using the executed immediate...
    object is
    CREATE OR REPLACE TYPE ASI.sub_mark AS OBJECT (
    mark1 number,
    mark2 number
    t_sub_mark is a class of type sub_mark
    CREATE OR REPLACE TYPE ASI.t_sub_mark is table of sub_mark;
    create table sam1(id number,name varchar2(30));
    nested table is created below:
    begin
    EXECUTE IMMEDIATE ' create table '||op_sample||'
    (id number,name varchar2(30),subject_obj t_sub_mark) nested table subject_obj store as nest_tab return as value';
    end;
    now data from sam1 table and object (subject_obj) are inserted into the dynamic table
    declare
    subject_obj t_sub_mark;
    begin
    subject_obj:= t_sub_mark();
    EXECUTE IMMEDIATE 'insert into op_sample (select id,name,subject_obj from sam1) ';
    end;
    and got the below error:
    ORA-00904: "SUBJECT_OBJ": invalid identifier
    ORA-06512: at line 7
    then when we tried to insert the data into the dynam_table with the subject_marks object as null,we received the following error..
    execute immediate 'insert into '||dynam_table ||'
    (SELECT

    887684 wrote:
    ORA-00904: "SUBJECT_OBJ": invalid identifier
    ORA-06512: at line 7The problem is that your variable subject_obj is not in scope inside the dynamic SQL you are building. The SQL engine does not know your PL/SQL variable, so it tries to find a column named SUBJECT_OBJ in your SAM1 table.
    If you need to use dynamic SQL for this, then you must bind the variable. Something like this:
    EXECUTE IMMEDIATE 'insert into op_sample (select id,name,:bind_subject_obj from sam1) ' USING subject_obj;Alternatively you might figure out to use static SQL rather than dynamic SQL (if possible for your project.) In static SQL the PL/SQL engine binds the variables for you automatically.

  • How to populate a dynamic table according to the choice of the viewer

    Hi there,
    I ran into a dead-end on my  "Events" page.
    There is a dynamic table getting the info from a database. It will initially show the Upcoming Events.
    At this point my question is this:
    *Can I populate the dynamic table based on a condition where the current date and the event date (as in the db) will be compared and if the event date is later than the current date, it will be displayed in the table. Otherwise, it won't.
    If I can do that, can someone please help me out with the code?
    Besides that, on the right side of the page there are 3 options for the viewer:
    1. View upcoming events
    2. View past events
    3. Search events by month and year
    What I want to do is that when the viewer clicks on 'past events', the table will be reset and populated with those events whose date has passed.
    When the viewer clicks on "upcoming events", the table is reset again and populated with the relevant events.
    When the viewer selects a month and a year, search the database to find the relevant records.
    Can all of this be written in php? Since I read smwhere that php doesn't work with onclick functions... i got confused. Cuz the data in my table will have to vary depending on what the viewer is clicking (upcoming events/past events/search events). I do not wish to create separate pages for each type of event.
    If anybody has a better suggestion to carry out this task, please share!
    Thanks!

    >Can I populate the dynamic table based on a condition where the current date and the event date (as in the db)
    >will be compared and if the event date is later than the current date, it will be displayed in the table. Otherwise, it won't.
    Of course. You just need to compare the date field in your database with the current date as returned by your DBMS date function. Assuming you are using MySQL, you would compare your column with the currdate() function and use the appropriate greater than/ less than operators in the SQL WHERE clause. If you don't know what a WHERE clause is then I would urge you to learn SQL as soon as possible. You can't build data driven sites without a basic understanding of SQL.
    >Since I read smwhere that php doesn't work with onclick functions..
    What this means is that php is a server side language, where user interactions always occur at the client site. But that does not mean you can't invoke a server side action from a client side event. You most certainly can and would.
    You might consider adding links to the dynamic table page that pass a querystring to the php script which determine what filter to add in the WHERE clause- greater than the current date, less than, etc.
    Also, in the future, please post these questions to the application development forum.

  • Creating a function to return a table of records

    Okay, I thought I knew how to do this but apparently not. I have a very complex query that connects multiple tables. I want to put the results of that query into a "table" (non-persistent) that can be passed to another procedure. So, I created an object/record that defines a single row in this table:
    create or replace TYPE SHP_RECORD is OBJECT
    (FIELD01 NUMBER(10),
    FIELD02 NUMBER(10),
    FIELD03 NUMBER(10),
    FIELD04 NUMBER(10),
    FIELD05 NUMBER(10),
    FIELD06 VARCHAR2(200),
    FILED07 NUMBER(10),
    FIELD08 VARCHAR2(200),
    FIELD09 NUMBER(10),
    FIELD10 TIMESTAMP(6),
    FIELD11 TIMESTAMP(6),
    FIELD12 TIMESTAMP(6),
    FIELD13 VARCHAR2(5),
    FIELD14 NUMBER(10),
    FIELD15 VARCHAR2(100),
    FIELD16 VARCHAR2(4000),
    FIELD17 VARCHAR2(1),
    FIELD18 VARCHAR2(1));
    Then I create another type that defines a table of SHP_RECORD:
    Create or replace TYPE SHP_TABLE is TABLE of SHP_RECORD;
    Now I have a function that puts the huge query into a text string (because it's got elements that change depending on what day of the week it's being run on so I have to keep it as a dynamic query. Now I want to run this query and put the results into a table. I've changed all the names to protect the innocent in this code snippet:
    create or replace function get_SHP_data(p_cust_id IN NUMBER,
    p_date IN TIMESTAMP) return SHP_TABLE as
    begin
    declare
    shp_data_out SHP_TABLE;
    TYPE shp_cur_type is REF CURSOR;
    shp_cv shp_cur_type;
    TYPE daily_query is VARRAY(7) of VARCHAR2(15);
    query_values DAILY_QUERY;
    day_index NUMBER;
    old_program_id NUMBER;
    chk_rundown NUMBER;
    query_text VARCHAR2(3000);
    row_index NUMBER;
    program_freq_id NUMBER;
    prog_seg_count NUMBER;
    upload_seg_count NUMBER;
    xfer_count NUMBER;
    sched_count NUMBER;
    bill_count NUMBER;
    rcvr_text VARCHAR2(2000);
    xmsn_start TIMESTAMP;
    xmsn_end TIMESTAMP;
    epi_status VARCHAR2(2000);
    begin
    query_values := daily_query('1, 3, 4, 12','1, 2, 5, 12','1, 2, 6, 12','1, 2, 7, 12','1, 2, 8, 12','1, 2, 9, 12','1, 3, 10, 12');
    day_index := to_number(to_char(p_date,'D'));
    query_text := {really ugly query here that includes concatinating a value from query_values as well as defines five bind variables numbered :1 through :5};
    old_program_id := 0;
    open shp_cv for query_text using p_date, p_date, p_date, p_date, p_cust_id;
    fetch shp_cv bulk collect into shp_data_out;
    close shp_cv;
    end;
    end;
    Okay, the function compiles just fine. But when I try to run it I get:
    select * from table(get_shp_data(226, SYSTIMESTAMP))
    ERROR at line 1:
    ORA-00932: inconsistent datatypes: expected - got -
    ORA-06512: at "SCHEMA.GET_SHP_DATA", line 69
    The line it's blowing up on is "fetch ship_cv bulk collect into shp_data_out" I've checked and verified that the record/object structure SHP_RECORD matches in both type and order the values that are returned by the query. So...what gives? I've been beating my head against this particular problem for several days now and am no closer to a solution.
    Any and all suggestions or corrections gratefully appreciated.
    Oh, and this is being run in a 10g release 2 environment:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, Real Application Clusters, OLAP, Data Mining
    and Real Application Testing options
    HELP??!!

    Hi,
    Even though the fetch is seemingly taking the exact same types, Oracle will still need you to cast the resultset into the proper type.
    Here's a short example of one way of doing it:
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.5.0
    Connected as FSITJA
    SQL>
    SQL> create table my_table as select owner, table_name from all_tables where rownum <= 5;
    Table created
    SQL> create or replace type SHP_RECORD as object (owner varchar2(30), table_name varchar2(30));
      2  /
    Type created
    SQL> create or replace type SHP_TABLE as table of SHP_RECORD;
      2  /
    Type created
    SQL> create or replace function get_shp_data(p_owner in my_table.owner%type) return shp_table as
      2    shp_data_out shp_table;
      3    cur_shp sys_refcursor;
      4  begin
      5    open cur_shp for
      6      select cast (multiset(select owner, table_name
      7                              from all_tables
      8                             where owner = p_owner
      9                               and rownum <= 5) as shp_table)
    10         from dual;
    11    fetch cur_shp
    12      into shp_data_out;
    13    return shp_data_out;
    14  end;
    15  /
    Function created
    SQL> select * from table(get_shp_data('SYS'));
    OWNER                          TABLE_NAME
    SYS                            TABLE_PRIVILEGE_MAP
    SYS                            SYSTEM_PRIVILEGE_MAP
    SYS                            STMT_AUDIT_OPTION_MAP
    SYS                            P$POK_CFG
    SYS                            DUALYou might want to check on Pipelined table functions and perhaps the function result cache in the docs, as means to improve your performance.
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e17126/tuning.htm#LNPLS01210
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e17126/subprograms.htm#LNPLS00817

  • Update multiple rows in a dynamic table Dreamweaver CS5.5

    hello there
    i want to update multiple rows which comes from a dynamic table in Dreamweaver CS5 (a loop in php) here is my Mysql table :
    sql code
    CREATE TABLE `register`.`s_lessons` (
    `lid` int( 5 ) NOT NULL ,
    `sid` int( 9 ) NOT NULL ,
    `term` int( 5 ) NOT NULL ,
    `tid` int( 5 ) NOT NULL ,
    `point` double NOT NULL DEFAULT '0',
    PRIMARY KEY ( `lid` , `sid` , `term` ) ,
    KEY `tid` ( `tid` ) ,
    KEY `point` ( `point` )
    ) ENGINE = MYISAM DEFAULT CHARSET = utf8 COLLATE = utf8_persian_ci;
    and this is my page source code:
    php file
    <?php require_once('../Connections/register.php'); ?>
    <?php
    session_start();
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $colname1_rs1 = "-1";
    if (isset($_GET['term'])) {
      $colname1_rs1 = $_GET['term'];
    $colname_rs1 = "-1";
    if (isset($_GET['lid'])) {
      $colname_rs1 = $_GET['lid'];
    $colname2_rs1 = "-1";
    if (isset($_SESSION['tid'])) {
      $colname2_rs1 = $_SESSION['tid'];
    mysql_select_db($database_register, $register);
    $query_rs1 = sprintf("SELECT s_lessons.sid, s_lessons.lid, s_lessons.term, s_lessons.tid, s_lessons.point FROM s_lessons WHERE s_lessons.lid = %s AND s_lessons.term = %s AND s_lessons.tid  = %s", GetSQLValueString($colname_rs1, "int"),GetSQLValueString($colname1_rs1, "int"),GetSQLValueString($colname2_rs1, "int"));
    $rs1 = mysql_query($query_rs1, $register) or die(mysql_error());
    $row_rs1 = mysql_fetch_assoc($rs1);
    $totalRows_rs1 = mysql_num_rows($rs1);
    $count=mysql_num_rows($rs1);
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    for ($j = 0, $len = count($_POST['lid']); $j < $len; $j++) {
    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
      $updateSQL = sprintf("UPDATE s_lessons SET point=%s WHERE tid=%s, lid=%s, sid=%s, term=%s",
                           GetSQLValueString($_POST['point'] [$j], "double"),
                                GetSQLValueString($_SESSION['tid'], "int"),
                           GetSQLValueString($_POST['lid'] [$j], "int"),
                                GetSQLValueString($_POST['sid'] [$j], "int"),
                                GetSQLValueString($_POST['term'] [$j], "int"));
      mysql_select_db($database_register, $register);
      $Result1 = mysql_query($updateSQL, $register) or die(mysql_error());
      $updateGoTo = "student_lists.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $updateGoTo));
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>r</title>
    <link href="styles/style.css" rel="stylesheet" type="text/css" media="screen" />
    <link href="styles/in_styles.css" rel="stylesheet" type="text/css" media="screen" />
    </head>
    <body>
    <div id="wrapper">
         <div id="header-wrapper">
         </div>
         <!-- end #header -->
         <div id="page">
              <div id="page-bgtop">
                   <div id="page-bgbtm">
                        <div id="content">
                             <div class="post">
                               <div style="clear: both;">
                            <form name="form1" id="form1" method="post" action="<?php echo $editFormAction; ?>">
                            <table border="1" align="center">
                              <tr>
                                <th>Student ID</th>
                                <th>Lesson ID</th>
                                <th>Semester</th>
                                <th>Point</th>
                              </tr>
                              <?php do { ?>
                                <tr>
                                  <td class="data"><label for="sid[]"></label>
                                  <input name="sid[]" type="text" id="sid[]" value="<?php echo $row_rs1['sid']; ?>" size="9" readonly="readonly" /></td>
                                  <td class="data"><label for="lid[]"></label>
                                  <input name="lid[]" type="text" id="lid[]" value="<?php echo $row_rs1['lid']; ?>" size="5" readonly="readonly" /></td>
                                  <td class="data"><label for="term[]"></label>
                                  <input name="term[]" type="text" id="term[]" value="<?php echo $row_rs1['term']; ?>" size="4" readonly="readonly" /></td>
                                  <td><label for="point[]"></label>
                                    <input name="point[]" type="text" id="point[]" value="<?php echo $row_rs1['point']; ?>" size="4" />                             
                              </tr>
                                <?php } while ($row_rs1 = mysql_fetch_assoc($rs1)); ?>
                            </table>
                            <p>
                              <input type="submit" name="Submit" id="Submit" value="Submit" />
                              <input type="hidden" name="MM_update" value="form1" />
                            </p>
                            </form>
                               </div>
                             </div>
                        <div style="clear: both;">
                    </div>
                        </div>
                        <!-- end #content -->
                        <!-- end #sidebar -->
                        <div style="clear: both;"> </div>
                   </div>
              </div>
         </div>
         <!-- end #page -->
    </div>
    <!-- end #footer -->
    </body>
    </html>
    <?php
    mysql_free_result($rs1);
    ?>
    All i want is that when users click on SUBMIT button values of point column in s_lessons(database table) be updated by new entries from user.
    i did my best and result with that code is :
    You  have an error in your SQL syntax; check the manual that corresponds to  your MySQL server version for the right syntax to use near ' lid=888,  sid=860935422, term=902' at line 1
    I would appreciate any idea.
    with prior thanks

    Go to the Row Properties, and in the Visibility tab, you have "Show or hide based on an expression". You can use this to write an expression that resolves to true if the row should be hidden, false otherwise.
    Additionally, in the Matrix properties you should take a look at the filters section, perhaps you can achieve what you wish to achieve through there by removing the unnecessary rows instead of just hiding them.
    It's only so much I can help you with the limited information. If you require further help, please provide us with more information such as what data are you displaying, what's the criteria to hiding rows, etc...
    Regards
    Andrew Borg Cardona

  • A dynamic table based on run-time created view object -- please help!

    Hello!
    I'm trying to create a dynamic table based on an run-time created view object. All go ok, but table binding component take the first view/iterator state and don't reflect changes they have. Please, take a look:
    1. At run-time the view is being replaced by new red-only one based on query in application module:
    getQueryView().remove();
    createViewObjectFromQueryStmt("QueryView", statement);
    2. Page definition file contains an iterator (using iterator or methodIterator - doesn't matter) binding and table, which binds to the iterator, like:
    <methodIterator id="distributeQuery1Iter" Binds="distributeQuery1.result"
    DataControl="QueryServiceDataControl" RangeSize="10"/>
    <table id="distributeQuery11" IterBinding="distributeQuery1Iter"/>
    3. The page code uses <af:table>. But, if I use table binding (it's right) like this:
    <af:table var="row" value="#{bindings.distributeQuery11.collectionModel}">
    <af:forEach items="#{bindings.distributeQuery11.attributeDefs}" var="def">
    the table will never changed (i.e. still show the first view instance).
    When I tried to use iterator binding directly (it's bad and cannot provide all needed features unlike CollectionModel from table binding) I saw that table works!
    (Code is somehing like:
    <af:table var="row" value="#{bindings.myIterator.allRowsInRange}">
    <af:forEach items="#{bindings.myIterator.attributeDefs}" var="def">
    Why the table binding do not reflect changes in iterator? Or should I use different approach?
    Thanks in advance!
    Ilya.

    I got it to work! I used a hybrid approach comprised of some of your code and some of Steve Muench's AcceessAppModuleInBackingBean example.
    In the setBindings method, I execute an app module method that redefines the query, then I used your code to delete and recreate bindings and iterator:
    public void setBindingContainer(DCBindingContainer bc) {
    this.bindingContainer = bc;
    rebuildVO();
    The rebuildVO() method looks like the code you provided in your example:
    private void rebuildVO() {
    DCDataControl dc;
    DispatchAppModule dApp;
    DCBindingContainer bc;
    DCIteratorBinding it;
    OperationBinding operationBinding;
    ViewObject vo;
    DCControlBinding cb;
    try {
    bc = getBindingContainer();
    dc = bc.findDataControl(DATACONTROL);
    dApp = (DispatchAppModule)dc.getDataProvider();
    // Execute App Module Method to rebuild VO based upon new SQL Statement.
    dApp.setDispatchViewSQL();
    vo = dApp.findViewObject(DYNAMIC_VIEW_NAME);
    it = bc.findIteratorBinding(DYNAMIC_VO_ITER_NAME);
    it.bindRowSetIterator(vo, true);
    // logger.info("Remove value binding...");
    cb = bc.findCtrlBinding(DYNAMIC_VIEW_NAME);
    cb.getDCIteratorBinding().removeValueBinding(cb);
    bc.removeControlBinding(cb);
    // logger.info("Creating new value binding...");
    FacesCtrlRangeBinding dynamicRangeBinding =
    new FacesCtrlRangeBinding(null,
    bc.findIteratorBinding(DYNAMIC_VO_ITER_NAME), null);
    // logger.info("Add control binding...");
    bc.addControlBinding(DYNAMIC_VIEW_NAME, dynamicRangeBinding);
    } catch (Exception e) {
    e.printStackTrace();
    And my App Module method that redefines the view object looks like this:
    public void setDispatchViewSQL() {
    String SQL =
    "begin ? := PK_BUsiNESS.F_GETDISPATCHVIEWSQL();end;";
    CallableStatement st = null;
    String ViewSQL = null;
    try {
    st = getDBTransaction().createCallableStatement(SQL,
    DBTransaction.DEFAULT);
    * Register the first bind parameter as our return value of type LONGVARCHAR
    st.registerOutParameter(1, OracleTypes.LONGVARCHAR);
    st.execute();
    ViewSQL = ((OracleCallableStatement) st).getString(1);
    findViewObject(DYNAMIC_VO_NAME).remove();
    ViewObject vo = createViewObjectFromQueryStmt(DYNAMIC_VO_NAME, ViewSQL);
    vo.executeQuery();
    } catch (SQLException s) {
    throw new JboException(s);
    } finally {
    try {
    st.close();
    } catch (SQLException s) {
    s.printStackTrace();
    When I run it I get my desired results. One thing I don't quite understand is why when the page is first rendered it shows the last set of records rather than the first. Now I have to figure out how to put navigation URLS in each of the table cells.
    Thanks for your help; I would not have gotten this far without it,
    Jeff

Maybe you are looking for

  • How do I "compact" a row?

    Hi Folks, This seems like it should be simple, but i'm having trouble finding an obvious solution. Consider the following row: Header 1 Header 2 Header 3 Header 4 Header 5 Header 6 534 a comment 27 I would like to create another row in another table

  • Theoretical question re: ipad 3 update from iOS6 to iOS7

    With Apple's recent statement regarding breaking Facetime on iOS6 iPads, do we have recourse if the update to 7.1.1 slows the machine down, as I've read here that it does in many posts? For example, my iPad 3 is under AppleCare. if the update cripple

  • Keyboard sluggish on 4s iPhone with IOS 7

    Hello, I installed IOS 7 onto my iPhone 4s today. Looks beautiful. However, keyboard is extremely sluggish. If I type a letter, it takes at least 5 seconds for the symbol to appear. Anyone else having this problem? Regards, Tom

  • How to get last slide to stay on screen?

    How do I get the text on my last slide to stay on screen indefinitely? I've got my project preferences set to not fade out on last slide, but the screen goes blank when I get to the end of my timeline. Any ideas? Do I have to set an invisible click b

  • Authorware Web Player won't download from our server

    We have used the same code to download the 2004 web player successfully from our server since 2005. Recently however, during the download, the player starts, but it hangs at the point where the progress bar with the label "Loading Files" displays. Th