comparing RunRev SQL method with Valentina method

Neal Campbell nealk3nc at gmail.com
Sat Jul 5 10:42:28 CDT 2008


Here is a stack from the V4REV example stack that has Vlnk in. I
always go to the example stack's substack when I want to know how
things work!

--> all handlers

local mDBRef
local mConn
local mTbl1
local mTbl2
local mKey
local mPtr

----------------------------------------------------------
function ShowStatistic_ForTable inTblRef, inHeadStr

 -- put "SetProp_TableName(" & inTblRef & ", " & quote & inHeadStr &
quote & ")" into tblNameCall
  put "SetProp_TableName(" & inTblRef & ", " & inHeadStr & ")" into tblNameCall
  get value(tblNameCall,card 1 of stack "WProperties")
  get value("SetProp_RecCount(" & inTblRef &  ")",card 1 of stack "WProperties")
  get value("SetProp_LinkCount(" & inTblRef &  ")",card 1 of stack
"WProperties")

  put VTable_LinkCount( inTblRef ) into lnkCount
  if lnkCount = 1 then
    put VTable_Link( inTblRef, "1" ) into lnkRef
    get value("SetProp_LinkName(" & lnkRef & "," & inTblRef &
")",card 1 of stack "WProperties")
  end if

end ShowStatistic_ForTable

----------------------------------------------------------
function showStatistic
  go stack "WProperties"
  --get value("ShowError(" & mDBRef & ")",card 1 of stack "WProperties")

  get value("SetProp_TableCount(" & mDBRef & ")",card 1 of stack "WProperties")

  -- we have at least one table. PERSON table.
  get ShowStatistic_ForTable( mTbl1, Table1 )

  -- info of PHONES table
  if mTbl2 contains "ERROR" = false and mTbl2 <> 0 then
    get ShowStatistic_ForTable( mTbl2, TableM )
  end if


  end showStatistic

----------------------------------------------------------
function ShowTables
  go stack "LinkTest"
  get value("ShowStructure(" & mTbl1 & ", Grid1 )",card 1 of stack "LinkTest")
  get value("ShowContent(" & mTbl1 & ", Grid1 )",card 1 of stack "LinkTest")

  get value("ShowStructure(" & mTbl2 & ", Grid2 )",card 1 of stack "LinkTest")
  get value("ShowContent(" & mTbl2 & ", Grid2 )",card 1 of stack "LinkTest")

end ShowTables

----------------------------------------------------------
function Step1
  set the cursor to watch

  put VDatabase_CreateTable(mDBRef, "person" ) into mTbl1
  put VTable_CreateULongField( mTbl1, "id", "fUnique, fIndexed" ) into mKey
  put VTable_CreateStringField( mTbl1, "FirstName", 40 ) into fldString

  get showStatistic()
  set the cursor to arrow

end Step1

----------------------------------------------------------
function Step2
  set the cursor to watch

  put VDatabase_CreateTable(mDBRef, "phones" ) into mTbl2
  put VTable_CreateStringField( mTbl2, "Number", 10 ) into fldString
  put VTable_CreateULongField( mTbl2, "person_ptr", "fIndexed,
fNullable" ) into mPtr
  get showStatistic()
  set the cursor to arrow

end Step2

----------------------------------------------------------
function Step3
  set the cursor to watch

  -- create ForeignKey LINK between 2 tables.
  put VDatabase_CreateForeignKeyLink( mDBRef, "link_person_phone",
mKey, mPtr ) into link

  get showStatistic()
  set the cursor to arrow

end Step3


----------------------------------------------------------
function Step4
  set the cursor to watch

  get AddRecordsToPerson()
  get AddRecordsToPhones()

  get ShowTables()
  get showStatistic()
  set the cursor to arrow

end Step4

----------------------------------------------------------
function AddRecordsToPerson
  put VTable_Field( mTbl1, "FirstName") into fldFirstName

  -- before add we need clear all fields
  get VTable_SetBlank( mTbl1 )

  get VField_Value( mKey, 1 )
  get VField_Value( fldFirstName, "Robert" )
  get VTable_AddRecord( mTbl1 )

  get VField_Value( mKey, 2 )
  get VField_Value( fldFirstName, "Brian" )
  get VTable_AddRecord( mTbl1 )

  get VField_Value( mKey, 3 )
  get VField_Value( fldFirstName, "John" )
  get VTable_AddRecord( mTbl1 )

  get VField_Value( mKey, 4 )
  get VField_Value( fldFirstName, "Peter" )
  get VTable_AddRecord( mTbl1 )

end AddRecordsToPerson

----------------------------------------------------------
function AddRecordsToPhones
  put VTable_Field( mTbl2, "Number") into fldNumber

  -- before add we need clear all fields
  get VTable_SetBlank( mTbl2 )

  -- 1 - 1
  -- 1 - 3
  -- 2 - 4
  -- 3 - 2

  get VField_Value( fldNumber, "1111" )
  get VField_Value( mPtr, 1 )
  get VTable_AddRecord( mTbl2 )

  get VField_Value( fldNumber, "2222" )
  get VField_Value( mPtr, 2 )
  get VTable_AddRecord( mTbl2 )

  get VField_Value( fldNumber, "3333" )
  get VField_Value( mPtr, 1 )
  get VTable_AddRecord( mTbl2 )

  get VField_Value( fldNumber, "4444" )
  get VField_Value( mPtr, 2 )
  get VTable_AddRecord( mTbl2 )

  get VField_Value( fldNumber, "5555" )
  get VField_SetBlank( mPtr )
  get VTable_AddRecord( mTbl2 )

  get VField_Value( fldNumber, "6666" )
  get VField_SetBlank( mPtr )
  get VTable_AddRecord( mTbl2 )

end AddRecordsToPhones

----------------------------------------------------------
function CreateDb
  if the gClient of this stack is true then
    put VConnection_Constructor( "localhost", "sa", "sa") into mConn
    get VConnection_Open( mConn )

    put VDatabase_Constructor( mConn ) into mDBRef
  else
    put VDatabase_Constructor() into mDBRef
  end if

  put the mPath of this stack into path

  get VDatabase_Create( mDBRef, path, "kDscDatBlbInd", 32 * 1024, "kOsDefault" )

end CreateDb

----------------------------------------------------------
function DBClose
  get VDatabase_Close( mDBRef )
  put VDatabase_Destructor( mDBRef ) into mDBRef

  if the gClient of this stack is true then
    get VConnection_Close( mConn )
  end if

end DBClose

----------------------------------------------------------
on openCard
 get SubInit()

  get CreateDb()
    go stack "WProperties"
    get value("Init()",card 1 of stack "WProperties")

end openCard

----------------------------------------------------------
on closeCard
  get DBClose()
 get SubDone()

end closeCard

On Sat, Jul 5, 2008 at 10:22 AM, william humphrey <shoreagent at gmail.com> wrote:
> Then if that is true I will need to continue my RunRev stack using all
> valentina methods. This means that I need an answer and clear example for
>
> VTable_Link(tblPref, inIntIndexOrSTrName) as so far I'm unable to return the
> tables that link to my other fields in the front end I'm building.
>
>
> I think it is my lack of understanding of what  "inIntIndexOrStrName" is.
>
>
> Please throw me some more information than what I can read in
> V4REV_Referernce_3 and an the WIKI.
>
>
> Thanks a bunch,
>
>
> Bill
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina
>



-- 
Neal Campbell
Abroham Neal Software
Programming Services for Windows, OS X and Linux
(540) 242 0911
---------------------------------------------------------------------
Try Spot for OS X, the intelligent DXCluster Client at
www.abrohamnealsoftware.com - introduction priced at $10.99
-------------------------------------------------
For a great dog book, visit www.abrohamneal.com
-------------------------------------------------
See the FlexRadio Systems Flex-5000a in
action at www.flex-videos.com


More information about the Valentina mailing list