Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7765059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:04:48+00:00 2026-06-01T15:04:48+00:00

I need to pass multiple rows to a stored procedure. Can I use a

  • 0

I need to pass multiple rows to a stored procedure. Can I use a ref cursor? because I have tried the following:

Inside my package I have:

TYPE FACT_VND_RECORD
IS
  RECORD
  (
    COD_NOMCPDT P6PCM2_PARMCMS.COD_NOMCPDT%TYPE,
    LIB_LIBNOMCPDT P6PCM2_PARMCMS.LIB_LIBNOMCPDT%TYPE,
    DHS_MAJ P6PCM2_PARMCMS.DHS_MAJ%TYPE,
    LIB_AUTH_MAJ P6PCM2_PARMCMS.LIB_AUTH_MAJ%TYPE );

TYPE FACT_VND_CURSOR
    IS
      REF
      CURSOR
        RETURN FACT_VND_RECORD;

and 2 procedures:

PROCEDURE REC_FACT_VND(
      P_IN_NUM_VND   IN OUT P6PCM2_PARMCMS.NUM_VND%TYPE,
      P_OUT_FACT_VND IN OUT FACT_VND_CURSOR,
      P_OUT_CODE_RET OUT INTEGER,
      P_OUT_MSG_ERR OUT VARCHAR2);

  PROCEDURE MAJ_FACT_VND(
      P_IN_NUM_VND   IN OUT P6PCM2_PARMCMS.NUM_VND%TYPE,
      P_IN_FACT_VND IN OUT FACT_VND_CURSOR,
      P_OUT_CODE_RET OUT INTEGER,
      P_OUT_MSG_ERR OUT VARCHAR2); 

Recieves the previously filled cursor and does something with the data.

I use these 2 calls; The first one works OK, I can see the data inside ref cursor C1 and then I try to use it.

C1 PACK_REC_FACT_VND.FACT_VND_CURSOR;
--other definitons
      PACK_REC_FACT_VND.REC_FACT_VND(NUM_VND,C1,COD_RET,MSG_ERR);
    PACK_REC_FACT_VND.MAJ_FACT_VND(NUM_VND,C1,COD_RET,MSG_ERR);

I can’t iterate over the data because it is undefined:
(Code from second procedure)

LIGNE_TAUX PACK_REC_FACT_VND.FACT_VND_RECORD;
    BEGIN
      DELETE FROM P6PCM2_PARMCMS WHERE NUM_VND=P_IN_NUM_VND;
      FOR LIGNE_TAUX IN P_IN_FACT_VND
      LOOP
        INSERT
        INTO P6PCM2_PARMCMS VALUES
          (
            P_IN_NUM_VND,   
LIGNE_TAUX.COD_NOMCPDT, 
LIGNE_TAUX.LIB_LIBNOMCPDT, 
LIGNE_TAUX.DHS_MAJ, 
LIGNE_TAUX.LIB_AUTH_MAJ);
      END LOOP;

Error(48,21): PLS-00221: 'P_IN_FACT_VND' is not a procedure or is undefined

Or should I switch to TABLE OF RECORD?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T15:04:49+00:00Added an answer on June 1, 2026 at 3:04 pm

    We can’t use ref cursors like that; we need to use the explicit cursor syntax. Try this (warning: untested code!):

            LIGNE_TAUX PACK_REC_FACT_VND.FACT_VND_RECORD;
        BEGIN
          DELETE FROM P6PCM2_PARMCMS WHERE NUM_VND=P_IN_NUM_VND;
    
          LOOP
             fetch P_IN_FACT_VND   into LIGNE_TAUX; 
             exit when P_IN_FACT_VND%notfound;
            INSERT
            INTO P6PCM2_PARMCMS VALUES
              (
                P_IN_NUM_VND,   
                LIGNE_TAUX.COD_NOMCPDT, 
                LIGNE_TAUX.LIB_LIBNOMCPDT, 
                LIGNE_TAUX.DHS_MAJ, 
                LIGNE_TAUX.LIB_AUTH_MAJ);
          END LOOP;
    
      close P_IN_FACT_VND;
    

    However, get better performance if you fetch the records into a collection. Something like this:

            type LIGNE_TAUX_NT is table of PACK_REC_FACT_VND.FACT_VND_RECORD;
            LIGNE_TAUX_COLL LIGNE_TAUX_NT;
        BEGIN
          DELETE FROM P6PCM2_PARMCMS WHERE NUM_VND=P_IN_NUM_VND;
    
          fetch P_IN_FACT_VND bulk collect  into LIGNE_TAUX_COLL; 
          close P_IN_FACT_VND;
    
          -- while we're at it why not use the more efficient FORALL syntax 
          -- to perform the inserts?
    
    
          forall idx in LIGNE_TAUX_COLL.first() .. LIGNE_TAUX_COLL.last()
                INSERT
               INTO P6PCM2_PARMCMS VALUES
                  (
                P_IN_NUM_VND,   
                LIGNE_TAUX_COLL(idx).COD_NOMCPDT, 
                LIGNE_TAUX_COLL(idx).LIB_LIBNOMCPDT, 
                LIGNE_TAUX_COLL(idx).DHS_MAJ, 
                LIGNE_TAUX_COLL(idx).LIB_AUTH_MAJ);
    

    Find out more.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to have a command handler for a ToggleButton that can take multiple
i have an update query where i need to pass multiple parameter. Please guide
I have an issue where I need to pass multiple criteria for a single
I need to pass multiple arguments to a function that I would like to
how do you pass a multiple serializable byte[]? I assume i can't pass it
I have a DataGridView that is populated with 4 columns and multiple rows of
Right now I have class MyParamClass { all the parameters I need to pass
I need to pass multiple parameters dynamically to my ascx file through the image
On my asp.net mvc page I need to render multiple images that are stored
How to set multiple Content-Types? I have to pass an array to request body.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.