Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PLSQL中声明常量_Sql_Oracle_Plsql - Fatal编程技术网

在PLSQL中声明常量

在PLSQL中声明常量,sql,oracle,plsql,Sql,Oracle,Plsql,我在声明常量并在简单查询中使用它时遇到问题 我尝试过许多在PLSQL中声明常量的变体,我在网上看到过这些变体,但我不断地出错。我做错了什么 DECLARE cobdate CONSTANT NUMBER(10) := 420181109; BEGIN SELECT * FROM THIS_TABLE dex WHERE dex.close_of_business_key = &cobdate AND dex.scenario_type

我在声明常量并在简单查询中使用它时遇到问题

我尝试过许多在PLSQL中声明常量的变体,我在网上看到过这些变体,但我不断地出错。我做错了什么

DECLARE 
    cobdate CONSTANT NUMBER(10) := 420181109;
BEGIN
    SELECT *
    FROM   THIS_TABLE dex
    WHERE  dex.close_of_business_key = &cobdate
    AND    dex.scenario_type_id = 'xxxx'
    AND    dex.s_counterparty_id = 'xxxx'
    AND    dex.run_type = 'xxxx'
    AND    dex.s_credit_line_type_id = 'xxxx'
END;

您不应该使用
&
作为常量名称的前缀

DECLARE 
   cobdate CONSTANT NUMBER(10) := 420181109;
   v_this_table this_table%rowtype;
BEGIN
   SELECT * into v_this_table
     FROM THIS_TABLE dex
    WHERE dex.close_of_business_key = cobdate
      AND dex.scenario_type_id = 'xxxx'
      AND dex.s_counterparty_id = 'xxxx'
      AND dex.run_type = 'xxxx'
      AND dex.s_credit_line_type_id = 'xxxx'
END;
此外,在PL/SQL中,您需要指定将结果集值存储在哪里(在我的示例中,
v_this_table


如果查询返回多行,则需要一个光标对其进行迭代。

不应使用
&
作为常量名称的前缀

DECLARE 
   cobdate CONSTANT NUMBER(10) := 420181109;
   v_this_table this_table%rowtype;
BEGIN
   SELECT * into v_this_table
     FROM THIS_TABLE dex
    WHERE dex.close_of_business_key = cobdate
      AND dex.scenario_type_id = 'xxxx'
      AND dex.s_counterparty_id = 'xxxx'
      AND dex.run_type = 'xxxx'
      AND dex.s_credit_line_type_id = 'xxxx'
END;
此外,在PL/SQL中,您需要指定将结果集值存储在哪里(在我的示例中,
v_this_table


如果查询返回多行,则需要一个光标来迭代它。

出现了什么错误?出现了什么错误?不是%record,而是%rowtype。不是%record,而是%rowtype。