文章詳情頁
用表單來提交sql(轉(zhuǎn))3
瀏覽:10日期:2023-03-24 09:22:45
正在看的db2教程是:用表單來提交sql(轉(zhuǎn))3。 列表 D: buildSQLInsert函數(shù)的最終版。
<%
function buildSQLInsert( targetTable, omitFields)
iStr = "insert into " & targetTable & " "
vStr = "values ("
nStr = "("
在表單集合中循環(huán),并建立起SQL語句的組成部分
for each x in request.form
fieldName = uCase(x)
判斷字段是否被省略?
if inStr(uCase(omitFields),x) = 0 then
fieldData = replace(request.form(fieldName), _
"", "")
如果沒有數(shù)據(jù),就插入 NULL
if trim(fieldData) = "" then
fieldData = "NULL"
vStr = vStr & fieldData & ", "
nStr = nStr & fieldName & ", "
else
typeDelimPos = inStr(fieldName, "_")
if typeDelimPos = 0 then
是文本字段
建立字段名列表
nStr = nStr & fieldName & ", "
vStr = vStr &
else
字段是其它類型
fieldType = left(fieldName, typeDelimPos - 1)
fieldName = mid(fieldName, typeDelimPos + 1)
把字段名加入名稱列表
nStr = nStr & fieldName & ", "
把字段類型變成大寫以確保匹配
select case uCase(fieldType)
case "NUM"
vStr = vStr & fieldData & ", "
把不明類型按文本型處理
case else
vStr = vStr & "" & fieldData & ", "
end select
end if
&
end if
next
把結(jié)尾的", " 從我們建立的字符串中去掉
vStr = left(vStr, len(vStr) - 2) & ")"
nStr = left(nStr, len(nStr) - 2) & ") "
把SQL語句整合起來
buildSQLInsert = iStr & nStr & vStr
end function
if trim(request("fName")&request("lname")&request("age")) <> "" then
response.write( buildSQLInsert("") & "
response.write( buildSQLInsert("NUM_AGE") & "
")
response.write( buildSQLInsert("lname,fname") & "
")
response.write( buildSQLInsert("mycheckbox,fname") &
=<"
else
%>
<%
end if
%>
列表 D: buildSQLInsert函數(shù)的最終版。
<%
function buildSQLInsert( targetTable, omitFields)
iStr = "insert into " & targetTable & " "
vStr = "values ("
nStr = "("
在表單集合中循環(huán),并建立起SQL語句的組成部分
for each x in request.form
fieldName = uCase(x)
判斷字段是否被省略?
if inStr(uCase(omitFields),x) = 0 then
fieldData = replace(request.form(fieldName), _
"", "")
如果沒有數(shù)據(jù),就插入 NULL
if trim(fieldData) = "" then
fieldData = "NULL"
vStr = vStr & fieldData & ", "
else
typeDelimPos = inStr(fieldName, "_")
if typeDelimPos = 0 then
是文本字段
建立字段名列表
nStr = nStr & fieldName & ", "
vStr = vStr & "" & fieldData & ", "
else
字段是其它類型
fieldType = left(fieldName, typeDelimPos - 1)
fieldName = mid(fieldName, typeDelimPos + 1)
把字段名加入名稱列表
nStr = nStr & fieldName & ", "
把字段類型變成大寫以確保匹配
select case uCase(fieldType)
&n
vStr = vStr & fieldData & ", "
把不明類型按文本型處理
case else
vStr = vStr & "" & fieldData & ", "
end select
end if
end if
end if
next
把結(jié)尾的", " 從我們建立的字符串中去掉
vStr = left(vStr, len(vStr) - 2) & ")"
nStr = left(nStr, len(nStr) - 2) & ") "
把SQL語句整合起來
buildSQLInsert = iStr & nStr & vStr
end function
if trim(request("fName")&request("lname")&request("age")) <> "" then
response.write( buildSQLInsert("") & "
response.write( buildSQLInsert("NUM_AGE") & "
")
response.write( buildSQLInsert("lname,fname") & "
")
response.write( buildSQLInsert("mycheckbox,fname") &
=<"
else
%>
<%
end if
%>
<%
function buildSQLInsert( targetTable, omitFields)
iStr = "insert into " & targetTable & " "
vStr = "values ("
nStr = "("
在表單集合中循環(huán),并建立起SQL語句的組成部分
for each x in request.form
fieldName = uCase(x)
判斷字段是否被省略?
if inStr(uCase(omitFields),x) = 0 then
fieldData = replace(request.form(fieldName), _
"", "")
如果沒有數(shù)據(jù),就插入 NULL
if trim(fieldData) = "" then
fieldData = "NULL"
vStr = vStr & fieldData & ", "
nStr = nStr & fieldName & ", "
else
typeDelimPos = inStr(fieldName, "_")
if typeDelimPos = 0 then
是文本字段
建立字段名列表
nStr = nStr & fieldName & ", "
vStr = vStr &
[1] [2] [3] [4] [5] 下一頁
正在看的db2教程是:用表單來提交sql(轉(zhuǎn))3。"" & fieldData & ", "else
字段是其它類型
fieldType = left(fieldName, typeDelimPos - 1)
fieldName = mid(fieldName, typeDelimPos + 1)
把字段名加入名稱列表
nStr = nStr & fieldName & ", "
把字段類型變成大寫以確保匹配
select case uCase(fieldType)
case "NUM"
vStr = vStr & fieldData & ", "
把不明類型按文本型處理
case else
vStr = vStr & "" & fieldData & ", "
end select
end if
&
上一頁 [1] [2] [3] [4] [5] 下一頁
正在看的db2教程是:用表單來提交sql(轉(zhuǎn))3。nbsp; end ifend if
next
把結(jié)尾的", " 從我們建立的字符串中去掉
vStr = left(vStr, len(vStr) - 2) & ")"
nStr = left(nStr, len(nStr) - 2) & ") "
把SQL語句整合起來
buildSQLInsert = iStr & nStr & vStr
end function
if trim(request("fName")&request("lname")&request("age")) <> "" then
response.write( buildSQLInsert("") & "
response.write( buildSQLInsert("NUM_AGE") & "
")
response.write( buildSQLInsert("lname,fname") & "
")
response.write( buildSQLInsert("mycheckbox,fname") &
=<"
else
%>
<%
end if
%>
列表 D: buildSQLInsert函數(shù)的最終版。
<%
function buildSQLInsert( targetTable, omitFields)
iStr = "insert into " & targetTable & " "
vStr = "values ("
nStr = "("
在表單集合中循環(huán),并建立起SQL語句的組成部分
for each x in request.form
fieldName = uCase(x)
判斷字段是否被省略?
if inStr(uCase(omitFields),x) = 0 then
fieldData = replace(request.form(fieldName), _
"", "")
如果沒有數(shù)據(jù),就插入 NULL
if trim(fieldData) = "" then
fieldData = "NULL"
vStr = vStr & fieldData & ", "
上一頁 [1] [2] [3] [4] [5] 下一頁
正在看的db2教程是:用表單來提交sql(轉(zhuǎn))3。 nStr = nStr & fieldName & ", "else
typeDelimPos = inStr(fieldName, "_")
if typeDelimPos = 0 then
是文本字段
建立字段名列表
nStr = nStr & fieldName & ", "
vStr = vStr & "" & fieldData & ", "
else
字段是其它類型
fieldType = left(fieldName, typeDelimPos - 1)
fieldName = mid(fieldName, typeDelimPos + 1)
把字段名加入名稱列表
nStr = nStr & fieldName & ", "
把字段類型變成大寫以確保匹配
select case uCase(fieldType)
&n
上一頁 [1] [2] [3] [4] [5] 下一頁
正在看的db2教程是:用表單來提交sql(轉(zhuǎn))3。bsp; case "NUM"vStr = vStr & fieldData & ", "
把不明類型按文本型處理
case else
vStr = vStr & "" & fieldData & ", "
end select
end if
end if
end if
next
把結(jié)尾的", " 從我們建立的字符串中去掉
vStr = left(vStr, len(vStr) - 2) & ")"
nStr = left(nStr, len(nStr) - 2) & ") "
把SQL語句整合起來
buildSQLInsert = iStr & nStr & vStr
end function
if trim(request("fName")&request("lname")&request("age")) <> "" then
response.write( buildSQLInsert("") & "
response.write( buildSQLInsert("NUM_AGE") & "
")
response.write( buildSQLInsert("lname,fname") & "
")
response.write( buildSQLInsert("mycheckbox,fname") &
=<"
else
%>
<%
end if
%>
上一頁 [1] [2] [3] [4] [5]
標(biāo)簽:
DB2
相關(guān)文章:
1. mysql like語句問題2. Mysql入門系列:MYSQL創(chuàng)建、刪除和選擇數(shù)據(jù)庫3. 解決mybatis一對多關(guān)聯(lián)查詢多條數(shù)據(jù)只顯示一條的問題4. Mysql入門系列:MYSQL表達(dá)式求值和MYSQL類型轉(zhuǎn)換5. MYSQL技巧:為現(xiàn)有字段添加自增屬性6. Oracle數(shù)據(jù)庫備份與恢復(fù)精華資料集錦7. Mysql實(shí)現(xiàn)主從配置和多主多從配置8. SQL Server補(bǔ)丁版本的檢查和安裝過程中常見問題9. MySQL 8.0.19安裝詳細(xì)教程(windows 64位)10. MySQL 常用的拼接語句匯總
排行榜
