Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to create INSERT with datetime type field?
Message
De
22/08/2005 09:35:51
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01042503
Message ID:
01042646
Vues:
26
>Cetin,
>
>>Why are you trying to create such a string in the first place? Is it a cursoradapter or SQLExec() string? If so you better use parametric insert. ie:
>>
>>cInsertCommand = "insert into mytable (mydtfld) values (?m.ltDatetime)"
>>m.ltDatetime = datetime()
>>SQLExec(m.lnHandle, m.cInsertCommand)
>>
>
>I am trying to create a 3-tier application where the UI tier passes an array of field/value pairs to the Data Access tier. Then in the Data Access tier I need to update database, either VFP or SQL Server. So I am experimenting with different approaches. I use SQLExec for the SQL Server, by the way, not a cursoradapter. So, for the VFP database, I was building this long string of fields and values. I am trying to make the routine somewhat generic, that's why I was building the Insert string in the Data Access tier.
>
>If you see that I am not on the right track with this approach, please let me know. Thank you.

And I missed you were saying field/value parameters. Then your routine could build it like this:
(warning off the top off my head):
*...
set textmerge to memvar m.lcInsert noshow
set textmerge on
\\insert into <<tcTableName>> (
for ix=1 to alen(taFVPair,1) && taFVPair[,1]=ColumnName, taFVPair[,2]=Value
  \\ <<iif(m.ix>1,',','')>><<taFVPair[m.ix,1]>>
endfor
\\) values (
for ix=1 to alen(taFVPair,1) && taFVPair[,1]=ColumnName, taFVPair[,2]=Value
  \\ <<iif(m.ix>1,',','')>>?taFVPair[<<m.ix>>,2]
endfor
\\)
set textmerge to
set textmerge off
SQLExec(m.tnHandle,m.lcInsert)
PS:This is if passed pairs as an array. Similar routine could be done using amembers() if you instead passed oRecord where Columns are properties (ie: what a scatter name creates).
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform