I want to Dynamically access SQLite result set? - blackberry-webworks

I want to dynamically access SQLite result set. Since webworks/javascript doesnt support "PRAGMA table_info(table_name); I am saving all newly created tables information in a single two column table called schema. schema has two columns, table_name and column_name.
So I created a function to access table data dynamically. I use the item=results.rows.item(i) and than access row data with item.column.
column is a variable that is assigned the value from schema, representing the column_name. When I alert(column) I get the correct column_name, but when I used item.column my results are "undefined".
any advice on how to resolve this matter.

If I understand you correctly, column is a variable that holds the value of a column name, and you want to access that column from the results item. If that's the case, then this might help:
//Assuming "var column" has already been defined,
//and given the value of the column name to be accessed in the results item.//
var item = results.rows.item(i);
var columnValue = item[column];
I struggled with this too, and this is what I found/use. You put in brackets the variable containing the column name, and that's how you access it.
EDIT: This is obviously Javascript stuff, and what I used for accessing SQLite in PhoneGap. Hopefully it helps.

Related

Adding rows to matlab table

I have a table named patients in matlab that I created from reading an excel file using the readtable command. Now I would like to add a new row to this table programmatically. I have attempted the following:
patients.LastName{end+1} = 'Stewart';
While this does add a value at the correct spot in the table, it gives a generic name to my row. My RowNames property in this instance is important.
How do I add a new row to my table in Matlab and give it a name, then populate it's contents?
This is because all other entries except Last Name are empty. But no worries. In order to assign specific Rownames, please use the following statement. Lets suppose you want to assign last names as row names of the table.
patients.Properties.RowNames = patients.LastName;

How to access a cell value when the column has been defined with ag-grid expression/value getters?

If the ag-grid column definition has been defined with a value getter or if an expression has been defined for a cell the value gets displayed fine on the grid. However I was not able to find a way to access a value in a given cell if the cell is using cell expression/value getters. Was trying to access the data through api.forEachLeafNode, but it seems even the in memory model does not have this data. The only way I found was to export the data as CSV and then parse it using getDataAsCsv(params).
Is exporting the data the only way to access value of a column in a grid with a value getter?
Why does the In Memory model not have this data to access?
valueGetter is used during the rendering stage, it only computes when needed to render the cell. if the cell is never rendered (eg row is below what is currently visible) then the valueGetter is never executed. the result is never stored in the model, it is only passed to the cellRenderer.
so what you need to do to get the result of valueGetter is use api.getValue(colKey,rowNode)
colKey is the id of your column. this can be the column itself (if you got the column from the grid column api) or the column id. the column id is what you will probably want to use. the column id is assigned to the column in the following order 1) the colDef.colId if exists 2) the colDef.field if exists 3) generated if both colId and field are missing. so if you are using a valueGetter, you are probably not providing a field, so just provide a colId.
rowNode is the row in question. this is what you get when you use api.forEachLeafNode.
the api.getValue() method is pretty recent, i know it's in version 7 - so if missing just make sure you are v7 or above.

I would like to use a parameter for the table name. The table names can be presented to the user from a database view.

I would like to use a parameter for the table name. I have an application that creates several new tables each month. I therefore need the table name to be sent into CR via a parameter. The fields for the tabkes are always identical. I can present a list (view) from the database to the end user that would display a user friendly name for the table, when the user selects the instance they want I then have the table name I want to report from.
I'm not sure if that is possible. Even if your tables have the same structure, the field names will ultimately be different. Let's say you have a {table1.field1} in your report. Now you want to run the report from table2 instead of table1. So your field now would have to become {table2.field1}. Does that make sense? I think a better approach might be to try stored procedures that will create the fields you need so the field names won't change.

TSQL - force update of persisted computed column

I have a persisted computed column in one table with the value calculated using a user function. How can I force that column to be updated without updating any other column in that table?
UPDATE: So as it turns out, this will not work as I imagined it.
I wanted to have user function that contains sub-query in it, gets me some data and stores it in computed column. But SQL Server won't allow this...
It looks like I will have to do something similar with insert/update triggers.
If you persist the value by adding the PERSISTED keyword, the value is both retained on insert and will be synchronized when the referenced column is updated.

How do I ignore the created column on a Zend_DB table save?

how would I ignore having Zend_DB save() from trying to fill out a created column? I do not need that column for a certain model.
Don't send the data. save() is part of the Zend_Db_Table_Row api and is designed to be somewhat intelligent in the way it saves data to a row. It will perform an insert or an update of a row depending on what is required.
save() will also only update the columns that it has data for. If you don't send new data for your created column save() won't overwrite the data.
When ever it is possible I let the database I'm using create and update the columns for created and updated. That way I have the information available to query if I need it but I don't have to do something with PHP that My database can do better.
Check out http://framework.zend.com/manual/1.12/en/zend.db.table.html Section "Advanced usage".
For more specific and optimized requests, you may wish to limit the
number of columns returned in a row or rowset. This can be achieved by
passing a FROM clause to the select object. The first argument in the
FROM clause is identical to that of a Zend_Db_Select object with the
addition of being able to pass an instance of Zend_Db_Table_Abstract
and have it automatically determine the table name.
Important
The rowset contains rows that are still 'valid' - they simply contain
a subset of the columns of a table. If a save() method is called on a
partial row then only the fields available will be modified.
So, if you called an update() I think it would be as simple as unsetting the value for the column you don't want to touch. Of course database constraints will need to be honored - i.e. column should allow nulls.