Switch to: V12V11V10V9V8V7V6V5

Valentina Class: Cursor Methods



    VCursor as inSourceCursor,
    VDatabase as inTargetDatabase,
    String as inNewTableName,
    EVStorage as inNewTableStorage = kDefault,
    bool as inCopyRecords = true ) 
as VTable


  • inSourceCursor The source cursor.
  • inTargetDatabase The database into which we want to copy the given cursor.
  • inNewTableName The name for a new table, into which cursor records will be copied.
  • inNewTableStorage The storage type for a new table. On default the same as a TargetDatabase storage.
  • inCopyRecords Specifies if records of the cursor should be copied into new table.


This is a very powerful and flexible function that allows you to copy a cursor from some database into a new table of the same or even another database. You can copy from one remote server db to another server db, or from a remote server db into a local db.

This function first of all creates in the TargetDatabase a new table with the name inNewTableName. inNewTableStorage allows you to specify if the table should be DISK or RAM based. On the default storage it is the same as inTargetDatabase.

Then new fields are created in the table, which correspond by names and types to the fields of the cursor.

Then if inCopyRecords is TRUE, records from cursor are copied into this new table.

NOTE: This method uses the same code-base to create fields of a new table as SQL command 'CREATE TABLE … AS SELECT …'. The advantage of this method is that it allows to copy cursor into a table of another database. In future, most probably, we will improve SQL command also in this regard.


' Let db1 is a remote database under some Valentina Server.
VCursor curs = db1.SqlSelect( 
    "SELECT * FROM tblPerson WHERE fldAge = 25 and fldIsMarried = false", 
    kClientSide, kReadOnly )
' Create RAM based TMP database on client side:
VDatabase pLocalRamDB = new VDatabase( kRAM )
pLocalRamDb.Create( "DummyNameForRamDB" )
VTable pTblNotMarried25 = Valentina.CopyCursorToNewTable( curs, pLocalRamDB, "tblNotMarried25" )
' We can destroy cursor now, if it will not be used anymore.
curs = nil

NOTE in this example we create a new LOCAL RAM database. This job can do VKERNEL.dll but not VCLIET.dll, so you should init Valentina engine before that by Valentina.Init() function.