SQL Expression for date conversion - version XI
I am trying to convert a number field to a date field in order to use it in a date parameter in Infoview. The database field is in a 15 digit DTM format but is stored as a number. There is also a zero stored in the database field. When I try to create the date SQL Expression I get this error: Error in compiling SQL Expression: Failed to retrieve data from the database. Details: ORA-01840: input value not long enough for date format. How can I get the SQL Expression to not look at the zero? I tried putting a statement in my Record Selection to not pull any zero fields but that doesn't work. Any ideas? Thanks! Kelley
Hi Kelly,
It's been a while since I used Info View, so if it's about registering, etc. I won't know the
answer.
Did you link it ? Have you tested that it should even return data ?
Check the filtering, etc in a query builder to make sure.
Have you tested the sub report by running it by itself ? (just add a value to the parameter
field request)
Do you have suppression formulas in the sub report ?
Is the section of the main report that is holding the sub report
free of "suppresion" formulas ?
Similar Messages
-
Entity DATE type attribute : Derieved From SQL Expression for date format
Hi,
I want to set one of the Entity's Date Attribute with specific format , for e.g DD-MM-YYYY
I see a Derieved From SQL Expression checkbox, how can I define the SQL Expression
can I use TO_DATE(EMP_START_DATE,'DD-MM-YYYY'), I want to insert a date in that format, when I am creating a row using viewObject.createRow()
Java Type is oracle.jbo.domain.Date which take YYYY-MM-DD as a string, I do not want to use this format
Thanks,Here is a solution, but I am sure it is not the best one. It will work in a hurry. Maybe you can create a helper method to generalize this conversion until something more succinct comes along for US:
This code assumes an import of jbo.oracle.domain.Date.
public void updateDateTest () {
AddressesViewImpl lVO = (AddressesViewImpl)this.getAddressesView1();
AddressesViewRowImpl lRow = (AddressesViewRowImpl)lVO.first();
System.out.println("create date for current record is currently: " +
lRow.getCreationDate());
java.util.Date today = new java.util.Date();
SimpleDateFormat dateFormat =
new SimpleDateFormat("dd-MM-yyyy");
SimpleDateFormat jboDateFormat =
new SimpleDateFormat("yyyy-MM-dd");
String lSampleDateString = "15-04-2010";
java.util.Date lSampleDate = null;
try {
lSampleDate = dateFormat.parse(lSampleDateString);
} catch (ParseException e) {
System.out.println("Parsing exception thrown: " + e.getMessage() +
"\n ==> caused by \n==>"+ e.getCause().getMessage());
lRow.setCreationDate(new Date(jboDateFormat.format(lSampleDate)));
System.out.println("about to commit; create date for current record is currently: " +
lRow.getCreationDate());
this.getDBTransaction().commit();
System.out.println("resetting to some other date; create date for current record is currently: " +
lRow.getCreationDate());
lRow.setCreationDate(new Date(jboDateFormat.format(today)));
this.getDBTransaction().commit();
}I defined this code in my Application Module Impl file and ran it with the BC tester. Here was its output:
Mar 18, 2010 8:27:54 AM oracle.jbo.jbotester.MainFrame main
INFO: BC4J Tester started.
Source breakpoint occurred at line 66 of FusionExperimentsAMImpl.java.
create date for current record is currently: 2009-02-02 12:09:54.0
about to commit; create date for current record is currently: 2010-04-15
resetting to some other date; create date for current record is currently: 2010-04-15I spent a little time looking around the forum for additional solutions. I think several years ago I even wrote a blog entry on this subject. If I remember how to do this right I will amend with more information. -
Using CVS in SQL Developer for Data Modeler changes.
Hi,
I am fairly new to SQL Developer Data Modeler and associated version control mechanisms.
I am prototyping the storage of database designs and version control for the same, using the Data Modeler within SQL Developer. I have SQL Developer version 3.1.07.42 and I have also installed the CVS extension.
I can connect to our CVS server through sspi protocol and external CVS executable and am able to check out modules.
Below is the scenario where I am facing some issue:
I open the design from the checked out module and make changes and save it. In the File navigator, I look for the files that have been modified or added newly.
This behaves rather inconsistently in the sense that even after clicking on refresh button, sometimes it does not get refreshed. Next I try to look for the changes in Pending Changes(CVS) window. According to the other posts, I am supposed to look at the View - Data Modeler - Pending Changes window for data modeler changes but that shows up empty always( I am not sure if it is only tied to Subversion). But I do see the modified files/ files to be added to CVS under Versioning - CVS - Pending Changes window. The issue is that when I click on the refresh button in the window, all the files just vanish and all the counts show 0. Strangely if I go to Tools - Preferences - Versioning - CVS and just click OK, the pending changes window gets populated again( the counts are inconsistent at times).
I believe this issue is fixed and should work correctly in 3.1.07.42 but it does not seem to be case.
Also, I m not sure if I can use this CVS functionality available in SQL Dev for data modeler or should I be using an external client such as Wincvs for check in/ check out.
Please help.
ThanksHi Joop,
I think you will find that in Data Modeler's Physical Model tree the same icons are used for temporary Tables and Materialized Views as in SQL Developer.
David -
Executing xml sql using jdbc adapter for date conversion
Hi experts,
I am following the fllowing blog for date format conversion for a jdbc receiver.
/people/alessandro.berta/blog/2005/10/04/datetime-datatypes-and-oracle-database
I constructed my graphical mapping to generate the following query
DateField in receiver structure = TO_DATE('2008-03-24','DD-MON-YY')
attribute hasQuot = No
The result that i want is 24-MAR-08
I am getting the error in communication channel monitoring as does not match string format.
The database gets successfully updated without this date conversion. But when i try to use this, it give the above error.
Is there any other configuration to be done to make the adapter execute this statement?
Regards,
ShamlyThe issue is solved.
The SQL statement was wrong.
The correct version is,( as was specified in the blog ) :-
DateField in receiver structure = TO_DATE('2008-03-24','YYYY-MM-DD')
Automatically in the database it is converted to 24-MAR-2008
Edited by: Shamly MM on Mar 27, 2008 8:01 AM -
Displaying diff dates using PL/SQL expression for 'display only' item ?
Hi ,
I am having a display only item -- :P2_FROM_Date . If its Thu,Fri,Sat or Sun I want to set the date as the last Monday's date . If its Mon,Tue or Wed then it should be the present Monday's date .
E.g: Today is Friday and the last Monday was on 18th .
So for yesterday , today,tomorrow and Sunday , the date should be displayed as 18-JUN-2012.
From the coming Monday to Wednesday , the date should of be the coming Monday i.e , 24-JUN-2012
I tried it doing under 'Source ' of item using PL/SQL expression and PL/SQL function body. Not working
Can someone help ?
Thanks & Regards
UmerNice1 wrote:
declare
lv_date number;
begin
select to_char(sysdate,'D') into lv_date from dual;
if lv_date=2 then
:P2_FROM_DATE := to_char(sysdate-1);
end if;
end;I tried this under " PL/SQL function body " in "Source " tab of the item P2_FROM_DATE
When I run this , nothing is displayed corresponding to the item P2_FROM_DATEExactly as expected. This code will only set a value for <tt>P2_FROM_DATE</tt> when run on Mondays in territories where the first day of the week is Sunday, and when run on Tuesdays where Monday is the first day of of the week:
SQL> var P2_FROM_DATE varchar2(30)
SQL> alter session set nls_date_format='Dy DD-MON-YYYY';
Session altered.
SQL> select sysdate from dual
SYSDATE
Mon 25-JUN-2012
SQL> alter session set nls_territory='AMERICA';
Session altered.
SQL> declare
2 lv_date number;
3 begin
4 select to_char(sysdate,'D') into lv_date from dual;
5 if lv_date=2 then
6 :P2_FROM_DATE := to_char(sysdate-1);
7 end if;
8 end;
9 /
PL/SQL procedure successfully completed.
SQL> print p2_from_date
P2_FROM_DATE
Sun 24-JUN-2012
SQL> alter session set nls_territory='UNITED KINGDOM';
Session altered.
SQL> exec :p2_from_date := null
SQL> declare
2 lv_date number;
3 begin
4 select to_char(sysdate,'D') into lv_date from dual;
5 if lv_date=2 then
6 :P2_FROM_DATE := to_char(sysdate-1);
7 end if;
8 end;
9 /
PL/SQL procedure successfully completed.
SQL> print p2_from_date
P2_FROM_DATE
SQL>Hence the questions about language above.
>
I am having a display only item -- :P2_FROM_Date . If its Thu,Fri,Sat or Sun I want to set the date as the last Monday's date . If its Mon,Tue or Wed then it should be the present Monday's date .
E.g: Today is Friday and the last Monday was on 18th .
So for yesterday , today,tomorrow and Sunday , the date should be displayed as 18-JUN-2012.
From the coming Monday to Wednesday , the date should of be the coming Monday i.e , 24-JUN-2012
>
The coming Monday is 25-JUN-2012.
Aren't these rules equivalent to "Monday this week, where Monday is the first day of the week"? In which case the PL/SQL Expression you require is:
trunc(sysdate, 'iw')For example:
SQL> with t as (
2 select date '2012-06-21' + level d from dual connect by level <= 17)
3 select
4 d
5 , trunc(d, 'iw') monday
6 from
7 t;
D MONDAY
Fri 22-JUN-2012 Mon 18-JUN-2012
Sat 23-JUN-2012 Mon 18-JUN-2012
Sun 24-JUN-2012 Mon 18-JUN-2012
Mon 25-JUN-2012 Mon 25-JUN-2012
Tue 26-JUN-2012 Mon 25-JUN-2012
Wed 27-JUN-2012 Mon 25-JUN-2012
Thu 28-JUN-2012 Mon 25-JUN-2012
Fri 29-JUN-2012 Mon 25-JUN-2012
Sat 30-JUN-2012 Mon 25-JUN-2012
Sun 01-JUL-2012 Mon 25-JUN-2012
Mon 02-JUL-2012 Mon 02-JUL-2012
Tue 03-JUL-2012 Mon 02-JUL-2012
Wed 04-JUL-2012 Mon 02-JUL-2012
Thu 05-JUL-2012 Mon 02-JUL-2012
Fri 06-JUL-2012 Mon 02-JUL-2012
Sat 07-JUL-2012 Mon 02-JUL-2012
Sun 08-JUL-2012 Mon 02-JUL-2012
17 rows selected.
SQL> alter session set nls_territory='AMERICA';
Session altered.
SQL> alter session set nls_date_format='Dy DD-MON-YYYY';
Session altered.
SQL> with t as (
2 select date '2012-06-21' + level d from dual connect by level <= 17)
3 select
4 d
5 , trunc(d, 'iw') monday
6 from
7 t;
D MONDAY
Fri 22-JUN-2012 Mon 18-JUN-2012
Sat 23-JUN-2012 Mon 18-JUN-2012
Sun 24-JUN-2012 Mon 18-JUN-2012
Mon 25-JUN-2012 Mon 25-JUN-2012
Tue 26-JUN-2012 Mon 25-JUN-2012
Wed 27-JUN-2012 Mon 25-JUN-2012
Thu 28-JUN-2012 Mon 25-JUN-2012
Fri 29-JUN-2012 Mon 25-JUN-2012
Sat 30-JUN-2012 Mon 25-JUN-2012
Sun 01-JUL-2012 Mon 25-JUN-2012
Mon 02-JUL-2012 Mon 02-JUL-2012
Tue 03-JUL-2012 Mon 02-JUL-2012
Wed 04-JUL-2012 Mon 02-JUL-2012
Thu 05-JUL-2012 Mon 02-JUL-2012
Fri 06-JUL-2012 Mon 02-JUL-2012
Sat 07-JUL-2012 Mon 02-JUL-2012
Sun 08-JUL-2012 Mon 02-JUL-2012
17 rows selected.Also note that using the item source properties will only set the <tt>P2_FROM_DATE</tt> in the rendered page, not in session state. -
Pl/sql expression for default value
I'm trying to run this simple script as a default value using pl/sql expression, but I keep getting this error. THe select statement itself works fine as a sql statement source value, but will not work as a pl/sql exression as a default value. This (:P33_SYSUSERID_CREATED_BY ) is the field name on the form. Any ideas?
begin
select a.id || ', ' || A.NAME_LAST into :P33_SYSUSERID_CREATED_BY from S_USERSV a where a.name_last = 'HAMMAKER';
end;
Error ERR-9132 Error in PLSQL expression for item default code, item=P33_SYSUSERID_CREATED_BY
OK
ORA-06550: line 1, column 27: PLS-00103: Encountered the symbol "BEGIN" when expecting one of the following: ( - + case mod new not null avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date pipeSudha,
For a default value type of PL/SQL Expression, you could create a function that accepts an input and returns a value. If the function (not a procedure) is named GET_REFNO, you would call it using an expression in the default value field like:
get_refno(:P3_REFTYPE)
For a default value type of PL/SQL Function Body, you could call your existing procedure with a default value like:declare
l_value varchar2(32767);
begin
get_refno(:P3_REFTYPE, l_value);
return l_value;
end;Scott -
RH for Word conversions - version 5 to version 7
Hi,
We're considering an upgrade from RoboHelp 5.0.2 to RoboHelp
7. Has anyone out there converted an RH 5 for Word project to
RoboHelp for Word in version 7?
If you have, what issues did you encounter?
Thanks,
JimHello, I converted just after the first of the year. Here are
issues I encountered.
1. you will need to replace any curly quotes (single or
double) with straight quotes in your doc. Preferably shut this
option off in Word under autocorrect. The utf-8 feature does not
handle curly quotes. Basically when it encounters a curly quote, it
deletes it in the output.
2. the robohelp.dot file is set to automatically update the
template. I'm told there is a way to shut this feature off, but I
haven't found it yet. This is annoying.
3. when you generate a chm, the dialog box to launch the chm
comes up with an mskstor error. This may have something to do with
the character sets. The chm still works, you just may not be able
to launch it from the db.
4. you will need to setup the properties to generate the chm
file. the webhelp was fine. I lost the chm settings during the
conversion.
Otherwise, it is do-able. Hope this helps
In one project, I have 12 docs. 951 topics. I generate chm
for my testing, but deploy webhelp using RH7 for Word. -
Multiple pl/sql expressions for a conditonal process
Can I put multiple pl/sql expressions in the expression one box? I want run a process on conditions that posts an update when the user has checked a box that was not previously checked.
looks something like this:
when
(p1_checkbox1 = 'Y' or p1_checkbox2 = 'Y')
and ((p1_checkbox1 =! p1_checkbox1_sav)
or (p1_checkbox2 =! p1_checkbox2_sav))
Is this possible or will I need to create multiple processes that do the same thing with different run conditions?Please tell us your first name and update your forum profile with it to help us. Thanks.
The answer is no, you can only have one expression, for example:
(:p1_checkbox1 = 'Y' or :p1_checkbox2 = 'Y')
and ((:p1_checkbox1 =! :p1_checkbox1_sav)
or (:p1_checkbox2 =! :p1_checkbox2_sav))Scott -
Hi Friends,
I Have a view named - item_sales with 4 column
Item code
Item name
Transaction_YYYYMM (Date stored in YYYYMM format )
QTY_RECEIVED
QTY_SOLD
Sample data is
ITEM_CODE ITEM NAME TRANSACTION_YYYMM QTY_RECD QTY_SOLD
AX TSHIRT 201307 3000 2000
AX TSHIRT 201308 2000 500
AX TSHIRT 201309 1000 3000
CX XLSHIRT 201307 3000 2000
CX XLSHIRT 201308 3000 2500
CX XLSHIRT 201309 3000 2500
EVERY MONTH END I WILL RUN THIS QUERY TO FIND OUT THE BELOW DETAILS
1. TO FIND ITEM_NAME WISE - QTY_RECEIVED AND QTY_SOLD ( FOR CURRENT MONTH - EXAMPLE SEP )
2. TO FIND ITEM_NAME WISE - QTY_RECEIVED AND QTY_SOLD (FOR CURRENT YEAR EXAMPLE FROM JAN TO SEP )
OUTPUT FOR SEPTEMBER MONTH LOOK LIKE THIS
SEP-MONTH JAN TO SEP
ITEM_CODE ITEM_NAME QTY_RECEIVED QTY_SOLD QTY_RECEIVED QTY_SOLD
AX TSHIRT 1000 3000 6000 5500
CX XLSHIRT 3000 2000 9000 7000
Pls advise me how to write queries for this
RdkJust FYI, you *can* edit your own posts, you know
Rdk wrote:
Transaction_YYYYMM (Date stored in YYYYMM format )
First "problem". Don't store dates as string. Store them as dates. It will save you so much headache don't the road you won't believe it.
True, this is a view, so maybe not as critical - assuming the underlying *DATA* is actually a date.
1. TO FIND ITEM_NAME WISE - QTY_RECEIVED AND QTY_SOLD ( FOR CURRENT MONTH - EXAMPLE SEP )
2. TO FIND ITEM_NAME WISE - QTY_RECEIVED AND QTY_SOLD (FOR CURRENT YEAR EXAMPLE FROM JAN TO SEP )
So yeah, based on these requirements, I'd recommend you make that column a DATE, not a string. Dates are easier to parse for date-related logic - such as month by month as you need here.
Using that, here's one way to do it:
with w_data as (
select 'AX' item_code, 'TSHIRT ' item_name, to_date('20130701','yyyymmdd') trans_dt, 3000 qty_recd, 2000 qty_sold from dual union all
select 'AX' , 'TSHIRT ' , to_date('20130801','yyyymmdd') , 2000 , 500 from dual union all
select 'AX' , 'TSHIRT ' , to_date('20130901','yyyymmdd') , 1000 , 3000 from dual union all
select 'CX' , 'XLSHIRT' , to_date('20130701','yyyymmdd') , 3000 , 2000 from dual union all
select 'CX' , 'XLSHIRT' , to_date('20130801','yyyymmdd') , 3000 , 2500 from dual union all
select 'CX' , 'XLSHIRT' , to_date('20130901','yyyymmdd') , 3000 , 2500 from dual
w_base as (
select item_code, item_name, trans_dt, qty_recd, qty_sold,
sum(qty_recd) over (partition by item_code, trunc(trans_dt, 'MM')) mm_recd,
sum(qty_sold) over (partition by item_code, trunc(trans_dt, 'MM')) mm_sold,
sum(qty_recd) over (partition by item_code, trunc(trans_dt, 'YY')) yy_recd,
sum(qty_sold) over (partition by item_code, trunc(trans_dt, 'YY')) yy_sold,
row_number() over (partition by item_code order by trans_dt desc) rnum
from w_data d
Select item_code, item_name, mm_recd, mm_sold, yy_recd, yy_sold
from w_base
where rnum = 1
IT ITEM_NA MM_RECD MM_SOLD YY_RECD YY_SOLD
AX TSHIRT 1000 3000 6000 5500
CX XLSHIRT 3000 2500 9000 7000 -
SQL Query for Date field updation
I want a query from u.. Hope u help me with a
solution soon..
My Q: I want to update a date field in Oracle
database. But the condition is that i shouldnt change
the hours, minutes & seconds of the date field.
generally , if we update the date field then it takes
the default values for hours, min's & sec's to
00:00:00.
EX : if we have a value 21-SEP-2002 04:54:44 in a date
field. I want to update it to 22-SEP-2002 04:54:44.
But it updates to 22-sep-2002 00:00:00 if we use
UPDATE command.Use a PreparedStatement:
PreparedStatement ps = conn.prepareStatement("SELECT * FROM TEMP WHERE TDATE > ? AND TDATE < ?");
// note: month numbers start at 0, so 1 is february
GregorianCalendar c1 = new GregorianCalendar(2002, 1, 11, 11, 0);
GregorianCalendar c2 = new GregorianCalendar(2002, 1, 18, 22, 0);
Date d1 = c1.getTime();
Date d2 = c2.getTime();
java.sql.Timestamp sqlDate1 = new java.sql.Timestamp(d1.getTime());
java.sql.Timestamp sqlDate2 = new java.sql.Timestamp(d2.getTime());
ps.setTimestamp(1, sqlDate1);
ps.setTimestamp(2, sqlDate2);
ResultSet rs = ps.executeQuery();
// get results from the result setJesper -
SQL query for date & time interval
Hello everyone,
there is my problem
I have to make a search for events that are taking place during inserted date & time .
There's the table structure:
event
datefrom
dateto
timefrom
timeto
The problem is, when I try:
select * from xyz where datefrom <= inserted_date and dateto >= inserted_date and timefrom <= inserted_time and timeto >= inserted time;
then I don't get back all records.
eg: user inserts date = 10.10.2010 and time 10:00 and in the table is event [abc 11:00 9.10.2010 -> 09:00 11.10.2010] stored following way:
event abdc
datefrom 09.10.2010
dateto 11.10.2010
timefrom 11:00
timeto 09:00
=> this event won't be found, because the sql logic compares only single parameters and not their context.
Do you have any idea, how to solve this issue?
Thank you.
LukasHello Hubert,
thank you very much for your proposal, but your code makes the same select as mine (but in a more user friendly look :).
Table:
datefrom 09.10.2010
dateto 11.10.2010
timefrom 11:00
timeto 09:00
Event date = 10.10.2010 and time 10:00.
Your query:
select * from xyz where 10.10.2010 between 09.10.2010 and 11.10.2010 (that's so far ok) and 10:00 between 11:00 and 9:00 (no return there, because 10:00 doesn't lie within interval 11:00 -> 9:00... actually no value lies there) ;
Don't you have any other idea?
Thank you
Lukas -
What is the proper SQL syntax for dates input as variable
Hello,
I am working on an ASP JavaScript page that requests totals
from an Access database for a specific date range. I can write the
SQL statement to query the DB and get the results I need using the
WHERE statement below.
...WHERE LABOR_DATE BETWEEN #7/15/2006# AND #7/18/2006# GROUP
BY [LABOR].[JOB_NUMBER_NAME]
I have another page that I want to pass two variables in
Dreamweaver specifying the date range varBeginDate and varEndDate
and query the database using the date range input by the user.
What is the correct syntax for replacing the actual dates in
the example above with my variable values?Short answer - you can't. There's no automatic link between file paths and mounting servers. There are lots of valid reasons for this (e.g. preventing malicious links from automatically opening files from remote servers), but you can get there in a controlled environment.
You can configure Automounts on any directory. That way whenever any application tries to access a particular path the OS will automatically mount the directory, but it needs to be told in advance which directories (and which servers) to mount.
For example, if you'd configured your iTunes Library to be saved at /mnt/itunes and it's served from afp://mediaserver.your.net/path/to/itunes you would configure an automount to mount the AFP server at /mnt/itunes.
Since its an automount, the OS wouldn't mount the server until some process tried to read /mnt/itunes.
There are several ways of specifying automounts, and for each there are several tutorials online that walk you through the process. Try Mike Bombich's site for a starter. -
MS SQL Server 2005 Data Conversion Problem
Hello all,
I'm using the Microsoft JDBC Driver with SQL Server 2005 and getting an exception from the database server indicating that it is attempting to convert an nvarchar to an int (SQL Error 8114). This is the stack trace and code. I've exhausted all my resources... anybody have an idea?
com.microsoft.sqlserver.jdbc.SQLServerException: Error converting data type nvarchar to int.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.IOBuffer.processPackets(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.getPrepExecResponse(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement (Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PreparedStatementExecutionRequest.executeStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.CancelableRequest.execute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeRequest(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.execute(Unknown Source)
at com.boeing.ict.workmonitor.swing.JMainFrame$33.insertIntoDB (JMainFrame.java:986)
at com.boeing.ict.workmonitor.utils.SafeUDPWorker.respond(SafeUDPWorker.java:65)
at com.boeing.ict.workmonitor.utils.SafeNetWorker.runWork(SafeNetWorker.java:113)
at com.boeing.ict.workmonitor.utils.SafeNetWorker.access$000 (SafeNetWorker.java:21)
at com.boeing.ict.workmonitor.utils.SafeNetWorker$1.run(SafeNetWorker.java:59)
at java.lang.Thread.run(Unknown Source)
private void listenToCOTMessages() {
// the listener has not started yet.
if (cotMessageWorker == null) {
cotMessageWorker = new SafeUDPWorker() {
public void insertIntoDB(Iterator<NameValuePair> nvPairs) {
try {
int numParameters = 0;
if (isDebugMode()) {
System.err.println("Entered insertIntoDB");
while (nvPairs.hasNext()) {
NameValuePair pair = nvPairs.next();
// Aircraft callsign
if (pair.getName().equalsIgnoreCase("callsign")) {
cotStatement.setString(1, pair.getValue());
// debug code
System.err.println("{1} " + pair.getValue());
cotStatement.setString(2, pair.getValue());
// debug code
System.err.println("{2} " + pair.getValue());
numParameters++;
if (numParameters > 7)
break;
// Aircraft altitude (meters)
else if (pair.getName().equalsIgnoreCase("hae")) {
int height = Integer.parseInt(pair.getValue());
height = (int)((height * 39.37) / 12);
cotStatement.setInt(3, height);
// debug code
System.err.println("{3} " + height);
numParameters++;
if (numParameters > 7)
break;
// aircraft latitude N/S (+/-)
else if (pair.getName().equalsIgnoreCase("lat")) {
String rawLatitude = pair.getValue();
// we have a south latitude
if (rawLatitude.charAt(0) == '-') {
// we need to append an " S"
} else {
rawLatitude = rawLatitude.substring(1) + " S";
cotStatement.setString (4, rawLatitude);
System.err.println("{4} " + rawLatitude);
numParameters++;
if (numParameters > 7)
break;
// aircraft longitude E/W (+/-)
else if (pair.getName ().equalsIgnoreCase("lon")) {
String rawLongitude = pair.getValue();
// we have a west longitude
if (rawLongitude.charAt (0) == '-') {
rawLongitude = rawLongitude.substring(1) + " W";
cotStatement.setString(5, rawLongitude);
// debug code
System.err.println("{5}" + rawLongitude);
numParameters++;
if (numParameters > 7)
break;
// aircraft course
else if (pair.getName().equalsIgnoreCase("course")) {
cotStatement.setString(6, pair.getValue());
// debug code
System.err.println("{6} " + pair.getValue());
numParameters++;
if (numParameters > 7)
break;
// we have a speed number
else if (pair.getName ().equalsIgnoreCase("speed")) {
cotStatement.setInt(7, Integer.parseInt(pair.getValue()));
System.err.println("{7} " + pair.getValue ());
numParameters++;
if (numParameters > 7)
break;
else {
continue;
// execute the callable statement
cotStatement.execute();
} catch (SQLException ex) {
ex.printStackTrace();
// statusPanel.getStatusTextArea().append( ex.getMessage());
// set the debugging mode
cotMessageWorker.setDebugMode(debugMode);
// set the output area for the worker
cotMessageWorker.setMessageArea(cotTextArea);
String portField = cotPortTextField.getText();
// get the port setting from the portTextField
if (portField.length() != 0) {
try {
cotMessageWorker.setPort(Integer.parseInt(portField));
} catch (NumberFormatException nfe) {
cotPortTextField.setBackground(Color.RED);
cotMessageWorker.setStatusArea(statusPanel.getStatusTextArea());
// set the java.sql.Statement object to do the data insertion
if (cotStatement != null)
cotMessageWorker.setSqlStatement(cotStatement);
cotMessageWorker.start();
} else { // the listener has started
// there are no errors generated for making multiple resume requests
cotMessageWorker.resumeRequest();
}Ideas? Not really, there's nothing wrong-looking about your code, but maybe I could ask some dumb questions.
Has this code never worked, or does it usually work but occasionally this error occurs? Have you just switched to SQL Server 2005 from 2000 and the error started happening?
Does the table you are inserting to only have those 7 columns, or are there others that are getting default values? Does it contain auto-generated identity columns? Are you sure you're using the right table in the right database? -
Consideration of dbtimezone value for date conversion? right or wrong
Hi,
I am working on Day Light Saving issue in my application that uses the US based oracle 10g db and now having dbtimezone value as PDT, as part of DST changes we have written below function.
Pacific Standard Time (PST) = GMT-8
Pacific Daylight Time (PDT) = GMT-7
CREATE OR REPLACE FUNCTION GET_GMT_DATE (v_date DATE)
RETURN DATE AS
ndate DATE := v_date;
TIMEZONE VARCHAR(7) := NULL;
BEGIN
select TRIM(dbtimezone) INTO TIMEZONE from dual;
IF TIMEZONE = '-07:00' THEN
ndate := NEW_TIME(ndate, 'PDT', 'GMT');
ELSE
ndate := NEW_TIME(ndate, 'PST', 'GMT');
END IF;
RETURN ndate;
END get_GMT_date;
The funda behind the logic is Application uses the sysdate to enter the date record in XYZ oracle 10g db As per the requirement we have to convert the same date to GMT and show the same in our application.
Now to convert the date into GMT we have used the above function which is based on dbtimezone value of XYZ oracle 10g database. It also has a oracle DST patch applied.
Our assumption is to check the current time zone, if this is -7 than use the PDT in new_time function to GMT otherwise use pst for conversion.
We have tested the same in dev environment and it’s working fine for today but after November(DST over) it will work or not that’s a issue. Request any body to please confirm the logic of function.
Thanks in advance.
Edited by: 802313 on Oct 15, 2010 7:05 AMAlso Please let me know that Daylight saving Patch from oracle changes the dbtimezone value of oracle 10g db or not after DST and Before DST.
-
SQL scripts for Data Warehouse support team
Hi, I would like to have the SQL scripts that must be there with a person supporting a data warehousing system... like on locks, sessions, how much progress a transaction/SQL has made, resources being consumed.
There are various scripts available on the net. For example http://www.oracle-base.com/dba/DBACategories.php
Maybe you are looking for
-
My game center has been craked and take my game what should i do ?
pliz help me i play the game for 1 year
-
Hi Can some one explain me what is meant by cluster and transparent table Points will be rewarded. Regards Raghu Ram.
-
Hello Does anyone know of a library for Java that allows encoding and decoding videos frame by frame? Preferably also stepping to a given frame when decoding, and have support for as many different formats as possible. :)
-
ORA-00600 内部错误代码,参数:[kpncxcc-3]
OS WONDOWS2008 64位 数据库版本 11.1.0.7.0 - 64bit 数据库警告日志 Mon Nov 26 11:03:45 2012 ORA-00020: No more process state objects available ORA-20 errors will not be written to the alert log for the next minute. Please look at trace files to see all the ORA-20 e
-
ORA-06512: at "OWF_MGR.WF_LOAD
1602: Could not save. 1400: Could not save to database. MODE=UPLOAD EFFDATE=2009/07/29 13:26:26 1401: Could not upload ACTIVITY entity 'WFPING/RCVEVNT'. 210: Oracle Error: ORA-01422: exact fetch returns more than requested number of rows ORA-06512: a