程序问题

发布于 2024-08-01 20:44:57 字数 1243 浏览 7 评论 0原文

create or replace
PROCEDURE XXB_RJT_HEADER_PROCEURE 
  (
    V_PROD_ID  IN NUMBER,
    V_WARE_ID  IN XXB_RJT_HEADER.WAREHOUSE_ID% TYPE,
    V_PAY_METH IN XXB_RJT_HEADER.PAYMENT_METHOD% TYPE,
    V_PAY_STAT IN XXB_RJT_HEADER.PAYMENT_STATUS% TYPE,
    V_ORD_ID   IN XXB_RJT_HEADER.ORDER_ID% TYPE,
    V_ORD_DT   IN XXB_RJT_HEADER.ORDER_DATE% TYPE )
AS
  V_PROD_NM VARCHAR2(50);
  V_WAR_NM  VARCHAR2(15);
BEGIN
  SELECT PRODUCT_CAT
  INTO V_PROD_NM
  FROM xxb_rjt_inventory
  WHERE XXB_RJT_INVENTORY.product_id= V_prod_id;
  SELECT WAREHOUSE_NAME
  INTO V_WAR_NM
  FROM xxb_rjt_inventory
  WHERE XXB_RJT_INVENTORY.product_id= V_prod_id;

  INSERT
  INTO XXB_RJT_HEADER
    (                  /*second error*/
      warehouse_id,
      PAYMENT_METHOD,
      payment_status,
      product_name,
      order_id,
      wareshouse_name,
      order_date
    )
    VALUES
    (
      V_warehouse_id,
      v_pay_meth,  /*First error*/
      V_pay_stat,
      V_prod_nm,
      V_ord_id,
      V_war_nm,
      V_ord_dt
    );



END XXB_RJT_HEADER_PROCEURE;

当我编译这个时,我收到以下错误,

Error(37,7): PL/SQL: ORA-00984: column not allowed here

Error(24,65530): PL/SQL: SQL Statement ignored

感谢您的提前帮助

create or replace
PROCEDURE XXB_RJT_HEADER_PROCEURE 
  (
    V_PROD_ID  IN NUMBER,
    V_WARE_ID  IN XXB_RJT_HEADER.WAREHOUSE_ID% TYPE,
    V_PAY_METH IN XXB_RJT_HEADER.PAYMENT_METHOD% TYPE,
    V_PAY_STAT IN XXB_RJT_HEADER.PAYMENT_STATUS% TYPE,
    V_ORD_ID   IN XXB_RJT_HEADER.ORDER_ID% TYPE,
    V_ORD_DT   IN XXB_RJT_HEADER.ORDER_DATE% TYPE )
AS
  V_PROD_NM VARCHAR2(50);
  V_WAR_NM  VARCHAR2(15);
BEGIN
  SELECT PRODUCT_CAT
  INTO V_PROD_NM
  FROM xxb_rjt_inventory
  WHERE XXB_RJT_INVENTORY.product_id= V_prod_id;
  SELECT WAREHOUSE_NAME
  INTO V_WAR_NM
  FROM xxb_rjt_inventory
  WHERE XXB_RJT_INVENTORY.product_id= V_prod_id;

  INSERT
  INTO XXB_RJT_HEADER
    (                  /*second error*/
      warehouse_id,
      PAYMENT_METHOD,
      payment_status,
      product_name,
      order_id,
      wareshouse_name,
      order_date
    )
    VALUES
    (
      V_warehouse_id,
      v_pay_meth,  /*First error*/
      V_pay_stat,
      V_prod_nm,
      V_ord_id,
      V_war_nm,
      V_ord_dt
    );



END XXB_RJT_HEADER_PROCEURE;

when i compile this i get the following errors

Error(37,7): PL/SQL: ORA-00984: column not allowed here

Error(24,65530): PL/SQL: SQL Statement ignored

thanks for the help in advance

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

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

发布评论

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

评论(3

夏末的微笑 2024-08-08 20:44:57

您可以重写类似(未经测试)的内容:

create or replace
PROCEDURE XXB_RJT_HEADER_PROCEURE 
  (
    V_PROD_ID  IN xxb_rjt_inventory.product_id%type,
    V_WARE_ID  IN XXB_RJT_HEADER.WAREHOUSE_ID% TYPE,
    V_PAY_METH IN XXB_RJT_HEADER.PAYMENT_METHOD% TYPE,
    V_PAY_STAT IN XXB_RJT_HEADER.PAYMENT_STATUS% TYPE,
    V_ORD_ID   IN XXB_RJT_HEADER.ORDER_ID% TYPE,
    V_ORD_DT   IN XXB_RJT_HEADER.ORDER_DATE% TYPE )
AS
BEGIN

  INSERT
  INTO XXB_RJT_HEADER
    (                  
      warehouse_id,
      PAYMENT_METHOD,
      payment_status,
      product_name,
      order_id,
      wareshouse_name,
      order_date
    )
    select 
      V_ware_id,
      v_pay_meth,  
      V_pay_stat,
      product_cat,
      V_ord_id,
      warehouse_name,
      V_ord_dt
    from xxb_rjt_inventory
    where product_id= V_prod_id;

END XXB_RJT_HEADER_PROCEURE;

这意味着要声明更少的两个 sql 语句和两个更少的变量。 还要更改过程的名称,您编写过程而不是过程。 我还更改了程序第一个参数的类型。

You can rewrite is in something like (untested):

create or replace
PROCEDURE XXB_RJT_HEADER_PROCEURE 
  (
    V_PROD_ID  IN xxb_rjt_inventory.product_id%type,
    V_WARE_ID  IN XXB_RJT_HEADER.WAREHOUSE_ID% TYPE,
    V_PAY_METH IN XXB_RJT_HEADER.PAYMENT_METHOD% TYPE,
    V_PAY_STAT IN XXB_RJT_HEADER.PAYMENT_STATUS% TYPE,
    V_ORD_ID   IN XXB_RJT_HEADER.ORDER_ID% TYPE,
    V_ORD_DT   IN XXB_RJT_HEADER.ORDER_DATE% TYPE )
AS
BEGIN

  INSERT
  INTO XXB_RJT_HEADER
    (                  
      warehouse_id,
      PAYMENT_METHOD,
      payment_status,
      product_name,
      order_id,
      wareshouse_name,
      order_date
    )
    select 
      V_ware_id,
      v_pay_meth,  
      V_pay_stat,
      product_cat,
      V_ord_id,
      warehouse_name,
      V_ord_dt
    from xxb_rjt_inventory
    where product_id= V_prod_id;

END XXB_RJT_HEADER_PROCEURE;

This means two less sql statements and two less variables to declare. Also change the name of the procedure, you write proceure instead of procedure. I also changed the type of the first parameter of your procedure.

巾帼英雄 2024-08-08 20:44:57

您的 ORA-00984 错误意味着

列名被用在
不允许的表达方式,
例如在 VALUES 子句中
INSERT 语句。

检查 INSERT 的 VALUES 部分以确保没有任何参数是列。

解决该问题后,看看其他错误是否消失。 “PL/SQL: SQL 语句被忽略”似乎是在已经存在另一个错误之后出现的。

Your ORA-00984 error means:

A column name was used in an
expression where it is not permitted,
such as in the VALUES clause of an
INSERT statement.

Check the VALUES part of the INSERT to be sure none of the arguments are columns.

Once you fix that, see if the other error goes away. "PL/SQL: SQL Statement ignored" seems to appear after there's already another error.

空城缀染半城烟沙 2024-08-08 20:44:57

“V_warehouse_id”没有在任何地方声明。

"V_warehouse_id" is no declared anywhere.

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