Procedure with parameters

I have about 35 with Select INSERT in a single script file (example below) and they all accept two parameters (username, location).

What is the best way to create a package in this case?

And, instead of coding in hard pass UserID and its location; How to pass those values to the package?

declare

sUserID varchar2 (6): = "ABC112";

Location varchar2 (6): = "US0009";

INSERT INTO MyTempTable (city, State, Zip)

SELECT City, State, zip from MyTable1

WHERE UserID = 'JDOE01' AND the location = "US0009".

commit;

INSERT INTO MyTempTable (city, State, Zip)

SELECT City, State, zip from MyTable2

WHERE UserID = 'JDOE01' AND the location = "US0009".

commit;

And so on...

Hello

881668 wrote:

I have about 35 procedures in a single script file (example below) and they all accept two parameters (username, location).

What is the best way to create a package in this case?

And, instead of coding in hard pass UserID and its location; How to pass those values to the package?

declare

sUserID varchar2 (6): = "ABC112";

Location varchar2 (6): = "US0009";

INSERT INTO MyTempTable (city, State, Zip)

SELECT City, State, zip from MyTable1

WHERE UserID = 'JDOE01' AND the location = "US0009".

commit;

INSERT INTO MyTempTable (city, State, Zip)

SELECT City, State, zip from MyTable2

WHERE UserID = 'JDOE01' AND the location = "US0009".

commit;

And so on...

The code you posted is not ' t have procedures.  When you say 'procedure', do you mean 'anonymous block '?

Maybe you want a package body that looks like this:

CREATE or REPLACE PACKAGE BODY fubar
AS

PROCEDURE insert_MyTempTable
(
sUserID in VARCHAR2
in_Location IN VARCHAR2
)
IS
BEGIN

INSERT INTO MyTempTable (city, State, Zip)
SELECT City, State, zip
From MyTable1
WHERE UserID = sUserID
AND location = in_Location
UNION ALL
SELECT City, State, zip
From MyTable2
WHERE UserID = sUserID
AND the location = in_Location;

commit;  -Maybe
END insert_MyTempTable;

Fubar END;
/
DISPLAY ERRORS

Before you create the package body, however, you must create a package specification, which can be just the names of procedure and lists of arguments of the package body, like this;

CREATE or REPLACE PACKAGE fubar
AS

PROCEDURE insert_MyYempTable
(
sUserID in VARCHAR2
in_Location IN VARCHAR2
)
;

Fubar END;
/
DISPLAY ERRORS

Note that you can declare the types of the arguments (for example, VARCHAR2) in the package, but no details such as the maximum length (in other words, you don't tell VARCHAR2 (6).)  The actual size is determined by the appellant.

If a variable is used in a SQL statement, make sure that there not exactly the same name as a column in any table used in this declaration.  Since the argument is used in a SQL statement, and the statement references a table that has a column called location, location isn't a good name for the argument.  That's why I called it in_location.

It may be better not to be INVOLVED in the procedure.  It is better to give the appellant the opportunity to COMMIT or ROLLBACK later.

Tags: Database

Similar Questions

  • Calling stored procedures with parameters with the database connectivity Toolkit

    Hi all

    I'm new to the forum and struggling to find a solution to a particular problem I have in this respect, using the LabVIEW Database Connectivity Toolkit on a project, I am currently working on my work.  I have a database in which I tables and stored procedures with parameters.  Some of these stored procedures have input, output and return parameters.

    I tried to follow this example, but to no avail: http://digital.ni.com/public.nsf/allkb/07FD130746083E0686257300006326C4?OpenDocument

    Such a stored procedure I am working on the implementation is named "dbo.getAllowablePNs", running "SELECT * from DeviceType" (DeviceType is the table).  In this case, it requires no input parameter, it has an output parameter that generates the table [cluster] and has a return parameter that returns an integer value (status code for execution) 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 surpassed many examples and I talk to the support OR try to implement this and similar procedures stored in LabVIEW but have not been successful.  I am able to connect to the database with the VI of open connection without error, but spin in some confusion as a result of this step.  I then try to use the VI of parameter query create to call the stored procedure and set the parameters.  I guess I would then use the Set parameter value for each parameter that is connected to the entry of parameters on the previous query with parameters VI VI?  I am also having some confusion during and after these steps as well.  I would greatly appreciate advice or suggestions that anyone could have in this situation because I am not a SQL expert.  Also, I would be happy to provide more information that might be useful.

    Kind regards

    Jon

    Here's what I use to do this.  I think I had to change him create parameterized query VI for him to work.  There is a post on the forum about this somewhere.

  • How to run a procedure with parameters in pl/sql collections?

    I created a procedure with parameter from the collection. Can somone help me how to run a procedure in passing the parameters in the collection.
    Package and how to create is successful. But I get the error message when executing the procedure.

    ORA-06550: line 3, column 19:
    PLS-00222: no function with name 'T_TAB' does exist in this scope

    I gave the example of code here. Can someone please help me solve this problem.

    -Spec package

    create or replace package pkg_dist is

    TABLE index IS THE NUMBER of t_tab_num TYPE of PLS_INTEGER;


    procedure prc_test (a t_tab_num IN,
    b IN t_tab_num,
    c IN OUT t_tab_num);
    end pkg_dist;

    -Package body

    create or replace package body is pkg_dist

    procedure prc_test (a t_tab_num IN,
    b IN t_tab_num,
    c IN OUT t_tab_num) is


    Start


    IF (a (16) = 0) then
    (16) c: = 0;
    c (17): = 0;
    c (18): = 0;
    end if;
    c (15): = (14)-(15)-a (16);
    (16) c: = b (16) /b (17);
    c (17): = 50;
    (18) c: = a (16) * 2;

    end prc_test;
    end pkg_dist;

    -executeing procedure

    declare
    TABLE index IS THE NUMBER of t_tab TYPE of PLS_INTEGER;
    x t_tab: = t_tab (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);
    y t_tab: = t_tab (0,10,15,20,25,30,35,40,45,50,60,75,100,125,150,200,250,500);
    z t_tab;
    BEGIN
    pkg_dist.prc_test (x, y, z);
    dbms_output.put_line (z (18));
    END;

    Error:
    --------------------------------------------------------------------------------
    ORA-06550: line 3, column 19:
    PLS-00222: no function with name 'T_TAB' does exist in this scope

    My suggestion would be:

    CREATE OR REPLACE PACKAGE pkg_dist IS
    
       PROCEDURE prc_test (a IN SYS.odcinumberlist, b IN SYS.odcinumberlist, c IN OUT SYS.odcinumberlist);
    END pkg_dist;
    
    CREATE OR REPLACE PACKAGE BODY pkg_dist IS
       PROCEDURE prc_test (a IN SYS.odcinumberlist, b IN SYS.odcinumberlist, c IN OUT SYS.odcinumberlist) IS
       BEGIN
          IF (a (16) = 0) THEN
             c (16) := 0;
             c (17) := 0;
             c (18) := 0;
          END IF;
    
          c (15) := a (14) + a (15) + a (16);
          c (16) := b (16) / b (17);
          c (17) := 50;
          c (18) := a (16) * 2;
       END prc_test;
    END pkg_dist;
    /
    
    DECLARE
       x   SYS.odcinumberlist;
       y   SYS.odcinumberlist;
       z   SYS.odcinumberlist;
    BEGIN
       x := sys.odcinumberlist (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);
       y := sys.odcinumberlist (0,10,15,20,25,30,35,40,45,50,60,75,100,125,150,200,250,500);
       z := sys.odcinumberlist (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
       pkg_dist.prc_test (x, y, z);
       DBMS_OUTPUT.put_line (z (18));
    END;
    /
    

    See you soon,.
    Manik.

  • FND_REQUEST PL/SQL procedure with parameters

    Hi guys

    I created a concurrent program, using the PL/SQL procedure that has 2 parameters. I try to call the concurrent program to help

    v_req_id: = FND_REQUEST. SUBMIT_REQUEST ('INV', 'OMS_POP_INVVALUES_P',

    NULL, SYSDATE, FALSE, l_on_date, l_org_id,.

    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,

    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,

    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,

    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,

    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,

    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,

    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,

    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,

    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,

    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL

    );

    COMMIT;

    However, the competitor programming always fail with

    * Starts * August 26, 2013 14:02:31 error ORACLE 6550 for Cause of FDPSTP: FDPSTP failed due to the ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in the call to 'OMS_POP_INVVALUES_P' ORA-06550: line 1, column 7: PL/SQL: statement ignored

    and I doubt that it is because the database procedure call is not correct.

    I put four parameters with the simultaneous program, as they were with the procedure itself, which are

    p_on_date BY DATE, NUMBER, errbuff OUT VARCHAR2, OUT VARCHAR2 retcode p_org_id

    Help, please

    Kind regards

    REDA

    Okay I solved the problem of

    1. change the order of the parameters in the procedure

    CREATE OR REPLACE PROCEDURE OMS_POP_INVVALUES_P)

    errbuff OUT VARCHAR2, retcode ON NUMBER, p_on_date AS, p_org_id in NUMBER)

    IS

    and by changing the call of simultaneous program as follows

    l_req_id: =.

    fnd_request.submit_request ('INV', 'OMS_POP_INVVALUES_P',

    NULL, SYSDATE, FALSE, l_in_date, l_org_id, CHR (0));

    : SYSTEM. Message_Level: = '25';

    COMMIT;

    After removing all the parameters of the list of program parameters. No need to pass a value for errbuff and retcode, just pass other parameters and put an end to the list of parameters with CHR (0). Hope it's useful for someone else there.

    Kind regards

    REDA

  • How to perform the procedure with parameters of type collection

    Hello

    I have the setting as the procedure
     PROCEDURE addGroup (
        Id IN NUMBER,
        sId IN NUMBER,
        gIds IN NUMBERLIST)
    CREATE OR REPLACE TYPE NUMBERLIST AS TABLE NUMBER;
    /





    could you help me by asking this type as a parameter the procedure...

    Thank you

    This is the type:

    SQL> create or replace type NUMBERLIST is table of number;
      2  /
    
    Type created.
    

    This is the procedure:

    SQL> create or replace PROCEDURE addGroup (
      2      Id IN NUMBER,
      3      sId IN NUMBER,
      4      gIds IN NUMBERLIST)
      5  is
      6  begin
      7    null;
      8  end;
      9  /
    
    Procedure created.
    

    And you call it this way:

    SQL> declare
      2  n numberlist := numberlist(1,2,3,4);
      3  begin
      4    addGroup(1,2,n);
      5  end;
      6  /
    
    PL/SQL procedure successfully completed.
    

    Max
    [My Italian blog Oracle | http://oracleitalia.wordpress.com/2010/01/23/la-forza-del-foglio-di-calcolo-in-una-query-la-clausola-model/]

  • Call the PL/SQL procedure with different parameters?

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

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

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

    Thank you!

    user2960509 wrote:

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

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

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

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

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

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

    http://my-webserbver.my-domain.com/pls/dad/!scott.mywebproc?name-1=val-1&name-2=val-2..,name-n=val=n
    
  • Procedure with THE parameters - creating a report

    I have the following procedure which is used in our applications (non-APEX) internal:
    PROCEDURE SelIssueActivityPublic (
                                                p_results           OUT     SYS_REFCURSOR,
                                                p_IssueID                    IN     ems.issue.issue_id%TYPE,
                                                p_TransactionID         OUT VARCHAR2
                 ) 
    The body of the procedure made a lot of treatment and inserts data into an intermediate table. The cursor ON the parameter then returns a SELECT statement in the staging table. Since it is possible that this procedure be struck several times (several users), transaction ID is used to match the data in the staging table to demand appropriate. The procedure then deletes the data from the staging table. (I'll post if necessary, but it is quite long, and since it is used successfully in other applications, I don't think it relates to my question).

    Asked me to create a report of the APEX data generated by the procedure. I've never used a procedure with an OUT parameter to create a report. I was hoping to assign transaction ID to a variable hidden on the loading of the page and then use it to poplulate the report. I'm not interested in the OUT parameter slider, I wrote my own SELECT statement to retrieve the data from the staging table.

    I tried to create a page that did that - agenda: H_P19_TRANSID, before the header calculation = EMS. EMS_READER. SelIssueActivityPublic (: H_P19_CURSOR, 454551,: H_P19_TRANSID) [454551 is a test question id], but I get the following error:
    ORA-06550: line 1, column 43: PLS-00222: no function with name 'SELISSUEACTIVITYPUBLIC' exists in this scope ORA-06550: line 1, column 7: PL/SQL: Statement ignored flowComp=H_P19_TRANSID
     Error ERR-1030 Error executing computation expression.
    He seems to think that SelIssueActivityPublic is a function, and I don't know why.

    Basically, I need to know how to use this procedure to put up my report. Once I can enter the transaction ID in a page element, I'll be set.

    How your procedure? You know that you can have the same procedure in the package with several definitions. Oracle allows you to use polymorphism, the ability to have multiple definitions of the same object with different signatures.

    Correction... You can not have a procedure of p in the case, are a function, since the calculation is expected to a way to fill the hidden element... You need a function to return the type of variable you want in the hidden element...

    Thank you

    Tony Miller
    Webster, TX

    Published by: Tony Miller on March 16, 2010 12:34

  • How to get 2 out of procedure with sql dynamic param?

    Hello

    following my other question on the treatment in the ranks, so that I did a procedure defined ranges for the table I want to deal with;

    I did another procedure to obtain a particular range for treatment and that's where I have a problem;

    My data are:

    {

    CREATE THE TABLE PRECUBE. TEST_STG_TMO_RANGES

    (

    NUMBER OF GLASS FIBER,

    MIN_RID VARCHAR2 (18 BYTE),

    MAX_RID VARCHAR2 (18 BYTE)

    )

    tablespace UTI_DAT;

    Insert into TEST_STG_TMO_RANGES (GRP, MIN_RID, MAX_RID) values (0, 'AABKSxAAEAACW3pAAA', 'AABKSxAAEAADqCICcQ');

    Insert into TEST_STG_TMO_RANGES (GRP, MIN_RID, MAX_RID) values (1, "AABKSxAAEAADqCJAAA", "AABKSxAAEAAD + wICcQ");

    Insert into TEST_STG_TMO_RANGES (GRP, MIN_RID, MAX_RID) values (2, ' AABKSxAAEAAD/QJAAA', 'AABKSxAAEAAECyICcQ');

    Insert into TEST_STG_TMO_RANGES (GRP, MIN_RID, MAX_RID) values (3, 'AABKSxAAEAAEFQJAAA', 'AABKSxAAEAAEL8ICcQ');

    Insert into TEST_STG_TMO_RANGES (GRP, MIN_RID, MAX_RID) values (4, 'AABKSxAAEAAEMSJAAA', 'AABKSxAAEAAEPwICcQ');

    }

    my package:

    {

    create or replace
    PACKAGE C_UTI_BASIC AS
    procedure P_GET_RANGE (table_owner_in in varchar2
    TABLE_NAME_IN in varchar2
    range_no number
    Min_RANGE_OUT OUT varchar2
    max_range_OUT OUT varchar2
    );

    END C_UTI_BASIC;

    }

    My procedure:

    {

    procedure P_GET_RANGE (TABLE_OWNER_IN in varchar2
    TABLE_NAME_IN in varchar2
    RANGE_NO number
    MIN_RANGE_OUT OUT varchar2
    MAX_RANGE_OUT OUT varchar2
    )
    is

    DDL_STATEMENT varchar2 (4000);

    Start

    DDL_STATEMENT: ='select MIN_RID, MAX_RID in MIN_RANGE_OUT, MAX_RANGE_OUT in '. TABLE_OWNER_IN |'. ' || TABLE_NAME_IN | "_RANGES where PRV =' | RANGE_NO;

    immediately run DDL_STATEMENT;
    DBMS_OUTPUT. PUT_LINE (DDL_STATEMENT);
    DBMS_OUTPUT. Put_line ('Min_RANGE_OUT :'||) Min_RANGE_OUT);
    DBMS_OUTPUT. Put_line ('max_range_OUT :'|| max_range_OUT);
    end P_GET_RANGE;

    }

    I tried to call the procedure with:

    {

    declare

    V_MIN_RANGE_OUT varchar2 (30);

    v_Max_RANGE_OUT varchar2 (30);

    Start

    C_UTI_BASIC. P_GET_RANGE (TABLE_OWNER_IN = > 'PRECUBE')

    , TABLE_NAME_IN = > 'TEST_STG_TMO '.

    , RANGE_NO = > '4'

    , MIN_RANGE_OUT = > V_MIN_RANGE_OUT

    , MAX_RANGE_OUT = > v_Max_RANGE_OUT

    );

    end;

    }

    but it ends with the error:

    Error report:

    ORA-06510: PL/SQL: not supported by the user-defined exception

    ORA-06512: at "DWH_ADMIN. C_UTI_BASIC', line 2331

    ORA-00905: lack of keyword

    ORA-06512: at line 5

    06510 00000 - "PL/SQL: not supported by the user-defined exception.

    * Cause: A user-defined exception has been raised by PL/SQL code, but

    not been processed.

    * Action: Fix the problem that causes the exception or write an exception

    Manager for this condition. Or you may have to contact your

    Director of application or DBA.

    When I jump the "run immediately" just to see what is output through DBMS output here it is:

    {

    Select MIN_RID, MAX_RID in MIN_RANGE_OUT, PRECUBE MAX_RANGE_OUT. TEST_STG_TMO_RANGES where PRV = 4

    Min_RANGE_OUT:

    max_range_OUT:

    }

    the select statmetent seems OK for me, but the parameters are not met and have the value null;

    I would appreicate advice on where I went wrong here and how achieve a correct output

    THS

    Rgds

    Rgds

    Outside the use of SQL statements cr@p Dynamics (i.e. DML and not the DDL as implied by your code) and your total lack of variable bind...

    And that is your problem.  Your dynamic instruction seeks to select VARIABLES that are out of reach of the dynamic statement itself.  The IN such statements should be part of the EXECUTE IMMEDIATE for example

    EXECUTE IMMEDIATE ddl_statement INTO min_range_out, max_range_out;

  • Java - a stored procedure with call by result

    Hi the Oracle community,

    I'm looking for some example Code how to use a Java-Stored procedure with output parameters. Don't get me wrong. I don't want to call a procedure with the parameters Out of Java (there are many examples in this respect over there). I want to just implement the appeal of the concept of results in a Java-Stored procedure. A customer calls this procedure with certain parameters and the Java procedure will fill the. So my first question: is it possible? And my second Question: how to implement it?

    Greetings.

    I found a solution. It's very simple.

    Just setting the parameters as java array (e.g., String() P1). The first value (P1 [0]) is the returned value.

    Finally just contained JDeveloper in dialog box "Edit method Signature" the parametermode OUT.

    The dialog box are entitled on the stored procedure in the dbexport file. You can read this

    in Section 6, publishing Java Classes with call specifications-> defining the Modes parameter in

    The Oracle database Java Developer's Guide.

  • Call the PL/SQL procedure with in out parameter of OIC clob

    Hello

    For a few days, I am facing a problem. I have to call the pl/sql procedure with colb parameter out. I use c ++ and OIC (don't ask me why :)).

    I use a pl/sql problem test procedure:

    create or replace function Test (longField outside clob) return number is
    Number of result;
    Start
    longField: = 'prefix ';
    Result: = 12;
    Return (result);
    end Test;

    So I do all the stuff with the connection to the DB,

    I prepare the statement: "start: res: = test(:param); end; »
    So I OCIHandleAlloc (m_pCtx-> hpEnv,
    (void *) & m_hpStatement,.
    OCI_HTYPE_STMT,
    0,
    (NULL);
    and
    OCIStmtPrepare (m_hpStatement,
    m_pCtx-> hpErr,
    (...),
    (...),
    OCI_NTV_SYNTAX,
    OCI_DEFAULT);

    Before the binding I prepare parameters. For a clob I devote to the lob Locator:

    OCIDescriptorAlloc ((dvoid *) m_pCtx-> hpEnv, (dvoid *) & m_pLobLocator,)
    (ub4) OCI_DTYPE_LOB (size_t) 0, (dvoid *) 0);
    OCILobEnableBuffering (m_pCtx-> hpContext, m_pCtx-> hpErr, (OCILobLocator *) m_pLobLocator);

    that I bind parameters using OCIBindByName and OCIStmtExecute statement execution.

    I get an error
    ---------------------------
    Microsoft Visual C++
    ---------------------------
    Unhandled exception in... (ORAOCIEI11. (DLL): 0xC0000005: Access Violation.

    My question is: is it possible to call the pl/sql procedure with parameter BEAK clob?
    If Yes, what steps I need to do to succeed?

    Thank you for your response.

    Hello

    Of course, it is possible :)

    Show that you are your piece of code that is binding.
    Are you sure you had correctly the lob descriptor in the call to bind?

  • How to call a stored procedure with a REF CURSOR output parameter

    I'm looking forward to example calling a function/stored procedure with a REF CURSOR output parameter and get the result.
    In other words, I have a stored function/procedure that runs a SELECT statement using the OCI library and then he could get the values of each row and each column.

    I put a code snippet, it have only the main thing to call a simple stored procedure and to print the name of each column of the cursor, but I couldn t to print out values in the table that calls the stored procedure.
    I understand that the next step is to call an OCIStmtFetch.
    How to associate the slider with the OCIStmtFetch?

    If you need more information, just tell me.

    I use ANSI C with HP - UX (HP - UX C) operating system and Oracle 10 g.


    Kind regards.

    Antonio Garcia


    / * callOracleSP * /.

    #include < stdio.h >
    #include < string.h >
    #include < oci.h >
    #include < stdlib.h > to

    char * pConnectChar = "Server";
    char * pUsernameChar = "user";
    char * pPasswordChar = "passwd";
    char * sqlCharArray1 = "BEGIN SP_GETCITIES (:,: c); END; « ;
    int retval;
    UB4 parmcnt = 0;
    UB4 pos2 = 0;
    text * pcoln [20];
    UB4 namelen [20];
    char state_key [5];

    OCIStmt * pOciStatement;
    OCIStmt * pOciStatCursor;
    OCIError * pOciError;
    OCIEnv * pOciEnviron;
    OCIServer * pOciServer;
    OCISession * pOciSession;
    OCISvcCtx * pOciServiceContext;
    OCIBind * pOciBind [500];
    OCIParam * pOciParam;


    int main()
    {
    retval = OCIEnvCreate (& pOciEnviron, OCI_DEFAULT, NULL, NULL, NULL, NULL, 0, NULL);
    retval = OCIEnvInit (& pOciEnviron, OCI_DEFAULT, 0, NULL);
    retval = OCIHandleAlloc (pOciEnviron, (void *) & pOciError, OCI_HTYPE_ERROR, 0, NULL);
    retval = OCIHandleAlloc (pOciEnviron, (void *) & pOciServiceContext, OCI_HTYPE_SVCCTX, 0, NULL);
    retval = OCIHandleAlloc (pOciEnviron, (void *) & pOciStatement, OCI_HTYPE_STMT, 0, NULL);

    retval = OCILogon (pOciEnviron, pOciError, & pOciServiceContext,(unsigned char *) pUsernameChar,
    strlen (pUsernameChar), (unsigned char *) pPasswordChar, strlen (pPasswordChar).
    (unsigned char *) pConnectChar, strlen (pConnectChar));
    printf ("retval=%d\n",retval OCILogon);

    retval = OCIStmtPrepare (pOciStatement, pOciError, (unsigned char *) sqlCharArray1, strlen (sqlCharArray1),)
    OCI_NTV_SYNTAX, OCI_DEFAULT);
    printf ("StmtPrepare retval=%d\n",retval);

    retval = OCIHandleAlloc (pOciEnviron, (void *) & pOciStatCursor, OCI_HTYPE_STMT, 0, NULL);
    retval = 1 OCIBindByPos(pOciStatement,&pOciBind[0], pOciError, (ub4), (void *) & state_key,)
    ((sb4) sizeof (state_key), SQLT_STR, (void *) 0, (ub2 *) 0, (ub2 *) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT (ub4));
    printf ("BindByPos OCI_HTYPE_STMT retval=%d\n",retval);

    retval = OCIBindByPos(pOciStatement,&pOciBind[1], pOciError, (ub4) 2, (void *) & pOciStatCursor,)
    ((sb4) 0, SQLT_RSET, (void *) 0, (ub2 *) 0, (ub2 *) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT (ub4));
    printf ("BindByPos OCI_HTYPE_STMT retval=%d\n",retval);

    strcpy (state_key, 'ca');

    retval = OCIStmtExecute (pOciServiceContext, pOciStatement, pOciError, (ub4) 1, (ub4) 0,)
    (OCISnapshot *) NULL, (OCISnapshot *) NULL, OCI_DEFAULT (ub4));
    printf ("StmtExecute retval=%d\n",retval);

    / * How to get the values of the cursor? */

    / * Number of parameters of the cursor * /.
    OCIAttrGet ((void *) pOciStatCursor, OCI_HTYPE_STMT (ub4), (void *) & parmcnt,(ub4 *) 0,)
    (ub4) (OCI_ATTR_PARAM_COUNT, pOciError);
    printf ("\nNumber of the slider settings = %d\n",parmcnt);

    for (int pos = 1; pos < = (int) parmcnt; pos ++)
    {
    OCIAttrGet ((void *) pOciStatCursor, OCI_HTYPE_STMT (ub4), (void *) & pos2,(ub4 *) 0,)
    (ub4) (OCI_ATTR_CURRENT_POSITION, pOciError);
    retval = OCIParamGet ((void *) pOciStatCursor, OCI_HTYPE_STMT (ub4), pOciError, (void *) & pOciParam,)
    POS (ub4));
    OCIAttrGet pOciParam, (ub4) ((void*) OCI_DTYPE_PARAM,(void*) & pcoln [pos - 1],(ub4 *) & namelen [pos-1],)
    (ub4) OCI_ATTR_NAME,(OCIError *) pOciError);
    }
    for (int i = 1; i < = (int) parmcnt; i ++)
    printf ("%i\tNAME = % column. ("* s\n", i, namelen [i-1], pcoln [i-1]);

    return 0;
    }


    This is the script that create the table, insert records and create the stored procedure

    CREATE TABLE CITIES)
    STATE_CODE VARCHAR2 (2) NULL,
    CITY_CODE NUMBER (15.5) NULL,
    CITY_NAME VARCHAR2 (30) NULL
    )
    /


    INSERT INTO CITIES (STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES ('CA', 30, 'SAN DIEGO')
    /
    INSERT INTO CITIES (STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES ('CA', 40 'SACRAMENTO')
    /
    INSERT INTO CITIES (STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES ('FL', 10, 'MIAMI')
    /
    INSERT INTO CITIES (STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES ('FL', 20, 'ORLANDO')
    /
    INSERT INTO CITIES (STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES ('NEW YORK', 10, 'NEW YORK')
    /
    INSERT INTO CITIES (STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES ('NEW YORK', 20, 'ALBANY')
    /
    INSERT INTO CITIES (STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES ('CA', 10, 'LOS ANGELES')
    /
    INSERT INTO CITIES (STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES ('CA', 20, 'SAN FRANCISCO')
    /


    CREATE or REPLACE PACKAGE globalPkg AUTHID CURRENT_USER AS
    / * The following is specific global variables T/SQL. */
    TYPE RCT1 IS REF CURSOR; / * new cursor low definition * /.
    END globalPkg;
    /



    CREATE OR REPLACE PROCEDURE SP_ADDCITY)
    P_STATE_CODE IN VARCHAR,
    P_CITY_CODE NUMBER,
    P_CITY_NAME IN VARCHAR2,
    P_RETURN IN NUMBERS)
    AS
    StoO_error INTEGER;
    StoO_selcnt INTEGER;
    StoO_rowcnt INTEGER;
    StoO_errmsg VARCHAR2 (255);

    BEGIN
    StoO_rowcnt: = 0;
    StoO_error: = 0;
    StoO_selcnt: = 0;
    P_RETURN: = 0;
    INSERT INTO CITIES (STATE_CODE, CITY_CODE, CITY_NAME)
    VALUES (P_STATE_CODE, P_CITY_CODE, P_CITY_NAME);
    StoO_rowcnt: = number of LINES SQL %;
    EXCEPTION
    WHEN TOO_MANY_ROWS THEN
    StoO_rowcnt: = 2;
    WHILE OTHERS THEN
    StoO_rowcnt: = 0;
    StoO_selcnt: = 0;
    StoO_error: = SQLCODE;
    StoO_errmsg: = SQLERRM;
    IF StoO_error! = 0 THEN
    BEGIN
    P_RETURN: = 1;
    RETURN;
    END;
    END IF;
    END;
    /

    CREATE OR REPLACE PROCEDURE SP_GETCITIES)
    STATE_KEY IN VARCHAR,
    RC1 IN OUT globalPkg.RCT1)
    AS
    StoO_error INTEGER;
    StoO_selcnt INTEGER;
    StoO_rowcnt INTEGER;
    StoO_errmsg VARCHAR2 (255);
    BEGIN
    StoO_rowcnt: = 0;
    StoO_error: = 0;
    StoO_selcnt: = 0;
    OPEN FOR RC1
    SELECT STATE_CODE, CITY_CODE, FRANCISCO
    CITIES
    WHERE STATE_CODE = STATE_KEY
    ORDER BY CITY_CODE;
    StoO_rowcnt: = number of LINES SQL %;
    EXCEPTION
    WHILE OTHERS THEN
    StoO_rowcnt: = 0;
    StoO_error: = SQLCODE;
    StoO_errmsg: = SQLERRM;
    END;
    /

    Hi Antonio,.

    I see this:

    c_buf=(ub1 **)calloc(sizeof(ub1 *),3);
    
    ...
    
    rc=OCIDefineByPos(pOciStatCursor,&pdef,(OCIError *)pOciError,pos,c_buf[pos-1],size+1,(ub2)type,(dvoid *)c_indp[pos-1],(ub2 *)0,(ub2 *)0,OCI_DEFAULT);
    

    That I don't understand. You allocate space for 3 pointers ub1 but I don't see where these pointers are then initialized to point to where the data is to be stored.

    I do not read correctly?

    Sorry for posting code long, but here is an example of code that I have. It is much more 'code' for your code, but maybe that will be enough...

    NOTE: This is just the code example and not rigorous. For example, I don't check the memory, allocations etc in this code!

    Kind regards

    Mark

    #ifdef WIN32
    #define _CRT_SECURE_NO_DEPRECATE 1
    #endif
    
    #include 
    #include 
    #include 
    #include 
    
    void checkerr(sword status, OCIError *errhp);
    
    int main(int argc, char *argv[]) {
      OCIEnv      *envhp = NULL;  /* OCI Environment handle     */
      OCIError    *errhp = NULL;  /* OCI Error handle           */
      OCISvcCtx   *svchp = NULL;  /* OCI Service Context handle */
      OCIServer   *srvhp = NULL;  /* OCI Server handle          */
      OCISession  *usrhp = NULL;  /* OCI User Session handle    */
    
      OCIStmt     *stmtp = NULL;  /* OCI Statement handle       */
      OCIStmt     *cursr = NULL;  /* OCI Statement handle       */
    
      OCIParam    *prmp1 = NULL;  /* OCI Parameter handle       */
      OCIParam    *prmp2 = NULL;  /* OCI Parameter handle       */
      OCIParam    *prmp3 = NULL;  /* OCI Parameter handle       */
    
      OCIDefine   *defp1 = NULL;  /* OCI Define handle          */
      OCIDefine   *defp2 = NULL;  /* OCI Define handle          */
      OCIDefine   *defp3 = NULL;  /* OCI Define handle          */
    
      OCIBind     *bndp1 = NULL;  /* OCI Bind handle            */
      OCIBind     *bndp2 = NULL;  /* OCI Bind handle            */
      OCIBind     *bndp3 = NULL;  /* OCI Bind handle            */
    
      /* used to hold column width */
      ub2 col_width;
    
      /* used to set the prefetch count */
      ub4 prefetch_count = 32;
    
      /* will hold output from database */
      oratext *pEmpId = NULL;
      oratext *pFirstName = NULL;
      oratext *pLastName = NULL;
    
      /* the anonymous block to execute */
      /* this opens a ref cursor        */
      oratext *sqlstmt = "begin " \
                         "  open :1 for " \
                         "  select   to_char(employee_id), " \
                         "           first_name, " \
                         "           last_name " \
                         "  from     hr.employees " \
                         "  order by last_name, " \
                         "           first_name; " \
                         "end;";
    
      /* used to hold the results of each OCI call */
      sword result = 0;
    
      /* Initialize and create a default environment  */
      result = OCIEnvCreate(&envhp,
                            OCI_DEFAULT,
                            (dvoid *) 0,
                            0,
                            0,
                            0,
                            (size_t) 0,
                            (dvoid **) 0);
    
      /* allocate an error handle */
      result = OCIHandleAlloc((dvoid *) envhp,
                              (dvoid **) &errhp,
                              OCI_HTYPE_ERROR,
                              0,
                              (dvoid **) 0);
    
      /* allocate a service context handle */
      result = OCIHandleAlloc((dvoid *) envhp,
                              (dvoid **) &svchp,
                              OCI_HTYPE_SVCCTX,
                              0,
                              (dvoid **) 0);
    
      /* allocate a server handle */
      result = OCIHandleAlloc((dvoid *) envhp,
                              (dvoid **) &srvhp,
                              OCI_HTYPE_SERVER,
                              0,
                              (dvoid **) 0);
    
      /* allocate a user session handle */
      result = OCIHandleAlloc((dvoid *) envhp,
                              (dvoid **) &usrhp,
                              OCI_HTYPE_SESSION,
                              0,
                              (dvoid **) 0);
    
      /* create a server context using the "ORADEMO" database */
      result = OCIServerAttach(srvhp,
                               errhp,
                               "ORADEMO",
                               (ub4) strlen("ORADEMO"),
                               OCI_DEFAULT);
    
      /* set the server attribute in the service context handle */
      result = OCIAttrSet((dvoid *) svchp,
                          OCI_HTYPE_SVCCTX,
                          (dvoid *) srvhp,
                          (ub4) 0,
                          OCI_ATTR_SERVER,
                          errhp);
    
      /* open the session with the database */
      /* using external authentication      */
      result = OCISessionBegin(svchp,
                               errhp,
                               usrhp,
                               OCI_CRED_EXT,
                               OCI_DEFAULT);
    
      /* set the user session attribute in the service context handle */
      result = OCIAttrSet((dvoid *) svchp,
                          OCI_HTYPE_SVCCTX,
                          (dvoid *) usrhp,
                          (ub4) 0,
                          OCI_ATTR_SESSION,
                          errhp);
    
      /* allocate the statement handle */
      result = OCIHandleAlloc((dvoid *) envhp,
                              (dvoid **) &stmtp,
                              OCI_HTYPE_STMT,
                              0,
                              (dvoid **) 0);
    
      /* prepare the statement for execution */
      result = OCIStmtPrepare(stmtp,
                              errhp,
                              sqlstmt,
                              (ub4) strlen((char *) sqlstmt),
                              OCI_NTV_SYNTAX,
                              OCI_DEFAULT);
    
      /* allocate the handle for the ref cursor */
      result = OCIHandleAlloc((dvoid *) envhp,
                              (void **) &cursr,
                              OCI_HTYPE_STMT,
                              0,
                              NULL);
    
      /* bind the ref cursor parameter */
      result = OCIBindByPos(stmtp,
                            &bndp1,
                            errhp,
                            1,
                            &cursr,
                            0,
                            SQLT_RSET,
                            NULL,
                            0,
                            NULL,
                            0,
                            0,
                            OCI_DEFAULT);
    
      /* execute the statement */
      result = OCIStmtExecute(svchp,
                              stmtp,
                              errhp,
                              1,
                              0,
                              NULL,
                              NULL,
                              OCI_DEFAULT);  
    
      /* get parameter descriptor for first column */
      result = OCIParamGet((dvoid *) cursr,
                           OCI_HTYPE_STMT,
                           errhp,
                           (dvoid **) &prmp1,
                           (ub4) 1);
    
      /* get parameter descriptor for second column */
      result = OCIParamGet((dvoid *) cursr,
                           OCI_HTYPE_STMT,
                           errhp,
                           (dvoid **) &prmp2,
                           (ub4) 2);
    
      /* get parameter descriptor for third column */
      result = OCIParamGet((dvoid *) cursr,
                           OCI_HTYPE_STMT,
                           errhp,
                           (dvoid **) &prmp3,
                           (ub4) 3);
    
      /* get the first column width in characters */
      result = OCIAttrGet((dvoid*) prmp1,
                          (ub4) OCI_DTYPE_PARAM,
                          (dvoid*) &col_width,
                          (ub4 *) 0,
                          (ub4) OCI_ATTR_DATA_SIZE,
                          errhp);
    
      /* allocate memory to hold the result */
      pEmpId = (oratext *) malloc(sizeof(oratext) * (col_width + 1));
    
      /* define the first column in the results */
      result = OCIDefineByPos(cursr,
                              &defp1,
                              errhp,
                              1,
                              (dvoid *) pEmpId,
                              (sword) col_width + 1,
                              SQLT_STR,
                              (dvoid *) NULL,
                              (ub2 *) 0,
                              (ub2 *) 0,
                              OCI_DEFAULT);
    
      /* get the second column width in characters */
      result = OCIAttrGet((dvoid*) prmp2,
                          (ub4) OCI_DTYPE_PARAM,
                          (dvoid*) &col_width,
                          (ub4 *) 0,
                          (ub4) OCI_ATTR_DATA_SIZE,
                          errhp);
    
      /* allocate memory to hold the result */
      pFirstName = (oratext *) malloc(sizeof(oratext) * (col_width + 1));
    
      /* define the second column in the results */
      result = OCIDefineByPos(cursr,
                              &defp2,
                              errhp,
                              2,
                              (dvoid *) pFirstName,
                              (sword) col_width + 1,
                              SQLT_STR,
                              (dvoid *) NULL,
                              (ub2 *) 0,
                              (ub2 *) 0,
                              OCI_DEFAULT);
    
      /* get the third column width in characters */
      result = OCIAttrGet((dvoid*) prmp3,
                          (ub4) OCI_DTYPE_PARAM,
                          (dvoid*) &col_width,
                          (ub4 *) 0,
                          (ub4) OCI_ATTR_DATA_SIZE,
                          errhp);
    
      /* allocate memory to hold the result */
      pLastName = (oratext *) malloc(sizeof(oratext) * (col_width + 1));
    
      /* define the third column in the results */
      result = OCIDefineByPos(cursr,
                              &defp3,
                              errhp,
                              3,
                              (dvoid *) pLastName,
                              (sword) col_width + 1,
                              SQLT_STR,
                              (dvoid *) NULL,
                              (ub2 *) 0,
                              (ub2 *) 0,
                              OCI_DEFAULT);
    
      /* loop through and print the results */
      while ((result = OCIStmtFetch(cursr,
                                    errhp,
                                    (ub4) 1,
                                    (ub2) OCI_FETCH_NEXT,
                                    (ub4) OCI_DEFAULT)) == OCI_SUCCESS)
      {
        printf("Employee ID: %s\n", pEmpId);
        printf(" First Name: %s\n", pFirstName);
        printf("  Last Name: %s\n\n", pLastName);
      }
    
      /* free allocated memory */
      free(pEmpId);
      free(pFirstName);
      free(pLastName);
    
      pEmpId = NULL;
      pFirstName = NULL;
      pLastName = NULL;
    
      /* terminate the session with the database */
      result = OCISessionEnd(svchp, errhp, usrhp, OCI_DEFAULT);
    
      /* detach from the server */
      result = OCIServerDetach(srvhp, errhp, OCI_DEFAULT);
    
      /* deallocate the environment handle     */
      /* OCI will deallocate the child handles */
      result = OCIHandleFree((dvoid *) envhp, OCI_HTYPE_ENV);
    
      return OCI_SUCCESS;
    }
    
    void checkerr(sword status, OCIError *errhp)
    {
      oratext errbuf[512];
      sb4 errcode = 0;
    
      switch (status) {
        case OCI_SUCCESS:
          break;
    
        case OCI_ERROR:
        case OCI_SUCCESS_WITH_INFO:
          (void) OCIErrorGet((dvoid *) errhp, (ub4) 1, (oratext *) NULL, &errcode, errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
          (void) printf("Error: %.*s\n", sizeof(errbuf), errbuf);
          break;
    
        case OCI_NEED_DATA:
          (void) printf("Error - OCI_NEED_DATA\n");
          break;
    
        case OCI_NO_DATA:
          (void) printf("Error - OCI_NO_DATA\n");
          break;
    
        case OCI_INVALID_HANDLE:
          (void) printf("Error - OCI_INVALID_HANDLE\n");
          break;
    
        case OCI_STILL_EXECUTING:
          (void) printf("Error - OCI_STILL_EXECUTING\n");
          break;
    
        case OCI_CONTINUE:
          (void) printf("Error - OCI_CONTINUE\n");
          break;
    
        default:
          break;
      }
    }
    
  • How to call a procedure with two arguments.

    Hello
    I have a procedure with two arguments, IE. MyProcedure (p1 in numbers, p2 in number) to display an image blob.
    How can I call this image blob in the url.
    I tried http://127.0.0.1:7777/pls/apex/SCHEMA.myprocedure?p1=1 & p2 = 2, but it does not work...
    Thank you
    Vincent

    Vincent,

    As long as you've got the possibility to execute the procedure and there is no space in the url and you have not misspelled the names of parameters then it looks right.

    Here is a link to a procedure to download a file that takes two parameters.

    http://mywebsite.com/pls/htmldev/schema.package.function.download_file?p_session_id=1221970786026206&p_seq_id=724

    See you soon,.

    Janet Tyson

  • HP 40GS systems of linear equation with parameters

    Hello

    I'm in the learning curve of the HP 40GS - a very interesting tool.

    Is it possible to solve systems of equations with parameters, for example:

    A * X + Y = 2 * 12

    5 * X - 3 * A * Y = 5

    HP 50 g, this isn't a big deal, but with HP 40GS I don't have an idea so far.

    If this is not possible, it will be possible if I have a third equation (so 3 equations in 3 unknowns)?

    Thank you very much in advance,

    Joachim

    P.S.: So far, I feel very comfortable with the HP 40GS and menus!

    ----------------------------------------
    I am not a member of the HP Calculator development team - unfortunately!

    Hello

    now, I found a way to calculate the systems of equations with symbolic coefficients:

    See the document: http://www.hp.com/ctg/Manual/c00829737.pdf to page 346ff

    With the command 'linsolve', it is possible to calculate with more unknown than equations.

    I hope this helps anyone with the same or close problem.

    Have fun with your calculators and do not hesitate to write other ways of calculations.

    Greetings,

    Joachim

  • HTTP request with parameters

    Help, please!

    I am currently working on a version of BB10 to an existing application. The application calls a Web service with parameters (including a key). The service then returns the data. It works very well on java with HttpConnection. I'm having a hard time doing the same thing in c ++. I am following the tutorial here:

    https://developer.BlackBerry.com/Cascades/documentation/device_comm/networking/tutorial_http_comm.ht...

    It works very well for URLS with the format:

    ""http://developer.blackberry.com/cascades/files/documentation/images/model.xml " "

    But what happens if my URL looks like this:

    "http://developer.blackberry.com/cascades/files/documentation/images/getModel?serviceKey=0xd2341ed0d0... ".

    How to pass the parameter "serviceKey"?

    If you use the url that you have shown, did you get a response in your browser?

  • Procedure with the DML statements that insert values from 1 to 100 in only one table and it is matching word equivalent in the other

    Can someone help me create a procedure with the DML statements that insert values from 1 to 100 in a table "abc" and the procedure must connect the numbers into words in another table "xyz" without doing a commit explicitly. "."

    Currently on trial...

    SQL > create table abc (num number);

    Table created.

    SQL > create table xyz (num varchar2 (100));

    Table created.

    SQL > ed
    A written file afiedt.buf

    1. insert all
    2 values of 1 = 1 then in abc (num) (l)
    3 when the values of 1 = 1 then in xyz (num) (to_char (to_date(l,'j'), 'jsp'))
    4 * Select the level from dual connect by level<=>
    SQL > /.

    200 rows created.

    And the result...

    SQL > select * from abc;

    NUM
    ----------
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    ..
    ..
    ..
    98
    99
    100

    100 selected lines.

    SQL > select * from xyz;

    NUM
    ----------------------------------------------------------------------------------------------------
    one
    two
    three
    four
    five
    six
    seven
    eight
    nine
    ten
    Eleven
    twelve
    ..
    ..
    ..
    98
    Nineteen eighty
    Cent

    100 selected lines.

Maybe you are looking for

  • to clear the cache before loading each page

    I can't access a particular Web site. I can reach other sites very well. I had it happen with another site and my history of compensation has solved the problem. Now, it's another site. If I clear my history (cache, cookies) I can get to the first pa

  • iOS 9.3 killed my iPad 2 cellular connection

    iOS 9.3 killed my iPad 2 cellular connection.  A friend had exactly the same experience. Instead of text 'Telstra' (my provider name) upper-left screen, I have "No Service" Settings > general > topic > network says "Not available" and number of data

  • HP 15 ay008tx: bad warranty period

    I bought my new laptop computer HP on October 2, 2016, and when I checked its warranty status, he showed the date as June 22, 2016. It is wrong, and my warranty period must be corrected. I have disputed against the warranty period, but received no an

  • Re: 610CT OS INSTALL---DOS/WIN3.11/95/98

    I try to install any operating system (DOS, or a Microsoft Windows operating system specifically) on a Toshiba Portege 610CT. The hard drive in the unit has been cleared, and the system boot with the message: "Insert system disk in drive.Press any ke

  • Re-setup of UNCDMS.dll

    error message