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

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

ERROR: More positional parameters found than defined

问题

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

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

%let m_msi=123465;
%let m_msg=Hi, Kindly help me to resolve the issue;

insert into my_table
            ( 
Column1,
Column2
)
values
(
%tslit(%sysfunc(strip(&m_msi.))),
%tslit(%sysfunc(strip(&m_msg.)))
)                       
英文:

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.

%let m_msi=123465;
%let m_msg=Hi, Kindly help me to resolve the issue;

insert into my_table
			( 
Column1,
Column2
)
values
(
%tslit(%sysfunc(strip(&m_msi.))),
%tslit(%sysfunc(strip(&m_msg.)))
)                       

答案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.

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

Try adding %STR or %NRSTR as follows.

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

You could also try %QSYSFUNC

%Qsysfunc(strip(&m_msi.))

答案2

得分: 0

你在插入时需要引用数值。

    proc sql;
    	create table my_table 
    	(
    		column1 char(200),
    		column2 char(200)
    	);
    quit;
    
    %let m_msi=123465;
    %let m_msg=嗨,请帮我解决这个问题;
    
    proc sql;
    	insert into my_table ( 
    		Column1,
    		Column2
    	)
    	values (
    		"&m_msi",
    		"&m_msg"
    	);
    quit;
英文:

You need to quote values when inserting.

proc sql;
	create table my_table 
	(
		column1 char(200),
		column2 char(200)
	);
quit;

%let m_msi=123465;
%let m_msg=Hi, Kindly help me to resolve the issue;

proc sql;
	insert into my_table ( 
		Column1,
		Column2
	)
	values (
		"&m_msi",
		"&m_msg"
	);
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:

确定