错误:找到的位置参数多于定义的参数。

huangapple go评论92阅读模式
英文:

ERROR: More positional parameters found than defined

问题

尝试通过proc sql向数据库表插入值。我的值是宏。在其中一个宏中,它包含一个带有逗号的文本。所以我得到了下面的错误

错误:找到的位置参数比定义的多。

  1. %let m_msi=123465;
  2. %let m_msg=Hi, Kindly help me to resolve the issue;
  3. insert into my_table
  4. (
  5. Column1,
  6. Column2
  7. )
  8. values
  9. (
  10. %tslit(%sysfunc(strip(&m_msi.))),
  11. %tslit(%sysfunc(strip(&m_msg.)))
  12. )
英文:

Trying to insert values to a database table through proc sql. my values are macros. In one of the macro it contain a text which has comma in between. So I'm getting below error

> ERROR: More positional parameters found than defined.

  1. %let m_msi=123465;
  2. %let m_msg=Hi, Kindly help me to resolve the issue;
  3. insert into my_table
  4. (
  5. Column1,
  6. Column2
  7. )
  8. values
  9. (
  10. %tslit(%sysfunc(strip(&m_msi.))),
  11. %tslit(%sysfunc(strip(&m_msg.)))
  12. )

答案1

得分: 1

我认为M_MSG中的逗号是引发问题的原因。

尝试像下面这样添加%STR或%NRSTR。

%let m_msg=%str(Hi, Kindly help me to resolve the issue);

您还可以尝试%QSYSFUNC。

%Qsysfunc(strip(&m_msi.))

英文:

I think the comma in M_MSG is causing the problem.

  1. %let m_msg=Hi, Kindly help me to resolve the issue;

Try adding %STR or %NRSTR as follows.

  1. %let m_msg=%str(Hi, Kindly help me to resolve the issue);

You could also try %QSYSFUNC

  1. %Qsysfunc(strip(&m_msi.))

答案2

得分: 0

  1. 你在插入时需要引用数值。
  2. proc sql;
  3. create table my_table
  4. (
  5. column1 char(200),
  6. column2 char(200)
  7. );
  8. quit;
  9. %let m_msi=123465;
  10. %let m_msg=嗨,请帮我解决这个问题;
  11. proc sql;
  12. insert into my_table (
  13. Column1,
  14. Column2
  15. )
  16. values (
  17. "&m_msi",
  18. "&m_msg"
  19. );
  20. quit;
英文:

You need to quote values when inserting.

  1. proc sql;
  2. create table my_table
  3. (
  4. column1 char(200),
  5. column2 char(200)
  6. );
  7. quit;
  8. %let m_msi=123465;
  9. %let m_msg=Hi, Kindly help me to resolve the issue;
  10. proc sql;
  11. insert into my_table (
  12. Column1,
  13. Column2
  14. )
  15. values (
  16. "&m_msi",
  17. "&m_msg"
  18. );
  19. quit;

huangapple
  • 本文由 发表于 2023年7月4日 22:19:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/76613582.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定