Database array
I created a simple database array. It got cluster controls showing name, age and martial status. But I need to write these data into a xls file and I can't add new data. With bundle by name function I can only change some data but I can't add new one.
Attachments:
Cluster.vi 12 KB
If this is to be a subVI of a larger program, you need to set up the connector pane. You also need an output indicator for the Database Array. You cannot pass the control to the output. Generally the use of local variables should be minimized in LabVIEW. If this is not a subVI, then you need to add a while loop around the code. Do NOT use Run Continuously! It is only for debugging purposes.
You do not need the unbundle and bundle nodes since you are setting the entire New Data cluster.
You should make the New Data cluster a typedef so that when you make changes such as adding an address field, you only need to change it one place. Use the typedef cluster as the element in the Database Array also.
If you do not care where the new data is placed in the Database Array, and generally a database does not care, then just use Build Array in the New Data Case.
Here is a modified version with these changes.
Lynn
Attachments:
New Data.ctl 13 KB
Database update ni_com forum.2.vi 14 KB
Similar Messages
-
Disclaimer: I am new to DB's.
I'm looking at creating a MySQL database to hold tests done on DUTs (each with a specific serial). In theory, each DUT undergoes 3 tests. Each test produces a 401x9 2D array of DBLs. I am not concerned with the write speed to the DB, but I do want to optimize the read of the DB (potentially may need to retrieve 1000+ of these 2D arrays as fast as possible). I have the DB Toolkit; using LV 8.5. Questions:
1. I have seen two different ways to save a 2D array in a DB mentioned: first, writing one row at a time with the DB Insert vi, resulting in a 2D array in a table (which is slow writing) or second, changing the 2D array to a variant and using the DB Insert vi, resulting in a single cell in a table. I know I can use other methods (parameterized vi, sql commands, user defined functions on the DB server, please do comment if you have found drastic performance increase with these methods), but of the two ways of storing a 2D array, can I read a 2D array from a table faster than reading a 2D array from a single cell? Whenever I need this data, I will read it all (i.e. I will never have to search for certain data within these individual 2D arrays)
2. I may have installed the 8.2.1 DB toolkit, because the Database Variant to Data vi/function does not drop onto the Block Diagram when I drag it from the palette, and the Help has ???. I assume this is because it just points to the normal Variant to Data, which in 8.5 is in a subpalette as compared to 8.2.1. Any quick way to fix this?
3. Any other general suggestions for a DB newbie? I've been trying to derive best practices from KB aritcles, this forum, and the web, but there is so much information and so many varying opinions I find it hard to narrow down best practices.
MichaelHi Miguel,
It looks like you are embarking on a very interesting project. Although you probably have seen many of the following documents, I've linked a few to get you started.
Discussion forum using LabVIEW to read from tables
Developer Zone article about developing a test system
Knowledgebase article about imitations of speed with database toolset
As far as your first question, I would suggest trying out both methods with simple code and testing with a small amount of values to determine which one will be the fastest.
Good luck with your project!
Amanda Howard
Americas Services and Support Recruiting Manager
National Instruments -
Here it goes. I have to write a program that firstly loads a .txt file into an array of Student Objects using a for loop. Then I have to display a menu. In this menu, lets say option 1 is chosen, it will ask for the full name of the student. Once the full name is taken it should check to see if it is in the array/file, and if so it will allow the user to add grades and whatnot, and if it isn't there it repors back the error that it could not find it.
I'm a pretty huge beginner so feel free to laugh away at the code, and I say urgent because I need to get this done and am only using thios forum as a last resort since I seem to be unable to get things going.
Tell me what you think of what I have so far, did I load the .txt file correctly? I'm pretty sure I did the menu and everything right:
import java.lang.*;
import type.lib.Student;
import java.util.*;
import java.io.*;
import java.util.Scanner;
public class StudentDbase2 {
public static void main(String[] args) throws java.io.IOException{
PrintStream output = System.out;
PrintStream fileOutput = new PrintStream(new File("whateveroutput.txt")); // not sure I need this line
Scanner input = new Scanner(System.in);
Scanner fileInput = new Scanner(new File("whatever.txt"));
final int NUMBER_OF_RECORDS = 10;
Student studentDbase[] = new Student[NUMBER_OF_RECORDS];
String []menu = { "1 - Add Courses and Grades" ,
"2 - View a Course Grade",
"3 - View GPA",
"4 - View all Courses and Grades",
"5 - View student record",
"6 - Output entire databse to a file",
"Quit - Exit databse"};
for (int i = 0; i < menu.length; i++)
System.out.println(menu);
System.out.print("Enter menu option: ");
String choice = input.next();
if (HERE IS WHERE I AM TOTALLY LOST
while (!choice.equals("Quit"))
try
int intChoice = Integer.parseInt(choice);
System.out.println("Choice was: " + intChoice);
if ((intChoice < 1) || (intChoice > 4))
System.out.println("Invalid choice made. Choose again.");
catch (Exception e)
System.out.println("Invalid choice made. Choose again.");
System.out.print("Enter menu option: ");
choice = input.next();
}So yeah if you read through it, I mentioned wher eI am lost, and that is when I have to start carrying out the options. I was about to write "if the user inputs 1 then ask for the full name. That I can do. But then how to scan it for the name and do the rest is foreign to me.
Any help/guidance is very much appreciated. Time is of the essence! Thanks in advance.
side note* So far all this does is display the menu, hopefully load the txt file correctly, and allow me to Quit. The actual meat of the program is where I'm lost.
another side note* the .txt file contains full names and student numbers
Edited by: SmallyLarges on Dec 4, 2009 1:05 AMSmallyLarges wrote:
Here it goes. I have to write a program that firstly loads a .txt file into an array of Student Objects using a for loop. Then I have to display a menu. In this menu, lets say option 1 is chosen, it will ask for the full name of the student. Once the full name is taken it should check to see if it is in the array/file, and if so it will allow the user to add grades and whatnot, and if it isn't there it repors back the error that it could not find it.To add to Melanie's good advice, I would say this: separate the problem from the implementation (ie, what it's going to look like in Java).
Taking your description above, I've simply repeated it, substituting words where you've made those assumptions or been "wooly" (in brackets) with a more "English" word or suggestion:
"I have to write a program that firstly loads a .txt file into an (array|*table*) of Student Objects (using a for loop|*<remove>*). Then I have to display a menu. In this menu, lets say option 1 is chosen, it will ask for the full name of the student. Once the full name is taken it should check to see if it is in the (array/file|*table*), and if so it will allow the user to add grades and (whatnot|*<specify>*), and if it isn't there it repors back the error that it could not find it."
It may seem like a trivial thing, but its a very important point: Don't tie yourself down to an implementation before you have to.
The nice thing about this is that now you can probably write a bit of "pseudo"-code to see what your main() might look like. When you do this, don't worry about the details, just try to translate the things in your problem description onto paper.
Perhaps something like:
load Students
while the user is not finished
do
display menu
read option chosen
process option:
if the option == Quit
do
signal that the user is finished
exit process option
end
else if the option == 1
do
ask for full name
if the full name is in our table
add grades
else
report "not found" error
end
else if the option == 2
end of process option
endDo you see what's happened here? You've broken down the problem into workable chunks; and it's in your own language.
Now, translating to Java becomes much easier.
Furthermore, those chunks will often become methods, and your eventual main() method will often look quite similar to your pseudo-code.
Now, what was that question again....?
Winston
Edited by: YoungWinston on Dec 4, 2009 2:32 AM -
Issues on setting the SQL ARRAY in Weblogic 10.3
Hello,
I am facing problem while migrating my application from Weblogic 8.1 to Weblogic 10, and problem is on setting the database ARRAY.
here is the brief of the problem which we are facing during weblogic upgrade, appreciate if someone could help us in this regard.
Requirement:- Upgrading the Weblogic Server from 8.1 SP4 to 10.3.
Problem Description :- We are facing issue with Weblogic server 10.3 related to JDBC call for setting the Database Array. We are using Spring framework JDBC templates.
In 8.1 we used to send the database Array by using two different methods mentioned below.
Method 1 :- First method which we are using to set the ARRAY object to database.
CODE:
public Object doBaseInConnection(Connection connection) throws SQLException
OracleCallableStatement callableStatement = OracleCallableStatement)connection.prepareCall(DBUtils.createPreparedStatementFunctionString("bbvoice_customer_discovery_ng", "validate_password_3", 8));
callableStatement.registerOutParameter(1, Types.INTEGER);
callableStatement.setString(2, identifier);
callableStatement.setString(3, password);
ArrayDescriptor arrayDesc = ArrayDescriptor.createDescriptor("TACTOSS.PRODUCT_NAME_ARRAY", connection);
ARRAY ocbsArray = new ARRAY(arrayDesc, connection, productSearchList); -- Exception in this LINE
callableStatement.setARRAY(4, ocbsArray);
callableStatement.execute();
EXCEPTION:
This was working fine in Weblogic8.1 where as giving the below exception in Weblogic 10.3.
java.lang.ClassCastException: $Proxy439 cannot be cast to oracle.jdbc.OracleConnection
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:155)
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:123)
CHANGE:
Only change in Weblogic 10.3 in this area is earlier in weblogic 8.1 we used to have ojdbc14.jar but weblogic10.3 is having ojdbc6.jar.
Method 2 :- Second method which we are using to set the ARRAY object to database.
CODE:
public Object doBaseInConnection(Connection connection) throws SQLException
OracleConnection oracleConnection = (OracleConnection) ((WLConnection)connection).getVendorConnection(); -- Exception in this LINE
OracleCallableStatement callableStatement = (OracleCallableStatement)connection.prepareCall(DBUtils.createPreparedStatementFunctionString("bbvoice_business_bbv_ng", "create_service_3_mb", 15));
callableStatement.registerOutParameter(1, Types.INTEGER);
callableStatement.setBigDecimal(2, new BigDecimal(customerId.intValue()));
callableStatement.setString(3,businessBBVDTONG.getCpeType() );
ArrayDescriptor arrayDesc = ArrayDescriptor.createDescriptor( "TACTOSS.GEO_DETAILS_ARRAY", oracleConnection);
List geoList = businessBBVDTONG.getGeoNumberList();
int size = geoList.size();
Object arrayValues[][] = new Object[size][];
Object[] str = new Object[3];
for(int i=0;i<geoList.size();i++)
GeoNumberDTO geoNumberDetails = (GeoNumberDTO)geoList.get(i);
str[0]=geoNumberDetails.getDirectoryEntry();
str[1]=geoNumberDetails.getCssDistrictId();
str[2]=geoNumberDetails.getCssExchangeGroupCode();
arrayValues[i] = str;
str = new Object[3];
ARRAY ocbsArray = new ARRAY(arrayDesc, oracleConnection, arrayValues);
callableStatement.setARRAY(4, ocbsArray);
callableStatement.execute();
EXCEPTION:
This was also working fine in Weblogic8.1 where as giving the below exception in Weblogic 10.3.
java.lang.ClassCastException: $Proxy216 cannot be cast to weblogic.jdbc.extensions.WLConnection
at com.bt.bbv.core.dao.bbvoice.nextgen.BusinessBBVDAONGImplDB$2createService.doBaseInConnection(BusinessBBVDAONGImplDB.
java:171)
at com.bt.bbv.core.util.BaseConnectionCallback.doInConnection(BaseConnectionCallback.java:38)
CHANGE:
Changes from Weblogic 8.1 to 10.3 are
1) We are not having the WLConnection in weblogic.jar instead it is present in com.bea.core.datasource6_1.4.0.0.jar
2)Weblogic 10.3 server is having ojdbc6.jar instead of ojdbc14.jar.You'll also need to map the security role defined in web.xml to a Weblogic principal (an actual Weblogic user or a group) in weblogic.xml.
Example:
web.xml
<web-resource-collection>
<web-resource-name>PowerPointTemplates.jws</web-resource-name>
<description>A web service secured by SSL and basic authentication</description>
<url-pattern>/PowerPointTemplates.jws/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>Friends</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>CLIENT-CERT</auth-method>
<realm-name>myrealm</realm-name>
</login-config>
<security-role>
<description>Role description</description>
<role-name>Friends</role-name>
</security-role>
weblogic.xml
<security-role-assignment>
<role-name>Friends</role-name>
<principal-name>weblogic</principal-name> <!-- the following 3 are users that exist in Weblogic -->
<principal-name>user1</principal-name>
<principal-name>user2</principal-name>
<principal-name>Turbo_Users</principal-name> <!-- this is a Weblogic group -->
</security-role-assignment> -
Problem accessing VARRAY OF VARCHAR in 9i, but working in 8i
The following code (modified sample ArrayExample.java for VARRAY
OF VARCHAR) produces different results on a 8.1.7 and 9.0.1
database. The standard way of accessing the members of an array
of strings in the database:
ARRAY array = ((OracleResultSet)rs).getARRAY (1);
// get Array elements
String[] values = (String[]) array.getArray();
for (int i=0; i<values.length; i++)
System.out.println(">> index "+i+" = "+values);
seems not to work for strings in 9i. Instead it prints the byte
representation of the strings ("0x313233" instead of "123").
Code below shows, that using a workaround it is possible to
access the string itself.
Results of code below (always using the 9i JDBC driver).
8i (correct):
Row 1 :
Array is of type SDMC_FS.STR_VARRAY
Array element is of type code 12
Array is of length 2
index 0 = 123 =?= 123
index 1 = 456 =?= 4569i (incorrect):
Row 1 :
Array is of type SDMC_FS.STR_VARRAY
Array element is of type code 12
Array is of length 2
index 0 = 123 =?= 0x313233
index 1 = 456 =?= 0x343536Whats wrong?
br Thomas Spaarmann
import java.sql.*;
import oracle.sql.*;
import oracle.jdbc.oracore.Util;
import oracle.jdbc.*;
import java.math.BigDecimal;
public class ArrayExample
public static void main (String args[])
throws Exception
// Register the Oracle JDBC driver
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
// The sample retrieves an varray of type "NUM_VARRAY",
// materializes the object as an object of type ARRAY.
// A new ARRAY is then inserted into the database.
String url = "jdbc:oracle:oci8:@";
try {
String url1 = System.getProperty("JDBC_URL");
if (url1 != null)
url = url1;
} catch (Exception e) {
// If there is any security exception, ignore it
// and use the default
// Connect to the database
Connection conn =
DriverManager.getConnection (url, "scott", "tiger");
// It's faster when auto commit is off
conn.setAutoCommit (false);
// Create a Statement
Statement stmt = conn.createStatement ();
try
stmt.execute ("DROP TABLE varray_table");
stmt.execute ("DROP TYPE str_varray");
catch (SQLException e)
// the above drop statements will throw exceptions
// if the types and tables did not exist before. Just
ingore it.
stmt.execute ("CREATE TYPE str_varray AS VARRAY(10) OF
VARCHAR(256)");
stmt.execute ("CREATE TABLE varray_table (col1 str_varray)");
stmt.execute ("INSERT INTO varray_table VALUES
(str_varray('123', '456'))");
ResultSet rs = stmt.executeQuery("SELECT * FROM
varray_table");
showResultSet (rs);
rs.close();
stmt.close();
conn.close();
public static void showResultSet (ResultSet rs)
throws SQLException
int line = 0;
while (rs.next())
line++;
System.out.println("Row "+line+" : ");
ARRAY array = ((OracleResultSet)rs).getARRAY (1);
System.out.println ("Array is of type
"+array.getSQLTypeName());
System.out.println ("Array element is of type code
"+array.getBaseType());
System.out.println ("Array is of length "+array.length());
// get Array elements
Datum[] values = (Datum[]) array.getOracleArray();
String[] strValues = (String[]) array.getArray();
for (int i=0; i<values.length; i++)
String value = new String( values[i].getBytes());
System.out.println(">> index "+i+" = "+value+" =?=
"+strValues[i]);Are you including nls_charset11.zip (or nls_charset12.zip) in
your CLASSPATH?
Whenever a conversion into (or out of) a particular character set
fails you may see a hex representation instead. By default the
JDBC driver classes111/12 do not include the conversions
required for the Windows character set. -
I'm a flex noob and have been stuck on this one problem for
hours and still haven't found a solution - any suggestions?
My application includes a custom component (canvas container
with 10 comboboxes). I populate each of the comboboxes with data I
collect from my database using simple SQL queries (SELECT DISTINCT
MIXES FROM MYTABLE, etc). The custom component isn't displayed at
startup and isn't between the <mx:Application> ...
</mx:Application> tags but I would like to populate the
comboboxes at application startup so that they are ready for
display later. Initially I thought that a simple
creationComplete="initCombos()" call in my custom component mxml
would do this but I found that this function is called 10 times for
each of the comboboxes, which overwhelms the database. Setting a
boolean flag to ensure that the initCombos function was only called
once also didn't help - the flag is reset :(
Is there an event that I can trigger when the custom
component has been completely created i.e. after all the combos
have been created?
I tried applicationComplete in the application mxml but how
do I reference a function in the custom component mxml. I can
reference a public function in the application mxml from my custom
components mxml using the Application.application.Function1
approach but not vice versa. I am hesitant to create a custom event
and am eager to hear of possible solutions to this. TIA
AndreHere's some code - sorry I'm pasting as is but the "Attach
Code" button isn't showing.
This is my application mxml showing the initApp function
called after the creationComplete event. It calls my custom
component that is embedded within customWidget.
<code>
<mx:Application
xmlns:mx="
http://www.adobe.com/2006/mxml"
xmlns:awx="
http://www.arcwebservices.com/2007/awx"
xmlns:widget="com.esri.aws.awx.widget.*"
xmlns:custom="components.*"
xmlns:local="*"
xmlns:view="view.*"
layout="absolute"
horizontalAlign="center"
verticalAlign="middle"
pageTitle="TxFlex Database"
creationComplete="initApp()">
<mx:Script>
<![CDATA[
import mx.containers.VBox;
import mx.controls.Alert;
import com.esri.aws.awx.widget.WidgetPopupManager;
import com.esri.aws.awx.map.layers.overlays.BubbleMarker;
import components.*;
private function initApp():void {
WidgetPopupManager.openWidget(customWidget);
]]>
</mx:Script>
<awx:DockWidgetContainer>
<widget:MyWidget id="customWidget"/>
<awx:BaseMapWidget/>
<awx:FindWidget/>
<awx:PanZoomWidget/>
</awx:DockWidgetContainer>
</mx:Application>
</code>
Here's the custom component trimmed down. The function I
would like to run at startup is initArrays().
<code>
<mx:Canvas
xmlns:mx="
http://www.adobe.com/2006/mxml"
width="225"
height="225">
<mx:Script>
<![CDATA[
import mx.core.Application;
import mx.collections.ArrayCollection;
[Bindable]
private var Database_dp:ArrayCollection;
private var response:Responder;
private var SQL:String;
private function getDatabases(Database:Array):void {
var DatabasesForComboBox:Array=new Array(Database.length);
DatabasesForComboBox[0]={label:"ALL",data:"%"};
for(var i:int=1;i<=Database.length;i++) {
DatabasesForComboBox
={label:Database[i-1].ORIGINAL_DB,data:Database[i-1].ORIGINAL_DB};
Database_dp=new ArrayCollection(DatabasesForComboBox);
public function initArrays():void {
response=new
Responder(getDatabases,Application.application.onFault("DB
Error"));
SQL="SELECT DISTINCT ORIGINAL_DB FROM SEC_DEF;";
Application.application.gateway.call("TxFlex.doSQL",response,SQL);
response=new
Responder(getFacilities,Application.application.onFault("FAC
Error"));
SQL="SELECT DISTINCT FACILITY_TYPE FROM SEC_DEF;";
Application.application.gateway.call("TxFlex.doSQL",response,SQL);
response=new
Responder(getDistricts,Application.application.onFault("District
Error"));
SQL="SELECT DISTINCT DISTRICT FROM SEC_DEF;";
Application.application.gateway.call("TxFlex.doSQL",response,SQL);
response=new
Responder(getCountys,Application.application.onFault("County
Error"));
SQL="SELECT DISTINCT COUNTY FROM SEC_DEF;";
Application.application.gateway.call("TxFlex.doSQL",response,SQL);
response=new
Responder(getClimates,Application.application.onFault("Climate
Error"));
SQL="SELECT DISTINCT CLIMATE FROM SEC_DEF;";
Application.application.gateway.call("TxFlex.doSQL",response,SQL);
response=new
Responder(getLayers,Application.application.onFault("Layer
Error"));
SQL="SELECT DISTINCT LAYER_TYPE FROM SEC_DEF;";
Application.application.gateway.call("TxFlex.doSQL",response,SQL);
]]>
</mx:Script>
<mx:Label text="Database" width="70" fontWeight="bold"
x="10" y="10"/>
<mx:ComboBox dataProvider="{Database_dp}" id="cbDatabase"
width="120" x="88" y="8"
change="numberSections()"></mx:ComboBox>
<mx:Label x="10" y="36" text="Facility" width="70"
fontWeight="bold"/>
<mx:ComboBox x="88" y="34" dataProvider="{Facility_dp}"
id="cbFacility" width="120"
change="numberSections()"></mx:ComboBox>
<mx:Label x="10" y="62" text="District" width="70"
fontWeight="bold"/>
<mx:ComboBox x="88" y="60" dataProvider="{District_dp}"
id="cbDistrict" width="120"
change="reDistrict()"></mx:ComboBox>
<mx:Label x="10" y="88" text="County" width="70"
fontWeight="bold"/>
<mx:ComboBox x="88" y="86" dataProvider="{County_dp}"
id="cbCounty" width="120"
change="numberSections()"></mx:ComboBox>
<mx:Label x="10" y="114" text="Climate" width="70"
fontWeight="bold"/>
<mx:ComboBox x="88" y="112" dataProvider="{Climate_dp}"
id="cbClimate" width="120"
change="numberSections()"></mx:ComboBox>
<mx:Label x="10" y="140" text="Layers" width="70"
fontWeight="bold"/>
<mx:ComboBox x="88" y="138" dataProvider="{Layer_dp}"
id="cbLayer" width="120"
change="numberSections()"></mx:ComboBox>
<mx:Button label="Map Sections" width="120"
id="btnUpdate" click="filterSections()" x="88" y="192"
toolTip="Plot markers identifying the filtered sections on the
map"/>
<mx:Label x="10" y="166" text="Number of filtered
sections" fontWeight="bold"/>
<mx:Label x="173" y="166" text="..." width="35"
textAlign="right" id="lblN" color="#ff0000"/>
</mx:Canvas>
</code>
Here's my widget container that holds the custom component
which is displayed using <custom:sectionFilter
id="buttonBox"/>
<code>
<mx:VBox
xmlns:mx="
http://www.adobe.com/2006/mxml"
xmlns:widget="com.esri.aws.awx.widget.*"
xmlns:custom="components.*"
implements="com.esri.aws.awx.widget.IWidgetView">
<mx:Script>
<![CDATA[
import com.esri.aws.awx.widget.WidgetStates;
import com.esri.aws.awx.widget.IWidget;
private var m_widgetContainer:IWidgetContainer;
[Bindable]
private var m_widget:MyWidget;
public function get widget():IWidget {
return m_widget;
public function set widget(value:IWidget):void {
m_widget=value as MyWidget;
public function set widgetState(value:String):void {
currentState=value;
public function get widgetState():String {
return currentState;
public function get widgetContainer():IWidgetContainer {
return m_widgetContainer;
public function set
widgetContainer(container:IWidgetContainer):void {
m_widgetContainer=container;
]]>
</mx:Script>
<mx:states>
<mx:State name="{WidgetStates.INFO}">
<mx:RemoveChild target="{buttonBox}" />
<mx:AddChild>
<mx:Text width="214" text="Use this filter tool to narrow
your search. Only markers for those sections that satisfy your
filter criteria will be shown." />
</mx:AddChild>
</mx:State>
<mx:State name="{WidgetStates.ICON}">
<mx:RemoveChild target="{buttonBox}" />
<mx:SetStyle target="{this}" name="paddingLeft" value="0"
/>
<mx:SetStyle target="{this}" name="paddingTop" value="0"
/>
<mx:AddChild>
<widget:IconWidgetView toolTip="Filter Sections"
widget="{m_widget}"
upIcon="@Embed(source='/images/customUp.png')"
downIcon="@Embed(source='/images/customDown.png')"
overIcon="@Embed(source='/images/customOver.png')"
disabledIcon="@Embed(source='/images/customDisabled.png')"
/>
</mx:AddChild>
</mx:State>
</mx:states>
<custom:sectionFilter id="buttonBox"/>
</mx:VBox>
</code>
Hope this all makes sense. -
Code seems logical enough to me, please help!!!!!??
int i = 0;
int j = database.length;
while ( i < j )
if (database[i] == null)
{ database[i] = bankrecord;
i = database.length ; //break out of the loop termination has ended
else if ( database.getUserID().equals(bankrecord.getUserID()) )
{} // do not add customer to database as it already exists
else
{ //the customer is not in database so add it to position
database[i+1] = bankrecord; //customer is not in database so add it to next position in database
i = database.length; //break out of loop.
i++;
please reply??Hi again,
ok, I will assume the [ ] at the right places - let's see what you are doing in the first while-loop
( I have substituted database.length by DATABASE_LENGTH because it is always the same as it)
I also use a x instead of an i - because i in brackets produce italic fontstyle :)
int x = 0;
while (x<DATABASE_LENGTH)
if (database[x]==null) { database[x]=bankrecord; x = DATABASE_LENGTH; } else
if (!database[x].getUserID().equals(bankrecord.getUserID()))
database[x+1] = bankrecord;
x = DATABASE_LENGTH;
x++;
ok, that inserts the first bankrecord correct - because there is nothing in the database-array - if there would be something in it - say position 0 to 2, and none of them are the same as the bankrecord to insert - what would happen?
Bankrecord on position 1 would be overwritten by the new one - losing that information stored there before.
You can add a new bankrecord only if you have tested all the other records before, if they all don't match with the new one - so the insertion is more like this
int x = 0;
while (x<DATABASE_LENGTH)
if (database[x]==null)
{ database[x]=bankrecord;
x = DATABASE_LENGTH; }
else if (database[x].getUserID().equals(bankrecord.getUserID()))
{ x = DATABASE_LENGTH;
} else x++;
this loop exits on 3 conditions:
1. record is added to the database in the first unused position
2. record has been in the database before
3. there is no room in the database for new entries
the same can be used to insert the second record - so it is obvious to use a method for that part:
method void insertRecord(BankRecord r) {
int x = 0;
while (x<DATABASE_LENGTH)
if (database[x]==null)
{ database[x]=r;
x = DATABASE_LENGTH; }
else if (database[x].getUserID().equals(r.getUserID()))
{ x = DATABASE_LENGTH;
} else x++;
now you can use that easy
bankrecord = new BankRecord();
bankrecord.setUserID("w110");
insertRecord(bankrecord);
bankrecord = new BankRecord();
bankrecord.setUserID("w119");
insertRecord(bankrecord);
it would be easier too, if you provide a second constructor for the BankRecord class
public BankRecord(String UserID) { userID = UserID; }
then you are able to use it that way
insertRecord(new BankRecord("w110"));
insertRecord(new BankRecord("w119"));
you see the difference? :)
greetings Marsian -
Java.sql.SQLException: Fail to convert to internal representation:
HI All,
I have a procedure hich is taking the Varray ADDR_CONTACT_VA as input which is varray of object .
ADDR_CONTACT_OBJ [] address = new ADDR_CONTACT_OBJ[20];
address[0] = new ADDR_CONTACT_OBJ();
address[0].setOpportunityId(26731);
address[0].setAddr_ln_1("100, Street");
address[0].setAddr_ln_2("Cast card Street");
address[0].setAddr_ln_3("Cast card Street");
address[0].setAddr_ln_4(null);
address[0].setAddr_ln_5(null);
address[0].setAddr_ln_6(null);
address[0].setAddress_name("GVPN Testing");
address[0].setAddressType("HQ");
address[0].setCity("Mumbai");
address[0].setContact_title("Mr.");
address[0].setCountry("India");
address[0].setEmail_contact_id(null);
address[0].setName_contact_id(null);
address[0].setOSO_Address_id(124959);
address[0].setOso_contact_id(317694);
address[0].setOso_party_site_id(69387);
address[0].setPincode("470003");
address[0].setState("Maharashtra");
address[0].setContact_firstname("First");
address[0].setContact_lastname("Last");
address[0].setContact_email(null);
address[0].setContact_phone_day("91-45234-4534556");
address[0].setDay_phone_contact_id(287326);
System.out.println("Vishwa3: after creating an y array");
ArrayDescriptor desc1 = ArrayDescriptor.createDescriptor("ADDR_CONTACT_VA",nativeConnection);
System.out.println("Vishwa4: after creating an y array");
ARRAY input1 = new ARRAY(desc1,nativeConnection,address);
System.out.println("Vishwa5: after creating an y array");
%>
<% proc_stmt = (OracleCallableStatement)nativeConnection.prepareCall("{ call DBP_UPDATE_STATUSCUSTOMER_DETAILS(?,?)}");
proc_stmt.setArray(1,input1);
proc_stmt.registerOutParameter(2,OracleTypes.CURSOR);
System.out.println("Vishwa6: after creating an y array");
%>
<% proc_stmt.execute();
ResultSet result =(ResultSet)proc_stmt.getObject(2);
while(result!=null)
System.out.println(result.getString(1));
System.out.println(result.getString(2));
System.out.println(result.getString(3));
System.out.println(result.getString(4));
System.out.println(result.getString(5));
when i try to execute this procedure ai m gettin the exception like
java.sql.SQLException: Fail to convert to internal representation: com.sy.vo.ADDR_CONTACT_OBJ@4a594a59_
Please help me to resolve this probelm .it is verey verey urgrnt for me
Thanks in Advance.....................
ViswaFirst use code tags when posting code.
Second you can't simply use a java object as an database array type. It certainly looks like you are doing that. -
here is my script
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="1920" height="1080"
creationComplete="inventoryService.send()" borderColor="#797979" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#636363, #9A9A9A]" color="#F3F3F3">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
private var omArray:ArrayCollection
private function resultHandler(event:ResultEvent):void
omArray = event.result.response.data.row;
]]>
</mx:Script>
<mx:HTTPService id="inventoryService"
url="http://localhost/OMRON-debug/Inventory.php?method=FindAll"
result="resultHandler(event)"/>
<mx:VBox width="1900" height="1060" x="10" y="10" borderColor="#7F8081">
<mx:ToggleButtonBar dataProvider="{mainStack}"/>
<mx:ViewStack id="mainStack" width="100%" height="100%">
<mx:HBox label="OVERVIEW" width="100%" height="100%">
<mx:Tile width="100%" height="100%">
<mx:Repeater id="omRepeater" dataProvider="{omArray}">
<mx:HBox width="271" height="353">
<mx:VBox>
<mx:HBox>
<mx:Text text="Machine:{omRepeater.currentItem.machine_id}"/>
<mx:Text text="Location:{omRepeater.currentItem.location}"/>
</mx:HBox>
<mx:HBox>
<mx:Text text="OS Status:{omRepeater.currentItem.os_status}"/>
<mx:Text text="Software Status:{omRepeater.currentItem.om_status}"/>
</mx:HBox>
<mx:Tile width="100%" height="100%">
<mx:Text text="1:{omRepeater.currentItem.coin_01}"/>
<mx:Text text="5:{omRepeater.currentItem.coin_05}"/>
<mx:Text text="10:{omRepeater.currentItem.coin_10}"/>
<mx:Text text="25:{omRepeater.currentItem.coin_25}"/>
</mx:Tile>
<mx:Tile width="100%" height="100%">
<mx:Text text="1:{omRepeater.currentItem.bill_1}"/>
<mx:Text text="5:{omRepeater.currentItem.bill_5}"/>
<mx:Text text="10:{omRepeater.currentItem.bill_10}"/>
<mx:Text text="20:{omRepeater.currentItem.bill_20}"/>
<mx:Text text="50:{omRepeater.currentItem.bill_50}"/>
<mx:Text text="100:{omRepeater.currentItem.bill_100}"/>
</mx:Tile>
<mx:HBox>
</mx:HBox>
<mx:HBox>
<mx:Text text="Running Total:{omRepeater.currentItem.bill_100}" textAlign="center"/>
</mx:HBox>
</mx:VBox>
</mx:HBox>
</mx:Repeater>
</mx:Tile>
</mx:HBox>
<mx:HBox label="RAW DATA">
</mx:HBox>
<mx:HBox label="SETTINGS">
</mx:HBox>
</mx:ViewStack>
</mx:VBox>
</mx:WindowedApplication>
I need to be able to do a few things.
1. Instead of doing the database query on creationComplete I need it to reload the database info "live" or every 10 seconds or so.
2. Right now the {omRepeater.currentItem.bill_xx} entries are raw count data from the database. I need to multiply this number by the bill type (5,10,20 etc) and display the actual currency amount.
3. For each entry I need to create a vertical bar graph. I checked out the bar graph component example but I cant figure out how to plug the database array into it.
thanks!!!While waiting for responses, I came up with this reload script after a little research. The only major problem is that it makes the entire page blink when it reloads. Any thoughts on improving or completely changing it to get rid of the blink and keeping everything efficient?
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="1920" height="1080"
creationComplete="dbTimer()" borderColor="#797979" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#636363, #9A9A9A]" color="#F3F3F3">
<mx:Script>
<![CDATA[
import mx.controls.Text;
import mx.controls.Label;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
private var omArray:ArrayCollection
private function resultHandler(event:ResultEvent):void
omArray = event.result.response.data.row;
import flash.utils.Timer
import flash.events.TimerEvent
import flash.display.Sprite
private function dbTimer():void
inventoryService.send();
var mTimer:Timer=new Timer(1000,10)
mTimer.addEventListener(TimerEvent.TIMER_COMPLETE,Comple);
mTimer.start();
private function Comple(e:TimerEvent):void
inventoryService.send();
dbTimer();
]]>
</mx:Script> -
Hi all,
I want to loop the names I stored in my database array.
There are total 9 records but i only want the record number 1 to 8 only.
Is that ok for me to use like this?
<cfloop index="i" from="1" to="#ArrayLen(Application.Names)-1#">
I am using SQL server 2008 and CF 8 on Windows 7.
Will really appreciate your help. ThanksHi A Cameron,
ya....it works...
i accidentally type as
<cfloop index="i" from="1" to="#ArrayLen(Application.Names)#-1"> in my code...tat y i couldn't get any result... -
How I can transfer data from the database into a variable (or array)?
I made my application according to the example (http://corlan.org/2009/06/12/working-in-flash-builder-4-with-flex-and-php/). Everything works fine. I changed one function to query the database - add the two parameters and get the value of the table in String format. A test operation shows that all is ok. If I want to display this value in the text area, I simply drag and drop service to this element in the design mode
(<s:TextArea x="153" y="435" id="nameText" text="{getDataMeanResult.lastResult[0].name}" width="296" height="89" />).
It also works fine, just a warning and encouraged to use ArrayCollection.getItemAt().
Now I want to send the value to a variable or array, but in both cases I get an error: TypeError: Error #1010: A term is undefined and has no properties..
How can I pass a value from the database into a variable? Thank you.
public var nameTemp:String;
getDataMeanResult.token = authors.getDataMean(arrayOfNumber[0], dir_id);
nameTemp = getDataMeanResult.lastResult[0].name;
public var nameArray:Array = new Array();
for (var i:uint=o; i<3; i++){
getDataMeanResult.token = authors.getDataMean(arrayOfNumber[i], dir_id);
nameArray[i] = getDataMeanResult.lastResult[0].name;
And how i can use syntax highlighting in this forum?Astraport2012 wrote:
I have to go back to the discussion. The above example works fine when i want to get a single value of the database. But i need to pass an array and get an array, because i want to get at once all the values for all pictures tooltips. I rewrote the proposed Matt PHP-script and it works. However, i can not display the resulting array.
yep, it won't work for Arrays, you'll have to do something slightly more intelligent for them.
easiest way would be to get your PHP to generate XML, then read that into something like an ArrayList on your HTTPService result event (depends what you're doing with it).
for example, you could have the PHP generate XML such as:
<pictures>
<location>test1.png</location>
<location>test2.png</location>
<location>test3.png</location>
<location>test4.png</location>
<location>test5.png</location>
<location>test6.png</location>
</pictures>
then you'll read that in as the ResultEvent, and perform something like this on it
private var tempAC:ArrayList = new ArrayList
protected function getStuff_resultHandler(event:ResultEvent):void
for each(var item:Object in event.result.pictures)
var temp:String = (item.@location).toString();
tempAC.addItem(temp);
in my example on cookies
http://www.mattlefevre.com/viewExample.php?tut=flash4PHP&proj=Using%20Cookies
you'll see an example of how to format an XML structure containing multiple values:
if($_COOKIE["firstName"])
print "<stored>true</stored>";
print "<userInfo>
<firstName>".$_COOKIE["firstName"]."</firstName>
<lastName>".$_COOKIE["lastName"]."</lastName>
<userAge>".$_COOKIE["userAge"]."</userAge>
<gender>".$_COOKIE["gender"]."</gender>
</userInfo>";
else
print "<stored>false</stored>";
which i handle like so
if(event.result.stored == true)
entryPanel.title = "Welcome back " + event.result.userInfo.firstName + " " + event.result.userInfo.lastName;
firstName.text = event.result.userInfo.firstName;
lastName.text = event.result.userInfo.lastName;
userAge.value = event.result.userInfo.userAge;
userGender.selectedIndex = event.result.userInfo.gender;
depends on what type of Array you're after
from the sounds of it (with the mention of picture tooltips) you're trying to create a gallery with an image, and a tooltip.
so i'd probably adopt something like
<picture>
<location>example1.png</location>
<tooltip>tooltip for picture #1</tooltip>
</picture>
<picture>
<location>example2.png</location>
<tooltip>tooltip for picture #2</tooltip>
</picture>
<picture>
<location>example3.png</location>
<tooltip>tooltip for picture #3</tooltip>
</picture>
etc...
or
<picture location="example1.png" tooltip="tooltip for picture #1"/>
<picture location="example2.png" tooltip="tooltip for picture #2"/>
<picture location="example3.png" tooltip="tooltip for picture #3"/>
etc... -
How can I get the data array from SQL Server Database?
Hi,
I can write a data array(2D)into a table of my SQL Server Database. The data array was writen to a column with image type. I know a data array is transformed a binary string when writing into database, but I dont know how to get the data array when I fetch the binary string from database.
My question is:
How to transform the binary string into data array? which vi's should I use? I have tried unflatten from string but failed.
Any response is appriciated.
Redhappyxh0518 wrote:
> I can write a data array(2D)into a table of my SQL Server Database.
> The data array was writen to a column with image type. I know a data
> array is transformed a binary string when writing into database, but I
> dont know how to get the data array when I fetch the binary string
> from database.
>
> My question is:
> How to transform the binary string into data array? which vi's should
> I use? I have tried unflatten from string but failed.
In order to use Unflatten from string you first need to Flatten it
before writing it. Also depending on the database driver, the returned
data may actually not be binary but Hexadecimal encoded ASCII which you
would first have to decode to binray.
Rolf Kalbermatter
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
How do I load values from a database column to an array variable in TS?
I'm trying to get the values from the column in a database into an array variable in TS using the property loader.
The Open Database, Open SQL Statement, and Property loader steps all complete and say "done". But my array is empty when it's all over.
Using TestStand 2010
Microsoft SQL Management Express 2008
Database configured by my company, I can not change it only read from it.
Thank you,
Newb-DThe database has to be in a form that will work with the PropertyLoader and it sounds like it isn't.
Try using the Import/Export Properties tool found in the Tool menu, to export some data to a database and then you can see if your database is compatible.
My guess is you will have to write your own loader.
Regards
Ray Farmer -
Updating array data in sql database
HI,
Im facing problems in updating array data in SQL database.
As of now, i am able to write an "insert" query and insert array data in an image datatype field. Im using image datatype because the array size is very big(around 80,000 x and y values).
Althoug inserting data is easy im unable to write a query to update this data.
Referring to the help of SQL server and Labview database connectivity toolkit, i came across a method of accessing image datatype....using textpointers, which are 16 bit binary values and using the WRITETEXT function instead of the UPDATE function.
but the problem im facing is that ive to pass the array as a 2d string array in the query as a result the updated array is retrieved in the form of a string a
nd not as an array. how do I get over this problem?Hi Pavitra,
I'm not very clear on how you have inserted the data into your application, but I do know that when you call the UPDATETEXT or WRITETEXT function you use the TEXTPOINTERS to point to the first location of a 1d array. So, depending on how you've stored the data, you may have problems updating your data if you're looking at it as a 1d array instead of how you originally formatted it. If you are able to successfully access the data as a 1d array, you can use the database variant to data type vi and pass in a string array constant for the data type. This will convert the variant datatype into whatever you specify. You may have to index the row and column of the variant (you receive a 2d array of variant) first before you convert. If possible, can yo
u provide some more detail and maybe some example code of how you perform the insert and plan to do the update? I can probably give you a better solution if I know how you are formatting the data. Thanks!
Jeremy L.
National Instruments
Jeremy L.
National Instruments -
How can I convert array of database variant to cluster?
When I use the Database Connectivity Toolkit to read a recordset from a database, I just use a SQL query. This returns an array of variant data. I have always just indexed this array in a sequence structure that has the database variant conversion function in it and build a cluster from that. There has got to be an easier way, but I can't find it. Of course, my recordset has various data types in it. Any ideas?
Here is the seed of an idea I had been nocking around.
Compose an SQL query based on the cluster elements. I chose to use the caption of the cluster elements so that the unbundles have the names I want but the caption can be set to match the collumn names from the table. (If you really want to get fancy, update the captions of the cluster of the typedef before the application opens)
Do the query and get your array of variants. They should be returned in the order of the query (which we composed based on the cluster order)
Pass the array of variants into another foor loop that uses the Class ID to do the variant conversion.
Come to think of it....
Just wiring the variants to the geneic value refs of the cluster may be good enough.?????
In theory if "cluster" is a type def, new fileds can be added to tthe typedef and it should get updated from the DB.
Maybe turn this into a template?
Your thoughts?
Ben
Message Edited by Ben on 01-03-2007 09:02 PM
Message Edited by Ben on 01-03-2007 09:04 PM
Message Edited by SarahM on 01-08-2007 12:24 PM
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction
Attachments:
Cluster.JPG 92 KB
Maybe you are looking for
-
How to open CR2 from XSi with CS2?
I want to know if I would be able to open up RAW files from my Canon Rebel XSi with CS2. First couldnt even preview the raw images on my computer so I downloaded a codec from Canon and now it shows the preview icons as the pics itself. Then I search
-
Block deleting DMS Document from user that is not initiator
Hi All Hello I Want to Block deleting DMS Document ((CV02N) form all users that are not the initiators of the Document or Bolcking for all user for that I created new user authrization for CV01N,CV02N without authorization for delete I created a DOC
-
Hyperion DataAccessLayerException database version mismatch
Hello, We receive the following error in the Event Viewer when attempting to start the process manager service: Hyperion DataAccessLayerException database version mismatch: Hyperion.SessionManager schema version is 11.1.2.0.0.11, database version sch
-
I have tried to use CS6 to create galleries like the on CS3 can create to update my website but I cannot reproduce what I do in CS3 can somebody help me? Thank you very much. Regards Francesco
-
Tried this on a different post with no success so now I've boiled the question down to the basics. Is there any advantage to shooting XDCAM 720p 50 fps for action video +(as opposed to 1080i 25)+ if the footage will be viewed on SD TV? Please explain