Trouble with storing values in 2-d array.
Hi, I am a Java newbie and would appreciate any help. I am writing a program to read in bandwidth traffic data from a text file and process it to make a graphical representation to analyze the data better. Anyways I haven't gotten very far yet. I am reading the text in from file a line at a time and splitting each line up into fields. I am trying to store each set of fields ( line of text) into a separate array so that I can manipulate the data better...when I get to that. Anyways, when I run the program it will output the first 3 fields of data and then give me the error 'Usage: java ReadFile filename' If I take out the code that stores my data in the array and just test it by outputting it to the screen it works fine. Reads in the file and prints out the entire file like I want it.
Thanks for any help.
import java.lang.*;
import java.io.*;
import java.util.regex.*;
public class Main{
public static void main(String[] args){
String line;
String [][] str = new String[88][4];
try {
FileReader input = new FileReader(args[0]); // Takes an arg and reads a file as input
BufferedReader bufRead = new BufferedReader(input);
line = bufRead.readLine(); // Reads the file one line at a time
while (line != null){
int i = 0;
String text = line;
String [] fields = text.split( "\\s*;\\s*" ); // splits data file into fields
while (fields.length < 3){ // this gets rid of the first 12 lines of my
line = bufRead.readLine(); // file that are unnecessary data
text = line;
fields = text.split( "\\s*;\\s*" );
for (int j = 0; j < fields.length; j++){
str[i][j] = fields[j];
System.out.print(fields[j]);
i++;
line = bufRead.readLine();
bufRead.close();
}catch (ArrayIndexOutOfBoundsException e){
/* If no file was passed on the command line, this expception is
generated. A message indicating how to the class should be
called is displayed */
System.out.println("Usage: java ReadFile filename\n");
}catch (IOException e){
// If another exception is generated, print a stack trace
e.printStackTrace();
}// end main
Here is my text file I am reading from.
version;3
active;1
interface;eth0
nick;eth0
created;1182373685
updated;1184735101
totalrx;7832
totaltx;142830
currx;2464128311
curtx;3121558764
totalrxk;1
totaltxk;867
btime;1181771048
d;0;1184731201;38;1698;405;794;1
d;1;1184644801;755;17589;559;855;1
d;2;1184558401;540;2647;958;1012;1
d;3;1184472001;112;3685;377;34;1
d;4;1184385601;102;2957;523;359;1
d;5;1184299201;90;2605;961;781;1
d;6;1184212802;199;2442;53;300;1
d;7;1184126401;103;3092;494;124;1
d;8;1184040002;117;3097;1008;1009;1
d;9;1183953601;109;3136;435;337;1
d;10;1183867202;115;3921;737;1001;1
d;11;1183780801;125;4307;984;332;1
d;12;1183694401;114;3854;11;225;1
d;13;1183608001;133;4790;157;480;1
d;14;1183521601;135;4871;0;364;1
d;15;1183435201;142;5121;736;898;1
d;16;1183348801;118;3914;500;578;1
d;17;1183262401;134;4759;470;335;1
d;18;1183176001;122;4302;771;761;1
d;19;1183089602;149;5408;308;445;1
d;20;1183043514;72;2534;178;297;1
d;21;1182902401;3059;8065;334;486;1
d;22;1182816001;240;9431;435;521;1
d;23;1182729602;381;12444;204;96;1
d;24;1182643201;135;5059;628;696;1
d;25;1182556801;130;4535;782;899;1
d;26;1182470401;152;5438;197;753;1
d;27;1182384001;184;6704;113;316;1
d;28;1182373685;13;411;1019;115;1
d;29;0;0;0;0;0;0
m;0;1183262401;3190;78494;152;602;1
m;1;1182373685;4641;64336;873;265;1
m;2;0;0;0;0;0;0
m;3;0;0;0;0;0;0
m;4;0;0;0;0;0;0
m;5;0;0;0;0;0;0
m;6;0;0;0;0;0;0
m;7;0;0;0;0;0;0
m;8;0;0;0;0;0;0
m;9;0;0;0;0;0;0
m;10;0;0;0;0;0;0
m;11;0;0;0;0;0;0
t;0;1184644801;755;17589;559;855;1
t;1;1182729602;381;12444;204;96;1
t;2;1182902401;3059;8065;334;486;1
t;3;1182816001;240;9431;435;521;1
t;4;1182384001;184;6704;113;316;1
t;5;1182470401;152;5438;197;753;1
t;6;1183089602;149;5408;308;445;1
t;7;1183435201;142;5121;736;898;1
t;8;1182643201;135;5059;628;696;1
t;9;1183521601;135;4871;0;364;1
h;0;1184734501;37757;1663897
h;1;1184735101;1560;75649
h;2;1184655301;2707;52378
h;3;1184658901;2309;29868
h;4;1184662501;5689;166692
h;5;1184666101;4951;132382
h;6;1184669701;4482;128149
h;7;1184673301;1305;389
h;8;1184676901;1304;380
h;9;1184680501;1463;9641
h;10;1184684101;7479;320802
h;11;1184687701;10266;215760
h;12;1184691301;7682;338884
h;13;1184694901;1533;11403
h;14;1184698501;144097;127520
h;15;1184702101;6260;290490
h;16;1184705701;7891;351298
h;17;1184709301;258228;2123273
h;18;1184712901;65965;2951165
h;19;1184716501;29618;1321867
h;20;1184720101;51062;2405040
h;21;1184723701;48907;2124114
h;22;1184727302;50111;2361284
h;23;1184730901;51224;2258344
Thanks for the help guys. I didn't set my array to
the right size. Also sorry about the formatting. I
will do better next time.A list would have made that more flexible:
http://java.sun.com/docs/books/tutorial/collections/index.html
Also, it may make sense to define a class to represent one row of data, rather than just using an array for that, too.
Similar Messages
-
Trouble with passing values into table !
Well my problem seems to be very small but have tried a lot of books and e-books to get a possible solution, but all in vain.
The problem is I have a table, lets say 'tab', which has a varchar2 column, lets say 'col'.
I want to be able to make an insert into this 'col' column of the table 'tab'.
Simple inserts with all symbols work fine. But when I run the following insert, it fails.....
insert into tab
values('abcn&def');
Assume the table tab has a single column 'col' of varchar2 datatype. When I run the insert statement it prompts a value. Is there anyway I can store '&' as a part of the data?In SQL*Plus ampersand character (&) is the default character to identify a parameter.
Either use set define off or set define to a different character.
SQL > set define off
--- this will turn off & as the input parameter definition charatcer
or use
SQL > set define *
-- this will set * as the input parameter definition charatcer instead of &
Shakti
(http://www.impact-sol.com)
(Developers of Guggi Oracle) -
Trouble with carrying values over to other pages and calculating
Hi folks - I have a calcuation I'm trying to do with five fields. Three of the fields come from other pages in my PDF (there are 10 pages total). When the first value gets carried over to my calculation, that number should show up in my 'Total' field but it isn't. I think it's b/c the other two fields which get carried over from other locations in my PDF, if they haven't been entered into the form yet, are basically NULL. Hence the calcuation doesn't work (just shows zero in my 'Total' field). However, if values are placed into these other 2 fields in my PDF, the calucaltion and subsequent 'Total' works. Not sure how to resolve this? Thanks!
Hi GKaiseril,
Thanks for replying...no javascript errors. Not sure how to determine the order, or where that is shown?
The first 2 fields get carried over, and added together as follows:
event.value = this.getField("Total endowment care fund corpus, reserves, and unexpended income").value + this.getField("Ending Balance, Cost Basis").value;
Then, once the 3rd field is carried over, I subtract it from the total of the previous 2 fields:
event.value = this.getField("Total trust funds corpus").value - this.getField("Cost Basis, Total Investments").value;
Here's the PDF in question, the calculations take place on page 10: http://www.cfb.ca.gov/audits/2012ecfscf_report.pdf
These calculations don't work when just the first number is carried over....so say I enter in 20 into the first line of Schedule A on page 5 - that number gets carried over to Schedule F on page 10 line #1 just fine, but it doesn't show in line 5 (Difference). However, the calcuations work perfectly once the next number (from Schedule D, page 8) gets placed into line 2 on page 10..... -
Having trouble with program (value return)
getting this error msg when i compile
could someone help me out, im lost, thanks a bunch
Prog4.java:57: '.class' expected
double prem_bill = premium_bill(int day, int night);
^
Prog4.java:57: ')' expected
double prem_bill = premium_bill(int day, int night);
import javax.swing.JOptionPane;
import java.text.DecimalFormat;
import java.util.Scanner;
public class Prog4
public static void main(String[] args)
String name, input;
char serv_code;
int acct_num, day_mins, night_mins;
for (int count = 1; count <= 5; count++) //looping construct-will run 5 times
//Get name
name = JOptionPane.showInputDialog("What is your name?");
//Get acct_num
input = JOptionPane.showInputDialog("What is your account number?");
//Convert input to integer
acct_num = Integer.parseInt(input);
//Get serv_code
input = JOptionPane.showInputDialog("Service code? (R-Regular, P-Premium)");
serv_code = input.charAt(0);
//Validate serv_code
while ((serv_code != 'R') && (serv_code != 'r') && (serv_code != 'P') && (serv_code != 'p'))
input = JOptionPane.showInputDialog("Error. (R-Regular, P-Premium)");
serv_code = input.charAt(0);
//Get minutes
if (serv_code == 'R' || serv_code == 'r')
input = JOptionPane.showInputDialog("How many minutes were used in the day?");
day_mins = Integer.parseInt(input);
regular_bill(day_mins);
double reg_bill = regular_bill(day_mins);
//Display output(regular)
System.out.println("Hello " + name + ".");
System.out.println("Your account number is " + acct_num + ".");
System.out.println("Your service type is " + serv_code + ".");
System.out.println("Number of minutes used was " + day_mins + ".");
System.out.println("Your total is " + reg_bill + ".");
else
input = JOptionPane.showInputDialog("How many minutes were used in the day?");
day_mins = Integer.parseInt(input);
input = JOptionPane.showInputDialog("How many minutes were used in the night?");
night_mins = Integer.parseInt(input);
premium_bill(day_mins, night_mins);
int total_mins = day_mins + night_mins;
double prem_bill = premium_bill(int day, int night);
//Display output (premium)
System.out.println("Hello " + name + ".");
System.out.println("Your account number is " + acct_num + ".");
System.out.println("Your service type is " + serv_code + ".");
System.out.println("Number of minutes used was " + total_mins + ".");
System.out.println("Your total is " + prem_bill + ".");
public static double regular_bill(int day)
double result; //Local variable
if (day > 50)
result = (((day - 50) * .2) + 10);
else
result = 10;
return result;
public static double premium_bill(int day, int night)
double result, day_total, night_total; //Local variables
if (day > 75)
day_total = (((day - 75) * .1) + 10);
else
day_total = 25;
if (night > 100)
night_total = (((night - 100) * .05) + 10);
else
night_total = 25;
result = (day_total + night_total);
return result;
}Edited by: dallasCowMavs on Mar 9, 2008 8:37 PM
Edited by: dallasCowMavs on Mar 9, 2008 8:42 PMYour problem is that you cannot call a method by initializing variables.
the method call: double prem_bill = premium_bill(int day, int night); is wrong.
You should replace it with this one: double prem_bill = premium_bill(day_mins, night_mins); assuming this is how you want the program to run. Otherwise, just use other variables that have already been initialized.
In short, consider the following method: public void method(int a, int b);
incorrect method call: method(int c, int d).
correct method call: method(5,9);
correct method call:
int c = 5, d = 9;
method(c,d);
I hope that was helpful -
Trouble with stored procedure date parameters in 10.2.0.2
Hello,
i have I couple of procedures which were running perfectly on 10.2.0.1.
After the upgrade to 10.2.0.2 i get the error: ORA-01843: not a valid month ORA-06512: at "MASTERDBI.CREATE_OR_UPDATE_VER_INFO", line 65 ORA-06512: at line 1
This error is fired up, on an simple insert-stmt within the procedure. That means, that the date-parameter itself ist ok.
If I set the nls_date_format w/ "alter session...", then the procedure is running like before and everthing is fine. But this causes a big change on other programs. So I tried to set the nls_date_format w/in an schema.logon-trigger. But w/out success. The only solution is to set the nls_date_format explicit like in this example:
begin
execute immediate 'alter session set nls_date_format = "dd.mm.yyyy"';
create_or_update_ver_info(
10552,
'VC BK Zuordnung',
'TEST',
sysdate,
1);
end;
It seems, that oracle converts the date-param into a string a back again into a date. But, the date format expected is the american date format. The date format delivered is the german format. And this causes the fault.
Any comments...
Kind regards
Harald Simon
Message was edited by:
[email protected]
Message was edited by:
[email protected]Proc:
PROCEDURE CREATE_OR_UPDATE_VER_INFO
p_vertrag_id number,
p_ver_infotyp varchar2,
p_text varchar2,
p_zeitstempel date,
p_benutzer_id number
) as
v_ver_infotyp_id ver_infotypen.ver_infotyp_id%type;
v_curr_text ver_infos.text%type;
begin
-- Ver-Infotyp ermitteln
begin
select ver_infotyp_id into v_ver_infotyp_id from ver_infotypen
where bezeichnung = p_ver_infotyp;
exception
when no_data_found then
raise_application_error(-20005, 'Vertragsinfotyp "' || p_ver_infotyp || '" in Tabelle VER_INFOTYPEN nicht gefunden.');
end;
-- Aktuelle Vertragsinfo ermitteln
begin
select text into v_curr_text
from ver_infos
where gueltig_bis = to_date('31.12.9999', 'dd.mm.yyyy')
and ver_infotyp_id = v_ver_infotyp_id
and vertrag_id = p_vertrag_id;
exception
when no_data_found then
null;
end;
-- Wenn der vorhandene Vertragsinfotyp der gleiche ist, dann
-- sofort wieder raus
if nvl(v_curr_text, '') = nvl(p_text, '') then
return;
end if;
-- Aktuelle VerInfo löschen
if not v_curr_text is null then
update ver_infos
set gueltig_bis = p_zeitstempel
where gueltig_bis = to_date('31.12.9999', 'dd.mm.yyyy')
and ver_infotyp_id = v_ver_infotyp_id
and vertrag_id = p_vertrag_id;
end if;
if p_text is null then
return;
end if;
-- Neue Vertragsinfo einfügen, falls es etwas zum Einfügen gibt
if not p_text is null then
insert into ver_infos
vertrag_id,
ver_infotyp_id,
gueltig_von,
text,
erstellt_am,
erstellt_durch
) values (
p_vertrag_id,
v_ver_infotyp_id,
p_zeitstempel,
p_text,
p_zeitstempel,
p_benutzer_id
end if;
end;
Test:
begin
create_or_update_ver_info(
10552,
'VC BK Zuordnung',
'TEST',
sysdate,
1);
end;
Result:
ORA-01843: not a valid month ORA-06512: at "MASTERDBI.CREATE_OR_UPDATE_VER_INFO", line 65 ORA-06512: at line 2
Test2:
begin
execute immediate 'alter session set nls_date_format = "dd.mm.yyyy"';
create_or_update_ver_info(
10552,
'VC BK Zuordnung',
'TEST',
sysdate,
1);
end;
Result:
Statement processed in 0,00 sec
It is nice, is`nt it?
Harald
Message was edited by:
HSimon -
I recently bought a 2GB ipod nano, and was told it stores 500 songs. But when I update it, it only stores 433. Why??!!
Because "500" can only be an estimate. Several things affect an iPod's capacity -- song lengths and the bitrate of songs are the primary variables that determine how large your library is. To a much lesser extent, artwork that you've added to songs, and other things like Notes and Calender entries also consume space.
-
Strange issue with POF: byte array with the value 94
This is a somewhat strange issue we’ve managed to reduce to this test case. We’ve also seen similar issues with chars and shorts as well. It’s only a problem if the byte value inside the byte array is equal to 94! A value of 93, 95, etc, seems to be ok.
Given the below class, the byte values both in the array and the single byte value are wrong when deserializing. The value inside the byte array isn’t what we put in (get [75] instead of [94]) and the single byte value is null (not 114).
Pof object code:
package com.test;
import java.io.IOException;
import java.util.Arrays;
import com.tangosol.io.pof.PofReader;
import com.tangosol.io.pof.PofWriter;
import com.tangosol.io.pof.PortableObject;
public class PofObject1 implements PortableObject {
private byte[] byteArray;
private byte byteValue;
public void setValues() {
byteArray = new byte[] {94};
byteValue = 114;
@Override
public void readExternal(PofReader reader) throws IOException {
Object byteArray = reader.readObjectArray(0, null);
Object byteValue = reader.readObject(1);
System.out.println(Arrays.toString((Object[])byteArray));
System.out.println(byteValue);
if (byteValue == null) throw new IOException("byteValue is null!");
@Override
public void writeExternal(PofWriter writer) throws IOException {
writer.writeObject(0, byteArray);
writer.writeObject(1, byteValue);
Using writer.writeObjectArray(0, byteArray); instead of writer.writeObject(0, byteArray); doesn't help. In this case byteArray would be of type Object[] (as accessed through reflection).
This is simply put in to a distributed cache and then fetched back. No EPs, listeners or stuff like that involved:
public static void main(String... args) throws Exception {
NamedCache cache = CacheFactory.getCache("my-cache");
PofObject1 o = new PofObject1();
o.setValues();
cache.put("key1", o);
cache.get("key1");
Only tried it with Coherecne 3.7.1.3.
Cache config file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cache-config SYSTEM "cache-config.dtd">
<cache-config>
<caching-scheme-mapping>
<cache-mapping>
<cache-name>my-cache</cache-name>
<scheme-name>my-cache</scheme-name>
</cache-mapping>
</caching-scheme-mapping>
<caching-schemes>
<distributed-scheme>
<scheme-name>my-cache</scheme-name>
<service-name>my-cache</service-name>
<serializer>
<class-name>
com.tangosol.io.pof.ConfigurablePofContext
</class-name>
<init-params>
<init-param>
<param-type>string</param-type>
<param-value>pof-config.xml</param-value>
</init-param>
</init-params>
</serializer>
<lease-granularity>thread</lease-granularity>
<thread-count>10</thread-count>
<backing-map-scheme>
<local-scheme>
</local-scheme>
</backing-map-scheme>
<autostart>true</autostart>
</distributed-scheme>
</caching-schemes>
</cache-config>
POF config file:
<?xml version="1.0"?>
<pof-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-pof-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-pof-config coherence-pof-config.xsd">
<user-type-list>
<!-- coherence POF user types -->
<include>coherence-pof-config.xml</include>
<user-type>
<type-id>1460</type-id>
<class-name>com.test.PofObject1</class-name>
</user-type>
</user-type-list>
</pof-config>Hi,
POF uses certain byte values as an optimization to represent well known values of certain Object types - e.g. boolean True and False, some very small numbers, null etc... When you do read/write Object instead of using the correct method I suspect POF gets confused over the type and value that the field should be.
There are a number of cases where POF does not know what the type is - Numbers would be one of these, for example if I stored a long of value 10 on deserialization POF would not know if that was an int, long double etc... so you have to use the correct method to get it back. Collections are another - If you serialize a Set all POF knows is that you have serialized some sort of Collection so unless you are specific when deserializing you will get back a List.
JK -
How to get all parameter names along with their values in stored procedure which is being executed
Im using sql server 2012, is there any possible way to get all the parameters of a stored procedure along with the values passed to it.
I need these things to build a xml. I mean this should happen in the procedure which being executed and it should be common for all the procedures.
For example, let us suppose we have to procedures,
uspSave, @name='test' @age=20
uspDelete @id=2
now in uspSave procedure, i need to get @name, @age and the values 'test', 20 and in uspDelete, i should get @id with value 2.
For getting the column names, i tried this,
select parameter_name from information_schema.PARAMETERS where specific_name=OBJECT_NAME(@@procid)
now is it possible to loop through the result of above query and can we get the values.I think you need running SQL Server Profiler to capture this info even in SQL Server 2012.
Best Regards,Uri Dimant SQL Server MVP,http://sqlblog.com/blogs/uri_dimant/
Blog : MS SQL Development and Optimization
Blog : Large
scale of database and cleansing -
Trouble with calling a stored procedure with VARCHAR parameter from trigger
Hi everybody,
today I ran across a problem with stored procedures and triggers that try to call them. Background info: I want to log changes in certain tables to another table in a trigger, so I can replicate the changes to another (non-Oracle) database in an asynchronous way. As an example I have the first data table "bak_s3_berufliste" and the table to store the changes in is "bak_s3_change_request".
DROP TABLE BAK_S3_BERUFLISTE;
CREATE TABLE bak_s3_berufliste (
id_bl NUMBER(27,0) NOT NULL,
berufsbez VARCHAR2(255),
CONSTRAINT PK_BAK_S3_BERUFLISTE PRIMARY KEY (id_bl) ENABLE);
DROP TABLE bak_s3_change_request;
CREATE TABLE bak_s3_change_request (
ID_CR NUMBER(27,0) NOT NULL,
TABELLE_NAME VARCHAR2(50) NOT NULL,
TABELLE_ID_ALT NUMBER(27,0),
TABELLE_ID_NEU NUMBER(27,0),
CONSTRAINT PK_BAK_S3_CHANGE_REQUEST PRIMARY KEY (ID_CR) ENABLE);
DROP SEQUENCE seq_bak_s3_change_request;
CREATE SEQUENCE seq_bak_s3_change_request;
For testing purposes I created the following stored procedure and trigger:
CREATE OR REPLACE PROCEDURE schreibe_cr (t_id_alt IN NUMBER, t_id_neu IN NUMBER) IS
BEGIN
INSERT INTO bak_s3_change_request(ID_CR, TABELLE_NAME, TABELLE_ID_ALT, TABELLE_ID_NEU)
VALUES (seq_bak_s3_change_request.NEXTVAL, t_name, t_id_alt, t_id_neu);
END;
CREATE OR REPLACE TRIGGER trg_bak_s3_berufliste
BEFORE INSERT OR UPDATE OR DELETE ON bak_s3_berufliste
FOR EACH ROW
call schreibe_cr(:old.id_bl,:new.id_bl)
*... and everything worked perfectly - except from the fact that I need to know which table had changed of course. So I added another parameter to the stored procedure:*
CREATE OR REPLACE PROCEDURE schreibe_cr (t_name IN VARCHAR2, t_id_alt IN NUMBER, t_id_neu IN NUMBER) IS
BEGIN
INSERT INTO bak_s3_change_request(ID_CR, TABELLE_NAME, TABELLE_ID_ALT, TABELLE_ID_NEU)
VALUES (seq_bak_s3_change_request.NEXTVAL, t_name, t_id_alt, t_id_neu);
END;
and tested it:
CALL schreibe_cr('Test',1,2);
*... successfully. So I also added the parameter to the trigger:*
CREATE OR REPLACE TRIGGER trg_bak_s3_berufliste
BEFORE INSERT OR UPDATE OR DELETE ON bak_s3_berufliste
FOR EACH ROW
call schreibe_cr('Tabellenname',1,2)
and what i get is:
Error starting at line 31 in command:
CREATE OR REPLACE TRIGGER trg_bak_s3_berufliste
BEFORE INSERT OR UPDATE OR DELETE ON bak_s3_berufliste
FOR EACH ROW
call schreibe_cr('Tabellenname',1,2)
When I try to insert something into that table I get the following error:
insert into bak_s3_berufliste (id_bl, berufsbez) values (seq_bak_s3_change_request.NEXTVAL, 'tueduelue');
Error report:
ORA-00911: Ungültiges Zeichen
00911. 00000 - "invalid character"
Cause: identifiers may not start with any ASCII character other than
letters and numbers. $#_ are also allowed after the first
character. Identifiers enclosed by doublequotes may contain
any character other than a doublequote. Alternative quotes
(q'#...#') cannot use spaces, tabs, or carriage returns as
delimiters. For all other contexts, consult the SQL Language
Reference Manual.
Action:
I tried everything that came to my mind, like using double-quotes (") instead of quotes (') in the trigger code or escaping the quotes (\'), but nothing worked. Can anybody help my and tell me what's wrong? After googling for hours I'm outta ideas :-(
Any ideas appreciated!
Thanks in advance,
JensWhy?
Are you looking for this?
satyaki>
satyaki>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
Elapsed: 00:00:01.61
satyaki>
satyaki>
satyaki>create table aud_dup_emp
2 as
3 select empno, ename
4 from dup_emp
5 where 1=2;
Table created.
Elapsed: 00:00:01.86
satyaki>
satyaki>select * from dup_emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
9999 SATYAKI SLS 7698 02-NOV-08 55000 3455 10
7777 SOURAV SLS 14-SEP-08 45000 3400 10
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 4450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 7000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
9999 SATYAKI SLS 7698 02-NOV-08 55000 3455 10
7777 SOURAV SLS 14-SEP-08 45000 3400 10
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
18 rows selected.
Elapsed: 00:00:00.10
satyaki>
satyaki>
satyaki>create or replace procedure ins_aud_dup(eno in number, enm in varchar2)
2 is
3 begin
4 insert into aud_dup_emp(empno,ename) values(eno,enm);
5 end;
6 /
Procedure created.
Elapsed: 00:00:03.36
satyaki>
satyaki>
satyaki>
satyaki>ed
Wrote file afiedt.buf
1 create or replace trigger trg_aud_dup
2 before insert on dup_emp
3 for each row
4 begin
5 ins_aud_dup(:old.empno,:new.ename);
6* end;
satyaki>/
Trigger created.
Elapsed: 00:00:01.47
satyaki>
satyaki>
satyaki>select * from aud_dup_emp;
no rows selected
Elapsed: 00:00:00.10
satyaki>
satyaki>
satyaki>insert into dup_emp(empno,ename,deptno) values(8855,'BILLY',40);
1 row created.
Elapsed: 00:00:00.19
satyaki>
satyaki>commit;
Commit complete.
Elapsed: 00:00:00.03
satyaki>
satyaki>
satyaki>select * from dup_emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
9999 SATYAKI SLS 7698 02-NOV-08 55000 3455 10
7777 SOURAV SLS 14-SEP-08 45000 3400 10
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 4450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 7000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
9999 SATYAKI SLS 7698 02-NOV-08 55000 3455 10
7777 SOURAV SLS 14-SEP-08 45000 3400 10
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
8855 BILLY 40
19 rows selected.
Elapsed: 00:00:00.20
satyaki>
satyaki>select * from aud_dup_emp;
EMPNO ENAME
BILLY
Elapsed: 00:00:00.09
satyaki>Regards.
Satyaki De. -
Trouble with array to spreadsheet string
I am having trouble with the array to spreadsheet string.
I have a 1-d array of string, the output spreadsheet string never puts a space on the first row, but all others.
example:
05:59:29.170 00000101 8 00 00 07 00 0B 0E 0D 0C
05:59:29.198 00000100 8 00 00 3A 3A 39 39 39 39
05:59:29.220 00000101 8 00 00 07 00 0B 0E 0D 0C
05:59:29.248 00000100 8 00 00 39 39 39 39 39 39
format string is %s and default tab is delimiter.
this is screwing up my program because of the "scan for string" function can't be used correctly if the spreadsheet string isnt consistent.
Any suggestions?
ThanksYou don't need to use "array to spreadheet string": You could use plain formatting for full control over the output.
Still, your observation is a bit odd. Could you attach a simple VI that shows the behavior? (Put your input array into a diagram constant).
LabVIEW Champion . Do more with less code and in less time . -
Can java quickly produce an array with specified values?
In Fortran I can quickly generate an array by typing
Dimension SMF(20,2)
DATA SMF/25*1.,3*0.,9*1.,3*0./
this creates SMF with the value 1 in allocations 1 to 25, 0 in 26 to 27 and so on .
Is there a way for java to do this ?Not necessarily. Maybe you can write a general Matrix type (an interface) and then write an implementation of Matrix in which its values are specified by an algorithm. So maybe your code would have lines like:
Matrix m1 = new InitWithHardcodedValuesMatrix("{ { 1 2 } { 3 4 }}");
Matrix m2 = new InitWithFormulaMatrix("/25*1.,3*0.,9*1.,3*0./");Or maybe someone has already done this. Have you tried Google?
Anyway, the primary purpose of Java is not formula translation, so it's not surprising that it doesn't have this kind of thing built into the standard libraries. -
Hello all,
may be the following question is very simple, but I am relatively new in labview and it would be great if somebody could help me:
I have a acquaried 1D array of data-points. Now, I have to find the element in this array which value is the closest to a calculated "target value".
After finding the element with the value close to the "target value", I have to get the position of this element (i.e. the index) in the 1D array.
Now, I have to use this index to find and extract the element at this position in an other 1D array.
It would be very nice if somebody could help me with this problem.
Thank you,
beamFind attached a sample vi that you can modify.
Attachments:
select_target_value.vi 22 KB -
Search Array with multiple values
Hello,
I've been helped with the prototype below by blemmo (thanks).
It allows me to search my array using one property == a
value.
Now, I'd like to use it to:
if ((prop1 == val1) &&(prop2 == val2) &&
(prop3 == val3) {
// search array for all values in array with the values of
val1, val2 and val3
Also, a way to search if one of the prop and val's are blank,
ie...
((prop1 == val1) &&(prop2 == val2) && (prop3
== val3)
where prop2 and val2 are "undefined"
so the search will only search for the prop and val that are
not "undefined"
make since? Don't know where to start.
help and thanks in advance.it is an array like this.. but with more properties... also,
is it better to use XML to load large arrays or is it ok to use
actionscript in the file.
which is faster to load? say if I had an array of 150
elements?
myArray = [{myname:"bob", county:"skagit", city:"Sedro
Woolley", id:1,
pic:"1.jpg",pic1:"2.jpg",pic2:"3.jpg",pic3:"4.jpg"},
{myname:"bob", county:"skagit", city:"Sedro Woolley", id:1,
pic:"1.jpg",pic1:"2.jpg",pic2:"3.jpg",pic3:"4.jpg" -
Trying to build (simple) color palette, but keep getting ArrayIndexOutOfBoundsException: 0 when trying to fill the array with Hue values (Saturation and Brightness remain 100%):
private Color[] hsb = new Color[numberOfCircles];
float h=0;
float raise=(1.f/numberOfCircles);
for (int i=0; i<stKrogcev; i++) {
hsb=Color.getHSBColor(h,1.0f,1.0f); //getHSBColor: "Creates a Color object based on the specified values for the HSB color model."
h+=raise;
}What am I doing wrong?
What other way could you fill array (Color, int, float, ...) with Hue values?
This is what I have thus far (only colors missing; not sure whether Sun supports images): [http://www.shrani.si/f/1G/uM/v29MKIC/palette.jpg]. First three columns in the right-hand table are awaiting RGB values respectively, the last column gets Hue value.pbrockway2, numberOfCircles (or stKrogcev ) is an int, and is NOT zero. That Color[] hsb is zero.
import javax.swing.*;
import java.awt.*;
public class BarvnaPaleta {
public static void main (String[] args) {
System.out.print("Stevilo krogcev: ");
int n = BranjePodatkov.preberiInt(); // BranjePodatkov: just some custom class for reading input
Okno o = new Okno(n);
o.setVisible(true);
class Okno extends JFrame {
RisalnaPlosca risalna;
public Okno(int n) {
setTitle("Barvna Paleta");
setSize(1200,900);
setLocation(0,0);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
risalna = new RisalnaPlosca(n);
add(risalna);
class RisalnaPlosca extends JPanel {
private final int ROB = 300;
int stKrogcev;
private int izhX, izhY;
private int r1;
private int sirina = 60;
private int visina = 20;
private double x, y, r2, r3;
private double vmesniKot;
private double polovicaVmesnegaKota;
//the much needed color arrays
public Color[] hsb = new Color[stKrogcev];
private String[] red = new String[stKrogcev];
private String[] green = new String[stKrogcev];
private String[] blue = new String[stKrogcev];
public RisalnaPlosca(int n) { //constructor
stKrogcev = n;
setBackground(Color.white);
public void paintComponent(Graphics g) {
super.paintComponent(g);
izhX = getWidth()/2 -r1;
izhY = getHeight()/2 -r1;
vmesniKot=(2*Math.PI/stKrogcev);
polovicaVmesnegaKota=(vmesniKot)/2;
r1=getHeight();
r3=(r1*Math.sin(polovicaVmesnegaKota))/(1+Math.sin(polovicaVmesnegaKota));
r2=r1-r3;
narisiKrog(g);
napolniHSB(g); // LINE 53
narisiKrogce(g);
private void narisiKrog(Graphics g) { //draw the BIG Circle
g.setColor(Color.BLACK);
g.drawOval(0, 0, r1, r1);
private void narisiKrogce(Graphics g) { //draw small circles (as many as user wants, max. is 256 of Hue values!
for(int i=0; i<stKrogcev; i++) {
x=(r2/2)*(Math.cos(vmesniKot*i)+1);
y=(r2/2)*(Math.sin(vmesniKot*i)+1);
//can't use below two because of the "fillHSB"=="napolniHSB" method not working
//Color c = new Color(Integer.parseInt(red),Integer.parseInt(green[i]),Integer.parseInt(blue[i]));
//g.setColor(c);
g.drawOval((int)x, (int)y, (int)r3, (int)r3);
narisiLegendo((int)x,(int)y, i, g); //draw a legend (last method)
private void napolniHSB(Graphics g) { //fillHSB method
float h=0, raise=1.0f/stKrogcev;
for (int i=0; i<stKrogcev; i++) {
hsb[i]=Color.getHSBColor(h,1.0f,1.0f); // LINE 75
red[i]=Integer.toString(hsb[i].getRed()); // this and below two for converting HSB/HSL into RGB
green[i]=Integer.toString(hsb[i].getGreen());
blue[i]=Integer.toString(hsb[i].getBlue());
h+=raise;
private void narisiLegendo(int x, int y, int i, Graphics g) { //draw a legend, i.e. 4 right columns
//can't use drawString as there are no color arrays (yet)
g.drawLine((int)(x+r3/2),(int)(y+r3/2),getWidth()-ROB,(visina+i*visina)+visina/2);
g.drawRect(getWidth()-ROB, (visina+i*visina), sirina, visina); //Red
//g.drawString(red[i], getWidth()-ROB, (visina+i*visina));
g.drawRect(getWidth()-ROB+sirina, (visina+i*visina), sirina, visina); //Green
//g.drawString(green[i], getWidth()-ROB, (visina+i*visina));
g.drawRect(getWidth()-ROB+2*sirina, (visina+i*visina), sirina, visina); //Blue
//g.drawString(blue[i], getWidth()-ROB, (visina+i*visina));
g.drawRect(getWidth()-ROB+3*sirina, (visina+i*visina), sirina, visina); //Hue
//g.drawString(, getWidth()-ROB, (visina+i*visina)); -
How to change stored procedure with Table Valued Parameter
I am not sure how to change the normal stored procedure with Table Value Parameter.Do I have to create a separate Table or do I have to create a datatype. Can you please help me with this
ALTER PROCEDURE [dbo].[uspInsertorUpdateINF]
@dp_id char(32),
@dv_id char(32),
@em_number char(12),
@email varchar(50),
@emergency_relation char(32),
@option1 char(16),
@status char(20),
@em_id char(35),
@em_title varchar(64),
@date_hired datetime
AS
BEGIN
SET NOCOUNT ON;
MERGE [dbo].[em] AS [Targ]
USING (VALUES (@dp_id, @dv_id , @em_number, @email, @emergency_relation, @option1, @status, @em_id, @em_title, @date_hired))
AS [Sourc] (dp_id, dv_id, em_number, email, emergency_relation, option1, status, em_id, em_title, date_hired)
ON [Targ].em_id = [Sourc].em_id
WHEN MATCHED THEN
UPDATE
SET dp_id = [Sourc].dp_id,
dv_id = [Sourc].dv_id,
em_number = [Sourc].em_number,
email = [Sourc].email,
emergency_relation = [Sourc].emergency_relation,
option1 = [Sourc].option1,
status = [Sourc].status,
em_title = [Sourc].em_title,
date_hired = [Sourc].date_hired
WHEN NOT MATCHED BY TARGET THEN
INSERT (dp_id, dv_id, em_number, email, emergency_relation, option1, status, em_id, em_title,date_hired)
VALUES ([Sourc].dp_id, [Sourc].dv_id, [Sourc].em_number, [Sourc].email, [Sourc].emergency_relation, [Sourc].option1, [Sourc].status, [Sourc].em_id, [Sourc].em_title, [Sourc].date_hired);
END;It's not clear how you would change the procedure. But assuming that you want to replace the existing scalar parameters with tabular input, this is how you would do it. You first create a table type:
CREATE TYPE Insertor_type AS TABLE
(dp_id char(32),
dv_id char(32),
em_number char(12),
email varchar(50),
emergency_relation char(32),
option1 char(16),
status char(20),
em_id char(35),
em_title varchar(64),
date_hired datetime)
Then you change the procedure header:
ALTER PROCEDURE [dbo].[uspInsertorUpdateINF] @tvp Insertor_type READONLY AS
And finally you change the USING clause:
USING (SELECT dp_id, dv_id , em_number, email, emergency_relation, option1, status, em_id, em_title, date_hired
FROM @tvp) AS [Sourc] ON [Targ].em_id = [Sourc].em_id
The rest is fine as it is.
Erland Sommarskog, SQL Server MVP, [email protected]
Maybe you are looking for
-
Excise and Non Excise Warehouse
Hi Friends, We are receiving the same material, sometimes cenvatable to cenvatable stores and some times non cenvatable to non cenvatable store. when I need it in cenvatable store, then I have to transfer from non cenvatable a
-
How can I paste an AP Group into a WLC so I don't have to do it by hand?
I'm creating a new AP group across a WiSM farm. All WiSMs will get the same AP Group. Problem is, the interfaces were created with spaces, such as "vlan 90". Other interfaces, created with names, such as "MyWLAN" will paste in. (controller) >config
-
Opening page in new window on click of link in Global button bar section
Hi, I have created a custom global link to appear alongside Home, Logout links. The requirement is to open a page in a new window when i click on the custom global link. Please let me know how to achieve this functionality. Thanks, VG
-
I downloaded this App for ringtones (Ringtones 500.000) , purchased a full version of it, so I should be able to download unlimited number of ringtones. The problem is, it won't let me download any ringtones after 10, which is how free version of thi
-
WebSphere Portal and BOXI R2 PIK errors
Post Author: leonpc CA Forum: Publishing I have Business Objects installed on a system. I am trying to install the JSR168 portlets on a WebSphere Portal server to access this BOXI R2 server. I have followed the instructions and update the web.xml i