0

これは、MS SQL proc で多くの経験を積んだ私の最初の MySQL proc です。MySQL Workbench では、唯一のアラートはプロセス全体の End 行にありますが、詳細は示されません。

他のいくつかのことを試した後、今残っているのはこのエラーだけです...

エラー コード: 1064 SQL 構文にエラーがあります。1 行目の near '' を使用する正しい構文については、MySQL サーバーのバージョンに対応するマニュアルを確認してください。

ちなみに、私はすべての変数に @ を付けましたが、それが問題であると確信しました。それがあったかどうかわからない?

手順は次のとおりです...

-- --------------------------------------------------------------------------------
-- Routine DDL
-- --------------------------------------------------------------------------------
DELIMITER $$

CREATE PROCEDURE `dbname`.`ImportAccountToGravityForm` ()
BEGIN

  DECLARE intForm_id INTEGER;
  DECLARE intLead_id_current INT;
  DECLARE fltField_number_current FLOAT;
  DECLARE vcrValue_current VARCHAR(200);
  DECLARE intWeb_Site_Member_ID INT; -- id in import table
  DECLARE vcrValue2 VARCHAR(200);  -- SCHOOL
  DECLARE vcrValue7 VARCHAR(200);  -- ADDRESS LINE 1
  DECLARE vcrValue8 VARCHAR(200);  -- CITY
  DECLARE vcrValue9 VARCHAR(200); -- STATE
  DECLARE vcrValue10 VARCHAR(200); -- ZIP
  DECLARE vcrValue11 VARCHAR(200); -- COUNTRY
  DECLARE vcrValue12 VARCHAR(200);  -- NON-STUDENT/STUDENT
  DECLARE vcrValue13 VARCHAR(200);  -- CLASS OF
  DECLARE vcrValue14 VARCHAR(200);  -- DESCRIPTION
  DECLARE vcrValue16 VARCHAR(200);  -- EMAIL
  DECLARE vcrValue17 VARCHAR(200);  -- AWARD
  DECLARE vcrValue19 VARCHAR(200);  -- SUBMITED BY - FULL NAME
  DECLARE vcrValue20 VARCHAR(200);  -- SUBMITTED BY - MAIL
  DECLARE vcrValue23 VARCHAR(200);  -- YEAR AWARDED
  DECLARE vcrValue24_6 VARCHAR(200);  -- FIRST NAME
  DECLARE vcrValue24_3 VARCHAR(200);  -- LAST NAME
  DECLARE vcrValue25 VARCHAR(200);  -- TITLE

  SET intForm_id = 2;
  SET intLead_id_current = -1;
  SET vcrValue19 = 'Import from YM';  -- SUBMITED BY - FULL NAME
  SET vcrValue20 = '';  -- SUBMITTED BY - MAIL
  SET vcrValue12 = '';  -- STUDENT/ALUMNI
  SET vcrValue14 = '';  -- DESCRIPTION

  SELECT e.Web_Site_Member_ID, e.School, e.Home_Address_Line1, e.Home_City, e.Home_State_Abbrev, e.Home_Postal_Code,
     e.Home_Country, e.Class_of, e.Email_Address, e.Membership, e.Year_award_or_scholarship_received,
     e.First_Name, e.Last_Name, e.Title
  INTO intWeb_Site_Member_ID,
            vcrValue2,  -- SCHOOL
            vcrValue7,  -- ADDRESS LINE 1
            vcrValue8,  -- CITY
            vcrValue9,  -- STATE
            vcrValue10,  -- ZIP
            vcrValue11,  -- COUNTRY
            vcrValue13,  -- CLASS OF
            vcrValue16,  -- EMAIL
            vcrValue17,  -- AWARD
            vcrValue23,  -- YEAR AWARDED
            vcrValue24_6,   -- FIRST NAME
            vcrValue24_3,   -- LAST NAME
            vcrValue25   -- TITLE
    FROM Export_fromYM_2012_06_25 e
    WHERE e.Imported <> 'Y' AND e.Member_Type_Code = 'Student/Alumni'
    ORDER BY e.Web_Site_Member_ID ASC;

    INSERT INTO wp_hpvyvb_rg_lead
        (form_id, date_created, ip, source_url, user_agent)
    VALUES
        (1, NOW(), '', 'import');

    SET intLead_id_current = LAST_INSERT_ID();

    IF intLead_id_current > 0 THEN
    BEGIN
            INSERT INTO wp_hpvyvb_rg_lead_detail
              (lead_id, form_id, field_number, value)
            VALUES
              (intLead_id_current, intForm_id, 2, vcrValue2);

            INSERT INTO wp_hpvyvb_rg_lead_detail
              (lead_id, form_id, field_number, value)
            VALUES
              (intLead_id_current, intForm_id, 7, vcrValue7);

            INSERT INTO wp_hpvyvb_rg_lead_detail
              (lead_id, form_id, field_number, value)
            VALUES
              (intLead_id_current, intForm_id, 8, vcrValue8);

            INSERT INTO wp_hpvyvb_rg_lead_detail
              (lead_id, form_id, field_number, value)
            VALUES
              (intLead_id_current, intForm_id, 9, vcrValue9);

              INSERT INTO wp_hpvyvb_rg_lead_detail
              (lead_id, form_id, field_number, value)
            VALUES
              (intLead_id_current, intForm_id, 10, vcrValue10);

              INSERT INTO wp_hpvyvb_rg_lead_detail
              (lead_id, form_id, field_number, value)
            VALUES
              (intLead_id_current, intForm_id, 11, vcrValue11);

              INSERT INTO wp_hpvyvb_rg_lead_detail
              (lead_id, form_id, field_number, value)
            VALUES
              (intLead_id_current, intForm_id, 12, vcrValue12);

              INSERT INTO wp_hpvyvb_rg_lead_detail
              (lead_id, form_id, field_number, value)
            VALUES
              (intLead_id_current, intForm_id, 13, vcrValue13);

              INSERT INTO wp_hpvyvb_rg_lead_detail
              (lead_id, form_id, field_number, value)
            VALUES
              (intLead_id_current, intForm_id, 14, vcrValue14);

              INSERT INTO wp_hpvyvb_rg_lead_detail
              (lead_id, form_id, field_number, value)
            VALUES
              (intLead_id_current, intForm_id, 16, vcrValue16);

              INSERT INTO wp_hpvyvb_rg_lead_detail
              (lead_id, form_id, field_number, value)
            VALUES
              (intLead_id_current, intForm_id, 17, vcrValue17);

              INSERT INTO wp_hpvyvb_rg_lead_detail
              (lead_id, form_id, field_number, value)
            VALUES
              (intLead_id_current, intForm_id, 19, vcrValue19);

              INSERT INTO wp_hpvyvb_rg_lead_detail
              (lead_id, form_id, field_number, value)
            VALUES
              (intLead_id_current, intForm_id, 20, vcrValue20);

              INSERT INTO wp_hpvyvb_rg_lead_detail
              (lead_id, form_id, field_number, value)
            VALUES
              (intLead_id_current, intForm_id, 23, vcrValue23);

              INSERT INTO wp_hpvyvb_rg_lead_detail
              (lead_id, form_id, field_number, value)
            VALUES
              (intLead_id_current, intForm_id, 24.6, vcrValue24_6);

              INSERT INTO wp_hpvyvb_rg_lead_detail
              (lead_id, form_id, field_number, value)
            VALUES
              (intLead_id_current, intForm_id, 24.3, vcrValue24_3);

              INSERT INTO wp_hpvyvb_rg_lead_detail
              (lead_id, form_id, field_number, value)
            VALUES
              (intLead_id_current, intForm_id, 25, vcrValue25);


        UPDATE Export_fromYM_2012_06_25 SET Imported = 'Y', CustomFieldsMemberID = intLead_id_current WHERE @intWeb_Site_Member_ID = Web_Site_Member_ID;

     END; -- IF

END;
$$

DELIMITER ;
4

1 に答える 1

0

私はそれを考え出した。

if ステートメントに「Begin」「End」は必要ありませんでしたが、代わりに「End If」が必要でした。

ありがとう!

于 2012-08-05T23:39:13.933 に答える