0

Trying to import this section here. Im getting a syntax error however Im not sure whats wrong or exactly how to tshoot this and Im working my way through mysql. There were some sequence issues in the tables in the original file. Had to reorg a couple. This is the last table to be imported.

Setup right now is using XAMPP Version 7.3.9

Scenario Info

File Source: https://github.com/WietseWind/xrptipbot/blob/master/install/db.sql
Server version: 10.4.6-MariaDB - mariadb.org binary distribution
Server charset: cp1252 West European (latin1)
DB Collation: latin1_swedish_ci

CODE

-- Create syntax for FUNCTION 'levenshtein'
CREATE DEFINER = `newuser`@`%` FUNCTION `levenshtein`(
    s1 VARCHAR(255),
    s2 VARCHAR(255)
) RETURNS INT(11) DETERMINISTIC BEGIN
    DECLARE
        s1_len,
        s2_len,
        i,
        j,
        c,
        c_temp,
        cost INT; DECLARE s1_char CHAR;
        -- max strlen=255
        DECLARE cv0,
        cv1 VARBINARY(256);
    SET
        s1_len = CHAR_LENGTH(s1),
        s2_len = CHAR_LENGTH(s2),
        cv1 = 0x00,
        j = 1,
        i = 1,
        c = 0; IF s1 = s2 THEN RETURN 0; ELSEIF s1_len = 0 THEN RETURN s2_len; ELSEIF s2_len = 0 THEN RETURN s1_len; ELSE WHILE j <= s2_len
    DO
SET
    cv1 = CONCAT(cv1, UNHEX(HEX(j))),
    j = j + 1;
END WHILE; WHILE i <= s1_len
DO
SET
    s1_char = SUBSTRING(s1, i, 1),
    c = i,
    cv0 = UNHEX(HEX(i)),
    j = 1; WHILE j <= s2_len
DO
SET
    c = c + 1; IF s1_char = SUBSTRING(s2, j, 1) THEN
SET
    cost = 0; ELSE
SET
    cost = 1;
END IF;
SET
    c_temp = CONV(
        HEX(SUBSTRING(cv1, j, 1)),
        16,
        10
    ) + cost; IF c > c_temp THEN
SET
    c = c_temp;
END IF;
SET
    c_temp = CONV(
        HEX(SUBSTRING(cv1, j +1, 1)),
        16,
        10
    ) + 1; IF c > c_temp THEN
SET
    c = c_temp;
END IF;
SET
    cv0 = CONCAT(cv0, UNHEX(HEX(c))),
    j = j + 1;
END WHILE;
SET
    cv1 = cv0,
    i = i + 1;
END WHILE;
END IF; RETURN c;
END;

ERROR

Error

SQL query:

-- Create syntax for FUNCTION 'levenshtein'
CREATE DEFINER = `newuser`@`%` FUNCTION `levenshtein`(
    s1 VARCHAR(255),
    s2 VARCHAR(255)
) RETURNS INT(11) DETERMINISTIC BEGIN
    DECLARE
        s1_len,
        s2_len,
        i,
        j,
        c,
        c_temp,
        cost INT

MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 13
Open new phpMyAdmin window
snub-fighter
  • 161
  • 2
  • 14

0 Answers0