我正在尝试使用以下过程为sp1表添加值。 但它不能检索正确的十六进制小数值。
String downloadFilepath = "C:\\seleniumDownloads";
HashMap<String, Object> chromePrefs = new HashMap<String, Object>();
chromePrefs.put("profile.default_content_settings.popups", 0);
chromePrefs.put("download.default_directory", downloadFilepath);
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", chromePrefs);
DesiredCapabilities cap = DesiredCapabilities.chrome();
cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
cap.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(cap);
通过调用以下函数向表中添加值。
create table sp1(
id varchar(10),
txt varchar(10)
);
create procedure sp_ins1(p varchar(10))
BEGIN
set @x = char_length(p);
set @y = binary(p);
insert into sp1(id,txt)
values(@x,@y);
END;
这是结果
call sp_ins1(4);
call sp_ins1(13);
call sp_ins1(45);
select * from sp1\g
这是什么原因?
答案 0 :(得分:1)
不要理解这个问题。另外sp_ins7
!= sp_ins1
。
尝试:
mysql> SELECT
-> CHAR_LENGTH('4') `id`,
-> BINARY('4') `txt_BIN`,
-> HEX('4') `txt_HEX`
-> UNION
-> SELECT
-> CHAR_LENGTH('13') `id`,
-> BINARY('13') `txt_BIN`,
-> HEX('13') `txt_HEX`
-> UNION
-> SELECT
-> CHAR_LENGTH('45') `id`,
-> BINARY('45') `txt_BIN`,
-> HEX('45') `txt_HEX`
-> UNION
-> SELECT
-> CHAR_LENGTH('6757') `id`,
-> BINARY('6757') `txt_BIN`,
-> HEX('6757') `txt_HEX`
-> UNION
-> SELECT
-> CHAR_LENGTH('1') `id`,
-> BINARY('1') `txt_BIN`,
-> HEX('1') `txt_HEX`;
+----+---------+----------+
| id | txt_BIN | txt_HEX |
+----+---------+----------+
| 1 | 4 | 34 |
| 2 | 13 | 3133 |
| 2 | 45 | 3435 |
| 4 | 6757 | 36373537 |
| 1 | 1 | 31 |
+----+---------+----------+
5 rows in set (0.00 sec)