Adding data to array from an empty query

I am trying to add data to an array from a database query, however some queries will return no data (empty set). In that case I would like to add fake data so that the index size matches my other array (assetsid).
Thank you for your time.
     int f2a=0;
     String[] exportedtime;
     String[] exportedtime_formated;
     ArrayList exportedtime_ar = new ArrayList(f2a);
     ArrayList exportedtime_formated_ar = new ArrayList(f2a);
     for (int jj=0; jj<assetsid_ar.size(); jj++)
          String eng_id_out = (String) eng_id_h2a_ar.get(jj);
          String fuel2a = "select engineserialnumber, TO_CHAR(exportedtime, 'MM/DD/YYYY HH24:MI:SS') exportedtime, TO_CHAR(exportedtime, 'DD/MON/YY') as exportedtime_formated from tblexportedjobs where exportid = (select max(exportid) from tblexportedjobs where engineserialnumber = "+eng_id_out+") and engineserialnumber = "+eng_id_out+"";
          ResultSet fuel2a_myResultSet = stmt.executeQuery(fuel2a);
              while (fuel2a_myResultSet.next()) {
               f2a=f2a+1;
               exportedtime = new String[f2a+1];
               exportedtime_formated = new String[f2a+1];
               exportedtime[f2a]=fuel2a_myResultSet.getString("exportedtime");
               exportedtime_formated[f2a]=fuel2a_myResultSet.getString("exportedtime_formated");
     if (exportedtime[f2a].equals("")) {
    exportedtime[f2a] = "01/01/2004 00:01:01";
     } else {
     exportedtime[f2a] = exportedtime[f2a];
               exportedtime_ar.add(exportedtime[f2a]);
     if (exportedtime_formated[f2a].equals("")) {
    exportedtime_formated[f2a] = "01/JAN/04";
     } else {
     exportedtime_formated[f2a] = exportedtime_formated[f2a];
               exportedtime_formated_ar.add(exportedtime_formated[f2a]);
     }

I'd be curious to know if it would be possible to rewrite your query using a JOIN so you could get all the data in one query. The way you've written it will require N network round trips, where N is the number of engine serial numbers. I wonder if clever application of a JOIN with a GROUP BY would do the trick in one?
I don't care for the formatting stuff you're doing, either. There's no need to ask the database for that. Bring the dates over and handle the formatting in Java using java.text.SimpleDateFormat. Less work for the database AND it won't be so tied to Oracle, since you won't need that TO_CHAR function anymore.
I'd give clients the raw java.sql.Date and let them worry about formatting it the way they wish. That's not a persistence concern.
I always prefer data structures like List and Map when I'm working with database result sets. They grow to fit the # of records that I get back. If I want arrays, I can always use the toArray() method to generate them.

Similar Messages

  • Adding data to HealthVault from Withings Device

    How do I upload data from my Withings Device to my HealthVault account?

    The nice people from Sinovo have developed a driver for Microsoft HealthVault Connection Center that will allow uploading CSV files downloaded from the Withings dashboard into HealthVault. Some restrictions do apply:
    only weight measurements work at the moment.
    you must download your CSV from the OLD version of the Withings Healthmate website, the CSV files from the new version DO NOT WORK with Sinovo's driver.
    the CSV file must not be opened and saved in Excel before uploading, Excel will change some formatting in the file rendering it useless for uploading.
    You can select a date range before downloading your CSV file from the Withings Healthmate website to avoid uploading duplicates.

  • Filter on date and time from Live Office query panel (Excel)

    Hi,
         I'd like to know if someone already tried this.
    1- Create a univers with 3 fields.
    a. Field 1 type date: points to a type date field (ex: 2011-12-31 00:00:00)
    b. Field 2 type date: points to a type time field (ex: 17:00:00) -> which is basically 5pm
    c. Field 3 type date: points to a type datetime field (ex: 2011-12-31 17:00:00)
    2- Open Excel and using Live Office plugins
    3- Open the univers
    4- Drag the Field 3 as filters.
    5- Choose an operator ex: Between, Greater, etc.
    6- Open the calendar and select a date
    7- Modify the 00:00:00 to put something like 17:00:00
    8- Click away
    9- The time resets back to 00:00:00
    So my question is how do I have to setup the field in the univers so that we can query on the time using the univers in Live Office.  I say Live Office because in WEBI, it works fine.  Changing the 00:00:00 to something else doesn't make it reset to 00:00:00 when you click elsewhere.
    Trying with Field 1 and 2 does the same thing.
    Purpose of this is to be able to filter on parts of the day, like am (8am to noon) and pm (1pm to 5pm).
    BOXI 3.1 SP3
    Windows Server 2008 R2
    Netezza database
    Live Office 3.1 SP3 (Client)
    Excel 2007 (Client)
    Windows 7 (Client)
    Thanks,
    Edited by: Sing Phommavong on Feb 23, 2012 11:24 AM

    Hi n,
    please search for your problem in the forum. This has been discussed a lot of times before! (keywords: Excel LabVIEW timestamps)
    Excel stores timestamps as number of days (your 41866) and part of days (0.5798d = 13H55M). You need to convert those numbers using some (more or less) simple math to LabVIEW timestamps!
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Loading an array from sql query

    I am trying to load an array from a sql query. I need the data to be numeric because I need to format the data using NumberFormat. Here is the query:
              int rd=0;
         Double[] rd_elapsedtime;
         ArrayList rd_elapsedtime_ar = new ArrayList(rd);
         ResultSet report1d_myResultSet = stmt.executeQuery(report1d);
    if (report1d_myResultSet != null) {
    while (report1d_myResultSet.next()) {
                   rd=rd+1;
                   rd_elapsedtime = new Double[rd+1];
                   rd_elapsedtime[rd]=report1d_myResultSet.getDouble("elapsedtime");
                   rd_elapsedtime_ar.add(rd_elapsedtime[rd]);
    This query fails, but if I change the type to string it does work. elapsedtime is a number column in the database.
    [javac] /usr/local/tomcat/work/Standalone/localhost/new_test/test1_jsp.java:358: incompatible types
    [javac] found : double
    [javac] required: java.lang.Double
    [javac]           rd_elapsedtime[rd]=report1d_myResultSet.getDouble("elapsedtime");
    Also, can I take the string and convert to a double, format that and then load the array?
    Thank you for your help.

    getDouble returns a double and you need a Double.
    This will do:
    rd_elapsedtime[rd]= new
    Double(report1d_myResultSet.getDouble("elapsedtime"));I tried the suggestion and it failed with a java.lang.ClassCastException error. I also tried changing the type to double and got this error:
    [javac] symbol : method add (double)
    [javac] location: class java.util.ArrayList
    [javac]           rd_elapsedtime_ar.add(rd_elapsedtime[rd]);
    [javac] ^
    [javac] 1 error
    Thanks for your help.

  • Error while trying to retrieve data from BW BEx query

    The following error is coming while trying to retrieve data from BW BEx query (on ODS) when the Characters are more than 50.
    In BEx report there is a limitation but is it also a limitation in Webi report.
    Is there any other solution for this scenario where it is possible to retrieve more than 50 Characters?
    A database error occured. The database error text is: The MDX query SELECT  { [Measures].[3OD1RJNV2ZXI7XOC4CY9VXLZI], [Measures].[3P71KBWTVNGY9JTZP9FTP6RZ4], [Measures].[3OEAEUW2WTYJRE2TOD6IOFJF4] }  ON COLUMNS , NON EMPTY CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( CROSSJOIN( [ZHOST_ID2].[LEVEL01].MEMBERS, [ZHOST_ID3].[LEVEL01].MEMBERS ), [ZHOST_ID1].[LEVEL01].MEMBERS ), [ZREVENDDT__0CALDAY].[LEVEL01].MEMBERS ) ........................................................ failed to execute with the error Invalid MDX command with UNSUPPORTED: > 50 CHARACT.. (WIS 10901)

    Hi,
    That warning / error message will be coming from the MDX interface on the BW server.  It does not originate from BOBJ.
    This question would be better asked to support component BW-BEX-OT-MDX
    Similar discussion can be found using search: Limitation of Number of Objects used in Webi with SAP BW Universe as Source
    Regards,
    Henry

  • Adding data from one matrix to another

    Hay guys.I'm having trouble with adding data, that is situated in a Matrix on form A and bound to a userdatasource,
    to a Matrix on form B that is bound to a dbdatasource.
    For some reason the data either does not display at all, or it only displays the last records' data as many times
    as there are records in the original matrix from form A.
    Here's the code I've tried: (Displays only last record x times)
    For i = 1 To oMatrixSync.RowCount
    oFormTime.DataSources.DBDataSources.Item("@TB_TIMEDET").SetValue("U_Activity", _
                              oMatrixTime.RowCount, _
                              oFormSync.DataSources.UserDataSources.Item("U_Act").ValueEx)
    oMatrixTime.AddRow()
    next
    And this code displays zip:
    For i = 1 To oMatrixSync.RowCount
      oCheckBox = oMatrixSync.Columns.Item("c_Check").Cells.Item(i).Specific
      If oCheckBox.Checked = True Then
        oEditS = oMatrixSync.Columns.Item("c_Activity").Cells.Item(i).Specific
        oFormTime.DataSources.DBDataSources.Item("@TB_TIMEDET").SetValue("U_Activity", _
                   oMatrixTime.RowCount, _
                   oEditS.Value)
      oMatrixTime.AddRow()
      oMatrixTime.LoadFromDataSource()
    next
    Any help would be greatly appreciated, thanx all!
    Message was edited by: Tjaard Du Plessis

    Thanks, Jaro!
    You are right. The code should look like this:
    Dim oDBDSTime As DBDataSource = oFormTime.DataSources.DBDataSources.Item("@TB_TIMEDET")
    Dim oUDSSync As UserDataSource = oFormSync.DataSources.UserDataSources.Item("U_Act")
    For i = 1 To oMatrixSync.RowCount
    oMatrixSync.GetLineData(i)
    oDBDSTime.InsertRecord(i)
    oDBDSTime.SetValue("U_Activity", _
                        i, _
                        oUDSSync.ValueEx)
    Next
    oMatrixTime.LoadFromDataSource()
    Regards,
    Frank

  • Why some columns are not read into Power Pivot when reading data from a SQL query

    I have this SQL query that I want to use to read data to PowerPivot from:
    SELECT Score.FieldCount as fieldcount, Score.Record.GetAt(0) as predicted_gender, Score.Record.GetAt(1) as probability_of_gender,  Score.Record.GetAt(2)
    as probability_of_m,  
    Score.Record.GetAt(3) as probability_of_f,  Score.Record.GetAt(4) as customerkey
    FROM 
    SELECT * FROM dbo.myCLR1(
    dbo.MyCLR2('c:\fILES\MLSM.xml'), 
    'SELECT * FROM [dbo].[Customer]') Input
    ) Score
    After I click 'Finish' in "Table Import Wizard", I can only get 1 column (FieldCount) in Power Pivot window. Why don't I get the other 4 columns? If I save the result to a table I do get all columns but my goal is to dynamically present the result
    so that's not an option. Can anyone shed some light?
    Thanks,
    Chu
    -- Predict everything. http://www.predixionsoftware.com

    If I only pass in query as 
    SELECT * FROM dbo.myCLR1(
    dbo.MyCLR2('c:\fILES\MLSM.xml'), 
    'SELECT * FROM [dbo].[Customer]') Input
    I do get 2 columns (FieldCount and Record as shown below)
    -- Predict everything. http://www.predixionsoftware.com

  • How to store data from a complex query and only fresh hourly or daily?

    We have a report which runs quite slow (1-2 minutes) because the query is quite complicate, so we would like to run this query daily only and store in a table so for those procedures that need to use this complex query as a subquery, can just join to this table directly to get results.
    However, I am not sure what kind of object I should use to store data for this complex query. Is data in global temp table only persist within transaction? I need something that can persist the data and be access by procedures.
    Any suggestions are welcome,
    Cheers

    Thank you for your reply. I looked at the materialized view earlier on, but have some difficulties to use it. So I have some questions here:
    1.The complex query is not a sum or aggregate functions, it just need to get data from different tables based on different conditions, in this case is it still appropriate to use meterialized view?
    2.If it is, I created one, but how to use it in my procedure? From the articles I read, it seems I can't just query from this view directly. So do I need to keep the complex query in my procedure and how the procedure will use the meterialized view instead?
    3. I also put the complex query in a normal view, then create a materialized view for this normal view (I expect the data from the complex query will be cache here), then in the procedure I just select * from my_NormalView, but it takes the same time to run even when I set the QUERY_REWRITE_ENABLED to true in the alter session. So I am not sure what else I need to do to make sure the procedure use the materialized view instead of the normal view. Can I query from the Materialized View directly?
    Below in the code I copied from one of the article to create the materialized view based on my normal view:
    CREATE MATERIALIZED VIEW HK3ControlDB.MW_RIRating
    PCTFREE 5 PCTUSED 60
    TABLESPACE "USERS"
    STORAGE (INITIAL 50K NEXT 50K)
    USING INDEX STORAGE (INITIAL 25K NEXT 25K)
    REFRESH START WITH ROUND(SYSDATE + 1) + 11/24
    NEXT NEXT_DAY(TRUNC(SYSDATE), 'MONDAY') + 15/24
    enable query rewrite
    AS SELECT * FROM HK3ControlDB.VW_RIRating;
    Cheers

  • Passing values to form bean string array from dynamic added textboxes

    Hi,
    I am unable to pass values to form bean string array from a jsp in which I have incorporated dynamically adding of textboxes in javascript.
    I have given add/delete row option in the jsp. If there is single row, this is working fine. But after adding a row, I am not able to either do any validations on added textboxes or pass the values to the String array form bean variable.
    code snippet:
    var cell6 = row.insertCell(4);
    var element5 = document.createElement("input");
    element5.type = "text";
    element5.className = "formtext1";
    element5.size = "5";
    element5.value = "00.00";
    element5.name= "qty"; // this is a string array of the form bean.
    element5.onchange=function() {checkNumeric(this);};
    cell6.appendChild(element5);
    <html:text styleClass="formtext1" property="qty" value="" size="5" styleId="qty" onchange="checkNumeric(this)"/></td>
    form bean declaration
    private String[] qty; Please help.
    Edited by: j2eefresher on Jan 12, 2010 11:23 PM

    Shivanand,
    There's no need to post that much code when you could create a very short test case that demonstrates only the problem you are having.
    You're using &NAME. notation on something that isn't a page or application item. You can't reference PL/SQL variables that way (or any other way) outside the PL/SQL scope. For your situation, you could create a page item named P55_DOCID and assign it a value in the PL/SQL process (:P55_DOCID := DOCID;), then reference &P55_DOCID. in HTML areas like the success message.
    Scott

  • Query data being picked from which data targets and dimension tables.

    Hi Guys,
    I need help from you people.
    My query is "If we execute any query, i want to know from which data targets and from which dimension tables data being read in the run time", is there any program or any table to find this data.
    thanks in advacne.
    Regards
    Prasad

    Hi Prasad,
    We will get Data target information in query level in information TAB.
    If you want get dimension tables information also you need use technical business content(bwstatistics) Cubes and need to customize the required information. I think standard statisics cubes is not provide dimention tables information. Need to customize that.
    Hope it will help for you.
    Thanks,
    Chandra

  • Drill Down when data is coming from a query

    Hello experts,
    I have one question regarding the drill down functionality. For sake of simplicity, let's assume we are working on a pie chart.
    i) Data is coming from a query (via the universe).
    ii) The data source is really the query itself, it is not coming from the excel sheet. In other words, the query is not first copied to the excel sheet and then fed to the pie chart. Pie chart directly uses the query binding.
    ii) When a slice in the pie is clicked, I want to copy that slice's information into a cell (basically the drill-down functionality).
    I wasn't able to achieve this functionality.  I think the problem is the 'source data' field in the 'insertion' tab. I select 'Row' as my insertion type and I also select a destination. However, when it comes to selecting 'source data' I have nowhere to point to since my source data is the query (query binding is not an option here). So, since I have no real source data, I cannot drill down and copy the values to the destination cell.
    The workaround is to copy the query data into excel first, but I don't that is an elegant solution. Is there any other way to achieve this?
    Regards,
    Guven.

    Hello David,
    You confirm that mapping the whole column would be an option, right?
    Here is why I asked this question: Let's assume I have a dashboard that displays the types of encounters in a hospital. Some examples of encounter types are: emergency, elective, newborn, etc... Currently, in the database, there is data for these 3 types. So, the dashboard contains a pie chart and each slice corresponds to the number of visits by patients for this encounter type (e.g. 450 emergency encounters, 9900 elective encounters and 32 newborn encounters).
    Tomorrow, a new encounter type could take place in the hospital and this of course has to be reflected in the dashboard. If I make the assumption that there are only 3 encounter types, then the dasboard would be missing information. So, in this case, should I be mapping the whole column to the pie chart?
    Regards,
    Guven.

  • Error While execting SQL Query : No Data to Read from Sockt.

    Hi,
    I am getting the Error "No Data To Read from Sockt" While executing SQL Query from PL/SQL Developer and same error i am getting while i trying on Toad and SQL*Plus also.
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE     10.2.0.3.0     Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production Pls suggest !!
    Thanks n Regards
    Rj

    Try to connect without tnsnames. So try the basic connection from SQLDeveloper.
    If it works, you have to verify your tnsnames.ora
    Are you th only person to have this connection problem or all users meet this error?
    Does this connection worked before, is it a new connection?
    What changes occured since the connection is out of service.

  • Adding data to Manual Distribution Rule from DIAPI

    Hi
    I am searching for the object to insert the data to OMDR (manual distribution rule) using DI API. Can any one help me out.
    I found many questions related to adding data to manual distribution rule using DIAPI which were not answered.
    Thanks in Advance.

    hi.
    Just check the below posts.
    object type of distribution rules
    Distribution rules setup..

  • Can I move Array from one Xserve RAID to another and keep the data

    I'd like to move a set of disk with an existing Array from one Xserve RAID to another. Can I simply shutdown both Xserve RAIDs and move the disk over, assuming I put the disk back in the same order?

    Yes, you should be able to do this.
    BE SURE YOU HAVE A BACKUP FIRST.

  • How do I return a Boolean array from LabView to TestStand?

    I am trying to return a Boolean array from Labview to TestStand and have TS evaluate the results. I can do this for arrays of integers or reals but booleans do not work. I tried copying the PassFailTest step type and adding an array of Bool but I couldn't get it to evaluate the array. It simply always passed. How can this be done?
    Bob A.

    I have thought about evaluating the Boolean data in TestStand but, as you say, this is a lot of work. What I have been doing is to map the boolean data to integers in LV (very easy) and then use the multiple numeric step type to evaluate the integer array automatically. This feels kludgy and I have tried a couple of times to create a "multiple boolean" step type with little success. I'm surprised TS hasn't anticipated a test returning multiple pass/fail results. I do this all the time for production code.
    What I have tried is to copy MultipleNumericLimitsTest data type to a custom type and add a BooleanArray with a data type Array of Boolean[0..empty]. Then when I specify module, I select Step.BooleanArray as the value. The last step (that I know of) is to select Step.BooleanArray as the data source in the edit limits window. At this point if I run the test, I get the error "expect numeric, found boolean" (or something similar). When I look at the properties of my custom step type, the Substeps has DoMultiNumericMeasEvaluation as the Post-Step. I believe this is the root of my problem but I can't figure out how to change this to "DoMultiBooleanMeasEvaluation" or similar. Any Ideas?

Maybe you are looking for

  • Youtube can not refresh

    The Youtube in my 3rd generaion Apple TV can not refresh the content of the channels I subscribed. And the Youtube shows only 5 of my favorite videos. But the situation above does not exist in my iphone and ipad. How can I solve these problems?

  • Goods issue for consignment material

    Hi , One of the materials used in bom is consignment material. When process order is made for it the movement type copied is 261. But i reqiore mov type '261 K'. How can it be defaulted as one material will be 'consignment ' material all the time. Re

  • How to automatically view all attached pdfs in an Acrobat form?

    Hi! I use an Adobe form that collates many different PDFs attached to various links within the form. When final review is required, I can (within that single form) click on each individual link, launching the attached PDF in a separate window. Howeve

  • How to create a revolving website list, like this...

    Hi there, Im new to flash, but the main reason I got it was so I could create an object to put on a webpage. I want to be able to create a revolving website list, with pictures of the sites in the list, like on the main page of this site:  http://www

  • Startup-flashing folder...won't respond to startup dvd

    hi- thanks in advance for any help you can give me. i have a small problem that i'd like help with. i have an ibook g3 (dual USB) with OS X 10.4. I went on vacation for a week, and when i got back the computer was having troubles. here's what's up: A