我從JMP表保存到MySQL數據庫。我可以控制保存時創建的MySQL列數據類型嗎?
A; lso,如果我在MySQL中設計我的模式並嘗試從JMP添加行,JMP是否知道/尊重現有MySQL列的數據類型?
這適用於MS SQL,但它應該與MySQL相同。我有一個存儲過程,它期望表中29列的數據。如你所見,日期需要一些工作。我正在使用JSL構建一個字符串,我將在任何SQL管理程序中鍵入。代碼的結尾交換了NULL的JMP缺失值。
我有代碼從表中獲取數據(只有那些忽略列= 0的行)。然後,查詢構建器代碼將此JSL作為名為“更新選定值”的腳本附加到數據表。就用戶而言,他們正在直接編輯數據表。
存儲過程檢查value1是否為NULL,在這種情況下,它會添加一個新行並生成一個ID。如果在value1中指定了ID,則它將舊條目設置為Ignore = 1,然後添加具有指定ID且Ignore = 0的新條目。
dbc = Create Database Connection(
"ODBC:..."
);
value1 = Column( Current Data Table(), 1 ) << Get Values;
value2 = Column( Current Data Table(), 2 ) << Get Values;
value3 = Column( Current Data Table(), 3 ) << Get Values;
value4 = Column( Current Data Table(), 4 ) << Get Values;
value5 = Column( Current Data Table(), 5 ) << Get Values;
value6 = Column( Current Data Table(), 6 ) << Get Values;
value7 = Column( Current Data Table(), 7 ) << Get Values;
value8 = Column( Current Data Table(), 8 ) << Get Values;
value9 = Column( Current Data Table(), 9 ) << Get Values;
value10 = Column( Current Data Table(), 10 ) << Get Values;
value11 = Column( Current Data Table(), 11 ) << Get Values;
value12 = Column( Current Data Table(), 12 ) << Get Values;
value13 = Column( Current Data Table(), 13 ) << Get Values;
value14 = Column( Current Data Table(), 14 ) << Get Values;
value15 = Column( Current Data Table(), 15 ) << Get Values;
value16 = Column( Current Data Table(), 16 ) << Get Values;
value17 = Column( Current Data Table(), 17 ) << Get Values;
value18 = Column( Current Data Table(), 18 ) << Get Values;
value19 = Column( Current Data Table(), 19 ) << Get Values;
value20 = Column( Current Data Table(), 20 ) << Get Values;
value21 = Column( Current Data Table(), 21 ) << Get Values;
value22 = Column( Current Data Table(), 22 ) << Get Values;
value23 = Column( Current Data Table(), 23 ) << Get Values;
value24 = Column( Current Data Table(), 24 ) << Get Values;
value25 = Column( Current Data Table(), 25 ) << Get Values;
value26 = Column( Current Data Table(), 26 ) << Get Values;
value27 = Column( Current Data Table(), 27 ) << Get Values;
value28 = Column( Current Data Table(), 28 ) << Get Values;
value29 = Column( Current Data Table(), 29 ) << Get Values;
rowsToUpdate = Current Data Table() << get selected rows;
NrowsToUpdate = N Rows( rowsToUpdate );
If( NrowsToUpdate > 0,
For( i = 1, i <= NrowsToUpdate, i++,
insertString =
"DECLARE @RC int
EXECUTE @RC = [DBNAME].[dbo].[SPNAME]
";
valueString = "";
j = rowsToUpdate[i];
valueString = valueString || Char( value1[j] ) || ",'" || Char( value2[j] )
|| "','" || Char( value3[j] ) || "','" || Char( value4[j] ) || "','" ||
Char( value5[j] ) || "','" || Char( value6[j] ) || "','" ||
Char( value7[j] ) || "','" || Char( value8[j] ) || "','" ||
Char( value9[j] ) || "','" || Char( value10[j] ) || "','" ||
Char( value11[j] ) || "','" || Char( value12[j] ) || "','" ||
Char( value13[j] ) || "','" || Char( value14[j] ) || "','" ||
Char( value15[j] ) || "','" || Char( value16[j] ) || "'," ||
Char( value17[j] ) || "," || Char( value18[j] ) || "," || Char( value19[j] )
|| "," || Char( value20[j] ) || "," || Char( value21[j] ) || "," ||
Char( value22[j] ) || ",'" || Char( value23[j] ) || "','" ||
Char( value24[j] ) || "','" || Char( value25[j] ) || "','" ||
Char( value26[j] ) || "','" || Char(
Substitute( Format( value27[j], "y/m/d h:m:s" ), "/", "" )
) || "','" || Char(
Substitute( Format( value28[j], "y/m/d h:m:s" ), "/", "" )
) || "','" || Char( value29[j] ) || "'";
insertString = insertString || valueString;
insertString = Substitute( insertString,
".,", "NULL,",
",''", ",NULL",
",,", ",NULL,",
"'.'", "NULL"
);
dt = Execute SQL( dbc, insertString );
);
Close Database Connection( dbc );
);嗨斯蒂芬,
謝謝!您是否可以分享幾行代碼作為示例?如果太麻煩,我理解。
約翰