Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Parameters passed using ? to SQL Server
Message
De
22/01/2015 04:18:23
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01614040
Message ID:
01614064
Vues:
49
This message has been marked as a message which has helped to the initial question of the thread.
>Hi everybody,
>
>We have queries like this:
>
>
>  text to lcSql textmerge noshow pretext 3
>                 select ri.*, rt.Descrip AS type_descrip, rt.maxdays, rt.maxrents, rt.shortdesc,
>                        rt.showinfo, rt.SigRequire
>                   from r_invent ri inner join r_types rt on ri.rentaltype = rt.typeid
>                  where ri.equip_tag = ?pnEquiptag
>            ENDTEXT
>
>The equip_tag column is defined as decimal(17,0) in SQL Server. In SQL Trace I see the following query being executed:
>
>
>exec sp_executesql N'select form_no from r_header where rental_no = @P1 ',N'@P1 float',719646112000
(for a similar query).
>
>Note, that the parameter is passed as float. The question is - how to pass this parameter as decimal(17,0) instead? Is there any way without changing the current code?
>
>May be I should put CAST on the right side, e.g.
>
> where ri.equip_tag = CAST(?pnEquiptag as decimal(17,0))
>
Yup, that would be the solution. Because there's nothing much else you can do fox-side. Fox parses the sql statement and if it encounters a question mark, it will repackage it as "exec sp_executesql" with parameters. Those parameters are fox variables, and fox really doesn't have any idea what they should be sql-side. The parser isn't too smart, which you'll discover as soon as you insert a comment containing a question mark in the sql statement - you get a bug which you can't really explain...

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform