Description:
An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30451: Name 'Sysdate' is not declared.
You should use Oracle Parameters and BIND variable to pass values into your INSERT statement
SYSDATE error is likely indirect effect of other failures
example
Imports System.Xml.Linq.XElement
Public Shared Sub updateUnitsActiveFlag(ByVal decQuantity As Decimal)
' Insert Quantity into new row Units table'
Dim OraConnStr As String = ConfigurationManager.ConnectionStrings("{YourOraConnStrName}").ConnectionString
Try
Dim SQL =
<SQL>
INSERT INTO {YOURSCHEMANAME}.UNITS
(UNITS_SEQ, QUANTITY, DATE_CLOSED, DATE_TODAY)
VALUES
(UNIT_SEQ.NextVal, :BindVarQuantity, :DateClosed, SYSDATE)
</SQL>
Using conn As New OracleConnection(OraConnStr)
Using cmd As New OracleCommand(SQL.Value, conn)
cmd.Parameters.Clear()
cmd.Parameters.Add("BindVarQuantity", OracleDbType.Decimal, decQuantity, ParameterDirection.Input)
cmd.Parameters.Add("DateClosed", OracleDbType.Date, dateDateClosed, ParameterDirection.Input)
conn.Open()
cmd.ExecuteNonQuery()
End Using
End Using
Catch ex As Exception
'you exception handling code
Description:
An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30451: Name 'Sysdate' is not declared.
Sysdate is an oracle function that returns the current date and time. It is not a dot net variable that you pass to oracle.
greenheck1
Member
14 Points
8 Posts
Insert Today into an oracle table
Mar 13, 2012 09:58 PM|LINK
This is driving me crazy! I keep on getting an error at the date part of the insert statement
ORA-00932: inconsistent datatypes: expected DATE got NUMBER
The data type in the oracle table is Date(7)
how do I fix this?
Thanks
oConnection = New OracleConnection("Data Source= ;User ID=;Password=;") oConnection.Open() oCommand.Connection = oConnection oCommand.CommandText = "INSERT INTO MAPS.GIS(ENTRYDATE,USERID,JOB_NUMBER,ENTRY_TYPE,CHANGE_DESCRIPTION) VALUES(" & Today & ",'" & "USERID', " & txtJO.Text & ",'" & txtType.Text & "','" & txtDesc.Text & "')" oReader = oCommand.ExecuteReader()ncsubbu
Member
535 Points
150 Posts
Re: Insert Today into an oracle table
Mar 15, 2012 04:58 AM|LINK
In Your query use SYSDATE instead of Today .SYSDATE is used today dateand time in oracle
http://subbarao515.wordpress.com
mamun22s
Member
537 Points
135 Posts
Re: Insert Today into an oracle table
Mar 15, 2012 05:09 AM|LINK
Use SYSDATE instead of Today
"INSERT INTO MAPS.GIS(ENTRYDATE,USERID,JOB_NUMBER,ENTRY_TYPE,CHANGE_DESCRIPTION) VALUES("SYSDATE ",'" & "USERID', " & txtJO.Text & ",'" & txtType.Text & "','" & txtDesc.Text & "')" Regards,Senior Software Engineer
Ennovia Technologies Limited
(Mark it as answer if it does help you!)
greenheck1
Member
14 Points
8 Posts
Re: Insert Today into an oracle table
Mar 16, 2012 05:16 PM|LINK
SYSDATE is not working ... I get an err
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30451: Name 'Sysdate' is not declared.
Lannie
Contributor
3724 Points
726 Posts
Re: Insert Today into an oracle table
Mar 19, 2012 01:31 AM|LINK
You should use Oracle Parameters and BIND variable to pass values into your INSERT statement
SYSDATE error is likely indirect effect of other failures
example
Imports System.Xml.Linq.XElement Public Shared Sub updateUnitsActiveFlag(ByVal decQuantity As Decimal) ' Insert Quantity into new row Units table' Dim OraConnStr As String = ConfigurationManager.ConnectionStrings("{YourOraConnStrName}").ConnectionString Try Dim SQL = <SQL> INSERT INTO {YOURSCHEMANAME}.UNITS (UNITS_SEQ, QUANTITY, DATE_CLOSED, DATE_TODAY) VALUES (UNIT_SEQ.NextVal, :BindVarQuantity, :DateClosed, SYSDATE) </SQL> Using conn As New OracleConnection(OraConnStr) Using cmd As New OracleCommand(SQL.Value, conn) cmd.Parameters.Clear() cmd.Parameters.Add("BindVarQuantity", OracleDbType.Decimal, decQuantity, ParameterDirection.Input) cmd.Parameters.Add("DateClosed", OracleDbType.Date, dateDateClosed, ParameterDirection.Input) conn.Open() cmd.ExecuteNonQuery() End Using End Using Catch ex As Exception 'you exception handling codeDan Bracuk
Contributor
3970 Points
1096 Posts
Re: Insert Today into an oracle table
Mar 19, 2012 01:34 AM|LINK
Sysdate is an oracle function that returns the current date and time. It is not a dot net variable that you pass to oracle.
greenheck1
Member
14 Points
8 Posts
Re: Insert Today into an oracle table
Mar 19, 2012 05:01 PM|LINK
Thank you guys for your posts
I tried the oracle parameters but i got a whole bunch of errs ... so I tried the below instead and it worked!!
String.Format("{0:dd-MMM-yyyy}", System.DateTime.Now) Thanks all