Copy values from stored procedure to a text pad

Any Suggestions
We have a table 'A' and wrote a select query to get the values from that table 'A'. I place this select query in Stored procedure and when I run that procedure every month the output should be sent t a text pad. Any suggestions how to write it
thanks
Is there any other method if we dont have the privelage to create directory?
Edited by: user646635 on Oct 2, 2008 7:16 AM

user646635 wrote:
want to store the output in a text file?
we are using oracle 9iHere's a basic example for you...
AS SYS:
create or replace directory TEST_DIR as 'c:\test_dir'; -- This creates an oracle directory object.  The actual operating system directory must be created manually
grant read,write on directory test_dir to my_user;  -- Grant permission to use that directory object to the required user(s)AS my_user:
declare
  cursor cur_emp is
    select ename, deptno
    from emp;
  v_fh UTL_FILE.FILE_TYPE;  -- This is a file handle
begin
  v_fh := UTL_FILE.FOPEN('TEST_DIR', 'file.txt', 'w', 32767);  -- Open the file for writing and obtain a handle to it
  FOR i IN cur_emp -- process the query in a loop
  LOOP
    UTL_FILE.FPUT_LINE(v_fh, i.ename||','||to_char(i.deptno,'fm099')); -- write out lines of text to the file
  END LOOP;
  UTL_FILE.FCLOSE(v_fh); -- Close the file (also flushes any unwritten buffered data).
end;

Similar Messages

  • How to get return values from stored procedure to ssis packge?

    Hi,
    I need returnn values from my stored procedure to ssis package -
    My procedure look like  and ssis package .Kindly help me to oget returnn value to my ssis package
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    -- =============================================
    -- Author: <Author,,Name>
    -- Create date: <Create Date,,>
    -- Description: <Description,,>
    -- =============================================
    ALTER PROCEDURE [TSC]
    -- Add the parameters for the stored procedure here
    @P_STAGE VARCHAR(2000)
    AS
    BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    -- Insert statements for procedure here
    --SELECT <@Param1, sysname, @p1>, <@Param2, sysname, @p2>
    truncate table [INPUTS];
    INSERT
    INTO
    [INPUTS_BASE]
    SELECT
    [COLUMN]
    FROM [INPUTS];
    RETURN
    END
    and i am trying to get the return value from execute sql task and shown below
    and i am taking my returnn value to result set variable

    You need to have either OUTPUT parameters or use RETURN statement to return a value in stored procedures. RETURN can only return integer values whereas OUTPUT parameters can be of any type
    First modify your procedure to define return value or OUTPUT parameter based on requirement
    for details see
    http://www.sqlteam.com/article/stored-procedures-returning-data
    Once that is done in SSIS call sp from Execute SQL Task and in parameter mapping tabe shown above add required parameters and map them to variables created in SSIS and select Direction as Output or Return Value based on what option you used in your
    procedure.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How to capture return value from stored procedure?

    Hi All,
    I want to capture the retun values from this procedure to a table - CALL SYS.GET_OBJECT_DEFINITION('SCHEMA_NAME', 'TABLE_NAME').
    The below approach is not working -
    Insert  into STG.STG_DDL
    Call SYS.GET_OBJECT_DEFINITION('DWG', 'DWG_SITE')
    Could you please have a look on the same?
    Thank you,
    Vijeesh

    Thanks a lot Everyone.
    Considering the discussed options, and an approach explained in this thread - -http://scn.sap.com/thread/3291461  , I have written an SQL to build the Alter statements to add the columns & Constrains to table.
    The below Query will provide the scripts to build a table in another environment.
    select * from (
       select TABLE_name,'tbl_Create' column_name, 1 as position, 'CREATE TABLE '|| schema_name ||'.'|| table_name ||' (  DUMMY_CLMN INTEGER);' as SQLCMD
         from tableS
        where  schema_name ='DWG'
          and TABLE_name ='DWG_PRODUCTION_VOLUME_TRX'
    UNION ALL
    -- MASS change of NOT NULL COLUMNS
    -- set to NOT NULL - character data type, double, decimal fixed - need the length but not the scale
       select TABLE_name,column_name, position + 100, 'ALTER TABLE '|| schema_name ||'.'|| table_name ||' ADD ('||column_name ||' '||data_type_name ||' (' || length ||') NOT NULL) ;' as SQLCMD
         from table_columns
        where is_nullable = 'FALSE'
          and schema_name ='DWG'
          and TABLE_name ='DWG_PRODUCTION_VOLUME_TRX'
          and data_type_name in ('VARCHAR', 'NVARCHAR', 'DOUBLE')
          and scale is NULL
    UNION ALL
    -- MASS change of NOT NULL COLUMNS
    -- set to NOT NULL - character data type, double, decimal fixed - need the length but not the scale
       select TABLE_name,column_name, position + 100,'ALTER TABLE '|| schema_name ||'.'|| table_name ||' ADD ('||column_name ||' '||data_type_name ||' (' || length ||') );' as SQLCMD
         from table_columns
        where is_nullable = 'TRUE'
          and schema_name ='DWG'
          and TABLE_name ='DWG_PRODUCTION_VOLUME_TRX'
          and data_type_name in ('VARCHAR', 'NVARCHAR', 'DOUBLE')
          and scale is NULL
    UNION ALL
    -- set to NOT NULL - DECIMAL (FLOATING POINT)- needs length and scale
       select TABLE_name,column_name, position + 100, 'ALTER TABLE '|| schema_name ||'.'|| table_name ||' ADD ('||column_name ||' '||data_type_name ||' (' || length ||','|| scale ||') NOT NULL) ;' as SQLCMD
         from table_columns
        where is_nullable = 'FALSE' 
          and schema_name ='DWG'
          and TABLE_name ='DWG_PRODUCTION_VOLUME_TRX'
          and data_type_name in ('DECIMAL' )
          and scale is not null
    UNION ALL
    -- set to NOT NULL - DECIMAL (FLOATING POINT)- needs length and scale
       select TABLE_name,column_name, position + 100, 'ALTER TABLE '|| schema_name ||'.'|| table_name ||' ADD ('||column_name ||' '||data_type_name ||' (' || length ||','|| scale ||') ) ;' as SQLCMD
         from table_columns
        where is_nullable = 'TRUE'
          and schema_name ='DWG'
          and TABLE_name ='DWG_PRODUCTION_VOLUME_TRX'
          and data_type_name in ('DECIMAL' )
          and scale is not null
    UNION ALL
    -- set to NOT NULL - DECIMAL (FLOATING POINT)- needs length and null scale
       select TABLE_name,column_name, position + 100, 'ALTER TABLE '|| schema_name ||'.'|| table_name ||' ADD ('||column_name ||' '||data_type_name ||' (' || length ||') NOT NULL) ;' as SQLCMD
         from table_columns
        where is_nullable = 'FALSE' 
          and schema_name ='DWG'
          and TABLE_name ='DWG_PRODUCTION_VOLUME_TRX'
          and data_type_name in ('DECIMAL' )
          and scale is  null
    UNION ALL
    -- set to NOT NULL - DECIMAL (FLOATING POINT)- needs length and null scale
       select TABLE_name,column_name, position + 100, 'ALTER TABLE '|| schema_name ||'.'|| table_name ||' ADD ('||column_name ||' '||data_type_name ||' (' || length ||') NOT NULL) ;' as SQLCMD
         from table_columns
        where is_nullable = 'TRUE'
          and schema_name ='DWG'
          and TABLE_name ='DWG_PRODUCTION_VOLUME_TRX'
          and data_type_name in ('DECIMAL' )
          and scale is  null
    UNION ALL
    -- set to NOT NULL -  DATE | TIME | SECONDDATE | TIMESTAMP | TINYINT | SMALLINT | INTEGER - don't need length  or scale
    select TABLE_name,column_name, position + 100, 'ALTER TABLE '|| schema_name ||'.'|| table_name ||' ADD ('||column_name ||' '||data_type_name ||' NOT NULL) ;' as SQLCMD
       from table_columns
      where is_nullable = 'FALSE'
        and schema_name ='DWG'
        and TABLE_name ='DWG_PRODUCTION_VOLUME_TRX'
        and data_type_name in ('DATE', 'LONGDATE', 'TIME', 'SECONDDATE', 'TIMESTAMP', 'TINYINT', 'SMALLINT', 'INTEGER' )
    --   and scale is not null   
    UNION ALL
    -- set to NOT NULL -  DATE | TIME | SECONDDATE | TIMESTAMP | TINYINT | SMALLINT | INTEGER - don't need length  or scale
    select TABLE_name,column_name, position + 100, 'ALTER TABLE '|| schema_name ||'.'|| table_name ||' ADD ('||column_name ||' '||data_type_name ||' ) ;' as SQLCMD
       from table_columns
      where is_nullable = 'TRUE'
        and schema_name ='DWG'
        and TABLE_name ='DWG_PRODUCTION_VOLUME_TRX'
        and data_type_name in ('DATE', 'LONGDATE', 'TIME', 'SECONDDATE', 'TIMESTAMP', 'TINYINT', 'SMALLINT', 'INTEGER' )
    --    and scale is not null
    UNION ALL
    select table_name, 'PK' AS column_name, 9990, 'ALTER TABLE '||table_name||' ADD CONSTRAINT Primary_key PRIMARY KEY ('||PK_COLUMN_NAME1||
    case when  PK_COLUMN_NAME2 is null then  ' ' else ','|| PK_COLUMN_NAME2 end ||
    case when  PK_COLUMN_NAME3 is null then  ' ' else ','|| PK_COLUMN_NAME3 end ||
    case when  PK_COLUMN_NAME4 is null then  ' ' else ','|| PK_COLUMN_NAME4 end ||');'
    from
    (SELECT DISTINCT C1.table_name , C1.COLUMN_NAME AS PK_COLUMN_NAME1, C2.COLUMN_NAME AS PK_COLUMN_NAME2, C3.COLUMN_NAME AS PK_COLUMN_NAME3, C4.COLUMN_NAME AS PK_COLUMN_NAME4
                         FROM (SELECT * FROM CONSTRAINTS WHERE POSITION=1 AND IS_PRIMARY_KEY = 'TRUE') C1
                         LEFT JOIN (SELECT * FROM CONSTRAINTS WHERE POSITION=2 AND IS_PRIMARY_KEY = 'TRUE') C2
                                ON C1.table_name = C2.table_name
                         LEFT JOIN (SELECT * FROM CONSTRAINTS WHERE POSITION=3 AND IS_PRIMARY_KEY = 'TRUE') C3
                                ON C2.table_name = C3.table_name
                         LEFT JOIN (SELECT * FROM CONSTRAINTS WHERE POSITION=4 AND IS_PRIMARY_KEY = 'TRUE') C4
                                ON C3.table_name = C4.table_name
                         LEFT JOIN (SELECT * FROM CONSTRAINTS WHERE POSITION=5 AND IS_PRIMARY_KEY = 'TRUE') C5
                                ON C4.table_name = C5.table_name
                         ) PK     
    where table_name = 'DWG_PRODUCTION_VOLUME_TRX'
    UNION ALL
    select table_name, 'UK' AS column_name, 9991,  'ALTER TABLE '||table_name||' ADD CONSTRAINT UNIQUE ('||UK_COLUMN_NAME1||
    case when  UK_COLUMN_NAME2 is null then  ' ' else ','|| UK_COLUMN_NAME2 end ||
    case when  UK_COLUMN_NAME3 is null then  ' ' else ','|| UK_COLUMN_NAME3 end ||
    case when  UK_COLUMN_NAME4 is null then  ' ' else ','|| UK_COLUMN_NAME4 end ||');'
    FROM
    (SELECT DISTINCT C1.table_name , C1.COLUMN_NAME AS UK_COLUMN_NAME1, C2.COLUMN_NAME AS UK_COLUMN_NAME2, C3.COLUMN_NAME AS UK_COLUMN_NAME3, C4.COLUMN_NAME AS UK_COLUMN_NAME4
                         FROM (SELECT * FROM CONSTRAINTS WHERE POSITION=1 AND IS_PRIMARY_KEY = 'FALSE') C1
                         LEFT JOIN (SELECT * FROM CONSTRAINTS WHERE POSITION=2 AND IS_PRIMARY_KEY = 'FALSE') C2
                                ON C1.table_name = C2.table_name
                         LEFT JOIN (SELECT * FROM CONSTRAINTS WHERE POSITION=3 AND IS_PRIMARY_KEY = 'FALSE') C3
                                ON C2.table_name = C3.table_name
                         LEFT JOIN (SELECT * FROM CONSTRAINTS WHERE POSITION=4 AND IS_PRIMARY_KEY = 'FALSE') C4
                                ON C3.table_name = C4.table_name
                         LEFT JOIN (SELECT * FROM CONSTRAINTS WHERE POSITION=5 AND IS_PRIMARY_KEY = 'FALSE') C5
                                ON C4.table_name = C5.table_name
                         ) UK    
    where table_name = 'DWG_PRODUCTION_VOLUME_TRX'
    UNION ALL
    SELECT REFERENCED_TABLE_NAME AS table_name,'FK' AS column_name, 9992,
    'ALTER TABLE DWG.'||TABLE_NAME||' ADD FOREIGN KEY ( '||COLUMN_NAME||' ) REFERENCES '|| REFERENCED_TABLE_NAME||'('||COLUMN_NAME||' ) ON UPDATE CASCADE ON DELETE RESTRICT;'
    FROM REFERENTIAL_CONSTRAINTS
    WHERE REFERENCED_TABLE_NAME = 'DWG_SITE'
    UNION ALL
    select TABLE_name,'tbl_ClmnDrop' column_name, 9995 as position, 'ALTER TABLE '|| schema_name ||'.'|| table_name ||' DROP (  DUMMY_CLMN );' as SQLCMD
    from tableS
    where  schema_name ='DWG'
      and TABLE_name ='DWG_PRODUCTION_VOLUME_TRX'
    order by position;

  • How to output value from stored procedure

    Hi folks, I need to output the OrderFK from a stored procedure not really sure how to achieve this any help or tips much appreciated.
    Sql code below
    USE [TyreSanner]
    GO
    /****** Object: StoredProcedure [dbo].[AddCustomerDetails] Script Date: 11/12/2014 20:56:34 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[AddCustomerDetails]
    /***********************Declare variables ***********************/
    /******tblCustomer******/
    @Forename nvarchar(50),
    @Surname nvarchar(50),
    @HouseNo nvarchar(50),
    @CustAddress nvarchar(50),
    @Town nvarchar(50),
    @Postcode nvarchar(50),
    @ContactNo nvarchar(50),
    @EmailAddress nvarchar(50),
    /******tblLink_OrderProduct******/
    @ProductQuantity int,
    @TotalProductSaleCost decimal,
    @ProductFK int,
    @FittingDate date,
    @FittingTime Time
    As
    DECLARE @CustomerFK int;
    DECLARE @OrderFK int;
    Begin TRANSACTION
    SET NOCOUNT ON
    INSERT INTO [TyreSanner].[dbo].[Customer](Forename, Surname, HouseNo, CustAddress, Town, Postcode, ContactNo, EmailAddress)
    VALUES (@Forename,@Surname,@HouseNo,@CustAddress,@Town,@Postcode,@ContactNo,@EmailAddress)
    Set @CustomerFK = SCOPE_IDENTITY()
    INSERT INTO [TyreSanner].[dbo].[Order] (CustomerFK)
    VALUES (@CustomerFK)
    SET @OrderFK = SCOPE_IDENTITY()
    INSERT INTO [TyreSanner].[dbo].[Link_OrderProduct](OrderFK, ProductFK, ProductQuantity, TotalProductSaleCost, FittingDate, FittingTime)
    VALUES
    (@OrderFK, @ProductFK, @ProductQuantity, @TotalProductSaleCost, @FittingDate, @FittingTime)
    COMMIT TRANSACTION

    Hi brucey54,
    There’re several ways to capture the value from a Stored Procedure. In you scenario, I would suggest 2 options, by an output parameter or by a table variable.
    By an output Parameter, you need to make a little bit modification on your code as below:
    USE [TyreSanner]
    GO
    ALTER PROCEDURE [dbo].[AddCustomerDetails]
    @Forename nvarchar(50),
    @FittingDate date,
    @FittingTime Time,
    @OrderFK int output
    As
    DECLARE @CustomerFK int;
    --DECLARE @OrderFK int;
    Run the following code, Then @OrderFKvalue holds the value you’d like.
    DECLARE @OrderFKvalue int;
    EXEC AddCustomerDetails(your parameters,@OrderFKvalue output)
    Anyway if you don’t like to add one more parameter, you can get the value by a table variable as well. Please append “SELECT @OrderFK;” to your Procedure as below:
    USE [TyreSanner]
    GO
    ALTER PROCEDURE [dbo].[AddCustomerDetails]
    SET @OrderFK = SCOPE_IDENTITY()
    INSERT INTO [TyreSanner].[dbo].[Link_OrderProduct](OrderFK, ProductFK, ProductQuantity, TotalProductSaleCost, FittingDate, FittingTime)
    VALUES
    (@OrderFK, @ProductFK, @ProductQuantity, @TotalProductSaleCost, @FittingDate, @FittingTime);
    SELECT @OrderFK;
    Then you can call the Stored Procedure as below:
    DECLARE @T TABLE (OrderFK INT);
    INSERT @T EXEC AddCustomerDetails(your parameters) ;
    SELECT OrderFK FROM @T;
    There’re more options to achieve your requirement, please see the below link:
    How to Share Data between Stored Procedures
    If you have any question, feel free to let me know.
    Best Regards,
    Eric Zhang

  • Get out values from stored procedure

    Hi folks,
    I have need of an aid. I have created this stored procedure:
    CREATE OR REPLACE PROCEDURE ProceduraDiProva (
    p_val1 IN NUMBER DEFAULT 1,
    p_val2 IN NUMBER DEFAULT 1,
    p_val3 OUT NUMBER,
    p_val4 OUT NUMBER)
    AS
    BEGIN
    p_val3 := p_val1 + p_val2;
    p_val4 := 999;
    END ProceduraDiProva;
    I call the procedure into shell script
    $ORACLE_HOME/bin/sqlplus -s user/pwd@oracleid > oracle.log << END
    spool ciccio.txt
    declare
    var a_out number;
    var b_out number;
    begin
    var a_out:=0;
    exec ProceduraDiProva(1, 2, a_out, b_out);
    end;
    spool off;
    exit
    END
    I would know as I make to insert 'a_out' and 'b_out' in a shell variables
    Tanks in advance

    I found an example with windows
    Create a file cmd with;
    FOR /F "usebackq delims=!" %%i IN (`sqlplus -s %usuario%/%pwd%@%ddbb% @1.sql`) DO set xresult=%%i
    echo %xresult%
    And the 1.sql:
    set timing off
    set feedback off
    set pages 0
    select sysdate from dual;
    exit
    ------------------------------------------------------------------------------------------

  • Unable to retrieve the values from stored procedure

    Hi all
    I written one procedure and when i am trying to invoke that store procedure from jdbc it is throwing the following error .
    java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.DelegatingCallableStat
    ement
            at com.srit.hrnet.helpdesk.grievancemechanism.GrievanceComplaintDAO.getE
    mployerGenDetails(GrievanceComplaintDAO.java:895)
            at com.srit.hrnet.helpdesk.grievancemechanism.GrievanceComplaintAction.d
    eleteComplaints(GrievanceComplaintAction.java:1095)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchActio
    n.java:276)
            at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:
    196)
            at org.apache.struts.action.RequestProcessor.processActionPerform(Reques
    tProcessor.java:421)
            at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
    va:226)
            at org.apache.struts.action.ActionServlet.process(ActionServlet.java:116
    4)
            at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
    icationFilterChain.java:252)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
    ilterChain.java:173)
            at com.srit.hrnet.filter.SessionValidateFilter.doFilter(SessionValidateF
    ilter.java:79)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
    icationFilterChain.java:202)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
    ilterChain.java:173)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
    alve.java:213)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
    alve.java:178)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
    ava:126)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
    ava:105)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
    ve.java:107)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
    a:148)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
    :856)
            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
    ssConnection(Http11Protocol.java:744)
            at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
    int.java:527)
            at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol
    lowerWorkerThread.java:80)
            at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
    ool.java:684)
            at java.lang.Thread.run(Unknown Source)
    java.lang.NullPointerException
            at com.srit.hrnet.helpdesk.grievancemechanism.GrievanceComplaintAction.d
    eleteComplaints(GrievanceComplaintAction.java:1098)and my code is
    store procedure is
    ============
    create or replace procedure SP_HD_GRIEVANCE_DELETE_DETAILS(in_queryid IN number DEFAULT NULL,RC1      IN OUT globalPkg.RCT1)
    as
    queryId number(18,0);
    BEGIN
    SP_HD_GRIEVANCE_DELETE_DETAILS.queryId := SP_HD_GRIEVANCE_DELETE_DETAILS.in_queryid;
      IF  SP_HD_GRIEVANCE_DELETE_DETAILS.queryId  = 1 THEN
             BEGIN
             OPEN RC1 FOR
            select HGRMCODE as compcode,emcode as applyEmpId,EMFNAME as assName,designame as desig,deptname as department ,to_char(HGRMOCCRDT,'DD/MM/YYYY') as occdate,
                        HGRMSLATYPE as category,HGRMSUBCAT as subcat,HGRMSLAPRIORITY as priority,HGRMSTATUS  as status from EMP_MSTR,HD_GRIEVANCE_RM_MSTR,
                        dept_mstr,desig_mstr where EMCODE=HGRMAPPLYEMCODE and EMDEPTCODE=deptcode and desigcode=EMDESIGCODE order by HGRMCODE;
            END;
         END IF;
    END SP_HD_GRIEVANCE_DELETE_DETAILS;and javacode is
    ==========
    con = new DBConnection().getConnection();
    java.sql.CallableStatement stmt = con.prepareCall("{call SP_HD_GRIEVANCE_DELETE_DETAILS(?,?)}");
                        stmt.clearParameters();
                        stmt.setInt(1,1);
                        stmt.registerOutParameter(2, OracleTypes.CURSOR);
                        stmt.execute();
                        cursor = ((OracleCallableStatement)stmt).getCursor(1);
    list  = new ArrayList();
                        while (cursor.next()) {
    compTO = new GrievanceComplaintTO();
    list.add(compTO);
    }where GrievanceComplaintTO is formbean class
    Please Guide me.
    Thanks in advance.

    Obviously, this
    cursor = ((OracleCallableStatement)stmt).getCursor(1);fails because you don't get an OracleCallableStatement.

  • Multiple Values from Stored Procedure

    Hello all,
    I have oracle table with 9 fields like startdate,enddate,name,id etc.
    Now from this table I want to to some manipulation like if if the startdate>enddate,if true return end date
    with
    StartDate,EndDate,CalculateEndDate,Name fields.
    I need this to be done all the rows in the table and return the result . What method I can for this
    I am using .Net as my Front End
    Thanks in advance

    My select is too complex to be returned in one Cursor.
    I have declared my own type
    TYPE myTableType AS TABLE OF myType;
    and
    TYPE myType AS OBJECT
    ( a NUMBER,b NUMBER,c VARCHAR2(5),d VARCHAR2(50) )
    Procedure p (inputpar IN VARCHAR2, Cur REF CURSOR);
    code
    LOOP
    .. code ..
    myData.EXTEND;
    myData(myData.COUNT) :=                     myType( variable1, var2, var3, var4);
    END LOOP;
    And at last returning a refcursor
    OPEN Cur FOR
    SELECT a,b,c..     
    FROM TABLE (CAST (myData AS myTableType));
    Lars Petersen

  • Multiples value from stored Procedure

    Hi all,
    I have a table with this structure.
    ID Startdate EndDate
    Now I want to retrive the row rows with time difference is >x , where the x has to passed as parameter.
    How can I do this one ?
    thanks in advance

    Are you date values stored as date or timestamps? It will make a difference. I'm not sure on these, but I'm new to Oracle as well. Give them a shot.
    With a date:
    where (Startdate - EndDate) > x OR (EndDate-StartDate) > x
    With a Timestamp:
    where Startdate>(EndDate-x) OR EndDate>(StartDate-x);

  • Copy value from item - disabling

    Hello all,
    How can I programatically disable 'copy value from item' property of a text item.Pls help....
    With regards
    Jeneesh.

    very easy : Don't use it
    You have to create your own functionality in this case.
    e.g. for QUERY use a PRE-QUERY, where you fill the item in the same way like the "copy value from item"
    when INSERTING use the PRE-INSERT, and so on...
    why did you have to disable the "copy value ..." ?

  • How to copy total freight value from pricing procedure to TAXINN procedure

    Dear Experts,
    I want to copy the total freight value from pricing procedure to TAXINN procedure , i think i have to use SUBROUTINE for that but can you guide me what is the routine number and in which coloum i i have to use e.g. requirement, or ALt CAl Typ, or cond Base value ???
    e.g.
    freight condition type (QTY , freight) will enter manually e.g. 100 Rs and material qty 4 so total freight is 400 Rs this value (400 Rs) i want to copy from Pricing procedure to TAXINN
    How can achieve this ????
    Thanks and regards
    Hanumant Nimbalkar

    Hello,
    If you want to calculate VAT above Freight, then in Pricing procedure make the Sub total as blank for Freight confition types.
    And in Tax procedure, make the condition base value as 363 for VAT condition type.
    Make the tax code for 4 % VAT and u'll get the desired result.
    This will solve ur purpose.
    Regards
    Prabhjot Singh Nayyar

  • Storing the values from a procedure - help required

    Hi All,
    I am having a package which consists of two procedures.
    Both the procedures need to calculate 6 averages of some of my fields based on unique number.
    (These two procedures process different unique numbers).
    Now, as same code is implemented in the two procedures for calculation,
    I want to move the logic into another procedure/function, with IN parameter as the unique number.
    Now how can I get these 6 values from the procedure.
    If I use OUT parameters, how can I get the values inside the procedure.
    Please suggest me a solution.
    Thanks in advance.
    Regards
    Raghunadh

    Example of pipelined function...
    SQL> CREATE OR REPLACE TYPE myrec AS OBJECT
      2  ( col1   VARCHAR2(10),
      3    col2   VARCHAR2(10)
      4  )
      5  /
    Type created.
    SQL>
    SQL> CREATE OR REPLACE TYPE myrectable AS TABLE OF myrec
      2  /
    Type created.
    SQL>
    SQL> CREATE OR REPLACE FUNCTION pipedata(p_str IN VARCHAR2) RETURN myrectable PIPELINED IS
      2    v_str VARCHAR2(4000) := REPLACE(REPLACE(p_str, '('),')');
      3    v_obj myrec := myrec(NULL,NULL);
      4  BEGIN
      5    LOOP
      6      EXIT WHEN v_str IS NULL;
      7      v_obj.col1 := SUBSTR(v_str,1,INSTR(v_str,',')-1);
      8      v_str := SUBSTR(v_str,INSTR(v_str,',')+1);
      9      IF INSTR(v_str,',')>0 THEN
    10        v_obj.col2 := SUBSTR(v_str,1,INSTR(v_str,',')-1);
    11        v_str := SUBSTR(v_str,INSTR(v_str,',')+1);
    12      ELSE
    13        v_obj.col2 := v_str;
    14        v_str := NULL;
    15      END IF;
    16      PIPE ROW (v_obj);
    17    END LOOP;
    18    RETURN;
    19  END;
    20  /
    Function created.
    SQL>
    SQL> create table mytab (col1 varchar2(10), col2 varchar2(10));
    Table created.
    SQL>
    SQL> insert into mytab (col1, col2) select col1, col2 from table(pipedata('(1,2),(2,3),(4,5)'));
    3 rows created.
    SQL>
    SQL> select * from mytab;
    COL1       COL2
    1          2
    2          3
    4          5Although I'm not sure you necessarily need to do it this way. Could you show us the code you are using and more details of what you are trying to do?

  • URGENT : Return Bulk data from Stored Procedure

    Hi,
    Tell me, how do I return a bulk of data which
    does not exist in the data base
    but is concluded while the Stored Procedure is executed
    from the Stored procedure
    to the C++ program.
    For Example:
    Table ABC
    Field1 Field2 Field3
    A 1 3
    B 1 5
    C 2 10
    Table DEF
    Field1 Field2 Field3
    D 10 24
    E 3 16
    F 8 19
    SP_TESTING
    Depending on the values in both the tables
    for some range of conditions,
    a conclusion X is derived for each range value of the
    condition range.
    Now I need to return this bulk of data X with the
    condition they belong to
    back to the C++ code calling it....
    NOTE : A stored procedure is requited as there is a lot
    of processing
    required before we conclude the result X for each value
    in the condition range.
    If I execute this code from C++ instead of Stored
    procedure
    it is very slow and speed is a prime requirement of my
    system.
    Also i'm not using any MFC class to access database.
    I'm using ConnectionPtr, RecordsetPtr and _CommandPtr
    from msado15.dll for database access...
    One solution to this could be use of Temp tables.
    As this process is used by a lot of different stored
    procedures having a common
    temp table to all will need something like 50 NUMERIC
    fields, 50 VARCHAR fields
    and so on, which doesn't seem like a very good solution
    to this problem.
    Sounds like something I would have done while in school,
    implement a dumb solution.
    So, please suggest me a solution as to how do I return
    bulk data in the form
    of recordsets from stored procedure.
    Regards
    Shruti

    Use Out parameter mode
    SQL> CREATE OR REPLACE procedure a1 (x  OUT NUMBER, y  OUT NUMBER) AS
      2  BEGIN
      3        x:= 1;
      4        y:= 2;
      5  END;
      6  .
    SQL> /
    Procedure created.
    SQL> SET SERVEROUTPUT ON
    SQL> DECLARE
      2   a NUMBER :=3;
      3   b NUMBER :=4;
      4  BEGIN
      5   a1 (a,b);
      6      DBMS_OUTPUT.PUT_LINE( 'a = ' || a );
      7      dbms_output.put_line( 'b = ' || b );
      8  END;
      9  .
    SQL> /
    a = 1
    b = 2
    PL/SQL procedure successfully completed.By default parameters are copied to the OUT parameter mode .
    COPY hint in PLSQL don’t send a pointer to calling program unit but NOCOPY
    does.
    Khurram

  • Copying value from one cursor to another

    Hi,
    I have a problem while copying values from one cursor to another cursor.
    The code looks like below.
    PROCEDURE XYZ
                TransactionResultSet OUT NOCOPY types.ref_cursor,
    IS
                temp_cursor types.ref_cursor;
                wip_rec types.ref_cursor;
    BEGIN
    DECLARE
                    CURSOR temp_cursor IS
                SELECT ...........
    END;
    BEGIN     
        FOR wip_rec IN temp_cursor
        LOOP
        update tinsagr set something
        where {the condition}
            IF SQL%ROWCOUNT = 0 THEN
      dbms_output.put_line('this is test ');
            Fetch wip_rec into TransactionResultSet;
         END IF;
       END LOOP;so basically i want to iterate the "temp_cursor" and depending on the values i get it from here i shall update a table. Actually i want to exclude few records from "temp_cursor" and add it/copy rest of the records to "TransactionResultSet"
    That means say initially " temp_cursor" has 100 records and i updated 5 records in a table and same number of records should be excluded and rest should be added to the output cursor TransactionResultSet.
    How do i achieve it?
    while saving i am getting
    (1): PLS-00456: item 'WIP_REC' is not a cursor.
    Do any one has any idea what to do in such scenario?

    There are options like....
    SQL> CREATE OR REPLACE TYPE emp_obj AS OBJECT (ename VARCHAR2(50), dept NUMBER);
      2  /
    Type created.
    SQL> CREATE OR REPLACE TYPE emp_tbl IS TABLE OF emp_obj;
      2  /
    Type created.
    SQL> set serverou on
    SP2-0158: unknown SET option "serverou"
    SQL> set serverout on
    SQL> DECLARE
      2    rc      sys_refcursor;
      3    v_ename emp.ename%TYPE;
      4    v_dept  emp.deptno%TYPE;
      5    ---End Of Local Varriable Declaration
      6    --Procedire declaration !
      7    PROCEDURE TEST_CUR(pi_out_ref_cur IN OUT sys_refcursor) IS
      8      emp_rec emp_tbl;
      9    BEGIN
    10      /* This BULK COLLECT can be done with explicit cursor,Ref Cursor
    11      with some simple modification, Here I have used implicit cursor! */
    12      SELECT emp_obj(ename, deptno) --Casting as the object
    13      BULK COLLECT
    14        INTO emp_rec
    15        FROM emp
    16       WHERE deptno = 10;
    17   
    18      dbms_output.put_line('Records selected are:');
    19      FOR i in 1 .. emp_rec.COUNT LOOP
    20        dbms_output.put_line(emp_rec(i).ename || '--' || emp_rec(i).dept);
    21      END LOOP;
    22      --Now we are filtering the record and may be doing some operation with each record.
    23      FOR i in 1 .. emp_rec.COUNT LOOP
    24        IF emp_rec(i).ename = 'KING' THEN
    25          --You can change this IF according to your need.
    26          emp_rec.DELETE(i);
    27        END IF;
    28      END LOOP;
    29      OPEN pi_out_ref_cur FOR
    30        SELECT * FROM TABLE(emp_rec); --Using the TYPE AS table.
    31    END TEST_CUR;
    32    /* Main execution or procedure calling section*/
    33  BEGIN
    34    --Actual calling
    35    TEST_CUR(rc);
    36    dbms_output.new_line;
    37    dbms_output.put_line('Now in Ref Cursor');
    38    dbms_output.put_line('****************');
    39    LOOP
    40      FETCH rc
    41        INTO v_ename, v_dept;
    42      dbms_output.put_line(v_ename || '--' || v_dept);
    43      EXIT WHEN rc%NOTFOUND;
    44    END LOOP;
    45 
    46  END;
    47  /
    Records selected are:
    CLARK--10
    KING--10
    MILLER--10
    Now in Ref Cursor
    CLARK--10
    MILLER--10
    MILLER--10
    PL/SQL procedure successfully completed.
    SQL>

  • Calling DTS package from Stored Procedure

    I am getting error calling DTS package from CF.
    So i want to call DTS package from SQL Server Stored
    Procedure.
    DTS package create text file. So no need of input or output
    parameter.
    What is the syntax?.
    thanks for ur help.

    Ted Kruger explains how this can be done in his blog post
    Run SSIS Package from Stored Procedure
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog

  • Copy values from a filed to another in different blocks in same table

    Hi All,
    How to copy value from a filed to another field in different blocks in same form ?
    example if i change value in Field A of block 1 it should reflect in Field B block 2 and again if i change in Field B block 2 it should reflect in Field A of block 1.
    values will change twice or thrice then it will not change. It is happening like that.
    how to do this ?
    Regards

    Same table / different blocks
    I guess, both blocks will be marked for update, and when your user presses commit, the same table will be updated twice!
    Are you sure that this is what you want to do? Is the same record current in both blocks? If so, you better use 1 block (it can be spread over several canvases and windows) and synchronize the items with the "synchronize item" property.
    Anyway: If you can't apply the synchronize-property bcos the items are in different blocks, you can synchronize with 2 when-validate-item triggers.
    Wolfram

Maybe you are looking for