简体   繁体   English

INSERT语句(sql)中“ http”处或附近的语法错误

[英]syntax error at or near “http” in INSERT statement (sql)

Getting error when trying to RUN: 尝试运行时出现错误:

INSERT INTO dtb_order VALUES (
    14,1920,NULL,
    'テスト',NULL,'03','6302','0215',NULL,NULL,NULL,'160','0023',NULL,0,13,
    '新宿区西新宿','セントラルパークタワー・ラ・トゥール',6,
    '1972-09-02 00:00:00',NULL,3150,0,1,500,0,0,0,0,150,3650,3650,8,
    'NP後払い',NULL,9000,'2013-09-12 18:42:56',
    '2013-09-23 19:42:22',NULL,NULL,10,1,NULL,
    'a:2:{s:5:\"title\";a:2:{s:4:\"name\";s:32:\"NP後払いでのお支払情報\";s:5:\"value\";b:1;}s:3:\"msg\";a:2:{s:4:\"name\";s:15:\"ご注意事項\";s:5:\"value\";s:388:\"株式会社ネットxxxションズより、商品とは別に郵送されます。\n主要コンビニ・銀行・郵便局でお支払いできますので、商品の到着を確認してから、\nお支払いをお願いいたします。\nNP後払いの詳しいご案内はこちら⇒ <a href=\'http://np-someurl.jp/about/\' target=\'_blank\'>http://np-someurl.jp/about/</a>\n\";}}',
    NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
);

Error message: 错误信息:

Error : ERROR:  syntax error at or near "http"
LINE 1: ...ます。\nNP後払いの詳しいご案内はこちら⇒ <a href=\'http://np-...
                                                             ^

Tried http:\\/\\/np-... no luck. 尝试过http:\\/\\/np-...没有运气。

++++++++ ++++++++

is there other way except $$ (my string with http) $$, because I have almost 200 000 INSERTs and only some of them have http://, I just want to fix "http://" with substitution by vim or something like that, not manually. 除了$$(我的带http的字符串)$$之外,还有其他方法吗,因为我有将近20万个INSERT,而其中只有一部分具有http://,我只想用vim或这样的东西,不是手动的。

You do not show the whole command. 您没有显示整个命令。 My guess is that it is not properly escaped. 我的猜测是它没有正确逃脱。 Use dollar quoting $$ in instead of single quotes so it is not necessary to escape single quotes in the string. 使用美元引用$$代替单引号,因此不必在字符串中转义单引号。 Also use escape string E syntax to have the new lines \\n 也使用转义字符串E语法以换行\\n

E$$a:2:{s:5:"title";a:2:{s:4:"name";s:32:"NP後払いでのお支払情報";s:5:"value";b:1;}s:3:"msg";a:2:{s:4:"name";s:15:"ご注意事項";s:5:"value";s:388:"株式会社ネットxxxションズより、商品とは別に郵送されます。\n主要コンビニ・銀行・郵便局でお支払いできますので、商品の到着を確認してから、\nお支払いをお願いいたします。\nNP後払いの詳しいご案内はこちら⇒ <a href='http://np-someurl.jp/about/' target='_blank'>http://np-someurl.jp/about/</a>\n";}}$$,

http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS

Changing \\' to " & \\" to " did the trick. \\'改为"\\"改为"就可以了。

VIM VIM

:%s/\\'/"/gc

:%s/\\"/"/gc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM