How to insert or update in the data type date
Hai AllI have two table T1 and T2 from T1 to T2 I have to move data
T1 structure code var, varchar of time that I said and T2 intimate outtime, intrinsically, all the introut are the date data type, so I need to pass the data to date the type varchar data
How to insert or update varchar to date
Concerning
Srikkanth.M
Hello
SQL> create table tabDate
2 (dt date);
Table created.
SQL> declare
2 v_date varchar2(10):='10-03-2010';
3 v_time varchar2(10):='0815';
4 Begin
5 insert into tabDate values(to_date(v_date||v_time,'dd-mon-yyyy hh24mi'));
6 end;
7 /
declare
*
ERROR at line 1:
ORA-01843: not a valid month
ORA-06512: at line 5
SQL> declare
2 v_date varchar2(10):='10-03-2010';
3 v_time varchar2(10):='0815';
4 Begin
5 insert into tabDate values(to_date(v_date||v_time,'dd-mm-yyyy hh24mi'));
6 end;
7 /
PL/SQL procedure successfully completed.
SQL> select to_char(dt,'dd-mm-yyyy hh24mi') from tabDate;
TO_CHAR(DT,'DD-
---------------
10-03-2010 0815
Twinkle
Tags: Database
Similar Questions
-
Mr President
Jdev worm is 12.2.1
How to modify and update a line later was inserted and updated in the doDML() method?
I added two rows in my table a method of action-listener in bean managed and secondly with operation doDML() as below.
Method 1-first row in managed bean
public void addNewPurchaseVoucher(ActionEvent actionEvent) { // Add event code here... BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry(); DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("VoucherView1Iterator"); RowSetIterator rsi = dciter.getRowSetIterator(); Row lastRow = rsi.last(); int lastRowIndex = rsi.getRangeIndexOf(lastRow); Row newRow = rsi.createRow(); newRow.setNewRowState(Row.STATUS_NEW); rsi.insertRowAtRangeIndex(lastRowIndex +1, newRow); rsi.setCurrentRow(newRow); BindingContainer bindings1 = BindingContext.getCurrent().getCurrentBindingsEntry(); DCIteratorBinding dciter1 = (DCIteratorBinding) bindings1.get("VdetView1Iterator"); RowSetIterator rsi1 = dciter1.getRowSetIterator(); Row lastRow1 = rsi1.last(); int lastRowIndex1 = rsi1.getRangeIndexOf(lastRow1); Row newRow1 = rsi1.createRow(); newRow1.setNewRowState(Row.STATUS_NEW); rsi1.insertRowAtRangeIndex(lastRowIndex1 +1, newRow1); rsi1.setCurrentRow(newRow1); }
Method of doDML() of line 2 seconds in the entityImpl class
protected void doDML(int operation, TransactionEvent e) { setAmount(getPurqty().multiply(getUnitpurprice())); if (operation == DML_INSERT) { insertSecondRowInDatabase(getVid(),getLineitem(),getDebitst(), (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100)); } if(operation == DML_UPDATE) { updateSecondRowInDatabase(getVid(),getLineitem(),getDebitst(), (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100)); } super.doDML(operation, e); } private void insertSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4) { PreparedStatement stat = null; try { String sql = "Insert into vdet (VID,LINEITEM,DEBITST,AMOUNT) values ('" + value1 + "','" + value2 + "','" + value3 + "','" + value4 + "')"; System.out.println("sql= " + sql); stat = getDBTransaction().createPreparedStatement(sql, 1); stat.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { try { stat.close(); } catch (Exception e) { e.printStackTrace(); } } } private void updateSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4) { PreparedStatement stat = null; try { String sql = "update vdet set vid='"+ value1+"',lineitem='"+ value2+"',DEBITST='" + value3 + "', AMOUNT='" + value4 + "' where VID='" + VID + "'"; System.out.println("sql= " + sql); stat = getDBTransaction().createPreparedStatement(sql, 1); stat.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { try { stat.close(); } catch (Exception e) { e.printStackTrace(); } } }
Now the problem is that when later I change the quantity and price of the first line isn't updated but second row, because I used the command
<af:button actionListener="#{bindings.Commit.execute}" text="Commit"
This button update the first line added by bean managed, but the second row remains unchanged.
Please help how to update the two lines with the same button or something else.
Concerning
DML_UPDATE will call only if there is some change data attributes.
I guess that the update statement is false because vid looks like a primary key for the table, then, how update you the primary key of the update statement and how the update condition statement where the vid = '0'
I assume the update statement should look like:
private void updateSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4) { PreparedStatement stat = null; try { String sql = "update vdet set lineitem='" + value2 + "',DEBITST='" + value3 + "', AMOUNT='" + value4 + "' where VID='" + value1 + "'"; System.out.println("sql= " + sql); stat = getDBTransaction().createPreparedStatement(sql, 1); stat.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { try { stat.close(); } catch (Exception e) { e.printStackTrace(); } } }
-
Create id, id of the update with the date for each record
Hello
Please give me brief idea or document for this concept:
I need to create id, date, update id, updated for each record inserted or updated in the database (multiple tables).
(1) how the user id can be obtained?
(2) is it better if I use views instead of tables for this?
(3) is it possible for each record?
Please show me the full scenario. a piece of code can also be useful.
Thanks in advance.http://psoug.org/reference/table_trigger.html
Concerning
Biju -
How to write a query for the data exchange between two columns?
How to write a query for the data exchange between two columns?
I tried a request, does NOT work.
Thank you.update tmp t1 set t1.m1=t1.m2 and t1.m2=(select t2.m1 from tmp t2 where t2.student_id = t1.student_id)
Published by: user533361 on October 23, 2009 14:04Just plain and simple:
update tmp t1 set t1.m1=t1.m2, t1.m2=t1.m1 /
SY.
-
Creating a trigger to insert delete update with the sequence number
Hey all,.
I have two tables. tbl_main, tbl_temp. Whenever a record is inserted, deleted, updated in tbl_main, I need to insert the records in tbl_temp. All field/column names are exactly the same, except that in tbl_temp, I now have a single column by using a sequence number, a column to determine if the record has been updated, remove, modified(hence the codes) and the date when a record has been added to the table.
So far, that's what I have:
create or replace
audit_trg relaxation
after update or insert or delete ON tbl_main
for each line
Start
If the update can
insert into tbl_temp (seq_id, idx, ctl, action_taken, date_added)
VALUES
(temp_seq.nextval, idx, mke, ctl, sysdate, 'U');
ELSif INSERTION then
insert into tbl_temp (seq_id, idx, ctl, action_taken, date_added)
VALUES (temp_seq.nextval, idx, mke, ctl, 'n', sysdate);
ELSIF deletion then
insert into tbl_temp (seq_id, idx, ctl, action_taken, date_added)
VALUES (temp_seq.nextval, idx, mke, ctl, would be ', sysdate);
END IF;
END audit_trg;
I tried several combinations, but I get many compilation errors. This code looks good or I am the way of track? Thanks in advance.Who looks fine for me. What are the mistakes are you?
Assuming that MKE and CTL are columns in the base table, your INSERT statements will insert either the: new.mke and: new.ctl values or the: old.mke and: old.ctl values in the table. Presumably, you could insert the: new values for inserts and updates, and the: old values for deletions.
Justin
Published by: Justin Cave 27 February 2009 16:08
DOH! Just noticed the error...
-
How can I remove updates in the App Store I want?
How can I remove updates in the App Store I want? that is no longer use app, but I'm getting updates listed.
Delete all copies of the application from the main HARD drive and all external drives or mounted partitions which can have the app.
By the end of 2012 mini Mac, OS X El Capitan 10.11.4. Apple Watch, 38 mm silver AL, Watch OS 2.2; iPad 2 Air & iPhone 6 + iOS 9.3
-
How to configure Outlook to display the date, they come in too?
Original title:
Dating of incoming emails
My incoming emails list the time they came. How to configure Outlook to display the date, they come in too?
Hello
Thanks for posting that ask about the Microsoft Community.
I understand that emails do not show the date on which they were received.
Are you referring to Outlook.com or Microsoft Office Outlook?
As Zigzag3143 mentioned previously, you should be able to see the dates of your emails received after 24 hours of arrival. If this function does not work for you, I suggest you check the following settings:
- View - this is located in the upper left corner of the Inbox pane, the parameters must be defined on all the.
- Reorganize by -this is found in the upper right of the Inbox pane, make sure that your emails are filed by Date.
This should fix your emails in the order of their arrival and should provide the date next to the subject line, if the enamel is older than 24 hours.
I hope this helps. Answer please if you need more help or have any other question about Windows and/or Outlook.com, we are here for you help.
-
Need help on the essential "UPDATE" of the data in the table...
Published by: W Nicloei on May 27, 2011 01:10Dear experts, Need Advice... I have one table in which i have 200,000 records, now in this table for each record i have to update quantity figures... To perform such bulk update i am using the following method... *1. At first i create TYPE* CREATE OR REPLACE TYPE T_OBJ_GET_QTY (--); *2. Create TYPE as table of object created in step 1* CREATE OR REPLACE TYPE T_GET_TEST_QTY AS TABLE OF T_OBJ_GET_QTY; *3. assign object type to the variable* p_get_test_qty T_GET_TEST_QTY; (Created in step 2). *4. now i write the cursor using type created in step 1...* cursor c_upd_qty as select T_OBJ_GET_QTY( col1, col2) from v_view; *5. open cursor and fetch into variable created in step 3...* open c_upd_qty; loop fetch bulk collect into p_get_test_qty limit 1000; --perfom update now.. forall rec_upd_qty in 1..p_get_test_qty.count update table t1 set c1 = treat(p_get_test_qty(rec_upd_qty) as T_OBJ_GET_QTY).c1 exit when notfound; end loop; close c1; Kindly let me if this correct way to perform bulk update of the data, or is there any better way to do so... Please share your inputs... I hope i am clear in asking my question Regards nic
Published by: W Nicloei on May 27, 2011 01:36
Published by: W Nicloei on May 27, 2011 01:45Ahh, ok.
And a row of the view corresponds to a line in the table that you want to update?
I guess that your update statement would have a WHERE clause identifies the row to be updated, right?If so, why not "merge" the view in the table, using the MERGE Oracle statement?
Something like:
MERGE INTO target_table tgt USING source_view vw ON ( vw.key-column(s) = tgt.key-column(s) ) WHEN MATCHED THEN UPDATE SET tgt.c1 = vw.c1 /
I still don't see why you would need a pl/sql program that retrieves all rows from the database in memory program and then writes all back in the database.
-
Can anyone tell how to insert a string between the two another string...?
Can anyone tell how to insert a string between the two another string...?
For example: String1 = 'ABC '.
String2 = "XY".
I want that the chain of output like "AXYBC".If you have the Position where you want to place your chain, this might work:
SQL> r 1 declare 2 vStr1 varchar2(20) := '123456789'; 3 vStr2 varchar2(20) := 'aa'; 4 nInsertPos number := 3; 5 vResult varchar2(20); 6 begin 7 vResult := substr(vStr1, 0, nInsertPos) || vStr2 || substr(vStr1, nInsertPos+1); 8 dbms_output.put_line(vResult); 9* end; 123aa456789
If you want to insert it after a special character, you can search for the position of your character with the help of instr
concerning
-
How to convert varchar to date datatype all insert or update in the table
Hai All
I need to convert to varchar type to date.
I have two Tables T1, T2
Structure of T1
Code varchar
Time varchar
Date varchar
Structure of T2
Var EmpName
Empcode var
Date of the respondent
Outtime date
Intrinsically date
Date of Introut
Att_date
Now I need to spend the time form T1 to T2 respondent, outtime, intrinsically, introut under certain conditions
So now I need to convert Varchar to Date so that the insert or update
I tried something
Insert into T1 (code, respondent, att_date) values
(To_date(Date|| dele de code temps, «hh24mi de mon-dd-yyyy»), att_date);
OR update while
Setting a day set Outtime T2 = To_date(Date||) Time, 'hh24mi mon-dd-yyyy') where...
I got an error Ora-01861
Concerning
Srikkanth.MYou did not show an example of your date or time values, control may be necessary to add a space between them, like
To_date(Date || ' ' || time,'dd-mon-yyyy hh24mi')
-
I feel as if I'm fighting my way around a paper bag trying to insert a record. I have recently converted from MySQL for PDP, which cannot be applied. I'm not trying to write routines to update data and started with insert. I tried the example in your PHP Solutions edition two, pp. 361-363, but I can't get a written account.
It is a database, which I supported since the host server using phpMyAdmin. I'm very well display the data on the site, so I guess that my login script is ok. However, nothing I've tried has got a registered insert. I tried to get back to the basics, and it still does not work. This is my current code. Something is wrong with my statement = $sql and I can't identify the problem. Help, please!
If (isset($_POST['insert'])) {}
try {}
create the SQL
$sql = "INSERT INTO Homepage_text (enriched, h_date, h_seq, h_col, p_heading, p_text, h_hide) VALUES ($_POST ['enriched'], $_POST ['h_date'], $_POST ['h_seq'], $_POST ['h_col'], $_POST ['p_heading'], $_POST ['p_text'], $_POST ['h_hide']);"
$sainttim-> execute ($sql);
echo "new record successfully created ';
}
catch (PDOException ($e) exception
{
echo $sql. "< br / > '. $e-> getMessage();
}
}
There are several things wrong with your code:
- You use elements of an associative array within a double quoted string. Which will cause a parse error.
- The values you are trying to insert in the database are for most (if not all) of the text fields. If you use a literal SQL query, text fields must be wrapped in quotes.
- You try to use the method execute() with a literal SQL query. In AOP, execute() only works with a prepared statement. To run a literal SQL query, you must use the exec() method.
- Passing the values in the array $_POST directly in the database without any sort of validation and without escaping quotes or other characters just asking for trouble.
Follow the examples in the book, and use a prepared statement. To address all these issues quickly and easily.
-
How to force you to update to the date entry before you validate a text field?
I have this code:
Custom blur for txtWeekEndingDate script
(function () {}
var weekEnding = new Date (event.value);
day of week var = new Array (7);
day of week [0] = 'Sunday ';
day of week [1] = "Monday";
day of week [2] = "Tuesday";
day of week [3] = "Wednesday";
day of week [4] = "Thursday";
day of week [5] = "Friday";
day of week [6] = "Saturday";
var dayOfWeek = weekday [weekEnding.getDay ()];
var strWeekEnding = weekEnding.toLocaleDateString ();
Do nothing if the field is empty
If (! event.target.value) return;
If the value is not a valid email address...
If (dayOfWeek! = 'Sunday') {}
.. .that the user knows that the value is not a valid end date of week...
App.Alert ({CMSG: "you entered, '" + strWeekEnding + "". ""}) Please enter a date on Sunday. ', nIcon:3, nType:0, cTitle:this.documentFileName});
.. .and set the focus on this field
event.target.setFocus ();
} / / endif dayOfWeek! = "Sunday".
})();
The problem is that if the user enters something like "1/1" in the input box (which has a date format defined in the properties of the text box in the "mm/dd/yyyy') it sets the variable weekEnding to"undefined ". Without the validation script, it properly changes the date "01/01/2013", but it seems that this change occurs after the execution of script OnBlur. How can I force the update occur before the script is run?
When an entry of "1/1" gets converted to "01/01/2013", it is only for what is displayed in the field. " The value of the underlying field remains on "1/1". The point is the value of the field does not change, just what is displayed in the field. This means that there is no direct method to get the text that is displayed.
You can add a custom script to Validate that changes a value entry of "1/1" to "01/01/2013".» Then, you would get just the value of the field to recover. If you want more help with this approach, after once again.
-
I WANT THE RESULT OF MY FORM PAGE TO INSERT A FORM OF UPDATE OF THE DATA INSERTED JUST
I WANT THE RESULT OF MY FORM PAGE TO INSERT A FORM OF UPDATE OF THE MEASURE WITH THE HELP OF JUST INSERTED DATA. PLS HELP FOR EXAMPLE. Thank you
It doesn´t works because the to-be-set record´s to update primary key cannot be determined by using a static value:
$upd_capital-> setPrimaryKey ("cap_id", "NUMERIC_TYPE", "VALUE", "new_id"); current code in page 2
Basic now needs to ensure that the primary key matches the Session Variable "new_id' thus:
See you soon,.
Günter
-
Restrict the update of the data in the report as a table...
Hello
I have a tabular report in Oracle APEX 4.0 based on a db table in which some columns (Textarea element and text element) after inserted must be restricted (view only). Could someone help me how this can be achieved. While trying to create a tabular report if I give as view only; the user is unable to grasp the data itself. All entries will be very appreciated.
Thank you
AhmedI suggest that you do with APEX_ITEMS: http://docs.oracle.com/cd/E14373_01/apirefs.32/e13369/apex_item.htm
You will have to work with collections to pull this off. Load all your data into a collection of apex: http://docs.oracle.com/cd/E17556_01/doc/apirefs.40/e15519/apex_collection.htm
Now, you can create a simple select statement
select decode(c001, null, apex_item.text(1, c002), c002) from apex_collections where collection_name = your_collection;
C001 corresponding to the primary key that is inside your table and c002 the value you want to insert.
You must update c001 with the primary key from the moment that the row will be exist. Then just decode function will display it so it is no longer editable.
Add lines to the collection will add new lines to your tabular form. Clear lines of the collection deletes the lines in the tabular presentation.
If you are a beginner with this I suggest that you submit to the page whenever you click an insert/update/delete button.
Concerning
Nico
-
Update of the data in the table using LAG/LEAD
Hello!
I have a table that looks like:
CREATE TABLE CUSTOMER_INFO_TEST
(
ACCOUNT_NUM VARCHAR2 (40 BYTE),
PHONE VARCHAR2 (100 BYTE),
E-MAIL VARCHAR2 (300 BYTE),
DATE OF START_DT,
DATE OF CHANGE_DT,
END_DT DATE
);
The example data:
INSERT INTO CUSTOMER_INFO_TEST VALUES ('BOB', 555-1234', ", TO_DATE ('2011-01-01', 'YYYY-MM-DD'), TO_DATE ('2011-01-06', 'YYYY-MM-DD'), TO_DATE ('2011-01-10', 'YYYY-MM-DD'));
INSERT INTO CUSTOMER_INFO_TEST VALUES ('BOB', 555-1234', ' BOB@GMAIL.) COM', TO_DATE ('2011-01-01', 'YYYY-MM-DD'), TO_DATE ('2011-01-11', 'YYYY-MM-DD'), NULL);
INSERT INTO CUSTOMER_INFO_TEST VALUES ('BOB', 555-1234', ' BOB@GMAIL.) COM', TO_DATE ('2011-01-01', 'YYYY-MM-DD'), TO_DATE ('2011-01-15', 'YYYY-MM-DD'), NULL);
INSERT INTO CUSTOMER_INFO_TEST VALUES ('JACK', 555-4321', ", TO_DATE ('01-03-2011', 'YYYY-MM-DD'), TO_DATE ('2011-03-06', 'DD-MM-YYYY'), NULL);
INSERT INTO CUSTOMER_INFO_TEST VALUES ('JACK', 555-4321', ' JACK@GMAIL.) COM', TO_DATE ('01-03-2011', 'YYYY-MM-DD'), TO_DATE ('2011-03-11', 'YYYY-MM-DD'), NULL);
My question:
How can I configure end_dt (if null), to the next change_dt minus one
It shows what I want to do:
Select the rowid, account_num, phone, e-mail, start_dt, change_dt, end_dt, nvl (end_dt, lead (change_dt-1, 1) over (partition by account_num of start_dt order)) enddt CUSTOMER_INFO_TEST where end_dt is null;
So, I want to update the table itself with the date in enddt. But how do I do this?
This must be done in a single statement...
Thanks in advance
Richard
Published by: user6702107 on 05-Jan-2011 09:11
Edited by: Rydman on April 17, 2012 15:01Please post sample data!
If your query returns the desired results, you can use the MERGE:SQL> select * 2 from customer_info_test; ACCOUNT_NU PHONE EMAIL START_DT CHANGE_D END_DT ---------- ---------- ------------------------- -------- -------- -------- BOB 555-1234 01-01-11 06-01-11 10-01-11 BOB 555-1234 [email protected] 01-01-11 11-01-11 BOB 555-1234 [email protected] 01-01-11 15-01-11 JACK 555-4321 01-03-11 06-03-11 JACK 555-4321 [email protected] 01-03-11 11-03-11 5 rows selected. SQL> -- SQL> merge into customer_info_test a 2 using ( select rowid rid 3 , nvl(end_dt, lead(change_dt-1, 1) over (partition by account_num order by start_dt)) new_end_dt 4 from customer_info_test 5 where end_dt is null 6 ) b 7 on (a.rowid = b.rid ) 8 when matched then update set a.end_dt = b.new_end_dt; 4 rows merged. SQL> -- SQL> select * 2 from customer_info_test; ACCOUNT_NU PHONE EMAIL START_DT CHANGE_D END_DT ---------- ---------- ------------------------- -------- -------- -------- BOB 555-1234 01-01-11 06-01-11 10-01-11 BOB 555-1234 [email protected] 01-01-11 11-01-11 14-01-11 BOB 555-1234 [email protected] 01-01-11 15-01-11 JACK 555-4321 01-03-11 06-03-11 10-03-11 JACK 555-4321 [email protected] 01-03-11 11-03-11 5 rows selected.
Maybe you are looking for
-
I can't update my firefox it tells me to remind my password and name, I got this laptop from a friend and I donot know what he used. Also it won't let me download from the web thanks mindee
-
can I restore or reset my iPhone 4 without upgrading to the most recent iOS?
I need eliminate some storage, have backed up using iTunes. Given that my device is an iPhone 4 and cannot move to end iOS, will be I stopped to restore my apps once I reset to purge the storage? Or is there a better way to serve the storage? Thank y
-
Hello I managed to run my custom device. Now I have the problem, that my framing, showed in the channel data viewer, do not correspond to my defined channels. For example, the 'seconds' are displayed in "id" and "hours" shown in "Bit8' (CAN-Message).
-
The VPN user cannot browse the internet
I recently found myself working with ASA 5505 and implementation so that remote users can connect through the VPN. In this part, I managed to cope. Users can connect and authenticate you. Once this link has been established that they can no longer br
-
Virus of blackBerry Smartphones? on my Pearl 8100
Hi please can someone help me with my Blackberry Pearl 8100? I have what appears to be a virus on my facebook app. I get an image which at the beginning was this Asian guy but here is a picture of two chairs with the title "the pressure of atlantic