1. Home
  2. Docs
  3. UniDB 1.2
  4. UniDB class
  5. SQL Functions

SQL Functions

The Value() and the comparison methods of the columns support SQL Functions as parameter. To use a SQL Function, just type a string value with the function inside double brackets:

…%Column%.$Value$( “{{sql_function}}” )

Just be careful to write correctly the SQL Function and use it in the proper way.

Have a look at this W3Schools website page for more information about SQL functions.


Example

A classic example is the use of the GETDATE() function, which returns the current date and time. You can use it in an Insert operation for writing the current date into the Record’s column:

var TestDB = new UniDB.Test();
var myUsers = TestDB.GetTable_Users();

// SQL equivalent:
// INSERT INTO users (username, regdate) VALUES ("pluto", GETDATE())
_ = myUsers
    .Insert()
    .Data(
          myUsers.C.username.Value("pluto"),
          myUsers.C.regdate.Value("{{GETDATE()}}")
    )
    .Run( ... )