How to get both, the ResultSet and Output (return value) from Oracle Stored Procedure

Hi! I am doing a conversion from MSSQL to Oracle with C++ and MFC ODBC. Any comment is appreciated!! I have Oracle 8i and Oracle ODBC 8.1.6 installed.
My question is how to retrieve the return value AND ALSO the resultSet at the same time by using Oracle function without modifying my souce codes (except puttting mypackage. string infron of my procedure name, see below).
-- My source code in C++ with MSSQL ....
sqlStr.Format("{? = call ListOfCustomers(%i)}", nNameID);
RcOpen = CustomerList.Open(CRecordset::forwardOnly, sqlStr, CRecordset::readOnly );
Where CustoemrList is a Crecordset object...
IN DoFieldExchange(CFieldExchange* pFX) I have ...
//{{AFX_FIELD_MAP(CQOSDB_Group)
pFX->SetFieldType(CFieldExchange::outputColumn);
RFX_Long(pFX, T("Name"), mCustoemrName);
//}}AFX_FIELD_MAP
// output parameter
pFX->SetFieldType( CFieldExchange::outputParam );
RFX_Int( pFX, T("IndexCount"), mCustomerNumber);
-- m_CustomerNumber is where i store the return value!!!
-- In Oracle Version, i have similar codes with ...
sqlStr.Format("{? = call mypackage.ListOfCustomers(%i)}", nNameID);
RcOpen = CustomerList.Open(CRecordset::forwardOnly, sqlStr, CRecordset::readOnly );
-- I have oracle package/Body codes as following...
create or replace package mypackage
as
type group_rct is ref cursor;
Function listgroups(
nameID NUMBER ,
RC1 IN OUT Mypackage.group_rct ) return int;
end;
Create or replace package body mypackage
as
Function listgroups(
NameID NUMBER ,
RC1 IN OUT Mypackage.group_rct )return int
IS
BEGIN
OPEN RC1 FOR SELECT Name
from Customer
WHERE ID = NameIDEND ListGroups;
END
return 7;
END listgroups;
END MyPackage;
Ive simplified my codes a bit....
null

yes, it is exactly what i want to do and I am using Oracle ODBC driver.
I tried using procedure with 1 OUT var fo numeric value and the other IN OUT ref cursor var instead of function, but error occurs when I called it from the application. It give me a memory ecxception error!!
sqlStr.Format("{? = call ListOfCustomers(%i)}", nNameID);
RcOpen = CustomerList.Open(CRecordset::forwardOnly, sqlStr, CRecordset::readOnly );
it seems to me that the ? marker var is making all the trouble... can you please give me any more comment on this?? thanks!
null

Similar Messages

  • Get a return value from a stored procedure.

    hi all ,
    i need to know where i am going wrong with the below code. I am trying to get a value from a stored procedure. the return type is int. The stored procedure works fine as i've debugged it. The variable have been declared correctly.
    int n = 0;
    proc = conn.prepareCall("{ ? = call SP_GETITEMCURRENTSOH(?,?) }");
                proc.registerOutParameter(1, java.sql.Types.INTEGER);
                proc.setString(1, locationCode);
                proc.setString(2, itemCode);
                proc.execute();           
                n = proc.getInt(1);thanks

    Hi ayub_a,
    According the [ *setString*|http://java.sun.com/javase/6/docs/api/java/sql/CallableStatement.html#setString(java.lang.String,%20java.lang.String)] method of the [*CallableStatement*|http://java.sun.com/javase/6/docs/api/java/sql/CallableStatement.html] interface, the first parameter must be a parameter name and not an ordinal position index !!!
    Edit : I've just found out the solution, it must be :
    int n = 0;
    proc = conn.prepareCall("{ ? = call SP_GETITEMCURRENTSOH(?,?) }");
                 proc.registerOutParameter(1, java.sql.Types.INTEGER);
                 proc.setString(2, locationCode);
                 proc.setString(3, itemCode);
                 proc.execute();           
                 n = proc.getInt(1);Edited by: Chicon on Jul 5, 2009 7:48 PM

  • Trying to get a return value from a Stored Procedure

    Hi folks,
    I have been tasked with something I thought was simple, but apparently its not that simple.  I am trying to call a Stored Procedure in UCCX that will do some calculations and returns back an integer value.  The stored procedure call I have is:
    DECLARE @return_status int
    EXEC @return_status = dbo.CTTLoginPhone @CTTId = $EmployeeID , @PIN = $EmployeePIN , @PhoneNumber = $CallingPhoneNumber ;SELECT 'Return_Status' = @return_status
    When I run this in this the editor, I get back one row.  If I run this in the debugger, I do not get any errors back and the stored procedure runs fine, however the Return_Status is not set either.  What am I doing wrong?
    I have defined Return_Status with intial value of 0 and the stored proc should be returning back 1 or 2, but the Return_Status remains as 0
    Can someone please let me know if I need a DB GET after a DB READ or can I just use the DB READ standalone when calling stored procedure.
    All help will be really appreciated.
    Thank you.

    I am having the same issue here... any help would be greatly appreciated. I am on UCCX 8
    I am getting 1 row returned when I click "TEST" in the READ step but the DB GET step is going into the SQL Error branch.
    Here are some details and I have attached screen shots of my script DB steps.....
    I have a Stored Procedure that is very simple...
    CREATE PROCEDURE sp_test AS
    Select 'N';
    GO
    Ive created a dummy table with 1 field..
    TABLE: testTable
    FIELD: code
    Let me know if there are any more details I can provide....

  • How to get both OTF data and spool at a time

    Hi Experts,
        My requirement is to get both OTF data and spool.
    In 'OPEN_FORM' i tried passing itcpo-TDGETOTF = 'X'. itcpo- TDNEWID = 'X'.
    I was able to get OTF data but spool is not getting generated.
    IF i pass only itcpo- TDNEWID = 'X'. the spool is getting generated but not OTF data.
    when both the fields are set i.e. itcpo-TDGETOTF = 'X'. itcpo- TDNEWID = 'X'.
    the spool is generation is getting supressed.
    Similarly when i tried to get OTF data by passing itcpo-TDGETOTF = 'X'. to 'OPEN_FORM' as i need to convert it to PDF and send it to vendors as email ,
    The print preview in TCODE ME23n was not getting generated for 'MESSAGE' option 'External send'.
    Please suggest me how to get both OTF data and spool at a time.

    Hi Kartik,
    This one is similar to my question to print and email invoice at same time.  I pass itcpo-tdgetotf = 'X' in order to get otfdata and send email with the attachment of otfdata.
    Now I have data in otfdata, but when I call print_otf function, I clear out itcpo-tdgetotf, and passed
    itcpo-tddest = device_type but I still get error message said 'Handler not valid for open spool request'.
    Can you give me a working example that you have otfdata table and print data from that table.  I also post my question on other thread
    submit report and export to memory
    thanks

  • How to continously recorded the iput and output wave

    I used NI-FGEN and NI-Scope in Bender element test a.I want to know how to continously recorded the input and output wave. Thanks you so much

    I did a bit more looking and found out that I was wrong. My apologies. NI-HWS is currently shipping with the high-speed digital products and the waveform editors (analog and digital). It is not shipping with NI-FGEN or NI-SCOPE. sfpFile shipped with NI-SCOPE 2.1.2 through 2.5 and NI-FGEN 1.5. NI-HWS was not finished in time for the latest NI-SCOPE and NI-FGEN releases. For now, you will need to use sfpFile. Copy the examples to make your life much easier. Your application is simple enough that the basic functions should work for you. Don't worry about losing your data, since sfpFile and NI-HWS use the same format. In any case, it is all based on HDF5, and you can get HDF5 utilities (free for any use) from the NCSA website. A word of warning - HDF5 is VERY powerful, but also VERY difficult to use. sfpFile and NI-HWS are based on the 1.4.4 release of HDF5. The current 1.6.x release of HDF5 is file format compatible, but binary incompatible with the 1.4.x release. NCSA did not change the format of the files they are writing, but did change the code that writes to them.
    This account is no longer active. Contact ShadesOfGray for current posts and information.

  • I've tried safe mode but I dont understand what is happening. I tried pressing the power button on and off for several times and nothing happens, I'm always stuck on an apple logo and a spinning wheel. I dont know how to get to the Partition and the DiskU

    I've tried safe mode but I dont understand what is happening. I tried pressing the power button on and off for several times and nothing happens, I'm always stuck on an apple logo and a spinning wheel. I dont know how to get to the Partition and the DiskUtility. The Apple Logo and the Progress Indicator will continue to spin and I have literally no idea what to do. i am in desperate need of help. help me pls

    Turn it off.
    Start it up again and (at the sound of the chime) press and hold the command and the R keys, hold them down until Recovery loads. When it does you will select Disk Utility and you should be on the First Aid tab when it opens, if you are not please select it. Then select the partition (in the side bar, 2nd entry on the list, see picture).
    Yours is probably called Macintosh HD.
    Once you have selected it go to the lower righthand corner of the First Aid dialog and press Repair Disk.
    This will take 10 minutes approximately. Post back when it is finished and tell me what it says.

  • Get OUTPUT and RETURN parameters from a stored procedure

    I have a stored procedure (MS SQL Server 2008 R2) like the following example.
    Using Database Connectivity I can get the OUTPUT parameters but I can't get de RECORDSET DATA and de RETURN value.
    Does anybody knows how to do that?
    CREATE PROCEDURE [dbo].[TS_Teste] (@T057_S_NOMEMAQUINA VARCHAR(20), @STATUS INT OUTPUT, @ERRO NVARCHAR(500) OUTPUT)
    AS
    BEGIN     
      DECLARE @TABLE TABLE(CODIGO INT, DESCRICAO VARCHAR(30))
      INSERT INTO @TABLE VALUES (51, 'A')     
      INSERT INTO @TABLE VALUES (52, 'B')
      INSERT INTO @TABLE VALUES (53, 'C')
      SELECT * FROM @TABLE
      SET @STATUS = 1
      SET @ERRO = 'Nenhum erro!'
      RETURN 0
    END
    Solved!
    Go to Solution.
    Attachments:
    SQL SP Return.vi ‏29 KB

    I finaly found what was wrong... It was necessary an only aditional line in the stored procedure. It should be like that:
    CREATE PROCEDURE [dbo].[TS_Teste] (@T057_S_NOMEMAQUINA VARCHAR(20), @STATUS INT OUTPUT, @ERRO NVARCHAR(500) OUTPUT)
    AS
    BEGIN    
      SET NOCOUNT ON;                                                                                               -- NEW LINE!!!
      DECLARE @TABLE TABLE(CODIGO INT, DESCRICAO VARCHAR(30))
      INSERT INTO @TABLE VALUES (51, 'A')    
      INSERT INTO @TABLE VALUES (52, 'B')
      INSERT INTO @TABLE VALUES (53, 'C')
      SELECT * FROM @TABLE
      SET @STATUS = 1
      SET @ERRO = 'Nenhum erro!'
      RETURN 0
    END

  • How to get report in excel format instead of pdf from oracle forms.

    Hi,
    How to get report in excel format instead of pdf from oracle forms.
    Form & Report developer 10g
    report format .rdf

    create a report using report builder.
    call the report from form using the following procedure
    DECLARE
         RO_Report_ID REPORT_OBJECT;
         Str_Report_Server_Job VARCHAR2(100);
         Str_Job_ID VARCHAR2(100);
         Str_URL VARCHAR2(100);
         PL_ID PARAMLIST ;
    BEGIN
    PL_ID := GET_PARAMETER_LIST('TEMPDATA');
         IF NOT ID_NULL(PL_ID) THEN
    DESTROY_PARAMETER_LIST(PL_ID);
         END IF;
         PL_ID := CREATE_PARAMETER_LIST('TEMPDATA');
         RO_Report_ID := FIND_REPORT_OBJECT('RP2RRO');
         Add_Parameter(pl_id,'P_SUPCODE',TEXT_PARAMETER,:CONTROL.S_CODE);
    Add_Parameter(pl_id,'P_INVOICE_NO',TEXT_PARAMETER,:CONTROL.IN_NO);
    Add_Parameter(pl_id, 'PARAMFORM', TEXT_PARAMETER, 'NO');
         SET_REPORT_OBJECT_PROPERTY(RO_Report_ID, REPORT_FILENAME, 'INVOICE_REG_DETAILS.rep');
         SET_REPORT_OBJECT_PROPERTY(RO_Report_ID, REPORT_COMM_MODE, SYNCHRONOUS);
         SET_REPORT_OBJECT_PROPERTY(RO_Report_ID, REPORT_EXECUTION_MODE, BATCH);
         SET_REPORT_OBJECT_PROPERTY(RO_Report_ID, REPORT_DESTYPE, FILE);
         SET_REPORT_OBJECT_PROPERTY(RO_Report_ID, REPORT_DESFORMAT, 'SPREADSHEET');
         SET_REPORT_OBJECT_PROPERTY(RO_Report_ID, REPORT_SERVER, 'rep_dbserver_frhome1');
         Str_Report_Server_Job := RUN_REPORT_OBJECT(RO_Report_ID, PL_ID);
         Str_Job_ID := SUBSTR(Str_Report_Server_Job, LENGTH('rep_dbserver_frhome1') + 2, LENGTH(Str_Report_Server_Job));
         Str_URL      := '/reports/rwservlet/getjobid' || Str_Job_ID || '?server=rep_dbserver_frhome1';
         WEB.SHOW_DOCUMENT(Str_URL, '_SELF');
         DESTROY_PARAMETER_LIST(PL_ID);
    END;

  • How to connect to UNIX OS from oracle stored procedure

    Hi,
    I need to connect to UNIX OS from oracle stored procedure.
    Curently working in Oracle9i.
    I tried in google but I could'nt get any.
    Can you send me pointers on how to do this.
    Thanks,
    Kavitha.

    Can use Java Stored Proc, or an External Proc.
    Java method:
    create or replace and compile Java Source named "OSCommand" as
    -- java:        OS COMMAND
    -- descr:       Executes an Operating System Command using the JAVA RTS
    -- IN parameter:        os command to execute (including fully qualified path names)
    -- OUT parameter:       returncode [\nstring]
    --                      where string a max of 32000 chars of the output of the command
    --                      (note that \n is used as separators in the string)
    --                      returncode=-1   Java RTS error occurred (e.g. command does not exist)
    --                      returncode=255  o/s command failed (e.g. invalid command params)
    import java.io.*;
    import java.lang.*;
    public class OSCommand{
            public static String Run(String Command){
                    Runtime rt = Runtime.getRuntime();
                    int     rc = -1;
                    try{
                            Process p = rt.exec( Command );
                            int bufSize = 32000;
                            int len = 0;
                            byte buffer[] = new byte[bufSize];
                            String s = null;
                            BufferedInputStream bis = new BufferedInputStream( p.getInputStream(), bufSize );
                            len = bis.read( buffer, 0, bufSize );
                            rc = p.waitFor();
                            if ( len != -1 ){
                                    s = new String( buffer, 0, len );
                                    return( s );
                            return( rc+"" );
                    catch (Exception e){
                            e.printStackTrace();
                            return(  "-1\ncommand[" + Command + "]\n" + e.getMessage() );
    show errors
    create or replace function osexec( cCommand IN string ) return varchar2 is
    -- function:    OS EXEC
    -- descr:       Executes an Operating System Command
    language        JAVA
    name            'OSCommand.Run(java.lang.String) return java.lang.String';
    show errors===
    This can then be used from PL/SQL and even SQL. e.g.
    SQL> select osexec( '/bin/date' ) from dual;
    OSEXEC('/BIN/DATE')
    Wed Nov  9 13:30:13 SAST 2005
    SQL>Note the Java permissions required - replace FOO with the name of applicable Oracle schema
    ==begin
            dbms_java.grant_permission(
                    'FOO',
                    'SYS:java.io.FilePermission',
                    '<<ALL FILES>>',
                    'execute'
            dbms_java.grant_permission(
                    'FOO',
                    'SYS:java.lang.RuntimePermission',
                    'writeFileDescriptor',
            dbms_java.grant_permission(
                    'FOO',
                    'SYS:java.lang.RuntimePermission',
                    'readFileDescriptor',
            commit;
    end;
    /==
    Last thing... note that opens a potential giant size security hole into the Oracle Server Platform. So implement it properly using a proper Oracle security model.

  • How do I return two values from a stored procedure into an "Execute SQL Task" within SQL Server 2008 R2

    Hi,
    How do I return two values from a
    stored procedure into an "Execute SQL Task" please? Each of these two values need to be populated into an SSIS variable for later processing, e.g. StartDate and EndDate.
    Thinking about stored procedure output parameters for example. Is there anything special I need to bear in mind to ensure that the SSIS variables are populated with the updated stored procedure output parameter values?
    Something like ?
    CREATE PROCEDURE [etl].[ConvertPeriodToStartAndEndDate]
    @intPeriod INT,
    @strPeriod_Length NVARCHAR(1),
    @dtStart NVARCHAR(8) OUTPUT,
    @dtEnd NVARCHAR(8) OUTPUT
    AS
    then within the SSIS component; -
    Kind Regards,
    Kieran. 
    Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/

    Below execute statement should work along the parameter mapping which you have provided. Also try specifying the parameter size property as default.
    Exec [etl].[ConvertPeriodToStartAndEndDate] ?,?,? output, ? output
    Add a script task to check ssis variables values using,
    Msgbox(Dts.Variables("User::strExtractStartDate").Value)
    Do not forget to add the property "readOnlyVariables" as strExtractStartDate variable to check for only one variable.
    Regards, RSingh

  • From which table ,i ll get both the invoice and cleared amount ???

    Hi Friends,
    i am making a report for my sales client where finance part is also required.
    the requirement is : the sales people want know the status of the invoice generated at their end.the report shud be like if they enter the invoice no,fiscal year and coustomer they will be able to see the status of the invoice.how much pmt has received for that particular invoice,wheather it is open or fully cleared?
    From which table i can get both invoice no. and the payment/pmts rerceived against that invoce/invoices.
    plz guide.
    Regards,
    Biswa

    Hi,
    SAP Standard Report itself covers all the requirements mentioned.  With FBL5N, we get to know how much has been invoiced, paid and cleared and how much advance has been paid by customer etc., in one screen.  Apart from this we have also all signs which show, which all invoices are due, overdue and its easy to analyse as well.
    Was this requirement given by client after seeing this standard report?
    Hope this info is helpful.
    Regards,
    Venkat

  • HT1483 Ipod froze. How to get over the problem and bring it back?

    Ipod froze and not responding. How to get over this problem and bring back the Ipod ?

    Go to the  menu/About This Mac - what OS version shows there?
    Do a backup, preferably 2 separate ones on 2 separate drives.
    Revert to a Previous OS X
    Revert to Snow Leopard
    If you do revert, I'd use Setup Assistant to restore your data. This process takes a while, so do it when you won't need the computer for several hours, based on my experience.

  • How to get list of Customers and their FOB terms from backend?

    Hi All,
    Can anyone help me with the customers and their FOB terms from the backend? What tables can be linked to get that information??
    Thanks,
    Prathima

    Can you please share your solution ?

  • How do I get return parameters from a stored procedure call?

    The Open SQL Statement has an option on the Advanced tab to specify a command type of 'stored procedure'. In addition to returning a recordset, a stored procedure can also return parameters (see http://support.microsoft.com/support/kb/articles/Q185/1/25.ASP for info on doing this with ADO). Is it possible to get those return parameters with TestStand? In particular, I want to be able to get error codes back from the stored procedure in case it fails (maybe there is another way).

    The Open SQL Statement step type does not fully support stored procedures. If the procedure returns a record set than you can fetch the values as you would a SELECT statement. Stored procedures require you to setup the parameters before the call and this is not yet supported. Bob, in his answer, made a reference to the Statements tab and I think that he was talking about the Database Logging feature in TS 2.0.
    If the stored procedure is returning a return value, it may return as a single column, single row recordset which can be fetched as you normally do a record set.
    Scott Richardson
    National Instruments

  • Get variable values from a stored procedure

    I am using SQL 2008R2 and I want to replace a view inside a stored procedure with a new stored procedure to return multiple variable values. Currently I am using the code below to get values for 4 different variables.  I would rather get the 4 variables
    from a stored procedure (which returns all of these 4 values and more) but not sure how to do so.  Below is the code for getting the 4 variable values in my current sp.
    DECLARE @TotalCarb real;
    DECLARE @TotalPro real;
    DECLARE @TotalFat real;
    DECLARE @TotalLiquid real;
    SELECT @TotalCarb = ISNULL(TotCarb,0),
    @TotalPro = ISNULL(TotPro,0),
    @TotalFat = ISNULL(TotFat,0),
    @TotalLiquid = ISNULL(TotLiq,0)
    FROM dbo.vw_ActualFoodTotals
    WHERE (MealID = @MealID);

    You can replace the view with inline table valued user-defined function:
    http://www.sqlusa.com/bestpractices/training/scripts/userdefinedfunction/
    See example: SQL create  INLINE table-valued function like a parametrized view
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

Maybe you are looking for

  • Ipod [fifth gen 30gb] crashes computer when transferring songs

    Hi Ive had my ipod for about 6 months. I update songs manually from my work and home macs. Last week I tried updating but the computer screen went dark(er) with the following message in a black box in middle of screen: "You need to restart your compu

  • User defined message search in PI 7.1 EHP1

    Helly, I heard about the new feature in EHP1: "Search asynchronous messages by business-relevant information criteria contained in the message payload (SalesOrder Number, customerID, etc)." Has anybody tried it yet? Is that realy as simple as it soun

  • Connecting Ipod Shuffle to windows

    I give. When I try to connect my Ipod shuffle 2nd gen. to my computer (dell running windows xp) it shuts down and re-boots the computer every time. I charged the Shuffle off line with a 120V plug in charger that didn't help. Other devices I.E. thumb

  • 10.4.7 problem...Please help

    I am kind of concerned about this. I trust Apple not to send me faulty software. But I am worried... Ever since installing the 10.4.7 update...my iMac G5 will not stop running a couple of things called "pplogger" & "pploader". My cooling fan is runni

  • Oracle/toplink/internal/helper/ConcurrencyManager.acquire "Hang"

    Hi, I am trying to test an application on WAS with some load (200 virtual users from a load-runner) experiencing a hand condition. There are 128 threads waiting with the below stack trace. at java/lang/Object.wait(Native Method) at java/lang/Object.w