Stored procedure with temp table creation inside and using it

I want to create a temp table inside a stred procedure and make use of it . I want perform some delete statements based on select statemets .An I want to drop the table at the end .
When I tried to create a table inside the stored procedure using exxecute immediate statement ,.
sql_stmt := 'CREATE GLOBAL TEMPORARY TABLE pattern_str_temp as select * from pattern_structure';
     EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE pattern_str_temp as select * from woc_pattern_structure' ;
Then my select statements that contain this table do not identify the table name.
I got compilor error when I use it in hte stored procedure in the select statement .Then I did like this-
WHENEVER SQLERROR CONTINUE
DROP TABLE pattern_str_temp;
CREATE TABLE pattern_str_temp AS SELECT * FROM pattern_structure ;
COMMIT;
CREATE OR REPLACE PACKAGE BODY Woc_Delete_Model_Data
AS
NAME: Woc_Delete_Model_Data
PURPOSE:
REVISIONS:
Ver Date Author Description
1.0 11/01/2008 gtutika 1. Deletes given Product Model
PROCEDURE deleteCategory(p_product_model IN varchar2,
               p_request_status OUT VARCHAR2,
               p_err_mesg OUT VARCHAR2
IS
l_category VARCHAR2(200);
l_count NUMBER;
CURSOR getAttribute IS
     SELECT Category_Name
     FROM
Woc_Attribute_Category
WHERE Attribute_Name in
(SELECT Child_Name FROM pattern_structure
WHERE Child_Type = 'Attribute' and product_Model_Name = p_product_model)
FOR UPDATE;
BEGIN
     DBMS_OUTPUT.ENABLE(1000000);
     --dbms_output.put_line('START-Inside DeleteCategory Procedure .........');
     --sql_stmt := 'CREATE GLOBAL TEMPORARY TABLE pattern_str_temp as select * from pattern_structure';
     --EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE pattern_str_temp as select * from pattern_structure' ;
     OPEN getAttribute ;
LOOP
     FETCH getAttribute INTO l_category ;
     EXIT WHEN getAttribute%NOTFOUND;
     l_count := Is_Category_Used(p_product_model , l_category);
IF (l_count=0) THEN
     DELETE FROM WOC_ATTRIBUTE_CATEGORY where CATEGORY_NAME = l_category;
     DELETE from woc_item_category
     where CATEGORY_NAME = l_category;
     DELETE FROM WOC_CATEGORY WHERE CATEGORY_NAME = l_category;
END IF;
     END LOOP;
     --(getAttribute%ROWCOUNT);
     CLOSE getAttribute;
     --dbms_output.put_line('END-Inside DeleteCategory Procedure .........');
EXCEPTION
     WHEN OTHERS THEN
     dbms_output.put_line(SQLERRM);
          p_err_mesg := 'ERROR IN CUSOR';
          --dbms_output.put_line('ERROR in CUSOR');
          ROLLBACK;
END;
FUNCTION Is_Category_Used(p_product_model IN varchar2 , p_category IN Varchar2)
     RETURN NUMBER IS
     l_count NUMBER;
     l_attribute VARCHAR2(40);
     l_pattern varchar2(30);
     CURSOR getAttribute IS
     SELECT attribute_Name from
     WOC_ATTRIBUTE_CATEGORY WHERE category_name = p_category and Attribute_Name in
     (Select Child_Name from pattern_str_temp
     where child_type = 'Attribute' and product_Model_Name = p_product_model);
BEGIN
DBMS_OUTPUT.ENABLE(1000000);
     SELECT count(*) into l_count from
     WOC_ATTRIBUTE_CATEGORY WHERE category_name = p_category and Attribute_Name in
     (Select Child_Name from pattern_str_temp
where child_type = 'Attribute' and product_Model_Name <> p_product_model);
     OPEN getAttribute;
LOOP
     FETCH getAttribute INTO l_attribute;
     EXIT WHEN getAttribute%NOTFOUND;
     DELETE FROM pattern_str_temp WHERE Product_Model_Name=p_product_model
     and child_type = 'Attribute' and child_Name= l_attribute;
     END LOOP;
     CLOSE getAttribute;
     RETURN l_count;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(SQLERRM);
          --dbms_output.put_line('ERROR in CUSOR');
          ROLLBACK;
END;
PROCEDURE delete_batch_woc_model(p_product_model IN VARCHAR2,p_flag IN VARCHAR2,
p_err_mesg OUT VARCHAR2)
     IS
     p_request_status VARCHAR2(30);
BEGIN
     deleteCategory(p_product_model,p_request_status ,p_err_mesg );
EXCEPTION WHEN OTHERS THEN
     dbms_output.put_line(SQLERRM);
          p_err_mesg := 'ERROR IN CUSOR';
          dbms_output.put_line('ERROR in CUSOR');
          ROLLBACK;
END;
END Woc_Delete_Model_Data;
--drop table pattern_str_temp ;
SHOW ERRORS;
But once the data is deleted , the data in the temp table is deleted when I load the data and try to delete it agian since I have no data in temp table ,the data is not deleted .So I need to create the temp table every time the stored procedure is called ,delete accordingly and drop the table at the end .
Please suggest how to do it.
Thanks.

I'm not sure I understand what you're attempting to do...
What is the benefit of a temporary table that stores the same set of data that is in the master table? Why not just
DELETE FROM child_table1
WHERE foreign_key IN (
    SELECT primary_key
      FROM master_table
     WHERE some_condition);
DELETE FROM child_table2
WHERE foreign_key IN (
    SELECT primary_key
      FROM master_table
     WHERE some_condition);
DELETE FROM child_table30
WHERE foreign_key IN (
    SELECT primary_key
      FROM master_table
     WHERE some_condition);
DELETE FROM master_table
WHERE some_condition;or
FOR x IN (SELECT * FROM master_table WHERE some_condition)
LOOP
  DELETE FROM child_table1 WHERE foreign_key = x.primary_key;
  DELETE FROM child_table2 WHERE foreign_key = x.primary_key;
  DELETE FROM child_table30 WHERE foreign_key = x.primary_key;
  DELETE FROM master_table WHERE primary_key = x.primary_key;
END LOOP;Justin

Similar Messages

  • Calling a stored procedure with a table of custom types as a out parameter

    Hi,
    I'm trying to use toplink 11.1.1.0.0 to call a stored procudure with 4 in paramrs and a single out parameter of type gsearch_type which is a userdefined type defined as below
    CREATE or replace TYPE search_object as object (mdlnumber varchar2(12), hit clob);
    create or replace type gsearch_type as table of search_object;
    Is it possible to get the return value from this stored procedure using toplink.
    Thanks in advance for any help.
    - Sunil

    Currently TopLink can't directly handle that kind of output parameter.
    As a workaround you would need a wrapper for the stored procedure - it could be either another stored procedure or an anonymous block which would return the components of the complex parameter as several simple parameters.

  • Java call stored procedure with nested table type parameter?

    Hi experts!
    I need to call stored procedure that contains nested table type parameter, but I don't know how to handle it.
    The following is my pl/sql code:
    create or replace package test_package as
    type row_abc is record(
    col1 varchar2(16),
    col2 varchar2(16),
    col3 varchar2(16 )
    type matrix_abc is table of row_abc index by binary_integer;
    PROCEDURE test_matrix(p_arg1 IN VARCHAR2,
    p_arg2 IN VARCHAR2,
    p_arg3 IN VARCHAR2,
    p_out OUT matrix_abc
    END test_package;
    create or replace package body test_package as
    PROCEDURE test_matrix(p_arg1 IN VARCHAR2,
    p_arg2 IN VARCHAR2,
    p_arg3 IN VARCHAR2,
    p_out OUT matrix_abc
    IS
    v_sn NUMBER(8):=0 ;
    BEGIN
    LOOP
    EXIT WHEN v_sn>5 ;
    v_sn := v_sn + 1;
    p_out(v_sn).col1 := 'col1_'||to_char(v_sn)|| p_arg1 ;
    p_out(v_sn).col2 := 'col2_'||to_char(v_sn)||p_arg2 ;
    p_out(v_sn).col3 := 'col3_'||to_char(v_sn)||p_arg3 ;
    END LOOP ;
    END ;
    END test_package ;
    My java code is following, it doesn't work:
    Class.forName ("oracle.jdbc.driver.OracleDriver");
    Connection con = DriverManager.getConnection
    ("jdbc:oracle:thin:@10.16.102.176:1540:dev", "scott", "tiger");
    con.setAutoCommit(false);
    CallableStatement ps = null;
    String sql = " begin test_package.test_matrix( ?, ? , ? , ? ); end ; ";
    ps = con.prepareCall(sql);
    ps.setString(1,"p1");
    ps.setString(2,"p2");
    ps.setString(3,"p3");
    ps.registerOutParameter(4,OracleTypes.CURSOR);
    ps.execute();
    ResultSet rset = (ResultSet) ps.getObject(1);
    error message :
    PLS-00306: wrong number or types of arguments in call to 'TEST_MATRIX'
    ORA-06550: line 1, column 8:
    PL/SQL: Statement ignored
    Regards
    Louis

    Louis,
    If I'm not mistaken, record types are not allowed. However, you can use object types instead. However, they must be database types. In other words, something like:
    create or replace type ROW_ABC as object (
    col1 varchar2(16),
    col2 varchar2(16),
    col3 varchar2(16 )
    create or replace type MATRIX_ABC as table of ROW_ABC
    /Then you can use the "ARRAY" and "STRUCT" (SQL) types in your java code. If I remember correctly, I recently answered a similar question either in this forum, or at JavaRanch -- but I'm too lazy to look for it now. Do a search for the terms "ARRAY" and "STRUCT".
    For your information, there are also code samples of how to do this on the OTN Web site.
    Good Luck,
    Avi.

  • Expose Stored Procedure with Dynamic Table Parameters

    Hi,
    I know Oracle 11g allows access via web service to all stored procedures.
    The basic idea of what we intend is to create groups of users.
    What I need, and I'm not sure if it's possible, is to expose a PLSQL that has the group's attributes and an xml:sequence of users that belong to that group. The procedure would be something like this:
    TYPE user IS RECORD (
      uid   NUMBER,
      name   VARCHAR2(100),
    TYPE users IS TABLE OF user INDEX BY BINARY_INTEGER;
    PROCEDURE add_group(g_name IN VARCHAR2(100), g_users IN users, ...) IS
    BEGIN
    END;
    The Procedure will be called from a BPEL Process as if it was a web service.
    Q:
    - Can this be done?
    - How will it map users?
    Thanks in advance :-)

    So, being as we don't have Oracle DB 11g that exposes WebServices natively to access the stored procedures, what would be the best way to access the stored procedure like a web service?
    What we are thinking of doing now is http://guidoschmutz.wordpress.com/2010/08/08/oracle-service-bus-11g-and-db-adapter-a-different-more-integrated-approach/
    Thanks again!

  • URGENT:Problem in a mapping with 8 tables in JOIN and using the DEDUP op.

    I have an urgent problem with a mapping: I must load data from 8 source tables (joined togheter) in a target table.
    Some data from 1 of the 8 tables have to be deduplicated, so I created a sort of staging table where I inserted the "cleaned" data, I mean, the deduplicated ones.
    I made it to make all the process faster.
    Then, I joined the 8 tabled, writing the join conditions in the operator properties, and connected the outputs into the fields of the target table.
    But..it does not work because this kind of mapping create a cartesian product.
    Then, I tried again with another mapping builted up in this way: after the joiner operator, I used the Match-Merge Operator and I load all data into a staging table exactly alike the target one, except for the PK (because it is a sequence). Then, I load the data from this staging table into the target one, and, of course, I connect to the target table also the sequence (the primary key). The first loading works fine (and load all the data as I expected).
    For the next loadings,I scheduled a pre-mapping process that truncate the staging table and re-load the new data.
    But..it does not work. I mean, It doesn't update the data previously loaded (or inser the new ones), but only insert the data, not considering the PK.
    So, my questions are as follow:
    1) Why loading the data directly from the joiner operator into the fact table doesn't work? Why does it generate a cartesian product??
    2) The "escamotage" to use the Match-Merge operator is correct? I have to admit that I didn't understand very well the behaviour of this operator...
    3) And, most of all, HOW CAN I LOAD MY DATA? I cannot find a way out....

    First of all, thanks for the answer!
    Yes, I inserted the proper join condition and in fact I saw that when WB generates the script it considers my join but, instead of using the fields in a single select statement, it builts up many sub-selects. Furthermore, it seems as it doesn't evaluate properly the fields coming from the source tables where I inserted the deduplicated data...I mean, the problems seems not to be the join condition, but the data not correctly deduplicated..

  • Using stored procedures with a timestamp parameter with Delphi  and ADO

    Dear Oracle experts,
    I have a problem concerning using a stored procedure with Delphi.
    I try to use a stored procedure which hast two input parameters ( a integer and a timestamp).
    The timestamp parameter is my problem since I would like to use the "to_timestamp"
    Oracle-function to create the timestamp parameter to be inserted into my procedure.
    If I insert the to_timestamp statement as a adodatetime I have to perform the conversion to the oracle timestamp in my application.
    If I want to use the to_timestamp statement I have to use the ftstring datatype but in that case I get an error because I use a string as input for my procedure were it awaits a timestamp.
    So the problem seems to be that the function call "to_timestamp" is not interpreted if it is transferred through my ADO component.
    Do you know how to use a procedure with Delphi (ADO) with a function as input parameter ?
    Best regards,
    Daniel Wetzler
    P.S. :
    This is the Delphi code to use my Procedure.
    FactsTempDS:=TADODataset.Create(nil);
    Sproc1 := TAdoStoredProc.Create(nil);
    Sproc1.Connection := TDBConnection(strlistConnectionstrings.objects[iConnectionIndex]).Connection;
    Sproc1.ProcedureName := 'ECSPACKAGE.PROCFINDINITIALSWITCHSTATE';
    Sproc1.Parameters.CreateParameter ('SwitchID',ftInteger,pdinput,0,0);
    //Sproc1.Parameters.CreateParameter ('StartTime',ftdatetime,pdinput,50,0);
    Sproc1.Parameters.CreateParameter ('StartTime',ftString,pdinput,50,0);
    Sproc1.Parameters.Findparam('SwitchID').value:=SwitchID;
    Sproc1.Parameters.FindParam('StartTime').Value:= 'to_timestamp(''2005/12/30 19:36:21'', ''YYYY/MM/DD HH:MI:SS'')';
    Sproc1.CursorType := ctKeyset;
    Sproc1.ExecuteOptions:=[];
    Sproc1.Open;
    Sproc1.Connection := nil;
    FactsTempDS.Recordset:= sproc1.Recordset;
    if FactsTempDS.RecordCount=0
    then raise Exception.Create('No line switch variable found for switch '+IntToStr(SwitchID)+' before starttime. Check BDE dump filter.')

    I have my entity manager setup in a singleton.
    I'm finding it's costly to generate the emf, but if I don't close the em (enitity manager) and emf (entity manager factory) my open cursor count climbs until I exceed the max number of open cursors on the database (11g RAC)
    I'm committing the connection, and uow, and closing the em at the end of each call.
    But until I close the emf, the open cursors aren't released.
    TransactionhistoryPkg tranPkg = new TransactionhistoryPkg(conn); //Class created over database package via JPublisher
    tranPkg.transactionhistoryInsSp(insertTrans.getCardId()); // executes db package
    tranPkg.closeConnection();
    conn.commit();
    uow.commit();
    uow.getAccessor().decrementCallCount();
    em.close();
    Am I missing something really obvious here??
    btw - I found this link helpful in troubleshooting the max cursors issue: https://support.bea.com/application_content/product_portlets/support_patterns/wls/InvestigatingORA-1000MaximumOpenCursorsExceededPattern.html

  • How to use stored procedure with many return results and variable with perl

    Hi everybody,
    i´m writtting now a Perl programm, wich use a oracle stored procedure with more than 1 result and 1 variable(I have to return 2 variable fpr each result). I don´t now how I can get it.I already search the web but I didn´t find.
    My example:
    PROCEDURE get_projects_and_sub_projects (
    v_project_id IN INTEGER,
    v_project_c_id OUT INTEGER,
    v_project_id_find OUT VARCHAR2
    IS
    BEGIN
    SELECT c_id, proj_id
    INTO
    v_project_c_id,
    v_project_id_find
    FROM t_projet
    WHERE t_projet .ksa_pro_art_kbz = 'KU'
    AND t_projet.proj_id LIKE v_project_id || '%';
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    v_project_c_id := NULL;
    v_project_id_find := NULL;
    WHEN OTHERS
    THEN
    kmessages.error (NULL,
    'get_projects_and_sub_projects',
    'Project-Name: ' || v_project_id,
    'Errornumber: '
    || SQLCODE
    || ' Error: '
    || SQLERRM,
    TRUE,
    TRUE
    raise_application_error (-20001,
    'Error '
    || SQLCODE
    || ' get_projects_and_sub_projects: '
    || SQLERRM,
    TRUE
    END get_projects_and_sub_projects;
    in Perl Program:
    sub get_projects_unterprojects_name($$){
    my ($db_handle, $proj_name_id) = @_; #$db_handle ist the DB Connection return value
    my $db_proj_c_id;
    my $db_proj_name;
    eval{ my $csr = $db_handle->prepare(q{
    BEGIN
    pro_doc_ber.get_projects_and_sub_projects(:proj_name_id, :db_proj_c_id, :db_proj_name);
    END;
    # parameter value
    $csr->bind_param(":proj_name_id", $proj_name_id);
    # return values
    $csr->bind_param_inout(":db_proj_c_id", \$db_proj_c_id, 11);
    $csr->bind_param_inout(":db_proj_name", \$db_proj_name, 20);
    $csr->execute(); };
    But this didn´t work. Could somebody give me some idea?
    Thank you
    Felx

    Some additional info would probably be helpful.
    What is your programming enviironment? Java?
    In any case I suspect that you will need to use the OCI to deal with specific Oracle types such as user defined object types -- thats not standard ANSI SQL.
    In Java I believe you need to use OPAQUE, there are some examples out there. I'm mostly a PL/SQL developer with some Java expereince so others here are more qualifed to answer your question more directly.

  • Reporting off oracle stored procedure with parameters error

    Erorr message: Error in File xxx.rpt: Failed to retrieve data from the database. Details: [Database Vendor Code: 907 ]
    Asp.net 2.0 web application.
    CR XI R2 sp2 in BOE XI R2 sp2 on Solaris 10.
    Database: Oracle 10g on Solaris 10. Oracle stored procedure defined in package.
    Happens with reports reporting off stored procedure with parameters.
    The sp is used in the crystal report.
    The web application passes parameters to crystal report, which then passes the parameters to stored procedure.
    Encountered error if:
    r.PromptOnDemandViewing = false;
    r.UseOriginalDataSource = false;
    r.CustomServerType = CeReportServerType.ceServerTypeOracle;
    Report can retrieves data if:
    r.PromptOnDemandViewing = false;
    r.UseOriginalDataSource = true;
    r.CustomServerType = CeReportServerType.ceServerTypeOracle;
    In addition
    The steps are:
    1)     Create oracle package and stored proc.
    2)     In CR Designer, select the stored proc as datasource.
    3)     The parameters names were "generated" by the CR Designer.
    4)     Rename the parameter names.
    5)     Drag the fields onto report.
    We noticed the following with different setting of database logon info:
    When previewing from BOE, get error when "Use custom database logon information specified here"
    However, no error when "Use original database logon information from the report". 
    Am i missing something?

    Please re-post if this is still an issue to the Data Connectivity - Crystal Reports Forum or purchase a case and have a dedicated support engineer work with you directly

  • Please help - Can not use stored procedure with CTE and temp table in OLEDB source

    Hi,
       I am going to create a simple package. It has OLEDB source , a Derived transformation and a OLEDB Target database.
    Now, for the OLEDB Source, I have a stored procedure with CTE and there are many temp tables inside it. When I give like EXEC <Procedure name> then I am getting the error like ''The metadata  could not be determined because statement with CTE.......uses
    temp table. 
    Please help me how to resolve this ?

    you write to the temp tables that get created at the time the procedure runs I guess
    Instead do it a staged approach, run Execute SQL to populate them, then pull the data using the source.
    You must set retainsameconnection to TRUE to be able to use the temp tables
    Arthur My Blog

  • T-sql 2008 r2 place results from calling a stored procedure with parameters into a temp table

    I would like to know if the following sql can be used to obtain specific columns from calling a stored procedure with parameters:
    /* Create TempTable */
    CREATE TABLE #tempTable
    (MyDate SMALLDATETIME,
    IntValue INT)
    GO
    /* Run SP and Insert Value in TempTable */
    INSERT INTO #tempTable
    (MyDate,
    IntValue)
    EXEC TestSP @parm1, @parm2
    If the above does not work or there is a better way to accomplish this goal, please let me know how to change the sql?

    declare @result varchar(100), @dSQL nvarchar(MAX)
    set @dSQL = 'exec @res = TestSP '''+@parm1+''','' '''+@parm2+' '' '
    print @dSQL
      EXECUTE sp_executesql @dSQL, N'@res varchar(100) OUTPUT', @res = @result OUTPUT
    select @result
    A complicated way of saying
    EXEC @ret = TestSP @parm1, @parm2
    SELECT @ret
    And not only compliacated, it introduces a window for SQL injection.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How to change stored procedure with Table Valued Parameter

    I am not sure how to change the normal stored procedure with Table Value Parameter.Do I have to create a separate Table or do I have to create a datatype. Can you please help me with this
    ALTER PROCEDURE [dbo].[uspInsertorUpdateINF]
    @dp_id char(32),
    @dv_id char(32),
    @em_number char(12),
    @email varchar(50),
    @emergency_relation char(32),
    @option1 char(16),
    @status char(20),
    @em_id char(35),
    @em_title varchar(64),
    @date_hired datetime
    AS
    BEGIN
    SET NOCOUNT ON;
    MERGE [dbo].[em] AS [Targ]
    USING (VALUES (@dp_id, @dv_id , @em_number, @email, @emergency_relation, @option1, @status, @em_id, @em_title, @date_hired))
    AS [Sourc] (dp_id, dv_id, em_number, email, emergency_relation, option1, status, em_id, em_title, date_hired)
    ON [Targ].em_id = [Sourc].em_id
    WHEN MATCHED THEN
    UPDATE
    SET dp_id = [Sourc].dp_id,
    dv_id = [Sourc].dv_id,
    em_number = [Sourc].em_number,
    email = [Sourc].email,
    emergency_relation = [Sourc].emergency_relation,
    option1 = [Sourc].option1,
    status = [Sourc].status,
    em_title = [Sourc].em_title,
    date_hired = [Sourc].date_hired
    WHEN NOT MATCHED BY TARGET THEN
    INSERT (dp_id, dv_id, em_number, email, emergency_relation, option1, status, em_id, em_title,date_hired)
    VALUES ([Sourc].dp_id, [Sourc].dv_id, [Sourc].em_number, [Sourc].email, [Sourc].emergency_relation, [Sourc].option1, [Sourc].status, [Sourc].em_id, [Sourc].em_title, [Sourc].date_hired);
    END;

    It's not clear how you would change the procedure. But assuming that you want to replace the existing scalar parameters with tabular input, this is how you would do it. You first create a table type:
    CREATE TYPE  Insertor_type AS TABLE
        (dp_id                char(32),
         dv_id                char(32),
        em_number            char(12),
        email                varchar(50),
        emergency_relation   char(32),
        option1              char(16),
        status               char(20),
        em_id                char(35),
        em_title             varchar(64),
        date_hired           datetime)
    Then you change the procedure header:
    ALTER PROCEDURE [dbo].[uspInsertorUpdateINF] @tvp Insertor_type READONLY AS
    And finally you change the USING clause:
       USING (SELECT dp_id, dv_id , em_number, email, emergency_relation, option1, status, em_id, em_title, date_hired
              FROM   @tvp) AS [Sourc] ON [Targ].em_id = [Sourc].em_id
    The rest is fine as it is.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Calling a stored procedure with RAW and SYS_REFCURSOR

    How do you call a stored procedure with the following input and output parameters?
    create or replace PROCEDURE test
    v_col1 IN NUMBER DEFAULT NULL ,
    v_col2 IN VARCHAR2 DEFAULT NULL ,
    v_col3 IN RAW DEFAULT NULL ,
    v_vol4 IN DATE DEFAULT NULL,
    cv_1 IN OUT SYS_REFCURSOR
    OPEN cv_1 FOR
    SELECT
    lv_tmp1 aaaa ,
    lv_tmp2 bbbb,
    lv_tmp3 cccc
    FROM DUAL ;
    END;
    Edited by: 925963 on Apr 6, 2012 10:50 AM

    Did you try just declaring the vars?
    untested
    declare
      myCur SYS_REFCURSOR;
      myRaw RAW(4);
      BEGIN
        test (0, 0, myRaw, sysdate, myCur);
      END;

  • Can Stored procedure with IN and OUT Paramter can be used in JDBC LOOKUP?

    can Stored procedure with IN and OUT Paramter can be used in JDBC LOOKUP?

    Checking online help, I do not see any possibility.
    "Queries a data base by the given SQL statement."
    http://help.sap.com/javadocs/pi/pi711sp03/com/sap/aii/mapping/lookup/DataBaseAccessor.html
    -> execute

  • Calling stored procedures with parameters with the Database Connectivi​ty Toolkit

    Hi all,
    I am new to the forum and am having difficulty finding a solution to a particular problem I am having regarding using the LabVIEW Database Connectivity Toolkit on a project I am currently working on at my job.  I have a database in which I have tables and stored procedures with parameters.  Some of these stored procedures have input, output, and return parameters.
    I have been trying to follow this example but to no avail:  http://digital.ni.com/public.nsf/allkb/07FD1307460​83E0686257300006326C4?OpenDocument
    One such stored procedure I am working on implementing is named "dbo.getAllowablePNs", which executes "SELECT * from DeviceType" (DeviceType is the table).  In this case, it does not require an input parameter, it has an output parameter that generates the table [cluster], and has a return parameter which returns an integer value (execution status code) to show if an error occurred.  The DeviceType table has 3 columns; ID (PK, int, not null), PN (nvarchar(15), null), and NumMACAddresses (int, null).  I have gone over many examples and have talking to NI support to try to implement this and similar stored procedures in LabVIEW but have not been successful.  I am able to connect to the database with the Open Connection VI without error, but am running into some confusion following this step.  I am then trying to use the Create Parameterized Query VI to call the stored procedure and set the parameters.  I assume I would then use the Set Parameter Value VI for each parameter that is wired into the parameters input on the previous Parameterized Query VI?  I am also having some confusion during and following these steps as well.  I would greatly appreciate any advice or suggestions anyone might have in regards to this situation as I am not a SQL expert.  Also, I would be happy to provide any more information that would be helpful.
    Regards,
    Jon
    Solved!
    Go to Solution.

    Also, I don't know if this would be helpful but here is the actual stored procedure in SQL:
    CREATEPROCEDURE [dbo].[getLastSequenceNumber]
    @p1 nvarchar(10)='WO-00000'
    AS
    BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SETNOCOUNTON;
    -- Insert statements for procedure here
    selectmax(SequenceNumber)from Devices where WorkOrderNumber= @p1
    END
    GO

  • Calling a stored procedure with a CLOB as input parameter

    Hello,
    I was unsuccessfully trying to call a stored procedure with a clob as input parameter from my C++ application using occi.
    Anyone got a working example to look at?
    I already checked the thread Invalid OCI handle when creating a Blob which didn't help.
    The problem seems to be that I don't have a lob locator to write my data (xml file) to. I tried creating a temporary clob using the sys.dbms_lob package which only resulted in a major headache on my part...
    I would appreciate any help.
    Kind regards
    Horst
    my environment:
    Visual Studio 2008, C++ application
    Oracle 11g

    To start using a blob you have to insert it into the database and then get it back. Sounds weird but that is how it is. Here is a very simple program to do this:
    #include<occi.h>
    #include <iostream>
    using namespace oracle::occi;
    using namespace std;
    int main()
      try
        Environment *env = Environment::createEnvironment(Environment::OBJECT);
        Connection *conn = env->createConnection("hr","hr","");
        string stmt1 = "insert into blob_tab values (:1) ";
        string stmt2 = "select col1 from blob_tab";
        Blob blob(conn);
        blob.setEmpty(conn);
        Statement *stmtObj = conn->createStatement(stmt1);
        stmtObj->setBlob(1,blob);
        stmtObj->executeUpdate();
        conn->commit();
        Blob blob1(conn);
        Statement *stmtObj2 = conn->createStatement(stmt2);
        ResultSet *rs = stmtObj2->executeQuery();
        while(rs->next())
         blob1 = rs->getBlob(1);
        string stmt3 = "begin my_proc(:1) ;end;";
        Statement *stmtObj3 =  conn->createStatement(stmt3);
        stmtObj3->setBlob(1,blob1);
        stmtObj3->executeUpdate();
      catch (SQLException e)
        cout << e.getMessage();
      /* The tables and procedure are primitive but ok for demo
        create table blob_tab(col1 blob);
        create or replace procedure my_proc(arg in blob)
        as
        begin
         -- just a putline here. you can do other more meaningful operations with the blob here
          dbms_output.put_line('hello');
       end;
    }Hope this helps.
    Thanks,
    Sumit

Maybe you are looking for

  • Blu Ray won't turn on after server issues

    So after the last couple days of not being able to connect properly to my online streaming, now my blu Ray won't even turn on all the way. It is stuck with the thin blue line on the screen and won't do anything else. I have tried unplugging it and pl

  • Tables used in SHD0 for saving screen variants?

    Hi all, Which are the tables are used in SHD0 , which saves details like transcation varinat, screen variant, groups etc? Reply urgent. Thaks, Madhura Nadgauda

  • Unable to connect to Apple TV after install Mavericks

    Hello I'm unable to connect to Apple TV after install Mavericks. :-( The icon of the Apple TV no longer appers on the top menu and my Mac is unable to discover it... The Apple TV Box is upedated to the most recent software version. Apple TV is connec

  • Converting Warning Message 06434 into Error message

    Hi Experts, While creating PO with ref to RFQ systems gives warning message 06434. Kindly any one guide me how to convert this warning message to error message. Thnxs Harish

  • I can't sync the calendar. I get the message 'sync server can't sync Iphone'.

    I cannot sync the calendar from my computer to the Iphone.  I receive the message 'sync server failed to sync the Iphone'. I have reset my I phone and reset sync history but it has not worked.  I am looking for any solutions to this problem. Thanks