Date objects. It converts null values to JavaScript null.
NOTE: Because JavaScript does not support fixed or packed decimal notation, some precision may be lost when reading and writing packed decimal data types. Be sure to check results before inserting values back into a database, and use appropriate mathematical functions to correct for any loss of precision.
Date objects. To insert a date value in a database, use a JavaScript Date object, as follows:
cursorName.dateColumn = dateObjHere,
cursorName is a cursor, dateColumn is a column corresponding to a date, and dateObj is a JavaScript Date object. You create a Date object using the new operator and the Date constructor, as follows:
dateObj = new Date(dateString)where
dateString is a string representing a date. If dateString is the empty string, it creates a Date object for the current date. For example:
custs.orderDate = new Date("Jan 27, 1997")NOTE: DB2 databases havetimeandtimestampdata types. These data types both convert to theDatetype in JavaScript.
WARNING: The LiveWire Database Service cannot handle dates after February 5, 2037.For more information on working with dates in JavaScript, see the JavaScript Guide.
Data-Type Conversion by Database
Table 11.1 shows the conversions made by the JavaScript runtime engine for DB2 databases.
Table 11.1 DB2 data-type conversions
| DB2 Data Type | JavaScript Data Type |
|---|---|
char(n), varchar(n), long varchar, clob(n) |
string
|
integer, smallint |
integer
|
decimal, double |
double
|
date, time, timestamp |
Date
|
blob |
Blob
|
Table 11.2 shows the conversions made by the JavaScript runtime engine for Informix databases.
Table 11.2 Informix data-type conversions
ODBC translates a vendor's data types to ODBC data types. For example, the Microsoft SQL Server varchar data type is converted to the ODBC SQL_VARCHAR data type. For more information, see the ODBC SDK documentation. Table 11.3 shows the conversions made by the JavaScript runtime engine for ODBC databases.
Table 11.3 ODBC data-type conversions
Table 11.4 shows the conversions made by the JavaScript runtime engine for Oracle databases.
Table 11.4 Oracle data-type conversions
| Oracle Data Type | JavaScript Data Type |
|---|---|
long, char(n), varchar2(n), rowid |
string
|
number(p,s), number(p,0), float(p) |
number
|
date |
Date
|
raw(n), long raw |
Blob
|
Table 11.5 shows the conversions made by the JavaScript runtime engine for Sybase databases.
Table 11.5 Sybase data-type conversions
| 1 The Sybase client restricts numeric data types to 33 digits. If you insert a JavaScript number with more digits into a Sybase database, you'll get an error. |
Last Updated: 10/30/97 12:19:41