USING THE parameters in procedures

Hello Experts;


Hello all;


I am trying to run a program by using the parameter of the procedure (IN and OUT IN).

I have an emp table I want to update the details of the column perk.


> > Here is coding > >


1 create or replace procedure emp_salary

2 (id IN emp.eid%type, salary IN OUT emp.esalary%type) IS

number of tmp_sal 3.

4 BEGIN

5. Select esalary in the tmp_sal of the emp where eid = id;

6 If tmp_sal between 10000 and 20000 THEN

7 salary_inout: = tmp_sal * 1.2;

8 tmp_sal between 20001 and 29999 ElseIf THEN

9 salary_inout: = tmp_sal * 1.8;

10 if ELS tmp_sal > 30000 then

11 salary_inout: = tmp_sal * 2.0;

12 * END;

SQL > /.

CAUTION: Procedure created with compilation errors.

SQL > show errors;

PROCEDURAL EMP_SALARY errors:

LINE/COL ERROR

-------- -----------------------------------------------------------------

10/5 PLS-00103: encountered the symbol "IF" when awaits an of the

Next: =. ( @ % ;   The symbol ';' was replaced by 'IF' continue.

12/4 PLS-00103: encountered the symbol ";" when expecting one of the

Suite: If

MY version of DB is: 10.2.0.1

Details of the EMP:


SQL > select * from emp;

| EID | ENAME |  EQUAL |  ESALARY | ECITY |  EPERK |

1 sona |   MBA |  10000 | ********    |            |

Maya 2 |   MCA |  15000 |  **********|            |

3 sony |   MSC |  20000 |  ****         |            |

4 King |   Magnin |  22000 |  **********|             |

5 ford |   Magnin |  40000 | **********|              |

Thanks in advance;

Hello

Sorry, I'm not sure to understand any issue.

8f953842-815B-4D8C-833d-f2a3dd51e602 wrote:

Hello Frank klush.

> Argument datatype >

EID NUMBER

ESALARY VARCHAR2 (15)

Question 1: if I declare esalary is varchar2, how will this affect my argument?

As I have already said, the pay argument is not used.  As long as it is not used, it doesn't matter what type of data it has, but you must call the procedure with an argument of this type of data.

Because you named the "wages" argument, I suppose that it is supposed to contain a value that could come from the emp table esalary column.  If that's what you plan to use it for, then you stated correctly in the procedure, such as emp.esalary%TYPE.  If you change the defifinitin = table one to be esalart (for example) a certain NUMBER (which seems to be a good idea), then you will not have to change the code anything in the procedure, simply recompile the procedure.

Question 2: Ok. Emp_salary procedure requires 2 arguments, if, therefore, here only one argument is passed for example salary only.

What makes sense here?

DECLARE

  1. s emp.esalary%TYPE;
  2. BEGIN
  3. emp_salary (123, s);
  4. END;
  5. /

Thanks in advance, really I put t know this logic. Please explain a little more.

because I learn pl/sql.

Thank you.

Where is that a single argument?

In your original code, zero arguments were passed.

In the anonymous block above, two arguments are passed:

(1) the literal NUMBER 123.  The 1st formal argument, id, has the data type of emp.eid%TYPE, and emp.eid said a NUMBER, so 123 is a value to pass as the argument IN perfectly well.

(2) the variable s.  The 2nd formal argument, salaries, is defined as emp.esalary%TYPE, and that's exactly how s is defined, so s is a perfectly fine variable pass as argument IN OUT.

Tags: Database

Similar Questions

  • SSL mutual authentication using the Oracle stored procedure

    Hello

    DB version:
    Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production

    Is possible to perform mutual authentication SSL uses the Oracle stored procedure?
    I read articles and forums saying that it is not a good approach to call the Web service using the Oracle procedure (and I don't know if it's even possible authentication using procs). But I would like to know if it's possible and how.

    In other is words there a way to incorporate the client certificate information into a procedure that calls a Web service.

    I read the articles to do it in JAVA or .net. But please advice how we can achieve using Oracle procedures.

    Thank you.

    934451 wrote:

    Is possible to perform mutual authentication SSL uses the Oracle stored procedure?

    To learn more. SSL what for?

    Oracle PL/SQL only supports client standard TCP sockets. However, interface for HTTP, Oracle PL/SQL also supports HTTPS - which requires the certificates of authentication of the server to be stored in a portfolio of Oracle web and used during the transmission via HTTPS. See the code example {message identifier: = 1925297} for more details.

    I read articles and forums saying that it is not a good approach to call the Web service using the Oracle procedure (and I don't know if it's even possible authentication using procs).

    Forums and articles written by idiots. For idiots.

    And no, I'm not to embellish my response to this pitch that you met. It is false. It is written by ignorant people who don't know ANYTHING about the use of Oracle and PL/SQL. And feel free to forward my response to these idiots. They find me here if they want to argue...

    As an example of how to call a web service, see {message identifier: = 10158148} and {message: id = 10448611}.

  • How to use the pl/sql procedure

    Hi all,

    How to use pl/sql packages and especially in what situations we are pl/sql, which is the cause of the procedure. Please explain with precision using small example.

    Thanks and greetings

    RAM

    I could tell this at a very high level.

    PL/SQL's procedural extension to SQL. SQL (structured query language) has no procedural capacity. They are executed as a stand-alone statement. When you want to generate a process flow with several SQL statement that you need to have a procedural language that could accommodate your SQL. PL/SQL is something similar to Java and Dot Net in this aspect. Said that PL/SQL is Oracle DB. This has some advantages. The most important thing is that when you have your SQL in PL/SQL oracle maintains its reliance on the object. Any database oracle related so you want to build, then you can consider to PL/SQL as the best way to use process flows.

    PL/SQL provides various methods such as the PROCEDURE, FUNCTION and the PACKAGE. The only thing that race stands is in its ability to modularize your code. So, using the package you can create process workflows that is modular and easy to understand.

  • Use the parameters in the variables

    Hi, please someone can help me with that I searched the forums for more than an hour.

    There is an indication that the code that Dreamweaver creates does not allow more than one recordset that you want to use the same variable parameter, IE a URL parameter in two queries of the recordset object.

    Can someone please help with how I can manually adjust the code so that it works?

    That's what I have so far for a Recordset, that little change?

    Quote:

    < %
    Dim RSsepcsubdetail
    Dim RSsepcsubdetail_cmd
    Dim RSsepcsubdetail_numRows

    Set RSsepcsubdetail_cmd = Server.CreateObject ("ADODB.Command")
    RSsepcsubdetail_cmd. ActiveConnection = MM_conn_vb_pureinfo_STRING
    RSsepcsubdetail_cmd.CommandText = "SELECT * FROM specs_detail WHERE prod_code =?"
    RSsepcsubdetail_cmd. Prepared = true
    RSsepcsubdetail_cmd. Parameters.Append RSsepcsubdetail_cmd. CreateParameter ("param1", 200, 1, 255, RSsepcsubdetail__MMColParam2) ' adVarChar

    Set RSsepcsubdetail = RSsepcsubdetail_cmd. Run
    RSsepcsubdetail_numRows = 0
    % >
  • Creating a fichierXML using the pl/sql procedure.

    Hello

    I have a scenario here. I need to create an XML file, in a format of perticular. Since this is not a well-formed XML format, I am facing questions during the creation of the file.

    The XML file format is as below.

    ARTICLE <>10-B < / SECTION >
    <? XML version = "1.0" encoding = "UTF-8"? >
    < name >
    < first > CBA < / first >
    BCD < middle > < / Middle >
    < Lastt > CBA < / last >
    <>brands
    < > 89 Subj1 < / Subj1 >
    < Subj2 > 89 < / Subj2 >
    < Subj3 > 89 < / Subj3 >
    < / brands >
    < / name >
    <? XML version = "1.0" encoding = "UTF-8"? >
    < name >
    < first > CBA < / first >
    BCD < middle > < / Middle >
    < Lastt > CBA < / last >
    <>brands
    < > 89 Subj1 < / Subj1 >
    < Subj2 > 89 < / Subj2 >
    < Subj3 > 89 < / Subj3 >
    < / brands >
    < / name >
    --
    --
    --
    < SECTIONCNT > 6 < / SECTIONCNT >

    I tried to create the file using the utl functions, but it did not work. I would like to know is there any other approach?


    -Anu

    This should keep you in suspense:

    DECLARE
    
      xml_prolog    clob := '';
      xml_header    clob;
      xml_trailer   clob;
      tmp_xml       clob;
      tmp_file      clob;
    
      cursor c_invoice is
        select xmlelement ("ABCD",
                 xmlelement ("BankSvcRq",
                   ...
                 )
               ).getclobval() as invoice_xml
        from ap_invoices_all ai
        where batch_id = :c_batch_id
        and org_id = :c_ord_id;
    
    BEGIN
    
      -- create the temporary clob :
      dbms_lob.createtemporary(tmp_file, true);
    
      -- fetch the header :
      select xmlelement ("BATCHHEADER", batch_name).getclobval()
      into xml_header
      from ap_batches_all ab
      where ab.batch_id = :c_batch_id
      and ab.org_id = :c_org_id;
    
      -- fetch the trailer :
      select xmlelement ("BATCHTRAILER", count(*)).getclobval()
      into xml_trailer
      from ap_invoices_all ai
      where ai.invoice_id = nvl (:c_invoice_id, ai.invoice_id)
      and ai.batch_id = :c_batch_id
      and ai.org_id = :c_org_id;
    
      -- append header
      dbms_lob.append(tmp_file, xml_header);
    
      -- fetch the invoices and append :
      for r in c_invoice loop
        dbms_lob.append(tmp_file, xml_prolog);
        dbms_lob.append(tmp_file, r.invoice_xml);
      end loop;
    
      -- append trailer :
      dbms_lob.append(tmp_file, xml_trailer);
    
      -- write file to directory :
      dbms_xslprocessor.clob2file(tmp_file, 'TEST_DIR', 'test.dat', nls_charset_id('AL32UTF8'));
      dbms_lob.freetemporary(tmp_file);
    
    END;
    /
    
  • Need to check delays in update of 1000 lines using the PL/SQL procedure.

    Hi all

    I'm new to PL/SQL. I need your help to build a procedure that executes the following statement and follows the time of update of 1000 rows. This is to check the performance of the database. I need to print the timestamp of start before the update and end timestamp after update. I need to do for the 1000 lines. The statement that will be used in the procedure is:

    SELECT

    'UPDATE XXAFL_MON_FACTS_F SET TASK_WID =' | NVL (TO_CHAR (TASK_WID), 'NULL') |', EXECUTION_PLAN_WID =' | NVL (TO_CHAR (EXECUTION_PLAN_WID), 'NULL').

    ', DETAILS_WID =' | NVL (TO_CHAR (DETAILS_WID), 'NULL') |', SOURCE_WID =' | NVL (TO_CHAR (SOURCE_WID), 'NULL') |', TARGET_WID = ' | NVL (TO_CHAR (TARGET_WID), 'NULL').

    ', RUN_STATUS_WID =' | NVL (TO_CHAR (RUN_STATUS_WID), 'NULL') |', SEQ_NUM =' | NVL (TO_CHAR (SEQ_NUM), 'NULL') |', NAME = "' | NVL (TO_CHAR (NAME), 'NULL').

    "', NO_POSITION =" ' | NVL (TO_CHAR (INSTANCE_NUM), e ') | " ', INSTANCE_NAME = "' | NVL (TO_CHAR (INSTANCE_NAME), 'NULL').

    "', TYPE_CD =" ' | NVL (TO_CHAR (TYPE_CD), e ') | " ', STATUS_CD = "' | NVL (TO_CHAR (STATUS_CD), e ') | " ', START_TS =' | NVL (TO_CHAR (START_TS), 'NULL').

    ', END_TS =' | NVL (TO_CHAR (END_TS), 'NULL') |', DURATION = ' | NVL (TO_CHAR (DURATION), 'NULL') |', STATUS_DESC = "' | NVL (TO_CHAR (STATUS_DESC), 'NULL').

    "', DBCONN_NAME =" ' | NVL (TO_CHAR (DBCONN_NAME), e ') | " ', SUCESS_ROWS =' | NVL (TO_CHAR (SUCESS_ROWS), 'NULL').

    ', FAILED_ROWS =' | NVL (TO_CHAR (FAILED_ROWS), 'NULL') |', ERROR_CODE = ' | NVL (TO_CHAR (ERROR_CODE), 'NULL') |', NUM_RETRIES =' | NVL (TO_CHAR (NUM_RETRIES), 'NULL').

    ', READ_THRUPUT =' | NVL (TO_CHAR (READ_THRUPUT), 'NULL') |', LAST_UPD = ' | NVL (TO_CHAR (LAST_UPD), 'NULL') |', RUN_STEP_WID = "' | NVL (TO_CHAR (RUN_STEP_WID), 'NULL').

    "', W_INSERT_DT = ' | NVL (TO_CHAR (W_INSERT_DT), 'NULL') |', W_UPDATE_DT = ' | NVL (TO_CHAR (W_UPDATE_DT), 'NULL').

    ', START_DATE_WID =' | NVL (TO_CHAR (START_DATE_WID), 'NULL') |', END_DATE_WID = ' | NVL (TO_CHAR (END_DATE_WID), 'NULL') |', START_TIME =' |

    NVL (TO_CHAR (START_TIME), 'NULL') |', END_TIME =' | NVL (TO_CHAR (END_TIME), 'NULL'). "WHERE INTEGRATION_ID ="' | INTEGRATION_ID | " « ; »  OF XXAFL_MON_FACTS_F;

    The above query creates instructions of update that must be executed 1000 times and the time required to update the 1000 lines should be followed.

    Thanks in advance!

    Code horribly wrong!

    Why this approach?

    Dynamic SQL is almost NEVER needed in PL/SQL. And if you think it's necessary and taking into account what is displayed as being problems here, you have a 99% chance of being wrong.

    This 1% where dynamic SQL is necessary, he will WITH bind variables to create shareable SQL, decrease memory requests, decrease the likelihood of a fragmented shared reel and decrease the burning CPU cycles on hard analysis.

    An example below. Your approach is the 1st. One that is slower than the correct approach to 37 (x_!) ...

    SQL> create table t ( n number );
    
    Table created.
    
    SQL>
    SQL> var ITERATIONS number;
    SQL> exec :ITERATIONS := 100000;
    
    PL/SQL procedure successfully completed.
    
    SQL>
    SQL>
    SQL> TIMING START "INSERTs using Hard Parsing"
    SQL> declare
      2          i      integer;
      3  begin
      4          for i in 1..:ITERATIONS
      5          loop
      6                  execute immediate 'insert into t values ('||i||')';
      7          end loop;
      8          commit;
      9  end;
    10  /
    
    PL/SQL procedure successfully completed.
    
    SQL> TIMING SHOW
    timing for: INSERTs using Hard Parsing
    Elapsed: 00:02:00.33
    SQL>
    SQL> TIMING START "INSERTs using Soft Parsing"
    SQL> declare
      2          i      integer;
      3  begin
      4          for i in 1..:ITERATIONS
      5          loop
      6                  execute immediate 'insert into t values ( :1 )' using i;
      7          end loop;
      8          commit;
      9  end;
    10  /
    
    PL/SQL procedure successfully completed.
    
    SQL> TIMING SHOW
    timing for: INSERTs using Soft Parsing
    Elapsed: 00:00:06.06
    SQL> drop table t;
    
    Table dropped.
    
    SQL> create table t( n number );
    
    Table created.
    
    SQL>
    SQL>
    SQL> TIMING START "INSERTs using a single parse and repeatable statement handle "
    SQL> declare
      2          i      integer;
      3  begin
      4          for i in 1..:ITERATIONS
      5          loop
      6                  insert into t values ( i );
      7          end loop;
      8          commit;
      9  end;
    10  /
    
    PL/SQL procedure successfully completed.
    
    SQL> TIMING SHOW
    timing for: INSERTs using a single parse and repeatable statement handle
    Elapsed: 00:00:04.81
    SQL>
    
  • RNR4000 password recovery (Readynas 1100) failed using the OS install procedure

    I followed the procedure to perform a password recovery by pressing the reset button while you turn on/off the system. Now the NAS is stuck saying "File System Check" in startup RAIDar. RAIDar shows correct, model host name and the IP address has reset to 192.168.168.168. All road lights are green. How can I recover this system now that it does not start? Should I make a boot USB or boot TFTP?

    What version of the firmware?

    Also note that for the 1100, the default password is netgear1 if running RAIDiator 4.x or so in running RAIDiator 3.x it is infrant1

  • Cannot create Materialized View using the PL/SQL procedure

    Hello

    I have a question related to the creation of materialized view.
    I have a stored procedure that creates the materialized view. When you try to perform this procedure, I get not enough privileges error: ORA-01031.

    When I run the content of this procedure as a PL/SQL block anonymous their materialized view is created without any complications.
    Can you please advice me on this subject?
    It is even possible to create a materialized view in the stored procedure as I found no info on this subject.

    Thank you
    Petr

    Hi chudapet,

    Whenever you make in procedure, you must have direct subsidies and not through a role.

    Most likely the grant to create a materialized view is available via a role to your username.
    Assign a direct grant to the user:

    grant create materialized view to scott;
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
    
  • How can I change the brightness of the screen without using the fn key?

    I want to know how to increase the brightness of the screen using the parameters of the computer, not a keyboard.

    Thank you

    Hello

    1. What is the brand and model of your computer?

    2. is it a laptop or desktop?

    I suggest to read the following steps and check if it helps.

    a. Click Start, click Control Panel.

    b. Select "Appearance and themes" when prompted in the Panel 'category view. " If you are in "Classic Mode", choose the "View" icon

    c. Select the 'Settings' tab in the display properties window.

    d. Select the button "Advanced" at the bottom of the window. This will take you to the properties of your screen.

    e. click on the tab "colors".

    f. Select the brightness scale and push or pull until you are satisfied with the brightness of your screen.

    g. Press 'OK' to adjust the brightness of your.

    More information consult:

    Adjust the brightness and contrast of your monitor: http://windows.microsoft.com/en-US/windows-vista/Adjust-your-monitors-brightness-and-contrast
    Note: There is for Windows XP as well.

  • Quiz jump when you use the outline Panel

    I have an author wishing to use the map view. The author has figured out that if the learner uses the part of the plan, they bypass the multiple questionnaires within the presentation.

    Using the parameters of the required quiz did not.

    Any ideas?

    In fact, the author wanted the part of the plan to display. But the author feared that the learner would use the Panel contour to navigate and do not enter the quiz (as the questionnaires were not in the outline Panel.)

    No worries now... I got another contact advice me to:

    1. go in Breeze, Quiz Manager, then press [edit Quiz settings].
    2. check Show Quiz slides in the outline

    In this way, the questionnaire slides will appear in the outline Panel.

    Thanks for your advice!

    Ingrid

  • How to use the nocopy with java stored procedures parameters

    
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for Linux: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    
    

    I'm a PL/SQL programmer, but not a Java programmer. I have the following java function that does what it's supposed to add a pdf at the end of another pdf document:

    import oracle.sql.BLOB;
    import org.apache.pdfbox.util.PDFMergerUtility;
    import oracle.jdbc.OracleConnection;
    import oracle.jdbc.driver.OracleDriver;
    import java.io.OutputStream;
    
    public class PDFUtilities {
    public static BLOB appendPDF(BLOB pdfdoc1, BLOB pdfdoc2) throws Exception {
           
            //create a connection object to the current instance
              OracleConnection conn = (OracleConnection)new OracleDriver().defaultConnection();
            //create the output blob using the connection
              BLOB outPDF = BLOB.createTemporary(conn, true ,BLOB.DURATION_SESSION);
            //create an output stream to the output blob
              OutputStream os = outPDF.setBinaryStream(0);               
            //instantiate the pdf merger utility
              PDFMergerUtility mergerUtility = new PDFMergerUtility();       
            //connect the merger to the output stream
              mergerUtility.setDestinationStream(os);
            //stream from each input blob into the merger utility
              mergerUtility.addSource(pdfdoc1.getBinaryStream());
              mergerUtility.addSource(pdfdoc2.getBinaryStream());
            //merge the 2 input pdfs
              mergerUtility.mergeDocuments();             
            //do not close the output stream
            //return the blob
            return outPDF;
        }
    
    }
    

    CREATE OR REPLACE package PDFTOOLS.pkg_pdf_utilities
    as
    function f_get_merged_pdf (
              pi_pdf1       blob
            , pi_pdf2    blob
      )
      return blob;
    end pkg_pdf_utilities;
    /
    
    CREATE OR REPLACE package body PDFTOOLS.pkg_pdf_utilities
    as
    function f_get_merged_pdf (
              pi_pdf1       blob
            , pi_pdf2    blob
      )
      return blob
      as language java name 
      'com.mycode.pdftools.PDFUtilities.appendPDF(oracle.sql.BLOB, oracle.sql.BLOB) return oracle.sql.BLOB';
    end PDFTOOLS.pkg_pdf_utilities;
    /
    

    It's very basic, but doesn't seem to work. However, I want to my function from PL/SQL to a procedure that looks like this:

    CREATE OR REPLACE package PDFTOOLS.pkg_pdf_utilities
    as
    procedure sp_append_pdf (
              pio_pdf2append2   IN OUT NOCOPY blob
            , pio_pdf2append   IN OUT NOCOPY blob
      )
    end pkg_pdf_utilities;
    /
    

    What is important, what I'm trying to do is to NOCOPY the BLOBs. Otherwise, I have to read my PDF files into 2 BLOBs and create a 3rd blob as output. I prefer to be able to keep the pio_pdf2append2 as the final output. What I actually do call thing in a loop to gradually add a PDF file to a big. I'm not linking this in one operation because of concerns over the use of the system and because the pdfbox library java has would have been question after 850 in PDF format, which is not completely unrealistic in my approach.

    How could I achieve this?

    Post edited by: Pollocks01 only formatted code blocks because atlassian {code} tags didn't work.

    Passage of an argument as input/OUTPUT requires the mapping to a Java array.

    Simplified example that adds one FOR the other:

    create or replace and compile java source named blob_appender_src as
    import oracle.sql.BLOB;
    import java.sql.SQLException;
    import java.io.OutputStream;
    import java.io.InputStream;
    import java.io.IOException;
    
    public class BLOBAppender {
        public static void run (BLOB[] p1, BLOB p2) throws SQLException, IOException { 
    
            InputStream is = p2.getBinaryStream();
            OutputStream os = p1[0].setBinaryStream(p1[0].length()+1);                
    
            byte[] buffer = new byte[1024];
            int len;
            while ((len = is.read(buffer)) != -1) {
                os.write(buffer, 0, len);
            }
            os.close();
            is.close();
        }
    }
    
    create or replace procedure blob_append (
      p_lob1  in out nocopy blob
    , p_lob2  in            blob
    )
    as language java name 'BLOBAppender.run(oracle.sql.BLOB[], oracle.sql.BLOB)' ;
    /
    
    SQL> declare
      2    p_lob1  blob := utl_raw.cast_to_raw('ABC');
      3    p_lob2  blob := utl_raw.cast_to_raw('DEF');
      4  begin
      5    blob_append(p_lob1, p_lob2);
      6    dbms_output.put_line(utl_raw.cast_to_varchar2(p_lob1));
      7  end;
      8  /
    
    ABCDEF
    
    PL/SQL procedure successfully completed.
    
  • Appeal procedure in another procedure using the Out parameter slider - lesson

    Hello

    I am new to Oracle development so first I wonder if it is a good place with a simple way of the of on how to create stored procedures?  I'm looking for the most part at this stage for a quick read.

    Second, currently have hacked and slashed my way into getting one built.  It has 3 parameters and an output parameter sys_refcursor.  This procedure works.

    I want to have another created procedure that will call the above procedure and loop through each row in the setting out and write to a file.  Can someone point me to an example of this by any chance?

    Thanks for the help.

    Hello

    e28d78d3-c6c6-4BCE-b14f-0f6bf26fa17c wrote:

    Thanks for the reply.

    Here's what I have, but I'm getting many errors.  When I seem to fix one that I get a new one. Kind of like what it show me all questions vs one question at a time.  I never know if I create another error of my attempts at fixing what, in my view, could be the problem.  In any case, something to get used to.

    When you do any type of programming, take baby steps.  Write less code as possible, test what you wrote ' worm and, if it contains errors, correct them and test again.

    The PL/SQL compiler tries to show all errors, but often it is impossible to say what is a separate mistake, and which is a consequence of a previous error.  For example, the DECLARE statements in your code are perfectly valid PL/SQL statements, but they are the mistakes in the sense that they are not what you think, and you may not use them.  PL/SQL does not know that (I don't really know that, either, but I'm willing to guess in this case).  The works of compiler on the explanation that you really wanted to say SAID, until what it becomes obvious, maybe several lines later, that something makes no sense, but at this time, there is no way he could say that the undesirable DECLARE was the cause.

    So here is where I am stuck currently.  What I want should first, run the stored procedure and I think I do as you suggest.  Which returns data in the output parameter, which is of type sys_refcursor.  I think I would need to loop through each element that cursor and output to the file using the dbms_output you reference and like I did below.  This should be it.  Sounds simple enough, but it's where some of the basics for me.

    For example, by creating the procedure some examples have the name of the procedure and then some "AS", "IS".  When use the beginning and the end and when not I need?

    There is no difference betwwen

    CREATE PROCEDURE... AS and

    CREATE PROCEDURE... Use IS the one you prefer.  You must always one or the other, however.

    PL/SQL is written in blocks.  The basic structure of a block is

    DECLARE - optional, sometimes involved

    ...

    BEGIN

    ...

    -Optional EXCEPTION; forget it for now

    ...

    END;

    Almost all of the PL/SQL code is part of a block.  In fact, you could argue that anything not in a block isn't really PL/SQL.  (For example, CREATE PROCEDURE is really an SQL, PL/SQL not, it indicates the SQL that some PL/SQL compiler is coming.)

    You should always BEGIN and END keywords in a PL/SQL block; None is never optional.

    I think I'm doing the for loop correctly but I get an error on the portion of loop-end.  It is a part of these simple things that become I think that.

    That's what I have:

    CREATE OR REPLACE PROCEDURE APPS.boact_report_3

    AS

    DECLARE v_cur SYS_REFCURSOR;

    DECLARE v_file_out UTL_FILE.file_type;

    BEGIN

    I said earlier, DECLARED may be implied.  It's one of those places if there is nothing after CREATE PROCEDURE... IS and before STARTING, it is supposed to be a statement.

    You can have as many statements (0, 1, 2 or more) that you want in this section of the statement.  The semicolon at the end of each of them is all the separation you need each other; you don't need any keyword as STATED.

    Open the v_cur for

    bo_report (p_sv_id, p_start_date, p_end_date, out v_cur);  -stored procedure that girls v_cur witch is a sys_refcursor parameter.  It works

    END;

    BEGIN

    Don't forget, how to call a procedure is

    bo_report (x, y, z);

    not

    bo_report (x, y, z OUT);

    The key words are only necessary (and only used) in the declaration of a procedure, not in his appeal.  When you create a procedure, you decide if each argument is going to be an argument IN, an OUT argument, or IN OUT argument, and you tell the compiler that you decide.  When you call a procedure, you have no choice; each argument is IN, OUT or IN OUT has already been decided, and suffice to say compiling what are the variables (or expressions) that you use to play these predetermined roles.

    Dbms_output.put_line ('Date: ');

    v_file_out: =.

    UTL_FILE.fopen (' / public/scripts/smorau02 ', 'w_act.csv', 'W');

    FOR x IN v_cur

    LOOP

    () UTL_FILE.put_line

    v_file_out,

    x.cl_num | ','

    || x.wa_id | ','

    || x.Description | ','

    || x.a_date | ','

    || x.a_by | ','

    || x.v_Name | ','

    || x.SITE_NAME | ','

    || x.stage | ','

    || x.in_queue);

    END LOOP;

    UTL_FILE.fclose (v_file_out);

    END;

    Thanks again for the help.

    You have not to send the code to bo_report, so I can't run the procedure.  I do not notice any obvious mistakes immediately superior.

  • Using the procedure with multiple output variables in a query

    Hello

    We have a process that takes time, which returns 4 variables as out parameters:
    procedure calc_values(id in number, val1 out number, val2 out number, val3 out number, val4 out number) is
    The id uniquely identifies a product in our database.

    I would use it in a query (or view), in the form
    select s.id, val1, val2, val3, val4 from something s, product_table p
    where s.id = p.id
    I tried the following approach, but I'm kinda stuck

    define the type
    define an array of this type
    write a wrapper function that calls this procedure and returns the results as a table
    * the PivotTable in columns
    * join this with the product table

    It's like I'm on the wrong track, I'm struggling to retrieve the id of the product table in the wrapper function.

    Is there a better approach for this? I'm on oracle 10g

    Thank you!

    Rob

    Below is my interpretation of what you were asked to do. I don't really know what you want to do or what you need to do.

    CREATE TYPE prod_vals_def
    AS OBJECT
     (VAL1      NUMBER,
      VAL2      NUMBER,
      VAL3      NUMBER,
      VAL4      NUMBER
    );
    
    create or replace
    TYPE   prod_vals_tab
    AS TABLE OF prod_vals_def;
    
    CREATE FUNCTION pvals (p_prod_id  NUMBER)
    RETURN prod_vals_tab PIPELINED
    AS
    
      TYPE         ref0 IS REF CURSOR;
      cur0         ref0;
      out_rec      prod_vals_def
                := prod_vals_def(NULL,NULL,NULL,NULL);
    
    BEGIN
      -- CASE replacing SELECT against table I'm not going to create
      CASE p_prod_id
        WHEN 1 THEN
          out_rec.val1 := 1;
          out_rec.val2 := 2;
          out_rec.val3 := 3;
          out_rec.val4 := 4;
        WHEN 2 THEN
          out_rec.val1 := 2;
          out_rec.val2 := 3;
          out_rec.val3 := 4;
          out_rec.val4 := 5;
        WHEN 3 THEN
          out_rec.val1 := 3;
          out_rec.val2 := 4;
          out_rec.val3 := 5;
          out_rec.val4 := 6;
        WHEN 4 THEN
          out_rec.val1 := 4;
          out_rec.val2 := 5;
          out_rec.val3 := 6;
          out_rec.val4 := 7;
        ELSE
          out_rec.val1 := 0;
          out_rec.val2 := 0;
          out_rec.val3 := 0;
          out_rec.val4 := 0;
      END CASE;
      PIPE ROW(out_rec);
    END pvals;
    
    WITH s_tab AS
      (SELECT 1 AS prod_id FROM dual
       UNION ALL
       SELECT 2 AS prod_id FROM dual
       UNION ALL
       SELECT 3 AS prod_id FROM dual
       UNION ALL
       SELECT 4 AS prod_id FROM dual
      )
    SELECT s.prod_id, p.val1, p.val2, p.val3, p.val4
    FROM   s_tab s,
           TABLE(pvals(s.prod_id)) p
    
    PROD_ID  VAL1     VAL2     VAL3     VAL4
    -------- -------- -------- -------- --------
    1        1        2        3        4
    2        2        3        4        5
    3        3        4        5        6
    4        4        5        6        7     
    
  • How to swap two values without using the third variable using the procedure

    How to exchange the two values without using the third variable using the procedure?

    In a procedure using two mode we pass two values A = x and B = y, and let us pass parameters to receive the output has A = y and B = x without using the third variable

    Published by: Millar on August 19, 2012 11:23

    Your question doesn't seem wise. As written, there is no reason to a third variable, just

    CREATE OR REPLACE PROCEDURE(
      x IN number,
      y IN number,
      a OUT number,
      b OUT number
    )
    AS
    BEGIN
      a := y;
      b := x;
    END;
    

    If it's an interview question, I suspect that the intention was that you had two settings IN OUT and you wanted to swap the values without the help of a third variable.

    Justin

  • Call the PL/SQL procedure with different parameters?

    I use PL/SQL for web development. I have a page of PL/SQL which collects information and returns the user off site with one return url (another PL/SQL procedure).

    I have the return procedure with every documented return variable (default null) in order to always take the return. However, there are (reported... cannot reproduce because of the nature of the business) cases where a 404 error is returned because of the incompatibility of parameter.

    Is it possible to proceed regardless of the parameters? Someone at - it suggestions?

    Thank you!

    user2960509 wrote:

    My problem is that they sometimes send back of settings that do not match what I expect.

    Use the interface "+ flexible +" mod_plsql - see the Oracle® HTTP Server mod_plsql user's Guide for the documented details.

    The signature of the procedure parameter is as follows (it is called by mod_plsql using tables of name value pairs):

    create or replace procedure Scott.MyWebProc( name_array owa.vc_arr, value_array owa.vc_arr) is
    ...
    

    In your code, you just browse the berries to get the name values passed query string. You can even filled an associative array in your code (a table indexed by string and no number, where the index string represents the name of param)-this approach can make it pretty easy for the code make reference to a parameter, with little effort on your part to provide an interface to query by name for code to get the value of a parameter name.

    To enable the flexible (aka parameter 2) call interface, precede the call to web with an exclamation character. For example

    http://my-webserbver.my-domain.com/pls/dad/!scott.mywebproc?name-1=val-1&name-2=val-2..,name-n=val=n
    

Maybe you are looking for