How to populate query multiple data returned as arrraylist?
I am new to JSP and likes to know as mentioned in the subject.
There are total 3 files.
createUser.jsp -> Here I have to pupulate TITLE form field drop-down.
TitleDAO.jsp -> Business logic has written to get DB records of titles.
TitleBean.jsp -> getter/setter bean object.
Now Here I am pasting all 3 files.
TitleBean.java
===========
package com.model;
public class TitleBean {
int titleID = 0;
String title = "";
public void TitleBean(){
//nothing for now
public void setTitleID(int titleID){
this.titleID = titleID;
public int getTitleID(){
return this.titleID;
public void setTitle(String title){
this.title = title;
public String getTitle(){
return this.title;
TitleDAO.java
============
package com.model;
import java.util.ArrayList;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
public class TitleDAO {
public ArrayList<Object> getTitles() {
Connection con = null;
ResultSet rs = null;
Statement stmt = null;
//compose the SQL query
String sql = "SELECT titleID,title FROM titleMaster ORDER BY titleID";
// create object for returning data back to calling code
ArrayList<Object> AL = new ArrayList<Object>();
try {
//load the driver
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
//set the connection string URL
String connectionUrl = "jdbc:sqlserver://localhost:1433;"
+ "databaseName=MyFirstServletDB;user=hitesh;password=hitesh;";
//make connection with database
con = DriverManager.getConnection(connectionUrl);
//create the statement with connection object
stmt = con.createStatement();
//get the data into result set
rs = stmt.executeQuery(sql);
//System.out.println("Recordcount==="+rowCount);
//looping through result set
TitleBean tbObj = new TitleBean();;
while(rs.next()){
tbObj.setTitleID(rs.getInt("titleID"));
tbObj.setTitle(rs.getString("title"));
AL.add(tbObj);
System.out.println("TitleID="+rs.getString("titleID")+", Title="+rs.getString("title"));
//close all objects
if(rs != null) rs.close();
if(stmt != null) stmt.close();
if(con != null) con.close();
//set null to the objects
rs = null;
stmt = null;
con = null;
} catch (ClassNotFoundException e) {
System.err.println("Error ClassNotFoundException: " + e.getMessage());
catch (Exception e) {
System.err.println("Error: " + e.getMessage());
return AL;
createUser.jsp
===========
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@page import="com.model.TitleDAO"%>
<%@page import="java.util.ArrayList"%>
<%
TitleDAO tdObj = new TitleDAO();
ArrayList<Object> getTitlesRs = new ArrayList<Object>();
getTitlesRs = tdObj.getTitles();
//show values came from DAO object
for (int i = 0; i < getTitlesRs.size(); i++) {
out.println("<br>Object[" + i + "]=" + getTitlesRs.get(i));
%>
=========================
Please guide me also if there is any other GOOD way to get data of this kind?
Thanks in advance.
Edited by: hiteshpatel1979 on Dec 5, 2007 4:16 AM
Try out following way, fetch bean data from Arraylist.
for (int i = 0; i < getTitlesRs.length; i++)
out.println("<br>Object[" + i + "]=" + getTitlesRs.getTitleID();
out.println("<br>Object[" + i + "]=" + getTitlesRs[i].getTitle();
Similar Messages
-
How to populate DataGird with data returned from php page?
Hi, I'm new in Flex, I try to populate DataGrid with data from PHP, My code is
<mx:HTTPService
id="personRequest" result="getPerson(event)" url=http://localhost/searchPerson.php useProxy="false" method="POST" showBusyCursor="true" resultFormat="e4x">
</ mx:HTTPService>
<mx:DataGrid
id="searchResult" dataProvider="{???what to paste here???}" y="30">
</mx:DataGrid>
private
function getPerson(evt:ResultEvent):void { var res:XMLList = evt.result..dane as XMLList;searchResults =
new XMLListCollection(res);
output from PHP
<person>
<dane>
<name>ABC</name>
<street>XLXXLX</street>
</dane>
<dane>
<name>DEF</name>
<street>YAYAYAY</street>
</dane>
</person>
If I set the dataProvider as "searchResults" it doesn't work. I probably have to set as dataprovider any ArrayCollection , but I don't know how to convert my XMLListCollection to it.
Could anyone help me populate Datagrid with
name | streer
ABC, XLXXLX
DEF, YAYAYAY
Best Regards,
MariuszThanks for your reply, but I'm afraid it doesn't work :-( Could you browse my code and check what I'm doing wrong???
full mxml code:
<?xml version="1.0" encoding="utf-8"?><mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="personRequest.send()">
<mx:Script><![CDATA[
import mx.rpc.events.ResultEvent;
[Bindable]
public var searchResultsXML:XML;
private function getPerson(evt:ResultEvent):void
{ searchResultsXML = (evt.result
as XML);
trace(searchResultsXML); }
]]></mx:Script>
<mx:HTTPService
id="personRequest" result="getPerson(event)" url=http://localhost/searchPerson.php useProxy="false"
method="POST" showBusyCursor="true" resultFormat="e4x"></mx:HTTPService>
<mx:DataGrid id="searchResult" dataProvider="{searchResultsXML.dane}"></mx:DataGrid>
</mx:Application>
trace statement returns:
<person>
<dane>
<id>1</id>
<nazwisko>Topczewski</nazwisko>
<imie>Mariusz</imie>
<imie2/>
<miejscowosc>Bia?ystok</miejscowosc>
<ulica>Nowogródzka</ulica>
<dom>7B</dom>
<lokal>25</lokal>
</dane>
<dane>
<id>1</id>
<nazwisko>Topczewski</nazwisko>
<imie>Mariusz</imie>
<imie2/>
<miejscowosc>Bia?ystok</miejscowosc>
<ulica>Sybiraków</ulica>
<dom>15</dom>
<lokal>27</lokal>
</dane>
</person> -
How to Populate Internal table data to Table Control in a Report Program
Dear All,
How to Populate Internal table data to Table Control in a Report Program? It is a pure report program with out any Module pool coding involved, which is just used to display data. Till now it is being displayed in a report. Now the user wants the data to be displayed in a table control. Could someone tell me how to go about with this.
Thanks in Advance,
Joseph ReddyIf you want to use a table control, you will need to create a screen.
In your report....
start-of-selection.
perform get_data. " Get all your data here
call screen 100. " Now present to the user.
Double click on the "100" in your call screen statement. This will forward navigate you to the screen. If you have not created it yet, it will ask you if you want to create it, say yes. Go into screen painter or layout of the screen. Use the table control wizard to help you along the process. It will write the code for you. Since it is an output only table control, it will be really easy with not a lot of code.
A better way to present the data to the user would be to give it in a ALV grid. If you want to go that way, it is a lot easier. Here is a sample of the ALV function module. You don't even have to create a screen.
report zrich_0004
no standard page heading.
type-pools slis.
data: fieldcat type slis_t_fieldcat_alv.
data: begin of imara occurs 0,
matnr type mara-matnr,
maktx type makt-maktx,
end of imara.
* Selection Screen
selection-screen begin of block b1 with frame title text-001 .
select-options: s_matnr for imara-matnr .
selection-screen end of block b1.
start-of-selection.
perform get_data.
perform write_report.
* Get_Data
form get_data.
select mara~matnr makt~maktx
into corresponding fields of table imara
from mara
inner join makt
on mara~matnr = makt~matnr
where mara~matnr in s_matnr
and makt~spras = sy-langu.
endform.
* WRITE_REPORT
form write_report.
perform build_field_catalog.
* CALL ABAP LIST VIEWER (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = fieldcat
tables
t_outtab = imara.
endform.
* BUILD_FIELD_CATALOG
form build_field_catalog.
data: fc_tmp type slis_t_fieldcat_alv with header line.
clear: fieldcat. refresh: fieldcat.
clear: fc_tmp.
fc_tmp-reptext_ddic = 'Material Number'.
fc_tmp-fieldname = 'MATNR'.
fc_tmp-tabname = 'IMARA'.
fc_tmp-outputlen = '18'.
fc_tmp-col_pos = 2.
append fc_tmp to fieldcat.
clear: fc_tmp.
fc_tmp-reptext_ddic = 'Material'.
fc_tmp-fieldname = 'MAKTX'.
fc_tmp-tabname = 'IMARA'.
fc_tmp-outputlen = '40'.
fc_tmp-col_pos = 3.
append fc_tmp to fieldcat.
endform.
Regards,
Rich Heilman -
How to populate the Quering data into Excel sheet in Oracle
Dear Guys,
How to populate the Quering data into Excel sheet in oracle.
Please provide a solution.
Thanks & Regards,
Senthil K KumarHi
To make Excel sheets from sqlplus, you can use the markup html tag in sqlplus.
Here's an example.
Example
<code>
SET LINESIZE 4000
SET VERIFY OFF
SET FEEDBACK OFF
SET PAGESIZE 999
SET MARKUP HTML ON ENTMAP ON SPOOL ON PREFORMAT OFF
SPOOL c:\test_xls.xls
SELECT object_type
, SUBSTR( object_name, 1, 30 ) object
, created
, last_ddl_time
, status
FROM user_objects
ORDER BY 1, 2
SPOOL OFF
SET MARKUP HTML OFF ENTMAP OFF SPOOL OFF PREFORMAT ON
SET LINESIZE 2000 VERIFY ON FEEDBACK ON
</code> -
Question:
There is a scenario that users want to send multiple rows returned by Execute SQL Task as Email content to send to someone. With Execute SQL Task, the Full result set is used when the query returns multiple rows, it must map to a variable of the Object data
type, then the return result is a rowset object, so we cannot directly send the result variable as Email content. Is there a way that we can extract the table row values that are stored in the Object variable as Email content to send to someone?
Answer:
To achieve this requirement, we can use a Foreach Loop container to extract the table row values that are stored in the Object variable into package variables, then use a Script Task to write the data stored in packages variables to a variable, and then set
the variable as MessageSource in the Send Mail Task.
Add four variables in the package as below:
Double-click the Execute SQL Task to open the Execute SQL Task Editor, then change the ResultSet property to “Full result set”. Assuming that the SQL Statement like below:
SELECT Category, CntRecords
FROM [table_name]
In the Result Set pane, add a result like below (please note that we must use 0 as the result set name when the result set type is Full result set):
Drag a Foreach Loop Container connects to the Execute SQL Task.
Double-click the Foreach Loop Container to open the Foreach Loop Editor, in the Collection tab, change the Enumerator to Foreach ADO Enumerator, then select User:result as ADO object source variable.
Click the Variable Mappings pane, add two Variables as below:
Drag a Script Task within the Foreach Loop Container.
The C# code that can be used only in SSIS 2008 and above in Script Task as below:
public void Main()
// TODO: Add your code here
Variables varCollection = null;
string message = string.Empty;
Dts.VariableDispenser.LockForWrite("User::Message");
Dts.VariableDispenser.LockForWrite("User::Category");
Dts.VariableDispenser.LockForWrite("User::CntRecords");
Dts.VariableDispenser.GetVariables(ref varCollection);
//Format the query result with tab delimiters
message = string.Format("{0}\t{1}\n",
varCollection["User::Category"].Value,
varCollection["User::CntRecords"].Value
varCollection["User::Message"].Value = varCollection["User::Message"].Value + message;
Dts.TaskResult = (int)ScriptResults.Success;
The VB code that can be used only in SSIS 2005 and above in Script Task as below, please note that in SSIS 2005, we should
change PrecompileScriptIntoBinaryCode property to False and Run64BitRuntime property to False
Public Sub Main()
' Add your code here
Dim varCollection As Variables = Nothing
Dim message As String = String.Empty
Dts.VariableDispenser.LockForWrite("User::Message")
Dts.VariableDispenser.LockForWrite("User::Category")
Dts.VariableDispenser.LockForWrite("User::CntRecords")
Dts.VariableDispenser.GetVariables(varCollection)
'Format the query result with tab delimiters
message = String.Format("{0}" & vbTab & "{1}" & vbLf, varCollection("User::Category").Value, varCollection("User::CntRecords").Value)
varCollection("User::Message").Value = DirectCast(varCollection("User::Message").Value,String) + message
Dts.TaskResult = ScriptResults.Success
End Sub
Drag Send Mail Task to Control Flow pane and connect it to Foreach Loop Container.
Double-click the Send Mail Task to specify the appropriate settings, then in the Expressions tab, use the Message variable as the MessageSource Property as below:
The final design surface like below:
References:
Result Sets in the Execute SQL Task
Applies to:
Integration Services 2005
Integration Services 2008
Integration Services 2008 R2
Integration Services 2012
Integration Services 2014
Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.Thanks,
Is this a supported scenario, or does it use unsupported features?
For example, can we call exec [ReportServer].dbo.AddEvent @EventType='TimedSubscription', @EventData='b64ce7ec-d598-45cd-bbc2-ea202e0c129d'
in a supported way?
Thanks! Josh -
Querying multiple date ranges in one select
Hello guys,
DDL:
CREATE TABLE DBO.SALES (
TYPE VARCHAR(50)
, REVENUE DECIMAL(19,2)
, SALE_DATE_TIME DATETIME)
What I'm trying to figure out is how I can pass two dates to a where clause querying this table, a start date and an end date. From this I can group up the REVENUE for each TYPE (but there's more):
SELECT TYPE, COUNT(*) AS NBR_OF_SALES, SUM(REVENUE) AS TOTAL_REVENUE
FROM REPORTS.DBO.SALES
WHERE SALE_DATE_TIME BETWEEN @STARTPERIOD AND @ENDPERIOD
GROUP BY TYPE
I'd now like to add a couple of extra columns in the select that calculates the TOTAL_REVENUE equal to the time period of the two dates, but offset by 1 week, 1 month and 1 year, so that would be three columns. I'm guessing this would be possible with a
CROSS APPLY, but I just can't get my head around it at this time. Just for clarity, the expected output would contain these columns:
TYPE, NBR_OF_SALES, TOTAL_REVENUE, TOTAL_REVENUE_LAST_WEEK, TOTAL_REVENUE_LAST_MONTH, TOTAL_REVENUE_LAST_YEAR
Any help is greatly appreciated.SELECT TYPE,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN @STARTPERIOD AND @ENDPERIOD THEN 1 ELSE 0 END) AS NBR_OF_SALES,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN DATEADD(WEEK,1,@STARTPERIOD) AND DATEADD(WEEK,1,@ENDPERIOD) THEN 1 ELSE 0 END) AS NBR_OF_SALES_WeekOffset,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN DATEADD(MONTH,1,@STARTPERIOD) AND DATEADD(MONTH,1,@ENDPERIOD) THEN 1 ELSE 0 END) AS NBR_OF_SALES_MonthOffset,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN @STARTPERIOD AND @ENDPERIOD THEN REVENUE ELSE 0 END) AS TOTAL_REVENUE,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN DATEADD(WEEK,1,@STARTPERIOD) AND DATEADD(WEEK,1,@ENDPERIOD) THEN REVENUE ELSE 0 END) AS TOTAL_REVENUE_WeekOffset,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN DATEADD(MONTH,1,@STARTPERIOD) AND DATEADD(MONTH,1,@ENDPERIOD) THEN REVENUE ELSE 0 END) AS TOTAL_REVENUE_MonthOffset
FROM REPORTS.DBO.SALES
WHERE SALE_DATE_TIME BETWEEN @STARTPERIOD AND DATEADD(MONTH,1,@ENDPERIOD)
GROUP BY TYPE
Is this what you want?
We have three total columns per metric, one for the period, one for the period offset by a week, and one for the period offset by a month.
We've also adjusted the where so all the data for the offset period is included. -
How to efficiently log multiple data streams with TDMS
Ok, first off, I'll admit I am completely clueless when it comes to logging, TDMS in particular. That said, I'm trying to work out the best way to log some data from an existing LabVIEW-based control system, so that users can later access that data in the event of catastrophic failure or other situations where they might want to see exactly what happened during a particular run.
I've got a total of between 6 and 12 data points that need to be stored (depending on how many sensors are on the system). These are values being read from a cRIO control system. They can all be set to Single data type, if necessary - even the one Boolean value I'm tracking is already being put through the "convert to 0,1" for graph display purposes. The data is currently read at 100ms intervals for display, but I will be toying with the rate that I want to dump data to the disk - a little loss is OK, just need general trending for long term history. I need to keep file sizes manageable, but informative enough to be useful later.
So, I am looking for advice on the best way to set this up. It will need to be a file that can be concurrently be read as it is being written, when necessary - one of the reasons I am looking at TDMS in the first place (it was recommended to me previously). I also need an accurate Date/Time stamp that can be used when displaying the data graphically on a chart, so they can sync up with the external camera recordings to correlate just what happened and when.
Are there specific pitfalls I should watch for? Should I bundle all of the data points into an array for each storage tick, then decimate the array on the other end when reading? I've dug through many of the examples, even found a few covering manual timestamp writing, but is there a preferred method that keeps file size minimized (or extraction simplified)?
I definitely appreciate any help... It's easy to get overwhelmed and confused in all of the various methods I am finding for handling TDMS files, and determining which method is right for me.I need to bump this topic again... I'll be honest, the TDMS examples and available help are completely letting me down here.
As I stated, I have up to 12 data values that I need to stream into a log file, so TDMS was suggested to me. The fact that I can concurrently read a file being written to was a prime reason I chose this format. And, "it's super easy" as I was told...
Here's the problem. I have multiple data streams. Streams that are not waveform data, but actual realtime data feedback from a control system, that is being read from a cRIO control system into a host computer (which is where I want to log the data). I also need to log an accurate timestamp with this data. This data will be streamed to a log file in a loop that consistently writes a data set every 200ms (that may change, not exactly sure on the timing yet).
Every worthwhile example that I've found has assumed I'm just logging a single waveform, and the data formatting is totally different from what I need. I've been flailing around with the code, trying to find a correct structure to write my data (put it all in an array, write individual points, etc) and it is, quite honestly, giving me a headache. And finding the correct way for applying the correct timestamp (accurate data and time the data was collected) is so uncharacteristically obtuse and hard to track down... This isn't even counting how to read the data back out of the file to display for later evaluation and/or troubleshooting... Augh!
It's very disheartening when a colleague can throw everthing I'm trying to do together in 12 minutes in the very limited SCADA user interface program he uses to monitor his PLCs... Yet LabVIEW, the superior program I always brag about, is slowly driving me insane trying to do what seems like a relatively simple task like logging...
So, does anyone have any actual useful examples of logging multiple DIFFERENT data points (not waveforms) and timestamps into a TDMS file? Or real suggestions for how to accomplish it, other than "go look at the examples" which I have done (and redone). Unless, of course, you have an actual relevant example that won't bring up more questions than it answers for me, in which case I say "bring it on!"
Thanks for any help... My poor overworked brain will be eternally grateful. -
InfoSet Query no data returned
Hi,
I've created InfoSet Query and Query respectively for the same InfoSet. However, only Query returns data and the InfoSet Query returns no data.
Best regards,
tsHi Venkat,
This is BW forum and never post/include your issue in other threads.
if your facing problem about plant data then please post your issue at SAP MM forum.
MM forum link can find below link.
SCN Site Index
How to create a discussion:
http://scn.sap.com/docs/DOC-46003
Thanks -
How to populate my input data into java bean through
Hi,
I have one doubt in swing how many ways we can populate the input properties(data fron gui screen) into my javabean object(Simple POJO)
Thanks,
TukuHi,
I have one doubt in swing how many ways we can populate the input properties(data fron gui screen) into my javabean object(Simple POJO)
Thanks,
Tuku -
Query multiple data sources via keys (federated query)
I have a requirement to fetch data from two different databases, one financial and one operational, to make compound measure (a ratio). I need to fetch a value for the number of calls answered in a call centre from one database (we'll call this "CustomerCare" and the measure "CallsAnswered") I have a good degree of control over this system as it sits in my department so I can add foreign keys into the live tables or add mapping tables, etc. The other measure I need is the wage bill for the same period which comes from a finance database (we'll call this "FinanceMart" and the measure "WageBill").
My problem is that we run this for several joint venture companies and the query needs to take that into account allowing each JV to see only their data. To date all of my tests with OBIEE would issue the following query to both databases...
SELECT Date,CallsAnswered,WageBill FROM <DATABASE> WHERE JointVenture = "JV Motors"
... but that only works if the joint ventures are named the same in both systems and they are not. I need to report by the names in my CustomerCare database (they are familiar to the business) so the only thing I can think to do is to put mapping details (either keys or text values) into my tables and have OBIEE join on those. When I tried this OBIEE failed to issue a query against the FinanceMart as soon as I introduced the JointVenture field but otherwise it works fine when I use either the mapping field or when I use just date.
If anyone can shed some light on this it would be much appreciated.
Thanks in advance.Both schemas are definitely stars, this example is a slimmed-down version of the real environment (I have many more measures and dimensions) but I only need the one measure from the FinanceMart.
As an example the CustomerCare DB has the following JVs: Star Autos, Fulton Honda, Mortlake Scooters. In the FinanceMart the same three would read: Automotive Sales (UK) Ltd, Jack Fulton & Son Ltd, Peter Evans Motor Company Ltd.
That's why I need some kind of mapping, I just need to know how to configure OBIEE to join on one column but allow you to report by another. -
Hi,
I have created procedure to analyze tables. I tried to get output but its not displaye in a proper way. I want to output as like as a query output.
create or replace procedure tablestats
as
begin
for cur in (SELECT OWNER,TABLE_NAME, NUM_ROWS, BLOCKS, AVG_ROW_LEN,TO_CHAR(LAST_ANALYZED, 'MM/DD/YYYY HH24:MI:SS')FROM DBA_TABLES WHERE OWNER='SCOTT') LOOP
dbms_output.put_line(cur.owner||' '||' '||cur.table_name||' '||cur.NUM_ROWS||' '||cur.BLOCKS||' '||cur.AVG_ROW_LEN);
DBMS_STATS.GATHER_TABLE_STATS('scott',cur.table_name);
end loop;
end;
Output came lke this:
SQL> exec tablestats
SCOTT DEPT 4 4 20
SCOTT EMP 14 4 38
SCOTT SALGRADE 5 4 10
SCOTT SERVICE 8 5 12
SCOTT BONUS 0 0 0
PL/SQL procedure successfully completed.
Acually i want output like..
1* SELECT OWNER,TABLE_NAME, NUM_ROWS, BLOCKS, AVG_ROW_LEN,TO_CHAR(LAST_ANALYZED, 'MM/DD/YYYY HH24:MI:SS') Last_Analyzed FROM DBA_TABLES WHERE OWNER=
'SCOTT'
SQL> /
OWNER TABLE_NAME NUM_ROWS BLOCKS AVG_ROW_LEN LAST_ANALYZED
SCOTT DEPT 4 4 20 11/27/2013 19:10:44
SCOTT EMP 14 4 38 11/27/2013 19:10:44
SCOTT SALGRADE 5 4 10 11/27/2013 19:10:44
SCOTT SERVICE 8 5 12 11/27/2013 19:10:44
SCOTT BONUS 0 0 0 11/27/2013 19:10:44
Please help me.
Thanks,Hi,
As John said, PL/SQL doesn't give you any of the nice formatting features that front end tools, like SQL*Plus, provide. If you want headers, you have to say exactly what they are, and write them yourself. If you want the columns to line up, you have to decide how long they will be and pad them yourself. It's a lot of work.
Why not let PL/SQL do the things that only PL/SQL can do, and let SQL*Plus do the things it does well? Have your procedure or function return a cursor, which you can then diplay in SQL*Plus, or write a piplined function, that you can use in queries where SQL*Plus can format the results.
The query you posted can eaisly be done directly from SQL*Plus, of course. I assume you posted a very simple example, becuase your question is just about display. If you don't absolutely need PL/SQL, don't use PL/SQL. What I said above applies if you really do need PL/SQL. -
How can I save multiple data coming in from my data string
I am a newbie at labview. I have a scale connected to my RS 232 and made a VI to display the changing scale. I am trying to save the multiple changes as my weight varies but have been only able to save the last value. Is there a simple way to save all the values I see in my VI to a file for later plotting? I have done one before using indexing but the case this time is that I am receiving a character string and not a numeric array. Any examples or advice would be great!!! Thanks
GeraldHi Gerald,
What you need to do is write to a file continuously, i.e. after each point you collect. You can do so by opening a new/existing file, write to it inside your while loop, and close it once you are done collecting and writing data points, i.e. outside the loop.
I believe the following example is a good demonstration of that operation.
Best of luck,
AG
Attachments:
write to file.vi 33 KB -
How To Populate An Advanced Data Grid In Flex With An XML Document Created In JAVA
Flex Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="856" height="698" initialize="onInitData()">
<mx:RemoteObject destination="utilityUCFlexRO" id="utilityUCFlexRO">
<mx:method name="updateStationDetails" result="handleUpdateStationDetailsResult(event)" fault="handleUpdateStationDetailsFault(event)"/>
</mx:RemoteObject>
<mx:RemoteObject id="uniqueIdMasterUCFlexRO" destination="uniqueIdMasterUCFlexRO">
<mx:method name="readByCustomerName" result="handleReadByCustomerNameResult(event)" fault="handleReadByCustomerNameFault(event)"/>
<mx:method name="getCustomerAcDetails" result="handlegetCustomerAcDetailsResult(event)" fault="handlegetCustomerAcDetailsFault(event)"/>
</mx:RemoteObject>
<mx:Script>
<![CDATA[
import mx.events.ListEvent;
import mx.collections.ItemResponder;
import com.citizen.cbs.model.UniqueIdMaster;
import mx.managers.PopUpManager;
import mx.controls.ProgressBarMode;
import mx.effects.Fade;
import mx.controls.ProgressBar;
import com.citizen.cbs.CitizenApplication;
import mx.core.Application;
import mx.messaging.messages.ErrorMessage;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
private var moduleCloseFlag:Boolean=false;
private var v:UniqueIdMaster;
[Bindable]
private var customerDetails:ArrayCollection;
[Bindable]
private var branch:int=0;
[Bindable]
private var XMLDocument:XML;
[Bindable]
private var acDetails:XMLList;
private var _progBar:ProgressBar = new ProgressBar();
private function showLoading(e:Event = null):void
_progBar.width = 200;
_progBar.indeterminate = true;
_progBar.labelPlacement = 'center';
_progBar.setStyle("removedEffect", Fade);
_progBar.setStyle("addedEffect", Fade);
_progBar.setStyle("color", 0xFFFFFF);
_progBar.setStyle("borderColor", 0x000000);
_progBar.setStyle("barColor", 0x6699cc);
_progBar.label = "Please wait.......";
_progBar.mode = ProgressBarMode.MANUAL;
PopUpManager.addPopUp(_progBar,this,true);
PopUpManager.centerPopUp(_progBar);
_progBar.setProgress(0, 0);
private function onInitData():void
utilityUCFlexRO.updateStationDetails(CitizenApplication.menuParameters["modulecode"]);
private function handleUpdateStationDetailsResult(event:ResultEvent):void
if(moduleCloseFlag==true)
Application.application.unloadModule();
private function handleUpdateStationDetailsFault(event:FaultEvent):void
var errorMessage:ErrorMessage = event.message as ErrorMessage;
Alert.show(errorMessage.rootCause.message);
private function onSearch():void
if(txtName.text=="" || txtName.text==null)
Alert.show("Enter a name for search");
return;
if((txtName.text).length < 4)
Alert.show("Search should contain more than 3 alphabets");
return;
var d:String = txtName.text;
branch = CitizenApplication.initInfo.registeredUser.branchDetails.bdBranchNo;
uniqueIdMasterUCFlexRO.readByCustomerName(d,branch);
showLoading();
private function handleReadByCustomerNameResult(event:ResultEvent):void //In handle if record does not exists, dsiplays error message and resets the field
customerDetails =ArrayCollection(event.result);
PopUpManager.removePopUp(_progBar);
if(customerDetails.length==0)
Alert.show("Record Not Found, Enter Proper Name ");
onReset();
private function handleReadByCustomerNameFault(event:FaultEvent):void
Alert.show(event.fault.faultDetail + " -- " + event.fault.faultString + "handleReadByCustomerNameFault");
private function onReset():void
customerDetails=new ArrayCollection();
txtName.text="";
private function onCancel():void
utilityUCFlexRO.updateStationDetails("MM0001");
moduleCloseFlag=true;
private function btnBackClick():void
view1.selectedIndex=0;
private function btnBackClick1():void
view1.selectedIndex=1;
private function onItemClick( e:ListEvent ):void
if(dgCustDetails.selectedItem == null)
Alert.show("Select Proper Record");
else
lblId.text = e.itemRenderer.data.uimCustomerId;
lblName.text = e.itemRenderer.data.uimCustomerName;
var custId:int = Number(lblId.text);
uniqueIdMasterUCFlexRO.getCustomerAcDetails(custId,branch);
showLoading();
private function handlegetCustomerAcDetailsResult(event:ResultEvent):void
//XMLDocument = event.result as XML;
acDetails = new XMLList(event.result.menu);
//Alert.show("Name: "+event.result.@name);
PopUpManager.removePopUp(_progBar);
view1.selectedIndex=1;
//adg1.dataProvider=acDetails;
private function handlegetCustomerAcDetailsFault(event:FaultEvent):void
PopUpManager.removePopUp(_progBar);
Alert.show(event.fault.faultDetail + " -- " + event.fault.faultString + "handlegetCustomerAcDetailsFault");
]]>
</mx:Script>
<mx:ViewStack height="688" width="856" id="view1">
<mx:Canvas>
<mx:Panel x="51" y="25" width="754" height="550" layout="absolute" title="Customer Search Page">
<mx:HBox x="174" y="26" horizontalAlign="center" verticalAlign="middle">
<mx:Label text="Enter Name:"/>
<mx:TextInput id="txtName" width="228"/>
<mx:LinkButton label="Search" click="onSearch()"/>
</mx:HBox>
<mx:Label text="--" id="lblId" x="40" y="194"/>
<mx:Label text="--" id="lblName" x="40" y="226"/>
<mx:DataGrid dataProvider="{customerDetails}" id="dgCustDetails" allowMultipleSelection="false" editable="false"
showHeaders="true" draggableColumns="false" width="718" height="373" itemClick="onItemClick(event);" x="10" y="61">
<mx:columns>
<mx:DataGridColumn headerText="Customer Id" dataField="uimCustomerId" width="150"/>
<mx:DataGridColumn headerText="Customer Name" dataField="uimCustomerName"/>
</mx:columns>
</mx:DataGrid>
<mx:ControlBar>
<mx:Button label="CANCEL" click="onCancel()" width="80"/>
<mx:Button label="RESET" click="onReset()" width="80"/>
</mx:ControlBar>
</mx:Panel>
</mx:Canvas>
<mx:Canvas>
<mx:TitleWindow x="10" y="10" width="836" height="421" layout="absolute">
<mx:AdvancedDataGrid x="6.5" y="10" id="adg1" designViewDataType="tree" variableRowHeight="true" width="807" height="278" fontSize="14">
<mx:dataProvider>
<mx:HierarchicalData source="{acDetails}"/>
</mx:dataProvider>
<mx:groupedColumns>
<mx:AdvancedDataGridColumn headerText="Type Of A/c" dataField="@Name" width="150"/>
<mx:AdvancedDataGridColumn headerText="Details Of A/c"/>
</mx:groupedColumns>
<mx:rendererProviders>
<mx:AdvancedDataGridRendererProvider id="adgpr1" depth="2" columnIndex="1" renderer="AcDetails1" columnSpan="0"/>
</mx:rendererProviders>
</mx:AdvancedDataGrid>
<mx:ControlBar height="56" y="335">
<mx:Button label="BACK" width="80" click="btnBackClick()"/>
<mx:Spacer width="100%"/>
<mx:Button label="EXIT" click="onCancel()" width="80"/>
</mx:ControlBar>
</mx:TitleWindow>
</mx:Canvas>
</mx:ViewStack>
</mx:Module>
XML File Generated In JAVA:
<?xml version="1.0" encoding="UTF-8"?>
<menu>
<AcType Name="Savings">
<SavingAcDetails AcName="Mr. MELROY BENT" AccountNo="4" ClearBalance="744.18" ProductID="SB" TotalBalance="744.18">
<SavingMoreAcDetails AcStatus="OPERATIVE" AcType="NORMAL" FreezeCode="No Freeze" ModeOfOper="AnyOne Single Or Survivor"/>
</SavingAcDetails>
</AcType>
<AcType Name="TermDeposit">
<TDAcDetails AcName="Mr. BENT MELROY" AccountNo="1731" ProductID="TD">
<TDMoreAcDetails AcStatus="OPERATIVE" AcType="NORMAL" FreezeCode="No Freeze" ModeOfOper="Either or Survivor"/>
</TDAcDetails>
<TDAcDetails AcName="Mr. BENT MELROY" AccountNo="2287" ProductID="TD">
<TDMoreAcDetails AcStatus="NEW" AcType="NORMAL" FreezeCode="No Freeze" ModeOfOper="Self"/>
</TDAcDetails>
<TDAcDetails AcName="Mr. BENT MELROY" AccountNo="78" ProductID="TD">
<TDMoreAcDetails AcStatus="OPERATIVE" AcType="NORMAL" FreezeCode="No Freeze" ModeOfOper="Self"/>
</TDAcDetails>
</AcType>
</menu>
Tried Alot Of Examples Online But In Vain....
Need Help....
Thanks In Advance....Please help me !!!! I have been stuck up with this issue for the past two days and I need to atleast figure out if this is possible or not in the first place.
-
How do you query activity data for accounts?
I need to extract account activity data. When I try to use the Activity WSDL it doesn't seem to provide any account information even though I do see fields like AccountId, AccountName. They are blank. Also it looks like there is way to do a activity query using the Account WSDL. Does anyone have an example of this?
We are using Release 18 with V2 WSDL.
Thank you,
Dan
Edited by: dansshin on Oct 14, 2010 2:33 PMI'm not sure what you mean by XML string but I'm trying to extract to CSV file using this code. It provides activity data but looks like account information fields are blank.
Thank you,
Dan
private static void ExtractGrowerAccountActivity(String sessionID, String csvFileName)
try
// Download the opportunity wsdl from the Admin section of the CRM application
// Add web reference to the wsdl
// Create the instance of the account entity
Activity myAcctAct = new Activity();
myAcctAct.Url = ConfigurationManager.AppSettings["OnDemandURL"] + "/Services/Integration;jsessionid=" + sessionID;
// Set the query
// To find the record with account type as grower
Activity_WS.queryType myAcctName = new Activity_WS.queryType();
myAcctName.Value = "";
// Create query instance and set the appropriate parameters
Activity_WS.ActivityQuery myAcctActQuery = new Activity_WS.ActivityQuery();
myAcctActQuery.AccountId = new Activity_WS.queryType();
myAcctActQuery.AccountName = myAcctName;
myAcctActQuery.AccountExternalSystemId = new Activity_WS.queryType();
myAcctActQuery.Id = new Activity_WS.queryType();
myAcctActQuery.Activity = new Activity_WS.queryType();
myAcctActQuery.CreatedByFullName = new Activity_WS.queryType();
myAcctActQuery.CreatedDate = new Activity_WS.queryType();
myAcctActQuery.DueDate = new Activity_WS.queryType();
myAcctActQuery.Completed = new Activity_WS.queryType();
myAcctActQuery.CompletedDatetime = new Activity_WS.queryType();
myAcctActQuery.Subject = new Activity_WS.queryType();
myAcctActQuery.Type = new Activity_WS.queryType();
// Set ListOfAccountQuery
Activity_WS.ListOfActivityQuery lstOfAcctActQuery = new Activity_WS.ListOfActivityQuery();
lstOfAcctActQuery.Activity = myAcctActQuery;
// Number of records to fetch
lstOfAcctActQuery.pagesize = "100";
// set ActivityQueryPage_Input
ActivityQueryPage_Input myActInput = new ActivityQueryPage_Input();
myActInput.ListOfActivity = lstOfAcctActQuery;
// Get the output
ActivityQueryPage_Output myOutput = myAcctAct.ActivityQueryPage(myActInput);
// Get ListOfAccountData
Activity_WS.ListOfActivityData myAcctActData = myOutput.ListOfActivity;
Activity_WS.ActivityData[] acctActData = myAcctActData.Activity;
// Write to output file
if (acctActData.Length > 0)
using (var sw = new StreamWriter(csvFileName))
// Write header
sw.WriteLine("AccountID, AccountName, AccountType, ExternalID, ActivityID, ActivityType, CreatedBy, CreatedDate, DueDate, IsCompleted, CompletedDate, Subject, Type");
for (int i = 0; i < acctActData.Length; i++)
// Write detail
sw.WriteLine(string.Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}",
acctActData.AccountId,
acctActData[i].AccountName,
"Account Type",
acctActData[i].AccountExternalSystemId,
acctActData[i].Id,
acctActData[i].Activity,
acctActData[i].CreatedByFullName,
acctActData[i].CreatedDate,
acctActData[i].DueDate,
acctActData[i].Completed == true ? "Y" : "N",
acctActData[i].CompletedDatetime,
acctActData[i].Subject,
acctActData[i].Type));
// Write to log
log.Message = string.Format("INFO: {0} Grower account activity record(s) extracted.", acctActData.Length);
log.Categories.Add(Category.General);
log.Priority = Priority.Normal;
writer.Write(log);
catch (Exception ex)
log.Message = string.Format("ERROR: " + ex.ToString());
log.Categories.Add(Category.Error);
log.Priority = Priority.High;
writer.Write(log); -
How can I copy multiple data cd's onto a dvd?
I figured I would copy all my 3rd party software cd's onto a dvd so it takes up less space. How can I do this?
RobI'm not entirely familliar with OS X and CD's, but I'd imagine you could copy the files to your Hard Drive, and then from there, burn them onto DVDs?
Maybe you are looking for
-
Illustrator CC won't open on Yosemite.
Hello I recently purchased the CC suite on a student payment plan. I primarily use Premiere, Photoshop and After Effects. Today I tried opening Illustrator for the first time and I'll get it to open but once I click create or hover over any of the
-
dear experts, what are the tables( with fields) and conditions to develope a report on daily cash receipts.
-
How to add various ttf fonts for office on e61i
hello i own e61i. its great. but this is one problem. i don't know how to add other fonts to it, so i can use them in quickoffise. our organisation uses specific ttf fonts. so i need them in my 61i. when i had 6630, i could use any font i wanted, so
-
Why can't I restore my ipod touch?
My ipod is still on the screen that shows the ipod needs to connect toitunes when i connect it to restore it won't connect to itunes
-
How to install silently Adobe Captivate 4
Hello, I have tried to use the KB 325175 and apply the same command line used in Captivate 3 to the new Captivate 4: setup.exe /s /v"/qn SERIALNUMBER=\"xxxxxxxxxxxxxxxxxxxxxxxx\" ALLUSERS=1 REBOOT=ReallySuppress" However, I got full user interface an