Parameter Add in SQL from Oracle Database with C#
In my SQL select part i have column like this;
NVL(RISK_SASI(A.TEKLIF_NO1, A.TEKLIF_NO2, C.URUN_SIRA_NO, C.SIRA_NO, :S_DATE),0) AS RISK
And I adding dinamicly with a TextBox
this S_DATE
value.
string txtBoxText1 = ((TextBox)Page.FindControl("TextBox1")).Text;
if (txtBoxText1 != "")
dt_stb = DateTime.Parse(txtBoxText1);
myCommand.Parameters.AddWithValue(":S_TARIH_B", dt_stb);
BUT it didn't work for my SQL
.
Here is mine full SQL;
SELECT A.HESAP_NO, A.TEKLIF_NO1 || '/' || A.TEKLIF_NO2 AS TEKLIF, A.MUS_K_ISIM AS MUSTERI,
B.MARKA, C.SASI_NO, C.SASI_DURUM, D.TAS开发者_StackOverflow社区_MAR, NVL(RISK_SASI(A.TEKLIF_NO1, A.TEKLIF_NO2, C.URUN_SIRA_NO, C.SIRA_NO, :S_TARIH_B),0) AS RISK,
NVL(MV_SASI(A.TEKLIF_NO1, A.TEKLIF_NO2, C.SIRA_NO, C.URUN_SIRA_NO, :S_TARIH_B),0) AS MV,
MV_K(A.TEKLIF_NO1,A.TEKLIF_NO2, :S_TARIH_B) AS KV
FROM S_TEKLIF A, S_URUN B, S_URUN_DETAY C, KOC_KTMAR_PR D
WHERE A.TEKLIF_NO1 || A.TEKLIF_NO2 = B.TEKLIF_NO1 || B.TEKLIF_NO2
AND A.TEKLIF_NO1 || A.TEKLIF_NO2 = C.TEKLIF_NO1 || C.TEKLIF_NO2
AND B.SIRA_NO = C.URUN_SIRA_NO
AND B.DISTRIBUTOR = D.DIST_KOD
AND B.MARKA = D.MARKA_KOD
AND B.URUN_KOD = D.TAS_KOD
How can i do that?
Best Regards, Soner
When using parameters with ORACLE, you'd have to use @ instead of :. I recently asked a question about how to make this generic in code. You might want to have a look at it: DbCommand and parameterized SQL, ORACLE vs SQL Server
精彩评论