本文介绍 OBClient 版本低导致 source 命令不兼容函数中的除号。
适用版本
OceanBase 数据库 V2.2.x、V3.1.x、V3.2.x 版本。
问题现象
通过 source 命令创建 function/procedure 报错。

测试案例如下:
创建函数 SQL 文件。
cat test_divide.sql CREATE OR REPLACE PROCEDURE test_divide AS ln_ret NUMBER(22,6); BEGIN ln_ret := 1/2; END; /查看 OBClient 版本。
/u01/obclient/bin/obclient --version /u01/obclient/bin/obclient Ver 2.2.1 Distrib 10.4.18-MariaDB, for Linux (x86_64) using readline 5.1连接数据库。
obclient -hxxx.xxx.xxx.xxx -P2881 -uroot@sys -p -AServer version: OceanBase 3.2.3.3 (r107040032023032910-c59670fcc6f48d0f6d7ba107e85d43efe85e6615) (Built Mar 29 2023 10:50:14) Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.使用
source命令创建 function/procedure 报错。obclient [ALVIN]> source test_divide.sql;ORA-00900: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near '1' at line 5 ORA-00900: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near '2' at line 1 ORA-00900: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'END' at line 1 ORA-00900: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near '/' at line 1
问题原因
ln_ret := 1/2; 中 / 与 Delimter / 冲突,将 ln_ret := 1/2; 修改为 ln_ret := 12; 就不报错。
obclient [ALVIN]> source test_divide.sql;
Query OK, 0 rows affected (0.020 sec)
解决方法
可以通过升级 OBClient 至 OBClient V2.2.3 以上版本解决。
升级 OBClient。
rpm -Uvh obclient-2.2.3-20230515141610.el7.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:obclient-2.2.3-20230515141610.el7################################# [ 50%] Cleaning up / removing... 2:obclient-2.2.1-20221122151945.el7################################# [100%]查看升级后 OBClient 版本。
/u01/obclient/bin/obclient --version /u01/obclient/bin/obclient Ver 2.2.3 Distrib 10.4.18-MariaDB, for Linux (x86_64) using readline 5.1升级后不报错。
obclient [ALVIN]> source test_divide.sql Query OK, 0 rows affected (0.016 sec)