SAS 中的 Oracle 连接

发布于 2024-11-28 20:53:26 字数 475 浏览 0 评论 0 原文

我在 sas 中使用这个 oracle 连接代码并收到此错误:

ORACLE 准备错误:ORA-06553:PLS-306:调用“get_pat_fix”时参数数量或类型错误;

我的代码如下所示:

proc sql;
 connect to oracle(user='XXXXX'orapw='XXXXXX'path='');

  create table work.XXX as select * from connection to oracle (

        select to_char(yy.XXXX) as XXXXXX,
substr(get_pat_fix ('XX', yy.XXXX , 'XX','XX'),1,5)   XXXX,
from XXX;

我尝试多次修改它但无法修复它。 我非常感谢您在这方面的帮助。

I am using this oracle connection code in sas and getting this error:

ORACLE prepare error: ORA-06553: PLS-306: wrong number or types of arguments in call to 'get_pat_fix';

my code looks like this:

proc sql;
 connect to oracle(user='XXXXX'orapw='XXXXXX'path='');

  create table work.XXX as select * from connection to oracle (

        select to_char(yy.XXXX) as XXXXXX,
substr(get_pat_fix ('XX', yy.XXXX , 'XX','XX'),1,5)   XXXX,
from XXX;

I have tried to modify it several times but could not get it fixed.
I would extremely appreciate your help regarding the same.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一场信仰旅途 2024-12-05 20:53:26

“我不明白 get_pat_fix 函数的解释。”

在 TOAD 或 SQL Developer 等 IDE 中浏览该函数,或者在 SQL*Plus 中对其进行描述,如下所示:

SQL> desc validate_salary
FUNCTION validate_salary RETURNS VARCHAR2
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 P_CURRENT_SAL                  NUMBER                  IN
 P_RAISE_PCT                    NUMBER                  IN
 P_JOB                          VARCHAR2                IN
 P_HIREDATE                     DATE                    IN
 P_DEPTNO                       NUMBER                  IN     DEFAULT

SQL>

这将显示参数的数字数据类型。我们必须为每个没有默认值的参数传递值,并且必须为任何 OUT 或 IN OUT 参数传递一个变量。传递的值必须与参数的数据类型匹配。

参数可以按位置传递...

SQL> select validate_salary (4000, 10, 'MGR', sysdate-720)
  2  from dual
  3  /

VALIDATE_SALARY(4000,10,'MGR',SYSDATE-720)
--------------------------------------------------------------
okay

SQL>

...或按命名符号...

SQL> select validate_salary (p_current_sal=> e.sal
  2                              , p_hiredate=> e.hiredate
  3                              , p_deptno => e.deptno
  4                              , p_job => e.job
  5                              , p_raise_pct=> 10 )
  6  from emp e
  7  /

VALIDATE_SALARY(P_CURRENT_SAL=>E.SAL,P_HIREDATE=>E.HIREDATE,P_DEPTNO=>E.DEPTNO,P
--------------------------------------------------------------------------------
okay
okay
okay  
...

无论哪种方式,参数都需要匹配:

SQL> select validate_salary (4000, 10, 'MGR')
  2  from dual
  3  /
select validate_salary (4000, 10, 'MGR')
       *
ERROR at line 1:
ORA-06553: PLS-306: wrong number or types of arguments in call to
'VALIDATE_SALARY'

SQL> select validate_salary (4000, 'MGR', sysdate-720, 40)
  2  from dual
  3  /
select validate_salary (4000, 'MGR', sysdate-720, 40)
       *
ERROR at line 1:
ORA-06553: PLS-306: wrong number or types of arguments in call to
'VALIDATE_SALARY'


SQL> 

当然,我错过了最明显的答案:查阅您的应用程序的文档,其中会有详细的描述GET_PAT_FIX() 函数的详细信息(包括其签名)。 :-D 抱歉,我以为我在打字时可以板着脸。

唉,在现实世界中,我们中有太多人不得不在没有像样的应用程序文档的情况下挣扎。所以我们必须询问数据库模式。我认为没有任何 SAS 工具可以执行此操作(在此处查找< /a>.

"I didnt understand the get_pat_fix function explanation."

Browse the function in an IDE like TOAD or SQL Developer, or describe it in SQL*Plus like this:

SQL> desc validate_salary
FUNCTION validate_salary RETURNS VARCHAR2
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 P_CURRENT_SAL                  NUMBER                  IN
 P_RAISE_PCT                    NUMBER                  IN
 P_JOB                          VARCHAR2                IN
 P_HIREDATE                     DATE                    IN
 P_DEPTNO                       NUMBER                  IN     DEFAULT

SQL>

This shows you the number and datatype of the parameters. We must pass values for every paramater which doesn't have a default, and we must pass a variable for any OUT or IN OUT parameter. The passed values must match the datatype of the parameter.

Parameters can be passed by position...

SQL> select validate_salary (4000, 10, 'MGR', sysdate-720)
  2  from dual
  3  /

VALIDATE_SALARY(4000,10,'MGR',SYSDATE-720)
--------------------------------------------------------------
okay

SQL>

... or by named notation...

SQL> select validate_salary (p_current_sal=> e.sal
  2                              , p_hiredate=> e.hiredate
  3                              , p_deptno => e.deptno
  4                              , p_job => e.job
  5                              , p_raise_pct=> 10 )
  6  from emp e
  7  /

VALIDATE_SALARY(P_CURRENT_SAL=>E.SAL,P_HIREDATE=>E.HIREDATE,P_DEPTNO=>E.DEPTNO,P
--------------------------------------------------------------------------------
okay
okay
okay  
...

Either way, the parameters need to match:

SQL> select validate_salary (4000, 10, 'MGR')
  2  from dual
  3  /
select validate_salary (4000, 10, 'MGR')
       *
ERROR at line 1:
ORA-06553: PLS-306: wrong number or types of arguments in call to
'VALIDATE_SALARY'

SQL> select validate_salary (4000, 'MGR', sysdate-720, 40)
  2  from dual
  3  /
select validate_salary (4000, 'MGR', sysdate-720, 40)
       *
ERROR at line 1:
ORA-06553: PLS-306: wrong number or types of arguments in call to
'VALIDATE_SALARY'


SQL> 

Of course, I missed out the most obvious answer: consult your application's documentation, which will have a detailed description of the GET_PAT_FIX() function including its signature. :-D Sorry, thought I could keep a straight face while I typed that.

Alas, in the real world too many of us have to struggle along without decent documentation for our apps. So we have to interrogate the database schema. I don't think there are any SAS tools for doing this (the ones Google throws up all seem to be just data browsers). So that means you'll need a database tool. I'm going to suggest Oracle's SQL Developer not because it's the best (that's a matter of taste) but because it is free, and it works. Find it here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文