PL/SQL - Using procedure parameters inside cursor definition.

Hello all,
I'm currently working on a procedure that has a cursor in it. The only parameter passed in when calling it is a table name (TABLE_NAME parameter) which I want to use as a string in a LIKE comparison inside the defined cursor.
Here is the code:
PROCEDURE PURGE (TABLE_NAME IN VARCHAR)
    IS
        CURSOR TABLES_CUR
        IS
            SELECT
                OBJECT_NAME
            FROM
                SYS.DBA_OBJECTS
            WHERE
                OWNER = 'MYSCHEMA'
                AND OBJECT_TYPE = 'TABLE'
                AND OBJECT_NAME like 'TABLE_NAME_%'
                AND CREATED = sysdate-3;
        TABLE_DEL TABLES_CUR%rowtype;
    BEGIN
        OPEN TABLES_CUR;
        LOOP
            FETCH TABLES_CUR INTO TABLE_DEL;
            EXIT WHEN TABLES_CUR%NOTFOUND;
            DBMS_OUTPUT.PUT_LINE('TABLE_DEL');
        END LOOP;
        CLOSE TABLES_CUR;
    END PURGE;However TABLE_NAME parameter value is not being interpolated, so cursor ends up returning nothing.
What must I do to get it interpolated and not interpreted as a literal string?
Thanks in advance.
Frank.

Alex Nuijten wrote:
OBJECT_NAME like your_parameter||'%'
That's it, thanks a lot Alex.
I'm such a stupid.. :(

Similar Messages

  • Can use aggregate functions inside cursor

    Hi
    Can i use aggergate functiions inside cursors because i was getting the below error message when try to execute the below procedure.
    I need following thins to implement procedure ,When pass 100 through parameter ,that will check the total count on the table if matches delete the records from table .
    create or replace procedure p12(p_count number) is
    cnt number :=0;
    tot number :=0;
    cursor c1 is select count(1),c2,rowid from t1 where
    group by c2,rowid;
    begin
    for y in c1
    loop
    delete from t1 where row_id=y.rowid;
    cnt:=y.cnt+1;
    tot:=y.tot+1;
    if mod(y.cnt,100)=0
    then
    dbms_output.put_line(y.tot||'total records deleted');
    end if;
    end loop;
    end;
    4/14 PL/SQL: SQL Statement ignored
    4/55 PL/SQL: ORA-00936: missing expression
    Thanksinadvance
    MR

    I was still getting the error
    create or replace procedure p12(p_count number) is
    cnt number :=0;
    tot number :=0;
    cursor c1 is select count(1),c2,rowid from t1
    where c2=100
    group by c2,rowid;
    begin
    for y in c1
    loop
    delete from t1 where rowid=y.rowid;
    cnt:=y.cnt+1;
    tot:=y.tot+1;
    if mod(y.cnt,100)=0
    then
    dbms_output.put_line(y.tot||'total records');
    end if;
    end loop;
    end;
    LINE/COL ERROR
    11/1 PL/SQL: Statement ignored
    11/8 PLS-00302: component 'CNT' must be declared
    12/1 PL/SQL: Statement ignored
    12/8 PLS-00302: component 'TOT' must be declared
    13/1 PL/SQL: Statement ignored

  • How to create an External Content Type with SQL Stored Procedures Parameters and query it in a SharePoint App

    Hi,
    I'm new to SharePoint 2013 I want to be able to query a MSSQL database from a SharePoint App I have tried to create an External Content Type (ECT) which is produced from a MSSQL stored Procedure, this procedure has several parameters which are needed to
    filter the data correctly.  From here I want to produce an external list which I can then query from a c# SharePoint app.  If I leave the filters in the ECT null then the list is of course empty or if enter a default values the results are limited
    for the app to query so are no good.
    I want to dynamically pass values to the ECT when querying from the app, is this not possible.  Should I just be returning everything in an external list and then letting the query in the app filter the data, this seems inefficient?
    Is this the best way to do this or should I be doing this differently?
    Please can someone point me in the right direction.
    Thanks

    Hi Pandra801,
    When you create a the external content type, please try to add a filter based on your select statement.
    http://arsalkhatri.wordpress.com/2012/01/07/external-list-with-bcs-search-filters-finders/
    Or, try to create a stored procedure based on your select statement, then create ECT using the SQL stored procedure.
    A step by step guide in designing BCS entities by using a SQL stored procedure
    http://blogs.msdn.com/b/sharepointdev/archive/2011/02/10/173-a-step-by-step-guide-in-designing-bcs-entities-by-using-a-sql-stored-procedure.aspx
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • Passing null to Optional SQL ServerStored Procedure parameters for Query

    Has anyone been able to pass null to a SQL Server Stored Procedure in a query for Interactive Reporting. I have a procedure that modifies the sql statement if the user passes additional filter data and I want to pass null to it. It works great if I use in reporting services, but I am being forced to us IR. Any help would be appreciated.
    And just a point of issue...why do I have to use an ODBC driver to see or use my stored procedure!! Sorry couldn't resist!
    Edited by: BISolutionBuilders on Jun 29, 2009 10:08 PM

    Why dynamic sql ? It can be static, you are just passing the filter value

  • Unable to use the values returned by a PL/SQL stored procedure in a XSQL page

    Hi,
    I've been messing around with XML and XSQL in particular. I was trying to write a xsql page to display a report with account totals...I have the following .xsql which calls a PL/SQL stored procedure :
    <?xml version="1.0"?>
    <xsql:query connection="pfcdm" xmlns:xsql="urn:oracle-xsql">
    <xsql:set-session-param name="zasset_total" value="100">
    <xsql:dml connection="pfcdm">
    rraman.sp_vw_id(zasset_total,zinvm_total,zmkt_val);
    </xsql:dml>
    </xsql:set-session-param>
    select 'Asset total is {@zasset_total}' as "ASSET_TOTAL" from dual
    </xsql:query>
    My procedure sp_vw_id returns the values that it should. But, I am not sure how to declare variables within a page, and to output the return values. There is very scanty documentation on the usage of <xsql:dml> or <xsql:ref-cursor-function>.
    Any response would be greatly appreciated.
    Thanks,
    Raja

    Here is the example from the Oracle9i (complete rewrite) of the XSQL Chapter in our Oracle documentation.
    Question
    I using <xsql:dml> to call a stored procedure which has one OUT parameter, but I was not able to see any results. The executed code results in the following statement:
    <xsql-status action="xsql:dml" rows="0"/>
    Answer
    You cannot set parameter values by binding them in the position of OUT variables in this release using <xsql:dml>. Only IN parameters are supported for binding. You can create a wrapper procedure that constructs XML elements using the HTP package and then your XSQL page can invoke the wrapper procedure using <xsql:include-owa> instead.
    For an example, suppose you had the following procedure:
    CREATE OR REPLACE PROCEDURE addmult(arg1 NUMBER,
    arg2 NUMBER,
    sumval OUT NUMBER,
    prodval OUT NUMBER) IS
    BEGIN
    sumval := arg1 + arg2;
    prodval := arg1 * arg2;
    END;You could write the following procedure to "wrap" it, taking all of the IN arguments that the procedure above expects, and then "encoding" the OUT values as a little XML datagram that you print to the OWA page buffer:
    CREATE OR REPLACE PROCEDURE addmultwrapper(arg1 NUMBER, arg2 NUMBER) IS
    sumval NUMBER;
    prodval NUMBER;
    xml VARCHAR2(2000);
    BEGIN
    -- Call the procedure with OUT values
    addmult(arg1,arg2,sumval,prodval);
    -- Then produce XML that encodes the OUT values
    xml := '<addmult>'&#0124; &#0124;
    '<sum>'&#0124; &#0124;sumval&#0124; &#0124;'</sum>'&#0124; &#0124;
    '<product>'&#0124; &#0124;prodval&#0124; &#0124;'</product>'&#0124; &#0124;
    '</addmult>';
    -- Print the XML result to the OWA page buffer for return
    HTP.P(xml);
    END;This way, you can build an XSQL page like this that calls the wrapper procedure:
    <page connection="demo" xmlns:xsql="urn:oracle-xsql">
    <xsql:include-owa bind-params="arg1 arg2">
    BEGIN addmultwrapper(?,?); END;
    </xsql:include-owa>
    </page>This allows a request like:
    http://yourserver.com/addmult.xsql?arg1=30&arg2=45
    to return an XML datagram that reflects the OUT values like this:
    <page> <addmult><sum>75</sum><product>1350</product></addmult>
    </page>

  • PL/SQL Using Cursor to Update Another Cursor

    Dear all,
    i am trying to do the below process ..i just wrote this code as an example ..can anyone give me idea how to acheive
    this .. i attached the error msg i am getting below ..
    CREATE OR REPLACE PROCEDURE EMP_COMPARE
    AS
    CURSOR c_emp_err
    IS
    SELECT EMPNO FROM EMP_ERR;
    CURSOR c_emp_cur
    IS
    SELECT EMPNO,FRST_NAME,LAST_NAME
    FROM EMP WHERE DEPTNO=20;
    BEGIN
    FOR r_emp IN c_emp_cur
    LOOP
    IF r_emp.EMPNO NOT IN(c_emp_err) --DONT PICK THE EMP'S WHICH ARE IN ERROR TABLE
    THEN
    UPDATE EMP SET APPLY_DATE=SYSDATE
    WHERE EMPNO=r_emp.EMPNO;
    END IF;
    END LOOP;
    END;
    ERR: PLS-00320: the declaration of the type of this expression is incomplete or malformed
    Thanks in Advance ...

    Hi,
    I see.
    My answer still applies: don't use cursors if you don't have to. Look for a way to do what you need to using just SQL statements.
    If you really do have to use two cursors, where some values in one are taken from the other, you can have nested cursors.
    For exampe, using scott's tables, say you want to give a 10% salaray raise to everyone in any department based in a given city.
    You could have two cursors:
    (1) find each department based in the right city
    (2) find each employee in the current department from (1)
    CREATE OR REPLACE PROCEDURE     slow_update
    (     in_city_name     IN     VARCHAR2
    AS
         CURSOR     dept_csr     (target_loc     VARCHAR2)
         IS     SELECT     deptno
              FROM     dept
              WHERE     loc     = UPPER (target_loc);
         CURSOR     emp_csr     (target_deptno     NUMBER)
         IS     SELECT     empno
              FROM     emp
              WHERE     deptno     = target_deptno;
    BEGIN
         FOR     dept_rec IN dept_csr (in_city_name)
         LOOP
              FOR     emp_rec IN emp_csr (dept_rec.deptno)
              LOOP
                   UPDATE     emp
                   SET     sal     = sal * 1.1
                   WHERE     empno     = emp_rec.empno;
              END LOOP;
         END LOOP;
    END     slow_update;Notice how I used parameters in the cursors.
    You would run the procedure like this:
    EXECUTE  slow_update ('Dallas');Repeat: This is for demonstration purposes only.
    The smart way to do such an UPDATE doesn't require cursors or PL/SQL:
    UPDATE     emp
    SET     sal     = sal * 1.1
    WHERE     deptno     IN     (
                   SELECT     deptno
                   FROM     dept
                   WHERE     loc     = UPPER (:target_city_name)
                   );

  • How to bind arrays to PL/SQL stored procedure using OCI?

    Hi,
    We are having problems trying to bind arrays to PL/SQL stored procedure using OCI. Here is the situation:
    - We have a stored procedure called "GetVEPFindTasks" with the following interface:
    PROCEDURE GetVEPFindTasks (
    p_ErrorCode OUT NUMBER,
    p_ErrorMsg OUT VARCHAR2,
    p_RowCount OUT NUMBER,
    p_VEPFindTasks OUT t_VEPFindTaskRecordTable,
    p_MaxTask IN NUMBER);
    t_VEPFindTaskRecordTable is a record with the following entries:
    TYPE t_VEPFindTaskRecord IS RECORD (
    RTCID NUMBER,
    TransNum NUMBER,
    TransTimestamp VARCHAR2(20),
    Pathname1 image_data.pathname%TYPE,
    Pathname2 image_data.pathname%TYPE,
    Pathname3 image_data.pathname%TYPE,
    OperatorID operator.id%TYPE);
    - Now, we are trying to call the stored procedure from C++ using OCI (in UNIX). The call that we use are: OCIBindByName and OCIBindArrayOfStruct to bind the parameters to the corresponding buffers. We bind all parameters in the interface by name. Now, we do bind the record's individual item by name (RTCID, TransNum, etc.), and not as a record. I don't know if this is going to work. Then, we use the bind handles of the binded record items (only record items such as RTCID, TransNum, and NOT error_code which is not part of the record) to bind the arrays (using OCIBindArrayOfStruct).
    All of the parameters that are binded as arrays are OUTPUT parameters. The rest are either INPUT or INPUT/OUTPUT parameters. Now, when we try to execute, OCI returns with an error "Invalid number or types of arguments" (or something to that sort... the number was something like ORA-06550). Please help...
    Is there any sample on how to use the OCIBindArrayOfStruct with PL/SQL stored procedures? The sample provided from Oracle is only for a straight SQL statement.
    Thank's for all your help.
    ** Dannil Chan **

    As you said:
    You have to pass in an array for every field and deconstruct/construct the record in the procedure. There is no support for record type or an array of records. Can you give me a example? I'am very urgently need it.
    thanks
    email: [email protected]

  • Creating XML report using PL/SQL Stored Procedure

    Hi Friends,
    I am working on an xml report with the xml source as PL/SQL Stored Procedure.
    I am referring the exercise shown in the following link to understand the process:
       http://orclapp.blogspot.com/2012/02/developing-xml-publisher-report-using.html
    In the example shown in the above link I could not understand the following:
    1) In the following procedure, the out parameter 'retcode' is not used at all.
       What is the importance of this parameter.
        PROCEDURE REPORT (errbuf  OUT VARCHAR2, retcode  OUT VARCHAR2, p_product_id   IN     NUMBER)
    2)  After the xml data is prepared and put to 'l_result' Clob variable, the following
        Loop is executed. I am not able to appreciate why the following loop is required.
         LOOP
             EXIT WHEN l_length = l_retrieved;
             IF (l_length - l_retrieved) < 32000
             THEN
                SELECT SUBSTR (l_result, l_retrieved + 1) INTO l_xmlstr FROM DUAL;
                l_retrieved := l_length;
                fnd_file.put_line (fnd_file.output, l_xmlstr);
             ELSE
                SELECT SUBSTR (l_result, l_retrieved + 1, l_offset)
                  INTO l_xmlstr
                  FROM DUAL;
                l_retrieved := l_retrieved + l_offset;
                fnd_file.put_line (fnd_file.output, l_xmlstr);
             END IF;
         END LOOP;
    3) In the example it is not explained how the concurrent program gets the xml data?
       I assume it is written to a file using the following line of code:
        fnd_file.put_line (fnd_file.output, l_xmlstr);
       I would appreciate if anyone can throw some light into my above queries so that I can understand the process clearly.
    Thanks & Regards
    Hawker

    Hi 32000 in the code is a 'safe' size smaller than the max available 32767, the loops purpose is to move through the entire thing in chunks that will be manageable in the limits of the data type.
    Btw; if you are in Oracle e-business suite then you can also use Oracle reports very simply to create XML output.
    If you have reports developer all you need to do is put raw sql (without any 'artifice' to create XML) in the report SQL and then set the reports output to XML in the program definition in Oracle e-business.
    best regards,
    Robert.

  • Using Procedure in SQL statement

    Dear Sir,
    As you know, I can use any function in SQL statement. For example:
    SELECT systimestamp,
    Function_Name(variable1, variable2,...)
    FROM anytable;
    So the previous function could only retrieve one value -as functions concepts-. Anyhow, Can I, in someway, use Procedure that take multiple in parameters and return multiple out parameters in SQL statement.
    Thank you in advance.

    Sir,
    I got a way in order to use the benefit of procedure in function. It's trough your idea in using TYPE OBJECT as the following:
    ===================================================================
    create or replace type Missed_Txn_type AS OBJECT
    (Txn_Timestamp_obj timestamp,
    Txn_Type_Obj Number(12));
    ===================================================================
    Then I created function and used this type as returned value:
    FUNCTION Get_Shift_Missed_Txn_Obj(F_Date_In     Date,
                        F_Time_In Timestamp,
                        F_Employee_Id     number)
    RETURN Missed_Txn_type;
    The issue is: I want send the variables of the function through SELECT statement which they come from another table like:
    SELECT
    EMP.ID,
    sd.date_value,
    shf.Time_In,
    T.OBJ.Txn_Timestamp_obj,
    T.OBJ.Txn_Type_Obj
    FROM
    EMPLOYEE EMP,
    Stored_Date SD,
    Shifts shf,
    (select Get_Shift_Missed_Txn_Obj(sd.date_value,
    shf.time_in,
    EMP.Id) OBJ from dual) T
    WHERE
    [where clause]
    But the previous statement returned an error shows that it couldn't determine the (EMP.ID, shf.time_in, sd.date_value...)...
    And the same if I use it in the select list!
    So sir, there is any way in order to solve this issue?
    Thank you in advance.

  • Using dbms_session.reset_package inside procedure

    How to use the line dbms_session.reset_package in a procedure.
    I used execute immediate 'dbms_session.reset_package' , but it is not executing.
    How to execute it
    Plese help me

    What do you think should happen when you execute that package?
    Or have you yet again ignored even bothering to RFTM the Oracle® Database PL/SQL Packages and Types Reference to see just what this call does?
    Quote:
    This procedure de-instantiates all packages in this session. It frees the package state.
    Memory used for caching the execution state is associated with all PL/SQL functions, procedures, and packages that were run in a session.
    For packages, this collection of memory holds the current values of package variables and controls the cache of cursors opened by the respective PL/SQL programs. A call to RESET_PACKAGE frees the memory associated with each of the previously run PL/SQL programs from the session, and, consequently, clears the current values of any package globals and closes any cached cursors.
    If you expect PGA to decrease, it will not. Dynamic memory allocation at o/s kernel does not work in such a simplistic way. Memory malloc'ed by an application (like an Oracle dedicated or shared server process) may only be actually freed by the kernel when the process terminates.
    Billy

  • Using ALTER SESSION inside a stored procedure.... not a good idea?

    Hi,
    I have two stored procedures, both of which are used to query a database to find a particular book, based on ISBN. One sproc searches our main product catalogue and the other searches our suppliers feed catalogues. The stored procedures are called from a C# application via a search tool and the user is able to search on either our catalogue or our suppliers. The appropriate procedure is called based on the users choices.
    However, the following behaviour is observed
    I search for an ISBN (is a varchar2 field, as isbn's may contain an X if the checksum digit equates to 10) on a feed, so uses the FEED SPROC. The book is found and returned to the app in about 0.5 seconds. I can repeat this as often as i like on different books etc. always works fine.
    I then do the same search but against our own catalogue, so uses our CATALOGUE SPROC. Again the book is found quickly, and the search can be repeated with the same results.
    If i then go back and run our FEED SPROC then the search time increases to about 3 minutes !
    Both the feed and our catalogue is in the same database, although different schema's the connections will be pooled through our app server.
    I can repliacte this every single time. I think i have narrowed doen the cause of this behaviour to a few lines of code in our CATALOGUE SPROC:
    -- store values
    select value into v_vch_NLS_COMP from nls_session_parameters nsp where nsp.parameter = 'NLS_COMP';
    select value into v_vch_NLS_SORT from nls_session_parameters nsp where nsp.parameter = 'NLS_SORT';
    -- Ensure case insensitivity throughout
    EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_COMP = LINGUISTIC';
    EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_SORT = BINARY_CI';
    do other stuff
    -- restore session variables
    EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_COMP = ' || v_vch_NLS_COMP;
    EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_SORT = ' || v_vch_NLS_SORT;
    If i remove this code then all is well, so i am assuming that using ALTER SESSION inside a stored procedure is the cause of the problem as it would be changing the execution plan of the FEEDS SPROC in some manner? Any ideas? I know i can just rewrite the sproc to avoid using this coding, but wanted to understand if i am doing something wrong by using ALTER SESSION in this manner?
    Any pointers would be appreciated.
    John Thompson
    Software Architect,
    play.com
    Edited by: user7186902 on 27-May-2009 03:51

    Hello (and welcome),
    It may be a case of having to create a linguistic index to facilitate the queries once you set these session level parameters, i.e..,
    CREATE INDEX idx_01 ON tab ((NLSSORT(col1, 'NLS_SORT=BINARY_CI'))It would appear that the setting of those parameters is invalidating index searching on the current indexes.

  • Using named parameters with an sql UPDATE statement

    I am trying to write a simple? application on my Windows 7 PC using HTML, Javascript and Sqlite.  I have created a database with a 3 row table and pre-populated it with data.  I have written an HTML data entry form for modifying the data and am able to open the database and populate the form.  I am having trouble with my UPDATE function.  The current version of the function will saves the entry in the last row of the HTML table into the first two rows of the Sqlite data table -- but I'm so worn out on this that I can't tell if it is accidental or the clue I need to fix it.
    This is the full contents of the function . . .
         updateData = new air.SQLStatement();
         updateData.sqlConnection = conn;
         updateData.text = "UPDATE tablename SET Gsts = "Gsts, Gwid = :Gwid, GTitle = :GTitle WHERE GId = ":GId;
              var x = document.getElementsById("formname");
              for (var i = 1, row, row = x.rows[i]; i++) {
                   updateData.parameters[":GId"] = 1;
                   for (var j = 0, col; col=row.cells[j]; j++) {
                        switch(j) {
                             case 0: updateData.parameters[":GTitle"] = col.firstChild.value; break;
                             case 1: updateData.parameters[":Gsts"] = col.firstChild.value; break;
                             case 2: updateData.parameters[":Gwid"] = col.firstChild.value; break;
    Note: When I inspect the contents of the col.firstChild.value cases, they show the proper data as entered in the form -- it just isn't being updated into the proper rows of the Sqlite table.
    Am I using the named parameters correctly? I couldn't find much information on the proper use of parameters in an UPDATE statement.

    Thank you for the notes.  Yes, the misplaced quotes were typos.  I'm handtyping a truncated version of the function so I don't put too much info in the post. And yes, i = 1 'cuz the first rows of the table are titles.  So the current frustration is that I seem to be assigning all the right data to the right parameters but nothing is saving to the database.
    I declare updateData as a variable at the top of the script file
    Then I start a function for updating the data which establishes the sql connection as shown above.
    The correctly typed.text statement is:
            updateData.text = "UPDATE tablename SET Gsts=:Gsts, Gwid=:Gwid, GTitle=:GTitle WHERE GId=:GId";
    (The data I'm saving is entered in text boxes inside table cells.) And the current version of the loop is:
            myTable = document.getElementById("GaugeSts");
            myRows= myTable.rows;
              for(i=1, i<myRows.length, i++) {
                   updateData.parameters[":GId"]=i;
                   for(j=0; j<myRows(i).cells.length, j++) {
                        switch(y) {
                             case 0: updateData.parameters[":GTitle"]=myrows[i].cells[y].firstChild.value; break;
                             case 1: updateData.parameters[":Gsts"]=myrows[i].cells[y].firstChild.value; break;
                             case 2: updateData.parameters[":Gwid"]=myrows[i].cells[y].firstChild.value; break;
                             updateData.execute;
    The whole thing runs without error and when I include the statements to check what's in myrows[i].cells[y].firstChild.value, I'm seeing that the correct data is being picked up for assignment to the parameters and the update. I haven't been able to double check that the contents of the parameters are actually taking the data 'cuz I don't know how to extract the data from the parameters. ( The only reference  I've found so far has said that it is not possible. I'm still researching that one.) I've also tried moving the position of the updateData execution statement to several different locations in the loop andstill nothing updates. 
    I am using a combination of air.Introspector.Console.log to check the results of code and I'm using Firefox's SQlite manager to handle the database.  The database is currently sitting on the Desktop to facilitate testing and I have successfully updated/changed data in this table through the SQLite Manager so I don't think I'm having permission errors and, see below, I have another function successfully saving data to another table.
    I currently have another function that uses ? for the parametersin the .text of a INSERT/REPLACE statement and that one works fine.  But, only one line of data is being saved so there is no loop involved.  I tried changing the UPDATE statement in this function to the INSERT/REPLACE just to make something save back to the database but I can't make that one work either.I've a (And, I've tried so many things now, I don't even remember what actually saved something --albeit incorrectly --to the database in one of my previous iterations with the for loops.)
    I'm currently poring through Sqlite and Javascript tomes to see if I can find what's missing but if anything else jumps out at you with the corrected code, I'd appreciate some ideas.
    Jeane

  • PL/SQL Procedure Parameters PROBLEM

    Here's my problem:
    When we describe the successfully compiled PL/SQL packaged procedures in SQL*Plus, the parameter order seems reversed. For instance, my PL/SQL source looks like this:
    Create Package pkg1...
    Procedure func1 (param1 in varchar2,
    param2 in number) is
    ...function body...
    end func1;
    end pkg1;
    After it is successfully compiled in SQL*Plus, when I describe it using the desc command, it shows:
    PROCEDURE FUNC1
    Argument Name Type ......
    PARAM2 VARCHAR2
    PARAM1 VARCHAF2
    This problem occurs occasionally, if we recompile the source, it goes away. We couldn't quite tell when and how this happens. When the problem occurs, we checked the ALL_SOURCE view and verified that the parameters are in the right order.
    We use the Merant Drivers for our client side interfaces and whenever we have this problem on the db server, we get the "wrong number of types or parameters" error.
    Any clues, hints, solutions are greatly appreciated.
    Thank you for your time.
    On a different note, I couldn't find the appropriate forum to post this PL/SQL specific message, wondering why there isn't a PL/SQL forum.
    Murthy.

    Hi Yegneshwar
    Can U tell me how to invoke the procedure ? If all it can be invoked the post it or mail me and then I might help U out.
    Thank U.
    edwin

  • Dynamic cursor definition in PL/SQL

    Is it possible to have dynamic cursor definition in PL/SQL. Like
    using DBMS_SQL for dynamic SQL. If yes, how?

    Assuming I understand your question correctly, you can use a REF
    CURSOR to which you associate a VARCHAR2 which is the query text:
    DECLARE
    TYPE t_cur IS REF CURSOR ; -- define t_cur as a type
    c_cur t_cur ; -- define an actual variable of type t_cur
    r_emp emp%ROWTYPE ; -- PL/SQL record to hold row
    v_query VARCHAR2(2000) := 'SELECT * FROM emp' ; -- the query!
    BEGIN
    OPEN c_cur FOR v_query ; -- v_query could contain any valid query
    FETCH c_cur INTO r_emp ; -- get first row from dataset
    CLOSE c_cur ; -- remember to close the cursor! ;)
    END ;
    HTH

  • Avoid procedure or function calls between a SQL operation and an implicit cursor test

    when i analyse this code with code expert

    atpidgeon wrote:
    when i analyse this code with code expert
                            UPDATE P_PM_CONTROL_COUNT
                            SET AVAIL_SEG = AVAIL_SEG -1,
                                ALLOCATION = ALLOCATION -1
                            WHERE PM_UNIT_TYPE_ID = vrectab(1)
                            AND USAGE_DATE = vrectab(2)
                            AND SEGMENT_CODE = vrectab(5)
                            AND ALLOCATION - UNITS_RESERVED > 0;
                            IF sql%rowcount = 0 then --Added block and exception to prevent invetory going negative when placing multi units in same unit type out of service.
                                vErrMsg := 'Could not process your out of service request because your selection for unit '|| vrectab(3) || ' at ' || pvPropertyId || ' for ' || vrectab(2) || ' would cause segment ' || vrectab(5) || ' to be over allocated.';
                                RAISE SegOverAllocated;
                            END IF;
    i get "Avoid procedure or function calls between a SQL operation and an implicit cursor test.",as far has i know
    iff you're doing a sql%rowcount    after an update.. trying to see how many rows were updated...  you dont want procedure or function calls between the update and the sql% line
    correct me if im wrong and how would i fix it?or maybe i shouldnt
    You correct it by NOT executing function calls as part of the UPDATE statement.
    1. Issue the function calls BEFORE the update statement
    2. save the function results into variables
    3. use those variables in the UPDATE statement.
    v_rectab1 := vrectab(1);
    v_rectab2 := vrectab(21);
    v_rectab5 := vrectab(5);
    UPDATE P_PM_CONTROL_COUNT 
                            SET AVAIL_SEG = AVAIL_SEG -1,
                                ALLOCATION = ALLOCATION -1
                            WHERE PM_UNIT_TYPE_ID = v_rectab1
                            AND USAGE_DATE = v_rectab2
                            AND SEGMENT_CODE = v_rectab5
                            AND ALLOCATION - UNITS_RESERVED > 0;

Maybe you are looking for

  • How do i uninstall directv app?

    does anyone know how to uninstall the directv app that i downloaded from their site?  it's supposed to let me watch shows from their site.  i can't find the thing anywhere except on my activity monitor where it is listed as NDSPCSHOWSERVER.  i can't

  • Issues in Rendering CSS File

    I am trying to render a page. This page uses a CSS file. I have used the following line to access CSS. <link type="text/css" rel="stylesheet" href="Demo/css/workingCSS1.css"/> where 'Demo' is the site name. I have enables 'stylesheet' asset type for

  • How can we implement a j2me application on mobile phone

    Hello to All I am working on j2me and made a application that is online ticket booking for cinema hall. it is running on j2me wireless toolkit . Now i want to run this application on mobile. and how can be access this application by every the user wh

  • Playing Game in Other Profiles

    Good afternoon, I recently installed a game for my daughter on my Powerbook but she is unable to play it from her profile. The message states that "You are unable to play the game from a locked or write protected volume." I'm not quite sure what this

  • Cold backup from AIX to HP-UX

    Hi, Is it possible to restore a coldbackup which has taken form AIX machine to HP-UX machine? I think there are endians different and not possible.. Please suggest me and correct me Thanks KSG Not (AIX to Solaris) Edited by: KSG on Aug 11, 2010 6:25