Stored procedures - default NULL

Glad that Oracle will continue development on the DSP!

I work with a huge procedure stored with several parameters are to be set as DEFAULT NULL in SQL.

When I generate a physical dataservice for this procedure he does not display as optional parameters.
How can I pass in NULL as xquery query parameter? -The models are varchar2, date and number (string, dataTime and decimal in xml/xquery).
If I pass an empty string to a decimal or date type, I get an error.


Does anyone have any experience with this kind of problem?

/ Jens-Martin

Change the schema manually and change the items so that they have minOccurs = '0 '.

A "null" in XQuery is the empty sequence.

In the test view 3.x, there is a box set as Null.

DSP 2.5, you cannot pass a value of null from the client - you need to call the function in the service of physical data of another function and pass it (). (i.e. leave $arg: = if (length ($mystring1) = 0) then () of other $mystring1)

Tags: Fusion Middleware

Similar Questions

  • Pass complex Types with chains to stored procedures: become null

    Hello

    I would like to pass an array of strings or a type of custom to a PL/SQL stored procedure object, you use the JDBC thin driver. It is possible if the tables or object types contain integers. With strings (resp. varchar2) However, I encountered a repetitive problem, no matter what I tried: the varchar2 field seems to be null in the stored procedure.

    There is something special with the passage of short strings?

    I tested with Oracle version server 10.2.0.3, 10.2.0.4 and 11.1.0.7.0.
    JDBC Thin drivers used are ojdbc14.jar is of 10.2.0.4 and ojdbc5.jar 11.1.0.7.0.
    I use Java 5.

    Tested approaches include:
    -oracle.sql.StructDescriptor, preparedStatement.setSTRUCT, or setStruct
    -Pass a Java type that implements the SQLData with preparedStatement.setObject
    -Pass a Java type that implements ORAData and ORADataFactory

    I tested it with an example of metalink (Doc ID 458572.1), and as I said, this example shows the same problem: strings passed appear as null - in three versions of Oracle that I tested. The example has been changed only with respect to the scheme name.
    ()Doc ID 458572.1 refers to a bug that shows the behavior I describe here, but this bug should be fixed in 10.2.0.4 and 11).

    I can paste some of my source code, but I feel that the solution could be found elsewhere, such as problems, version mismatch, the character set...

    Any ideas on the specialties with passage of strings in types of objects or paintings? My strings are null. (For tables, I get the right amount of NULL values).
    I even checked that I can pass a string argument simple to a procedure that worked indeed.

    Kind regards
    Carsten

    There is something special with the passage of short strings?

    Yes, this is a common problem. You must include orai18n.jar classpath. BTW it is documented here and here.

  • The Null value as the default value for an input to a stored procedure parameter

    Hello

    How can we set the default values with the NULL value for the parameter in a stored procedure.
    create or replace procedure emp_proc ( p_test_input in varchar2
                                                        p_emp_id in number,
                                                        p_emp_name in varchar2,
                                                       p_manager_id in number )
    as
      begin
       if ( upper ( p_test_input ) = 'I' )
       then
          insert into emp
          values      ( p_emp_id  ,p_emp_name ,p_Manager_id,sysdate );
       elsif ( upper ( p_test_input ) = 'D' )
       then
          delete from emp
          where       emp_id  = p_emp_id;
       else
          dbms_output.put_line
             ( 'Please input ''A'' for ADD or ''D'' Delete  EMPLOYEE'
             );
       end if;
    end;
    As described above if I want to delete only the functioning

    I want to call this procedure without pass additional parameters.
     EXECUTE  emp_proc('D',1010);
    Published by: Rede on May 28, 2010 12:21

    Published by: Rede on May 28, 2010 12:22
    create or replace procedure emp_proc ( p_test_input in varchar2,
                                                        p_emp_id in number,
                                                        p_emp_name in varchar2 default null,
                                                       p_manager_id in number default null )
    
  • Is it possible to move an Oracle null input parameter to a stored procedure

    I have a stored procedure taking 3 inputs and 1 output of donne. I use the Oracle parameter to add all the input parameters 3 as follows:

    OracleParameter = cmd inobj. Parameters.Add ("wid", OracleDbType.Int32, 50);
    inobj. Direction = ParameterDirection.Input;
    inobj. Value = _employeeID;

    and the addition of the setting of output as follows:

    OracleParameter outobj is _cmd. Parameters.Add ("w_first", OracleDbType.Varchar2, 50);
    outobj. Direction = ParameterDirection.Output;

    On the side of the user interface, the user has the option of providing 1 entry or all inputs or any 2 based on his interest. Stored proc looks like this:
    SP (inp1 in parameter, inp2 in inp3 in parameter, parameter, out parameter output1)

    If I just get 1 or 2 entries of the user, it is very good query output data using the same stored procedure or do I create stored procedures for each scenario (combination of different entries)?

    I get an error in pl/sql which indicates the invalid number of arguments?

    Maybe I can be more clear with c# code. :)

    void SaveSomethingInOracle(int param1, string param2 = null, decimal? param3 = null)
    {
    // Set up your oracle connection and query here
    OracleParameter inobj = _cmd.Parameters.Add("w_id", OracleDbType.Int32,50);
    inobj.Direction = ParameterDirection.Input;
    inobj.Value = param1;
    
    OracleParameter inobj2 = _cmd.Parameters.Add("name", OracleDbType.Varchar2,50);
    inobj2.Direction = ParameterDirection.Input;
    inobj2.Value = param2;
    
    OracleParameter inobj3 = _cmd.Parameters.Add("quantity", OracleDbType.Decimal,50);
    inobj3.Direction = ParameterDirection.Input;
    if (param3.HasValue)
    {
    inobj3.Value = param3.Value;
    }
    else
    {
    inobj3.Value = null;
    }
    }
    

    This c# method takes 3 parameters. The first is necessary, the other two are optional. If you do not set them, they take the value default null and passing it to the database. If you want to set the first and third only, you can still pass null as the other. If you have this piece of code to call the stored procedure any combination of parameters that you use, and the proc will get values or NULL values properly.

    Hope he says. You need only one together code to do what you want to do. :)

    Published by: Tridus on December 19, 2012 12:10

  • Classic ASP, passing Null to a stored procedure

    I'm having a problem passing NULL to a stored procedure on a MS SQL Server. The code is classic ASP.

    I built the sql Command first, and then remoteDB.Connection.Execute (sqlCommand, adCmdText)

    My classic asp code to construct the sqlCommand object
    sqlCommand = "procWebAddProspectOwner" & "1.25," & "'" & "HHTitle" & "','" & 'HHFirstName' & 'NULL' & ',' & 'NULL '.

    The writing of the response to the web browser for debugging shows this
    procWebAddProspectOwner 1.25, 'HHTitle', 'HHFirstName', NULL, NULL

    ADODB. Connection error '800a0bb9 '.
    Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.


    Trouble shoot I have cut and paste this into the asp the elucidating of SQL query page and it works fine.
    procWebAddProspectOwner 1.25, 'HHTitle', 'HHFirstName', NULL, NULL

    ideas:
    David

    "DEPearson" wrote in message
    News:f2hspv$8h1$1@forums. Macromedia.com...
    > ADODB. Connection error '800a0bb9 '.
    > Arguments are of the wrong type, are out of acceptable range, or are in
    > conflict between them.
    >

    It is usually a missing connection string. Make sure that the connection
    string is there, you wrote that your connections and right
    folder is located on the server.

  • Any way to change the procedures stored by default instead of viewing?

    When I click on a stored procedure, 99% of the time I want to edit rather than the default 'view' screen. I know you from click here to go directly to edit, but is there a way to just go to change default when you click on a stored procedure?

    Thank you!

    No, but the viewer and editor fit into one in v2.1.
    I did a custom forever, right click - Edit. Alternatively, you can double-click to open them both.

    Kind regards
    K.

  • Logic of tip insert - using a stored procedure?

    Here's my use case:

    • I have a table called TAGS that has two columns: id (number key, primary) and text (string)
    • the table has a constraint of database set that each text must be unique
    • the table also has a fixed sequence back next id available
    • I created an entity of the DB object and its default View object
    • I also created a page where I display a table read-only based on the View object
    • Finally, I added a text field and a button to the page
    • What I want to achieve is to insert all tags entered in the entry in the table fields, when the button is clicked. Note, however, that the entry field is a comma-separated list of tags, moreover, I have to insert only those tags that are new (to respect the constraint of database), and finally, I would like to use the sequence in insert or orders. Once completed, the page should also be updated.

    My first question is whether a stored procedure is the right way to perform such a step insert logical. If not, what other means must be used in the ADF.

    My second question is to know how to call the stored procedure and pass it the value of the input as a parameter field. I found this article http://andrejusb.blogspot.cz/2011/04/invoking-stored-procedures-and.html, but miss me a few transition points:

    1. How the callGreetingsFunction method call (I just get it that it's a method of the EO generated Java class?) after that the button is clicked?
    2. How to pass the value of the input field in this method as a parameter?

    Thanks in advance for your help.

    Now, what happens if I run it like this:

    A. the procedure is executed after a click on the button

    (B) the page is not updated (I had to do the research to get the new lines are visible in the table)

    C. the constraint is ignored (after discounting there were several lines with unique identification number, but pr is - empty)

    D. nothing has been committed to the database - if I closed the application window and it start again, the lines have disappeared from the table, but addition of new lines used number of increased seq

    E. Similarly, if I did directly inserts into the database, these lines did not appear until I transferred the application

    B. told it page to refresh. And that's usually enough to refresh your ViewObject with: viewObject.executeQuery)

    C. Si the constraint is not enforced for null values. And this has nothing to do with the adf, this is related to oracle db.

    D. you're calling commit.

    E. you must re-run your view object (viewObject.executeQuery ())

    Nevertheless, here is my rookie questions:

    There there a simple way to refresh the page (or just the table containing the data)?

    -How to validate changes (immediately after execution of the procedure)?

    -How is the constraint has been ignored? I am sure it would fail on validation, but I thought that it will be considered even for adding data to the table.

    -Are there a way to update the original Version of the database every time that the page is opened or refreshed?

    -Drag and drop operation Execute like button on your page (or call vo.executeQuery () by program)

    -Drag and drop the operation of posting as a button on your page (or invoke it by programming on the DBTransaction object)

    -ignored for what values? for null values? It is expected, because each null is "unique."

    -Yes, but you probably shouldn't do that for performance reasons, see this: Andrejus Baranovskis Blog: Cache results for ADF iterator property

    Read also this: Andrejus Baranovskis Blog: job ADF and PL/SQL Invocation changes side effect

    Dario

  • Why these stored procedures his does not work

    Hi I'm new and I need help following SQL works correctly, but when I walked into a stored procedure me displays error

    SELECT Por.PortalID,

    Name,

    Lower (LTrim (RTrim (SEOName))) SEOName,

    IsParent,

    Por.Parentid,

    (Select Seoname

    Portal port

    Where Por.Parentid = Port.Portalid) Parentportalname;

    SettingValue.SettingValue DefaultPage

    Por PORTAL

    JOIN SettingValue

    ON Por.PortalID = SettingValue.settingtypeid

    Where Settingtype = 'SiteAdmin '.

    And Settingkey = 'PortalDefaultPage. '

    his return:

    Portald Name SEONAME ISPARENT ParentId parentportalname DefaultPage
    1by defaultby default10nullHomepage

    It's my stored procedure

    create or replace

    Procedure Sp_Portalgetlist as

    Start

    SELECT Por.PortalID,

    Name,

    Lower (LTrim (RTrim (SEOName))) SEOName,

    IsParent,

    Por.Parentid,

    (Select Seoname

    Portal port

    Where Por.Parentid = Port.Portalid) Parentportalname;

    SettingValue.SettingValue DefaultPage

    Por PORTAL

    JOIN SettingValue

    ON Por.PortalID = SettingValue.settingtypeid

    Where Settingtype = 'SiteAdmin '.

    And Settingkey = 'PortalDefaultPage ';

    END SP_PORTALGETLIST;

    When I compile with oracle sqldeveloper show this error:

    • Error (4.1): PLS-00428: an INTO clause in this SELECT statement

    I appreciate all the help

    What about the compile error in a PL/SQL block a select statement has an additional part:

    Select attr1, attr2...

    in var1, var2,...

    Of...

    but you can also use your selection (without the) in a cursor:

    procedure is...

    cursor my_select is

    Select...;

    my_variable my_cursor % rowtype;

    Start

    Open my_cursor;

    extract my_cursor in my_variable; -fails at the record and then one more found!

    close my_cursor;

    ...

    Good bye

    DPT

  • NullPointerException when calling stored procedure

    I have the stored procedure

    create or replace PROCEDURE GREETING_PROC

    (

    TEXT_PARAM IN VARCHAR2

    MSG_TEXT VARCHAR2 OUT

    ) AS

    BEGIN

    MSG_TEXT: = "Hello" | TEXT_PARAM;

    END;

    My stored procedure call method

    public class UserBean {}

    public UserBean() {}

    Super();

    }

    Public Shared Sub main (String [] args) {}

    UserBean userBean = new UserBean();

    userBean.callP ();

    userBean.callStoreProcedure ();

    }

    public void callStoreProcedure() {}

    CallableStatement st = null;

    SysUser SysUserEOImpl = new SysUserEOImpl();

    try {}

    String sql = "BEGIN GREETING_PROC (: TEXT_PARAM,: MSG_TEXT); END; « ;

    St = sysUser.getDBTransaction () .createCallableStatement (sql, sysUser.getDBTransaction (). DEFAULT VALUE);

    st.setObject ("TEXT_PARAM", "Scoot");

    st.registerOutParameter ("MSG_TEXT", Types.VARCHAR);

    St.Execute ();

    System.out.println ((String) St.GetObject ("MSG_TEXT"));

    } catch (SQLException e) {}

    throw new Aexception.getLocalizedMessage (e);

    }

    }

    then I got an exception:

    Exception in thread "main" java.lang.NullPointerException

    at cic.opsi.model.bean.UserBean.callStoreProcedure(UserBean.java:35)

    at cic.opsi.model.bean.UserBean.main(UserBean.java:27)

    Hello

    What statemet is UserBean.java:35)?

    Second, create a new SysUserEOImpl()!

    If you want to call stored proc, put the java code calling stored proc in ViewRowImpl/ViewObjectImpl/ApplicationModuleImpl and export this code in the customer interface. Then put this method in the pageDef as a call him as an OperationBinding

    Zeeshan Baig blog: the PL/SQL procedure call and function in the Oracle ADF application

    Extending the functionality of the components Business

    ADF/OFA for Oracle Techies: ADF call stored procedure with Out parameters

    Latest Oracle technology: call Store procedures for Oracle ADF Application

  • Unexpected token: the error that occur inside a stored procedure

    I get an unexpected token error when you try to compile the following stored procedure. The error occurs on the run pk_proof.pr_ProofAssets inside the stored procedure exec statement. No reason?
    CREATE OR REPLACE PROCEDURE MONTHLY_ASSET (ln_business_dt_num IN NUMBER DEFAULT NULL,
                                               missing_tbl_name OUT NOCOPY VARCHAR2) 
    IS
       ln_business_dt_num NUMBER;
       missing_tbl_name VARCHAR2;
       no_tbl_name_found EXCEPTION;
       bad_date_value EXCEPTION;
       counts_not_matched EXCEPTION;
     BEGIN
       IF ln_business_dt_num < 0 THEN
       RAISE bad_date_value;
       ELSE
         Select MAX(business_dt_num) into ln_business_dt_num
         FROM sasor.dp_ca_proof;
          
       if missing_tbl_name IS NOT NULL then
          raise no_tbl_name_found;
       end if;
       
       exec pk_proof.pr_ProofAssets('SLH_DST_ASSET', ln_business_dt_num, 'sasor_batch');
     

    Remove 'exec '.

  • Required stored procedure

    Hello

    I need to create a stored procedure based on the requirements of the customer. Any body can help me...
    create table SAMPLE
    (
      WEB_LOGIN    VARCHAR2(30),
      WEB_PASSWORD VARCHAR2(30),
      PWD_EXP_DT   DATE
    );
    
    insert into SAMPLE (WEB_LOGIN, WEB_PASSWORD, PWD_EXP_DT)
    values ('[email protected]', 'abc', to_date('10-12-2010', 'dd-mm-yyyy'));
    insert into SAMPLE (WEB_LOGIN, WEB_PASSWORD, PWD_EXP_DT)
    values ('[email protected]', 'abc', to_date('01-01-2011', 'dd-mm-yyyy'));
    insert into SAMPLE (WEB_LOGIN, WEB_PASSWORD, PWD_EXP_DT)
    values ('[email protected]', 'def', to_date('10-02-2011', 'dd-mm-yyyy'));
    commit;
    
    conditions
    *********
    if web_login = web_login and web_password = web_password and 
    sysdate - pwd_exp_dt > 180 days 
    message " your password has been expired"
    
    if web_login = web_login and web_password = web_password and 
    sysdate - pwd_exp_dt > 165 days and sysdate-pwd_exp_dt <180 days then
    message " your password has been expired very soon..pls update ur old password"
    Please help me in this regard...!

    Concerning
    SA

    Hello

    845299 wrote:
    ...

    create table SAMPLE
    ( ...
    

    Thanks for posting the CREATE TABLE and INSERT statements; It's very useful!

    conditions
    *********
    if web_login = web_login and web_password = web_password and 
    

    Is not web_login always equal to web_login (unless its NULL value)?
    Did you mean you want to pass an argument to the procedure and test if argument equals web_login?

    sysdate - pwd_exp_dt > 180 days
    message " your password has been expired"
    
    if web_login = web_login and web_password = web_password and
    sysdate - pwd_exp_dt > 165 days and sysdate-pwd_exp_dt <180 days then
    message " your password has been expired very soon..pls update ur old password"
    

    I think that a function would be better than a procedure in this case. You probably want your front-end to display the message, and a function call is a logical way for the front-end information as necessary for the back-end.
    Here's one way:

    CREATE OR REPLACE FUNCTION     password_warning
    (     in_web_login     IN     sample.web_login%TYPE
    ,     in_web_password     IN     sample.web_password%TYPE
    ,     in_check_dt     IN     DATE     DEFAULT SYSDATE
    )
    RETURN     VARCHAR2
    IS
         password_age     NUMBER;          -- Days from pwd_exp_date to in check date
         return_txt     VARCHAR2 (100);     -- Message to be returned (may be NULL)
    BEGIN
         SELECT     in_check_dt - pwd_exp_dt
         INTO     password_age
         FROM     sample
         WHERE     web_login     = in_web_login
         AND     web_password     = in_web_password;
    
         IF    password_age > 180
         THEN
              return_txt := 'Your password has expired.';
         ELSIF password_age > 165
         THEN
              return_txt := 'Your password will expire very soon.  Please change your password.';
         END IF;
    
         RETURN     return_txt;
    EXCEPTION
         WHEN NO_DATA_FOUND
         THEN
              RETURN     NULL;     -- Or return 'Incorrect web_login/password.'
    END     password_warning
    ;
    /
    
    SHOW ERRORS
    

    This assumes that sample.web_login is unique.

    Here's some code to test. In addition to your actual data, I made some incorrect data, to see what the function returns when you give a bad web_login or web_password.

    WITH     expanded_sample     AS
    (
         SELECT     web_login
         ,     web_password
         FROM     sample
        UNION
         SELECT     CASE
                   WHEN  MOD (ROWNUM, 3) = 1
                   THEN  web_login
                   ELSE  '? ? ?'
              END     AS web_login
         ,     CASE
                   WHEN  MOD (ROWNUM, 3) = 2
                   THEN  web_password
                   ELSE  '? ? ?'
              END     AS web_login
         FROM     sample
    )
    SELECT       web_login
    ,       web_password
    ,       password_warning (web_login, web_password)     AS warning_now
    ,       password_warning (web_login, web_password, DATE '2011-06-19')
                                       AS warning_june_19
    FROM       expanded_sample
    ORDER BY  web_login
    ,       web_password
    ; 
    

    Output:

    WEB_LOGIN    WEB_PASSWORD WARNING_NOW                WARNING_JUNE_19
    ------------ ------------ -------------------------- --------------------------
    ? ? ?        ? ? ?
    ? ? ?        abc
    [email protected]  ? ? ?
    [email protected]  abc          Your password will expire  Your password has expired.
                              very soon.  Please change
                              your password.
    
    [email protected]  def
    [email protected]  abc                                     Your password will expire
                                                         very soon.  Please change
                                                         your password.
    

    As you can see, this function returns NULL when the password is aged less than 165 days, or when the web_login and/or the password does not match what is in the table. You can easily change this, if you wish, so that there is a separate message in each case.

    You can encrypt the passwords in the table. Oracle provides a package for encryption, called dbms_crypto.
    http://download.Oracle.com/docs/CD/B28359_01/AppDev.111/b28419/d_crypto.htm#i1005082

  • Stored procedure to add a record do not add record

    I have never successfully added a record via a stored procedure, but I managed with adding records through behaviors using recordsets with stored procedures and server, so I know that connections work. I have the data to MS SQL Server and ColdFusion web page. When I enter data and click 'Submit', it does absolutely nothing. When I check the SQL table, no record has been added. Any help would be greatly appreciated. Here are my stored procedure:


    Replace:



    Null value

    With:

    I provide each form with a value variable by default so that a value will always exist for each variable.

    Use the null attribute, if the value is 'yes', WHAT NULL value will be passed to the parameter of the stored procedure, if the content of the attribute value will be used

    http://livedocs.Adobe.com/ColdFusion/8/htmldocs/help.HTML?content=Tags_p-q_14.html#1102102

  • Select problem with a statement in the stored procedure oracle

    Hi guys,.

    I am new to oracle. I have a simple sql stored procedure that needs to be converted to oracle. The procedure is,

    CREATE PROCEDURE my_procedure
    Char (4) @my_var = null
    AS

    Select * from my_table where my_variable = @my_var

    I converted this SP as oracle and the convert SP is,

    create or replace
    My_procedure PROCEDURE
    (
    v_my_var in CHAR DEFAULT NULL
    )
    AS

    BEGIN

    SELECT * FROM my_table WHERE my_variable = v_my_var;

    END;

    But the SP above returns an error (Error (13.3): PLS-00428: an INTO clause in the following SELECT statement) when compiling.

    So I used the slider to get the results and send back them. Updated the SP is,

    create or replace
    My_procedure PROCEDURE
    (
    v_my_var in CHAR NULL by DEFAULT,
    cv_1 ON SYS_REFCURSOR
    )
    AS

    BEGIN

    OPEN cv_1 to SELECT * FROM my_table WHERE my_variable = v_my_var;

    END;

    Now, the SP is compiled successfully and return the result set correctly. My doubt is,
    What is the right way to solve the problem that I mentioned above? Is there another way to get the select query result without using a cursor?

    Please advice. Thank you for your help in advance.

    RAM

    Depends on where you are calling from SP.
    I assume you are using a windows client, as you referred to SQL Server.
    The .NET Oracle provider, allowing return of pl/sql types and as you return only all columns in a single line, you could change your procedure to something like this:

    create or replace procedure my_procedure(v_my_var in  char default null
                                            ,cv_1     OUT my_Table%rowtype) as
    
      rt my_table%rowtype;
    begin
    
      SELECT *
      into   rt
      FROM my_table
      WHERE my_var = v_my_var;
    
      cv_1 := rt;
    
    END my_Procedure;
    /
    
  • 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;
      }
    }
    
  • Table is recognized in a SQL statement, but in a stored procedure.

    Hello
    I'm using Oracle 9.2.0.6.0.

    I'm trying to compile a package of procedure in a 10 g database which has been cloned from a 9i database.

    I get an error that there is no sys.dba_refresh table (PL/SQL: ORA-00942: table or view does not exist). Here is the procedure from the package:
      procedure refresh_group
      (
       errbuf                 out varchar2
      ,retcode                out varchar2
      ,p_refresh_group_owner      varchar2
      ,p_refresh_group_name       varchar2
      ,p_trace_flag               varchar2 default 'N'
      )
      is
        cursor c_rg is
          select
                 job
                ,broken
          from
                 sys.dba_refresh
          where
                 rowner = upper(p_refresh_group_owner)
          and
                 rname = upper(p_refresh_group_name)
          ;
        v_job     number  default null;
        v_broken  char(1) default null
        ;
      begin
        /*
        ** Standard FORX Startup
        */
        forx_module.start_module('FORX_SNAPSHOT.REFRESH_GROUP')
        ;
        /*
        ** Verify parameters / status of request group
        */
        for c_rg_rec in c_rg
        loop
          v_job    := c_rg_rec.job;
          v_broken := c_rg_rec.broken;
        end loop
        ;
        if v_job is null
        then
          raise e_invalid_request_group;
        else
          if v_broken = upper('y')
          then
            raise e_dbms_job_is_broken;
          end if
          ;
        end if
        ;
        /*
        ** Move next execute date out one year (it will be scheduled via concurrent manager.)
        */
        dbms_refresh.change(p_refresh_group_owner || '.' || p_refresh_group_name
                           ,sysdate + 365
                           ,'sysdate + 365'
                           )
        ;
        forx_module.commit_force
        ;
        /*
        ** Refresh the specified group. Check the trace flag before. If Y then set the events
        ** to 4045 for the session
        */
        -- Disable query rewrite
    
        execute immediate ('alter session set query_rewrite_enabled=false');
    
        if (p_trace_flag = 'Y') then
        -- Set the event to trace ORA-4045 error
           fnd_file.put_line(fnd_file.log,'alter session set events = ''4045 trace name errorstack level 3'''
                             || ' : '
                             || to_char(sysdate,'MM-DD-YYYY / HH:MI:SS AM')
                            )
        ;
    
          execute immediate ('alter session set events = ''4045 trace name errorstack level 3''');
        end if;
    
        dbms_refresh.refresh(p_refresh_group_owner || '.' || p_refresh_group_name)
        ;
        forx_module.commit_force
        ;
        if (p_trace_flag = 'Y') then
           execute immediate ('alter session set events = ''4045 trace name errorstack off''');
        end if;
        -- Enable query rewrite
        execute immediate ('alter session set query_rewrite_enabled=true');
    
        fnd_file.put_line(fnd_file.output,'Snapshot refresh group: '
                                       || p_refresh_group_owner || '.' || p_refresh_group_name
                                       || ' refreshed on/at: '
                                       || to_char(sysdate,'MM-DD-YYYY / HH:MI:SS')
                         )
        ;
        /*
        ** Standard end-of-module processing.
        */
        forx_module.end_module(errbuf
                              ,retcode
                              )
        ;
      exception
        when e_invalid_request_group then
          forx_module.end_module(errbuf
                                ,retcode
                                ,'ERROR'
                                ,'Error!  Refresh group: '
                              || upper(p_refresh_group_owner)
                              || '.'
                              || upper(p_refresh_group_name)
                              || ' does not exist.'
                                )
          ;
        when e_dbms_job_is_broken then
          forx_module.end_module(errbuf
                                ,retcode
                                ,'ERROR'
                                ,'Error!  The refresh dbms_job (job: '
                              || to_char(v_job)
                              || ') for refresh group: '
                              || upper(p_refresh_group_owner)
                              || '.'
                              || upper(p_refresh_group_name)
                              || ' is flagged as BROKEN.  Seek DBA Assistance.'
                                )
          ;
        when others then
          forx_module.end_module(errbuf
                                ,retcode
                                ,'ERROR'
                                ,sqlcode || '-' || sqlerrm
                                )
          ;
      end refresh_group
      ;
    
      --
      -- Refresh an Individual Materialized View
      --
    I am able to describe the table. I am also able to execute the SQL statement in the cursor c_rg.
        select
                 job
                ,broken
          from
                 sys.dba_refresh;
    Anyone know if it has to do with the removal of this particular code in 10g 9i or is there a more general reason for this?

    Subsidies on the table are the same. The table was created as it was in the Database 9i with a public synonym. I don't see anything other than the DBA forgot to do.

    Does anyone have any ideas?

    Hello

    Make sure that all the necessary privileges have been granted directly to the owner of the package, not to a role that is the owner of the package. (The roles do not count in stored procedures).

Maybe you are looking for