Oracle Database Date Type Field Read and Write Experience

xiaoxiao2021-03-06  113

In the Oracle Database (Simplified Chinese), the DATE type data field will be more troublesome, and some of the experiences in the study are followed below:

1. In the OEM of the Simplified Chinese version, view this type of data from the "slave table data editor" to the following format:

26- August-2004 03:37:36 PM, but when you insert the date, if you enter: 26- August-2004, please prompt when applying: Invalid month, if you enter: 26- August - 2004, you can succeed - very strange. (The back time can be omitted, by default, add: 12: 00: 00 am), if you want to add time, the format is 26-8 months - 2004 03:23:34 afternoon, use Chinese "afternoon" Otherwise it will fail.

2, in the ASP.NET application, if you want to get the date of the user input, you must convert the date you entered to the above format, such as: Insert Into Sample Values ​​(3422, 'ssxxdd', 23-April -2003 ' ) Can we be successfully inserted. If you use a function now to get the current time, then use the Insert statement: "INSERT INTO MyTable (InDate) VALUES (" & NOW & ") prompts the missing number? ? (I don't know why?); If the NOW plus quotes, the prompt format is incorrect. I have to obtain the current time with the program and merge into the correct format, such as:

DIM RZ AS STRING = now.day.tostring "-" Now.month.toTRING "Month" & now.Year.toString

DIM SQLSTR AS STRING = "INSERT INTO SAMPLE VALUES (3233, 'XxDDSS', '" & RZ & ")"

But if you don't do it, you can't do it. I have tried a lot of ways. I don't know what format: (

If you use the process, there is not so much trouble! For example, the following process has been created:

CREATE OR REPLACE PROCEDURE "GF". "SAMPLE_ADD" (in_no in sample.no% type, in_message in sample.message% type, in_date in date) asbegininsert into gf.sample (no, message, indate) values ​​(in_no, in_message, IN_DATE); END;

Then just assign the in_date parameter directly to the in_date parameter directly:

Dim cmd As New OracleCommand ( "sample_add", cn) cmd.CommandType = CommandType.StoredProcedure cmd.Parameters.Add (New OracleParameter ( "in_date", OracleType.DateTime)) cmd.Parameters ( "in_date"). Value = Now

The data sheet can get the complete date.

Oh, oracle is really hard. However, I have to continue to ponder. Recently, a parameter insertion data method is used.

DIM SQLSTR AS STRING = "INSERT INTO SAMPLE VALUES (: NO,: Message,: Indate)" DIM CMD As New OracleCommand (Sqlstr, CN) cmd.Parameters.add (New OracleParameter ("NO", ORACletype.Number, 5) ) Cmd.Parameters ("no"). Value = 3222 cmd.parameters.add (New OracleParameter ("Message", ORACLETERE.VARCHAR, 100)) CMD.Parameters ("Message"). Value = "xxxxxxddddddddddddddddd" cmd.Parameters .Add (New OracleParameter ("INDATE", ORACLETYPE.DATETIME)) CMD.Parameters ("inDate"). Value = now

cmd.executenonquery ()

Note: The difference between SQLServer is: @ no →: NO

转载请注明原文地址:https://www.9cbs.com/read-122927.html

New Post(0)