Update existing date field
select date1, arrtime, deptime,
CASE WHEN arrdep = 'A' then
to_date(to_char(date1, 'dd/mm/yyyy')||to_char(to_date(arrtime, 'hh24:mi'), 'hh24:mi'), 'dd/mm/yyyy hh24:mi')
ELSE to_date(to_char(date1, 'dd/mm/yyyy')||to_char(to_date(deptime, 'hh24:mi'), 'hh24:mi'), 'dd/mm/yyyy hh24:mi')
END as DepArr from table1
output
====
date1 arrtime deptime DepArr
2005/10/25 0 0830 2005/10/25 08:30:00
2005/10/27 2215 0 2005/10/27 22:15:00
when i use the above select statement, the output displays fine, but when i tried to update the date1 field with DepArr, it fails with ORA-01861
update table1 set date1 =
CASE WHEN arrdep = 'A' then
to_date(to_char(dt, 'dd/mm/yyyy')||to_char(to_date(arrtime, 'hh24:mi'), 'hh24:mi'), 'dd/mm/yyyy hh24:mi')
ELSE to_date(to_char(dt, 'dd/mm/yyyy')||to_char(to_date(deptime, 'hh24:mi'), 'hh24:mi'), 'dd/mm/yyyy hh24:mi')
END
the date1 field's datatype is date
thanks.
As far as I can see, your select can be simplified to:
select date1, arrtime, deptime,
to_date(to_char(date1, 'ddmmyyyy')||decode(arrdep, 'A', arrtime, deptime), 'ddmmyyyyhh24mi') as DepArr
from table1Make sure that date1 and arrtime/deptime is not null otherwise to_date will fail
Message was edited by:
Jens Petersen
Similar Messages
-
How do I update a date field through CMP
I wonder how to update a date field through CMP.
For example, I can't update an employee table with following statement.
employee.setHire_date('2002-03-20');
Thanks,Thats correct......
Try using the following code....
String strDate ="2002-03-20";
String date_fmt = "yyyy-MM-dd";
java.text.SimpleDateFormat sdf=new java.text.SimpleDateFormat(date_fmt);
java.util.Date hireDate =null;
hireDate =(Date) sdf.parse(strDate);
employee.setHire_date(hireDate);
Hope this helps
Cheers
--Venky -
Update a date field using execute immediate statement..
I need to update a date field dynamically .
Below is the code I have written for the same..
EXECUTE IMMEDIATE
'UPDATE Temp_Emp ' ||
' SET ' || V_Fieldname || ' = ' || D_Value ||
'WHERE Emp_Id = ' || 8447;
I am getting the following error..
ORA-00904: "AUG": invalid identifier
Pls anyone have any ideas..
Thanks,
Xyzput D_Value in single quotes like this
EXECUTE IMMEDIATE
'UPDATE Temp_Emp ' ||
' SET ' || V_Fieldname || ' = ''' || D_Value ||''' WHERE Emp_Id = ' || 8447; -
Problem updating a date field via UnitOfWork - TopLink 9.0.3
Hello,
we want to change an exisiting application that employs TopLink 9.0.3, Build 423.
The data is stored in an Oracle 9.2.0.6.
The specific table has a composite primary key consisting of four fields.
I can easily create a new Object (foo)
uow.registerNewObject(foo)
uow.commit()
and see the results in the database.
If I obtain an exising Object (bar) and change an integer
bar = (Bar) Session.readObject(Bar.class, expr);
cloneBar = (Bar) uow.registerObject(bar);
cloneBar.setSomething(42);
uow.commit()
everything is fine.
But if I dare to change a Date field
cloneBar.setSomethingElse(cal.getTime());
then
uow.hasChanges()
returns true
but the update does not happen. It is neither logged nor is the data changed in the database.
Is this a known bug?
What have I done wrong?
How can I avoid using hard-coded SQL to update my Bar object?
Bye,
StephanHello,
it is very disturbing, but I finally found the reason for this problem.
After decompiling the Project class file (we have no source code of this third-party library), I saw that the mapping for this specific field is set to "readOnly".
I did not know that TopLink is able to have specific fields "readOnly" and others "readWrite", but it can handle this!
So it seems that the behaviour is not a bug but a feature :-(
We can change the mapping before creating the session, with the result that the field is updatable.
Have a nice day. -
Hi,
I have one table with a date field.
For display all rows in a table component i'm using a dateTimeConverter object with format 'dd/MM/aaaa' and work fine.
Bat when i update a data provider with follow code:
public String update_action() {
// TODO: Process the button click action. Return value is a navigation
// case name where null will return to the same page.
try {
myDataProvider.commitChanges();
myDataProvider.refresh();
} catch(Exception e) {
error("One error: " + e.getMessage());
return null;
return from brawser the follow message:
Number of conflicts while synchronizing: 1 SyncResolver.UPDATE_ROW_CONFLICT row 2 Data Exception -- No Applicable Cast Operator. from SQL type BINARY to SQL type DATE
Anyone help me!
Thanks.If you are getting the date from a calendar you have to convert it before storing it, for example, in the following code, the date got from the calendar is converted to a java.sql.Date
java.sql.Date date1 = new java.sql.Date(calendar1.getSelectedDate().getTime());
I hope this helps =) -
How to add 5 hours to an existing date field in the database
Have a date field 2013-11-21 00:00:00.000 but need to add 5 hours to it to make it 2013-11-21 05:00:00.000.
Please how can I do this?
MijecarrFantastic...
DATEADD (hour , 5 , Cast(ActivationDate as datetime) ) worked!!!
Thank you very much
Mijecarr -
Auto update of date field - SQL Server 2005
HI folks,
Is there a way I can automatially tell when a record was last updated?
I can set a field to get the date by using getdate(), but is there a way SQL server will insert the timestamp, without me having to create the date object in CF, then inserting it.
I'd like to add a 'last updated' function to my CMS.
Thanks in advanceFor UPDATE you are looking at trigger.
http://msdn.microsoft.com/en-us/library/ms189799.aspx -
Update a date field in SQL database
I am using MS SQL 2000..and .Jdbc-odbc bridge
I have a field of type datetime...
I am trying to update that field value...using the following code
rs.updateDate(fieldname,java.sql.Date.valueOf(fval));
rs.updateRow();
where fVal is a string...
It gives me a SQl Exception saying invalid date value..
Can any throw any light on this...helping me to overcome my error...This problem is solved...I am just inserting it as a string and the database takes care of everything...Now I have problems in inserting Integer value and a ntext value..
rs.updateInt(colname,1);
rs.updateRow();
This inserts a very big number like 1427560 etc into the database and second time it puts 0 to it...
For ntext it does not do anything
smita -
HOW TO CREATE A TRIGGER TO UPDATE A DATE FIELD WHEN RECORD IS MODIFIED
Hi,
I have a field (column)
SalesLeadLastModifiedDate
in the table
SalesPipeline
A record's field (SalesLEadLastModifiedDate) should be updated with current date and time every time any column in a record is modified. I'm new to SQL and can't figure out how to write this trigger. Could someone help me and also
refer literature that would give me independence? Online MSDN language without matching examples is not helping.
Tnx.,
IJBreak it down into pieces. Write a small script that updates some small (but more than 1) number of rows. After updating the rows, write another update statement that will set your modified date column to the current date and time. Once
you have that working, you can easily convert that into a trigger. Pseudo-code would be:
begin tran;
select * from dbo.SalesPipeline where SalesPipelineID in (45, 76);
update dbo.SalesPipeline set <some column> = <something> where SalesPipelineID in (45, 76);
update dbo.SalesPipeline set <your date colum> = ?? where SalesPipelineID in (45, 76);
select * from dbo.SalesPipeline where SalesPipelineID in (45, 76);
rollback tran;
Notice the transaction control statements. This will allow you to run the script, evaluate the result, and then revert all changes (leaving your database unchanged). In turn, this will allow you to run the same script over and over and over again
and achieve (for the most part) the same results with each execution. You can search the forums for examples of trigger code - just beware that many "solutions" are not necessarily well-written. -
Updating a date field witha field from another table
Hi friends
I have a table called Customer_Type with following fields
Customer_type ,Active_date, Inactive_date
regular,11/01/2011
daily,11/04/2011
monthly,11/05/2011/11/11/2011
Tbale 2:Customer
Customer_name,Customer_type,Customer_Inactive_date
John,regular,
James,monthly,
Jake,daily,
Jill,monthly
What i wnat is to update the Customer_inactive_date with the Incative_date field from Customer_type
based on their Customer_type... So james and Jill would have their rows updated in this scneario ..How can i achive this in pl/Sql
Thank you in advance...Hi,
You can look at this code; it's not PL/SQL but a simple MERGE statement:
CREATE TABLE CUSTOMER_TYPE
type_code VARCHAR2(10),
active_date DATE,
inactive_date DATE
INSERT INTO customer_type VALUES('REGULAR', TO_DATE('11/01/2011', 'DD/MM/YYYY'), null);
INSERT INTO customer_type VALUES('DAILY', TO_DATE('11/04/2011', 'DD/MM/YYYY'), null);
INSERT INTO customer_type VALUES('MONTHLY', TO_DATE('11/05/2011', 'DD/MM/YYYY'), TO_DATE('11/11/2011', 'DD/MM/YYYY'));
CREATE TABLE CUSTOMERS
customer_name varchar2(10),
customer_type varchar2(10),
customer_inactive_date DATE
INSERT INTO customers VALUES('John', 'REGULAR', null);
INSERT INTO customers VALUES('James', 'MONTHLY', null);
INSERT INTO customers VALUES('Jake', 'DAILY', null);
INSERT INTO customers VALUES('Jill', 'MONTHLY', null);
MERGE INTO customers dst
USING customer_type src
ON (dst.customer_type = src.type_code)
WHEN MATCHED THEN
UPDATE set dst.customer_inactive_date = src.inactive_date;
SELECT * FROM customers;
CUSTOMER_NAME CUSTOMER_TYPE CUSTOMER_INACTIVE_DATE
John REGULAR
James MONTHLY 11-NOV-11
Jake DAILY
Jill MONTHLY 11-NOV-11 If you don't understand it, just let me know... -
How to update existing data of specific UDF at UDT?
Hi Experts,
I have a UDT with one of the UDF, status. I would like to update the udf, status of the document after i converted it to other documents. So tat I can filter out the selection at the query data. How can i do tat?
Thanks and appreciate it.
Regards,
George
Edited by: George Shii on Jun 29, 2009 10:57 AMThanks Yatsea.
Can I have some sample code for updating child table? I try but seems like something is missing in between.
Problem solved. Thanks everone, appreciate it.
'Get GeneralService - Main UDO - Retrieve the relevant service
oGeneralService = oCmpSrv.GetGeneralService("G_OBCA")
'GetByKey
oGeneralParams = oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams)
'Child Order Key
oEditTextcolumn = oGrid.Columns.Item(12)
oGeneralParams.SetProperty("DocEntry", oEditTextcolumn.GetText(Count2))
'Create data for new row in main UDO
oGeneralData = oGeneralService.GetByParams(oGeneralParams)
'Get GeneralService - Child UDO
oChildren = oGeneralData.Child("G_BCA1")
'Child Line Number
oChild = oChildren.Item(oGrid.DataTable.GetValue(13, Count2) - 1)
oChild.SetProperty("U_iStatus", "C")
oGeneralService.Update(oGeneralData)
Edited by: George Shii on Jun 30, 2009 5:43 AM
Edited by: George Shii on Jun 30, 2009 6:18 AM -
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 -
Help with Updating Data Fields in Merged Document
I'm working in InDesign CS5 v7
I have a multipage report, all using one master page for about 80 seperate records. Each page has their own linked graphs/images.
We now have need to alter the source data, and while these alterations can be seen in 'Preview mode' on the Master Page, they are not carrying through into the pages themselves. No amount of 'Update Data Source' clinking changes this, and the 'Update Content Data Fields' remains greyed out...
I really don't want to have to remerge the whole document, as I will loose all of the linked graphs and images.
Can anyone help?You've seen the other thread, so I think you already know the answer...
-
Hi All,
I tried to update a date field to my database by using dataprovider, however, I got the following error "java.lang.RuntimeException: Number of conflicts while synchronizing: 1 SyncResolver.INSERT_ROW_CONFLICT row 1 Can't infer the SQL type to use for an instance of java.util.Date. Use setObject() with an explicit Types value to specify the type to use." Anyone can help me to resolve this problem?Also, following:
http://blogs.sun.com/jfbrown/entry/using_creator_to_insert_into
http://developers.sun.com/prodtech/javatools/jscreator/reference/techart/2/insert_row_in_table.html#4 -
Deleting date field value via import
I need to clear the value in a date field for a few thousand records. I tried doing this via import by setting the value to a space " " but it didn't work.
Any ideas on how this can be achieved through import or otherwise would be great.
Thanks.Hi Nakul,
Try any of the following, it will hopefully work in your case:
1) Import using excel with blank date field (no data in date field). This will erase the already existing value in the date field [provided there is no workflow that restricts such deletion of date data.]
2) Create a temp workflow on condition "before modified record saved" and update the date field value with blank (no values in fx), do the import, this workflow will delete the existing data.
Cheers!
Vix
Maybe you are looking for
-
I currently have 4 sus server in seperate domain that are havign a issues. I keep gettng connection reset on the GUI of WSUS. I noticed that my DB on the remote SQL server range from 20 GB to 40 GB The quesiton I have are this. Is there a max size fo
-
Why does my video keep on buffing
-
Batch export to MP3??
So, I am in the process of recording 1000 short dialogues russian-english using the podcast feature... but I need all these to end up as MP3. Is there some way to batch export/convert all the files (PLEASE!) While it only takes 1-2 minutes to export
-
Has the "quit mail to empty trash" bug been resolved in Lion?
This long-standing bug seems to persist in Lion. I haven't tested the old work-around which was to securely empty the trash. Any ideas on whether this will be resolved?
-
Programmatically show/hide rectangle on a canvas
Hi, is there a way of programmatically showing/hiding a rectangle on a canvas? Thanks, Monica