Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Insert without nulls from NET
Message
De
27/07/2009 15:58:52
 
 
À
27/07/2009 14:57:23
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01414410
Message ID:
01414854
Vues:
33
>>>>I am executing an SQL INSERT from a NET website. The insert statement has an incomplete list of the fields in the table. The intention is that the fields not listed would be left blank. The table is structured to not allow null values. The insert from the website fails with a message that the field does not allow null values. I am trying to find a way to deal with this. One solution is to revise the table to allow the nulls but this is undesireable. Another solution might be to establish a default value for each field (untested). But this is also undesireable. I would prefer the empty fields just be left blank.
>>>>
>>>There are some possibilities I see, depending on the backend.
>>>Do you INsert into a vfp table ?
>>>Is this single Record Insert or Bulk Insert operation ?
>>>
>>>regds
>>>
>>>thomas
>>
>>Yes, its a VFP database table.
>>It is a single record INSERT.
>>
>>I thought perhaps I could write a stored procedure and a trigger that would remove the nulls after they were inserted but so far my attempts at this have not been successful.
>
>Have you looked at set null and defined needed behaviour for your table ?
>Or you might
>loGather = createobject ("empty")
>insert into a cursor, 
>for lnRun = 1 to fcount()
>   lcFild = fieldnum(lnRun)
>   lcVal = eval (lcFld) && some tricks with nvl ??
>   if !isnull(lcVal)
>      = addproprty(loGather, lcFld, lcVal)
>   endif
>next
>insert from name loGather
>or similar tricks....
>
>HTH
>
>thomas

Well, it appears a SP like this will work.
procedure ExecuteSQL(SQLstatement)
set null off
execscript(SQLStatement)
Now the question is what kind of security holes does this create? Any thoughts? If I knew how to set null off by default maybe I wouldn't need the SP.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform