For now, I got put on another project before I could finish. This is what I had up until then [no workable Update method yet]. Nothing very complex because that was all I needed when I got sidetracked. Once it is completed I will post.
PROTECTED PROCEDURE GenerateSQLDelete
LPARAMETERS tcTable
LOCAL lcSQL
lcSQL = 'delete from ' + This.cGISSchema + '.' + tcTable
IF UPPER(ALLTRIM(crsFedTables.State_Col)) == 'LOOKUP'
RETURN lcSQL
ENDIF
lcSQL = lcSQL + ' where ' + ALLTRIM(crsFedTables.State_Col) ;
+ " = '" + This.cState + "'"
RETURN lcSQL
ENDPROC
PROTECTED PROCEDURE GenerateSQLSelect
LPARAMETERS tcTable
LOCAL lcSQL
lcSQL = 'select * from ' + This.cFedSchema + '.' + tcTable
IF UPPER(ALLTRIM(crsFedTables.State_Col)) == 'LOOKUP'
RETURN lcSQL
ENDIF
lcSQL = lcSQL + ' where ' + ALLTRIM(crsFedTables.State_Col) ;
+ " = '" + This.cState + "'"
IF NOT ISNULL(crsFedTables.Data_Filter) AND NOT EMPTY(crsFedTables.Data_Filter)
lcSQL = lcSQL + ' AND ' + EVALUATE(ALLTRIM(crsFedTables.Data_Filter))
ENDIF
RETURN lcSQL
ENDPROC
>Mark,
>
>Thank you for posting GenerateSQLInsert(). Would you share your other generic methods to generate SQL string to UPDATE, DELETE and perhaps others (CREATE TABLE?). I did download your ODBC_DSN and it isn't there.
>
>TIA, Alex
>
>
>
>>I don't have to set any properties. I have a generic method that create the INSERT, UPDATE or DELETE SQL string based on the structure of the cursor. I then use SPT to sen the SQL back to the server. I have simplified this by having a standard PK field in all my tables named KeyID which is an integer field [a NUMBER(8) data type column in Oracle].
>>
>>This is quite simple when using a FOR loop based on FCOUNT(), and FIELD(lnI). I just check the data type for each field in order to create the VALUES part of the SQL string.
>>
>>Here is an example of how I generate an INSERT - SQL string for Oracle:
>> PROTECTED PROCEDURE GenerateSQLInsert
>> LPARAMETERS tcLocalCursor, tcRemoteTable
>> LOCAL lcSQL, lnI, lcValues, lcString
>> lcSQL = 'insert into ' + tcRemoteTable + ' ('
>> lcValues = ''
>> FOR lnI = 1 TO FCOUNT(tcLocalCursor)
>> IF lnI > 1
>> lcSQL = lcSQL + ', '
>> lcValues = lcValues + ', '
>> ENDIF
>> lcSQL = lcSQL + FIELD(lnI)
>> DO CASE
>> CASE TYPE(FIELD(lnI)) = 'N'
>> IF ISNULL(EVALUATE(FIELD(lnI)))
>> lcString = '0'
>> ELSE
>> lcString = TRANSFORM(EVALUATE(FIELD(lnI)))
>> ENDIF
>> lcValues = lcValues + lcString
>> CASE TYPE(FIELD(lnI)) = 'T'
>> IF ISNULL(EVALUATE(FIELD(lnI)))
>> lcString = "''"
>> ELSE
>> lcString = "TO_DATE('" + TRANSFORM(EVALUATE(FIELD(lnI))) ;
>> + "', 'MM/DD/YYYY HH24:MI:SS')"
>> ENDIF
>> lcValues = lcValues + lcString
>> OTHERWISE
>> IF ISNULL(EVALUATE(FIELD(lnI)))
>> lcString = "''"
>> ELSE
>> lcString = "'" + STRTRAN(ALLTRIM(EVALUATE(FIELD(lnI))), "'", "") + "'"
>> ENDIF
>> lcValues = lcValues + lcString
>> ENDCASE
>> ENDFOR
>> lcSQL = lcSQL + ') values (' + lcValues + ')'
>> RETURN lcSQL
>> ENDPROC</font
>>
>>
>>>Thanks, but Can anyone give the advantages, disadvantages of using user DSN, system DSN, file DSN, or a connection String?
>>>
>>>As for your reply, how do you manage to update your tables? Do you have to set a looot of properties for each view and its fields?
>>>
>>>TIA
>>>
>>>
>>>>I have an ODBC_DSN class in the UT Downloads that has examples. I use Oracle, but the concept is the same. I connect using SQLStringConnect() then use SPT. I still have apps using Remote Views, but I am moving to using SPT almost exclusively.
>>>>
>>>>>I have an application that uses SQL Server 7 as a back end. So, I created a System DSN. Then I created a connection in my app's DBC that refers to that DSN. But the connection designer has an option to specify a Connection string. Would someone tell me what is the best way to connect to SQL Server? Through a user DSN, system DSN, file DSN, or a connection String???
>>>>>
>>>>>Another thing is (in case I use a DSN) How can I let the App setup create a DSN so I don't have to create and configure it by myself.???
>>>>>
>>>>>TIA
>>>>>
>>>>>
>>>>>Luis
Mark McCasland
Midlothian, TX USA