Invalid Object error in Stored Procedure


Royal Thomas

It was a bit of a puzzler, but here is a repro that demonstrates Thomas's problem:
CREATE USER svante WITHOUT LOGIN WITH DEFAULT_SCHEMA = guest
ALTER ROLE db_owner ADD MEMBER svante
go
EXECUTE AS USER = 'svante'
go
CREATE PROCEDURE dbo.testis AS
SELECT @@procid AS beata INTO sture
SELECT * FROM sture
go
EXEC testis  -- Invalid object name 'sture'.
go
REVERT
go
EXEC testis -- Succede
go
DROP USER svante
DROP TABLE guest.sture 
DROP TABLE sture
DROP PROCEDURE testis
What is happening is this: In the statement
   SELECT @@procid AS beata INTO sture
the table is created in the default schema of the current user, not in the default schema of the procedure owner (which is dbo, since the procedures was created in dbo). This was certainly unexpected, at least for me.
But in
  SELECT * FROM sture
the regular rules, and here sture resolves to dbo.sture, not guest.sture.
Thomas should make sure that he uses dbo.xxxx in all his SELECT INTO statements.
Erland Sommarskog, SQL Server MVP, [email protected]

Similar Messages

  • Invalid Object when Calling Stored Procedure from JDBC Adapter

    JDBC Outbound adapter in XI 2.0 connected to SQL Server.  I've coded my mapping to format the XSL mapping properly but the Adapter appears to not be able to find the Stored Procedure.  Error message returned is "Invalid Object spStoredProcedureName".
    Does anybody have any clue as to what I'm missing???

    I know this is trivial, but did you use the "full" name of the SP as <schema>.<procname>???
    HTH

  • Invalid Month error in stored procedure

    Hello, I have a simple stored procedure that I pass a begin and end date into and it is complaining about the date formatting. Below is the table layout and stored procedure in question. How can I format the date for example as MM-DD-YYYY and not have it complain? I have tried using TO_DATE and TO_CHAR and it still complains.
    Thank you.
    -- Table
    CREATE TABLE INV_MOVE_ARCHIVE
    *( "RETAILER_ID" NUMBER NOT NULL,*
    *"SKU_ID" VARCHAR2(18 BYTE) NOT NULL,*
    *"OUTLET_ID" VARCHAR2(20 BYTE) NOT NULL,*
    *"QTY_CHANGE" NUMBER NOT NULL,*
    *"TRANS_DATE" DATE DEFAULT sysdate*
    -- Stored procedure
    CREATE OR REPLACE PROCEDURE inv_move_update(beginDate IN DATE, endDate IN DATE, retailerId IN INT)
    IS
    skuId VARCHAR(18);
    outletId VARCHAR(20);
    qtyChange INTEGER;
    -- Declaring the cursor
    CURSOR getInvRecord IS
    SELECT
    sku_id,
    outlet_id,
    qty_change
    INTO
    skuId,
    outletId,
    qtyChange
    FROM
    inv_move_archive
    WHERE
    retailer_id = retailerId AND
    trans_date &gt;= beginDate AND
    trans_date &lt;= endDate;
    BEGIN
    FOR rec_getInvRecord IN getInvRecord LOOP
    UPDATE OUTLET_SKU_XREF
    SET qty = qty + qtyChange
    WHERE outlet_id = outletId
    AND sku_id = skuId;
    COMMIT;
    END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
    IF getInvRecord%isopen THEN CLOSE getInvRecord;
    END IF;
    END inv_move_update;
    */*

    Okay, I do not wantto change the table. I believe thatthe Java developers will need to change their code to call this procedure correctly. Another iss I am having is when I call this procedure manually from the database is is NOT doing the update. I put some debug statements in it and they indicate that the update statement is NOT updating any rows. If I run the select statement that is in the sp using the same parameters I pass into the sp it comes back with 1 row. The row to be updated is present in the table being updated.
    -- Here is my sp call
    DECLARE
      BEGINDATE DATE;
      ENDDATE DATE;
      RETAILERID NUMBER;
    BEGIN
      BEGINDATE := to_date('01/07/2009 00:00:00', 'MM/DD-YYYY HH24:MI:SS');
      ENDDATE := to_date('01/07/2009 11:59:59', 'MM/DD-YYYY HH24:MI:SS');
      RETAILERID := 104;
      INV_MOVE_UPDATE(
        BEGINDATE => BEGINDATE,
        ENDDATE => ENDDATE,
        RETAILERID => RETAILERID
    END;
    -- Select statement with same values
    SELECT
       sku_id,
       outlet_id,
       qty_change
    FROM
       inv_move_archive
    WHERE
       retailer_id = 104 AND
       trans_date >= to_date('01/07/2009 00:00:00', 'MM/DD-YYYY HH24:MI:SS') AND
       trans_date <= to_date('01/07/2009 11:59:59', 'MM/DD-YYYY HH24:MI:SS')
    -- Results from select
    036266579804040     9900165     500
    -- Here is the procedure with the debug statements in it.
    CREATE OR REPLACE PROCEDURE inv_move_update(beginDate IN DATE, endDate IN DATE, retailerId IN  INT)
    IS
            skuId VARCHAR(18);
            outletId VARCHAR(20);
            qtyChange NUMBER;
            errorMessage  VARCHAR(2500) := NULL;       
    -- Declaring the cursor
    CURSOR getInvRecord IS
          SELECT
             sku_id,
             outlet_id,
             qty_change
          INTO
             skuId,
             outletId,
             qtyChange
          FROM
             inv_move_archive
          WHERE
             retailer_id = retailerId AND
             trans_date >= beginDate AND
             trans_date <= endDate;
    BEGIN
       FOR rec_getInvRecord IN getInvRecord LOOP
          DBMS_OUTPUT.PUT_LINE('Rows Updated: ' || SQL%ROWCOUNT);
          UPDATE OUTLET_SKU_XREF
           SET qty = qty + qtyChange
          WHERE outlet_id = outletId
                AND sku_id = skuId;
          DBMS_OUTPUT.PUT_LINE('SKUID: ' || skuId);
          DBMS_OUTPUT.PUT_LINE('Rows Updated: ' || SQL%ROWCOUNT);
          COMMIT;       
       END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
        errorMessage := 'Error updating the OUTLET_SKU_XREF table: ' || SQLCODE || ':' || SQLERRM;
        RAISE_APPLICATION_ERROR(-20001,errorMessage);
        DBMS_OUTPUT.PUT_LINE(errorMessage);
        IF getInvRecord%isopen THEN CLOSE getInvRecord;
        END IF;  
    END inv_move_update;
    /I get no errors when running it. The DBMS_OUTPUT shows null for the skuId and 0 for Rows Updated. Like I said I ran the select manually and it returns a row and I see that the row does exist in the target table. Any ideas what is going on here?
    Thank you
    -- David

  • Error in stored procedure while using dbms_datapump for transportable

    Hi,
    I'm facing following issue:
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE 10.2.0.4.0 Production
    TNS for Solaris: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    ====================================================================================
    I'm trying to do transportable tablespace through stored procedure with help of DBMS_DATAPUMP, Following is the code :
    ==================================================================================
    create or replace
    procedure sp_tts_export(v_tbs_name varchar2) as
    idx NUMBER; -- Loop index
    JobHandle NUMBER; -- Data Pump job handle
    PctComplete NUMBER; -- Percentage of job complete
    JobState VARCHAR2(30); -- To keep track of job state
    LogEntry ku$_LogEntry; -- For WIP and error messages
    JobStatus ku$_JobStatus; -- The job status from get_status
    Status ku$_Status; -- The status object returned by get_status
         dts           varchar2(140):=to_char(sysdate,'YYYYMMDDHH24MISS');
         exp_dump_file varchar2(500):=v_tbs_name||'_tts_export_'||dts||'.dmp';
         exp_log_file varchar2(500):=v_tbs_name||'_tts_export_'||dts||'.log';
         exp_job_name varchar2(500):=v_tbs_name||'_tts_export_'||dts;
         dp_dir varchar2(500):='DATA_PUMP_DIR';
         log_file UTL_FILE.FILE_TYPE;
         log_filename varchar2(500):=exp_job_name||'_main'||'.log';
         err_log_file UTL_FILE.FILE_TYPE;
         v_db_name varchar2(1000);
         v_username varchar2(30);
         t_dir_name VARCHAR2(4000);
    t_file_name VARCHAR2(4000);
    t_sep_pos NUMBER;
         t_dir varchar2(30):='temp_0123456789';
         v_sqlerrm varchar2(4000);
    stmt varchar2(4000);
         FUNCTION get_file(filename VARCHAR2, dir VARCHAR2 := 'TEMP')
    RETURN VARCHAR2 IS
    contents VARCHAR2(32767);
    file BFILE := BFILENAME(dir, filename);
    BEGIN
              DBMS_LOB.FILEOPEN(file, DBMS_LOB.FILE_READONLY);
              contents := UTL_RAW.CAST_TO_VARCHAR2(
    DBMS_LOB.SUBSTR(file));
              DBMS_LOB.CLOSE(file);
              RETURN contents;
         END;
    begin
    --execute immediate ('drop tablespace test including contents and datafiles');
    --execute immediate ('create tablespace test datafile ''/home/smishr02/test.dbf'' size 10m');
    --execute immediate ('create table prestg.test_table (a number) tablespace test');
    --execute immediate ('insert into prestg.test_table values (1)');
    --commit;
    --execute immediate ('alter tablespace test read only');
    --dbms_output.put_line('11111111111111111111');
    dbms_output.put_line(log_filename||'>>>>>>>>>>>>>>>>>>>>>>>>>>>'|| dp_dir);
    log_file:=UTL_FILE.FOPEN (dp_dir, log_filename, 'w');
    UTL_FILE.PUT_LINE(log_file,'#####################################################################');
    UTL_FILE.PUT_LINE(log_file,'REPORT: GENERATED ON ' || SYSDATE);
    UTL_FILE.PUT_LINE(log_file,'#####################################################################');
    select global_name,user into v_db_name,v_username from global_name;
    UTL_FILE.PUT_LINE(log_file,'Database:'||v_db_name);
    UTL_FILE.PUT_LINE(log_file,'user running the job:'||v_username);
    UTL_FILE.PUT_LINE(log_file,'for tablespace:'||v_tbs_name);
    UTL_FILE.NEW_LINE (log_file);
    stmt:='ALTER TABLESPACE '||v_tbs_name || ' read only';
    dbms_output.put_line('11111111111111111111'||stmt);
    execute immediate (stmt);
    UTL_FILE.PUT_LINE(log_file,' '||v_tbs_name || ' altered to read only mode.');
    UTL_FILE.NEW_LINE (log_file);
    UTL_FILE.PUT_LINE(log_file,'#####################################################################');
    UTL_FILE.NEW_LINE (log_file);
    UTL_FILE.PUT_LINE(log_file,' Initiating the Datapump engine for TTS export..............');
    UTL_FILE.NEW_LINE (log_file);
    dbms_output.put_line('11111111111111111111');
    JobHandle :=
    DBMS_DATAPUMP.OPEN(
    operation => 'EXPORT'
    *,job_mode => 'TRANSPORTABLE'*
    *,remote_link => NULL*
    *,job_name => NULL*
    --,job_name => exp_job_name
    --        ,version => 'LATEST'
    UTL_FILE.PUT_LINE(log_file,'Done');
    UTL_FILE.NEW_LINE (log_file);
    UTL_FILE.PUT_LINE(log_file,' Allocating dumpfile................');
    DBMS_DATAPUMP.ADD_FILE(
    handle => JobHandle
    ,filename => exp_dump_file
    ,directory => dp_dir
    ,filetype => DBMS_DATAPUMP.KU$_FILE_TYPE_DUMP_FILE
    -- ,filesize => '100M'
    UTL_FILE.PUT_LINE(log_file,'Done');
    UTL_FILE.NEW_LINE (log_file);
    UTL_FILE.PUT_LINE(log_file,' Allocating logfile................');
    DBMS_DATAPUMP.ADD_FILE(
    handle => JobHandle
    ,filename => exp_log_file
    ,directory => dp_dir
    ,filetype => DBMS_DATAPUMP.KU$_FILE_TYPE_LOG_FILE
    UTL_FILE.PUT_LINE(log_file,'Done');
    UTL_FILE.NEW_LINE (log_file);
    UTL_FILE.PUT_LINE(log_file,' Setting attributes................');
    DBMS_DATAPUMP.set_parameter(handle => JobHandle,
    name=>'TTS_FULL_CHECK',
    value=>1);
    DBMS_DATAPUMP.METADATA_FILTER(
    handle => JobHandle
    ,NAME => 'TABLESPACE_EXPR'
    ,VALUE => 'IN ('''||v_tbs_name||''')'
    -- ,object_type => 'TABLE'
    UTL_FILE.PUT_LINE(log_file,'Done');
    UTL_FILE.NEW_LINE (log_file);
    UTL_FILE.PUT_LINE(log_file,' Now starting datapump job................');
    DBMS_DATAPUMP.START_JOB(JobHandle);
    UTL_FILE.PUT_LINE(log_file,'Done');
    UTL_FILE.NEW_LINE (log_file);
    UTL_FILE.PUT_LINE(log_file,' Monitoring the job................');
    --------------Monitor the job
    PctComplete := 0;
    JobState := 'UNDEFINED';
    WHILE(JobState != 'COMPLETED') and (JobState != 'STOPPED')
    LOOP
    DBMS_DATAPUMP.GET_STATUS(
    handle => JobHandle
    ,mask => 15 -- DBMS_DATAPUMP.ku$_status_job_error + DBMS_DATAPUMP.ku$_status_job_status + DBMS_DATAPUMP.ku$_status_wip
    ,timeout => NULL
    ,job_state => JobState
    ,status => Status
    JobStatus := Status.job_status;
    -- Whenever the PctComplete value has changed, display it
    IF JobStatus.percent_done != PctComplete THEN
    DBMS_OUTPUT.PUT_LINE('*** Job percent done = ' || TO_CHAR(JobStatus.percent_done));
    PctComplete := JobStatus.percent_done;
    END IF;
    -- Whenever a work-in progress message or error message arises, display it
    IF (BITAND(Status.mask,DBMS_DATAPUMP.ku$_status_wip) != 0) THEN
    LogEntry := Status.wip;
    ELSE
    IF (BITAND(Status.mask,DBMS_DATAPUMP.ku$_status_job_error) != 0) THEN
    LogEntry := Status.error;
    ELSE
    LogEntry := NULL;
    END IF;
    END IF;
    IF LogEntry IS NOT NULL THEN
    idx := LogEntry.FIRST;
    WHILE idx IS NOT NULL
    LOOP
    DBMS_OUTPUT.PUT_LINE(LogEntry(idx).LogText);
    idx := LogEntry.NEXT(idx);
    END LOOP;
    END IF;
    END LOOP;
         --copy the datafiles to data dump dir     
         UTL_FILE.PUT_LINE(log_file,'Done');
    UTL_FILE.NEW_LINE (log_file);
    UTL_FILE.PUT_LINE(log_file,' Copying datafiles to dump directory................');
    -- grant select on dba_directories to prestg;
    declare
    cnt number;
    begin
    select count(*) into cnt from dba_directories
    where directory_name=upper(t_dir);
    if cnt=1 then
    execute immediate('DROP DIRECTORY '||t_dir);
    end if;
    end;
         FOR rec in (select file_name from sys.dba_data_files where tablespace_name=v_tbs_name)
         LOOP
         t_sep_pos:=instr(rec.file_name,'/',-1);
    t_dir_name:=substr(rec.file_name,1,t_sep_pos-1);
    t_file_name:=substr(rec.file_name,t_sep_pos+1,length(rec.file_name));
    dbms_output.put_line(t_dir_name|| ' ' || t_dir);
    dbms_output.put_line(t_file_name);
         execute immediate('CREATE DIRECTORY '||t_dir||' AS '''||t_dir_name||'''');
         UTL_FILE.PUT_LINE(log_file,' Copying '||rec.file_name||'................');
         utl_file.fcopy(t_dir, t_file_name, dp_dir, t_file_name);
         UTL_FILE.PUT(log_file,'Done');
         execute immediate('DROP DIRECTORY '||t_dir);
         END LOOP;
    UTL_FILE.NEW_LINE (log_file);
    UTL_FILE.PUT_LINE(log_file,' Altering tablespace to read write................');
         execute immediate ('ALTER TABLESPACE '||v_tbs_name || ' read write');
    UTL_FILE.PUT(log_file,' Done');
         err_log_file:=utl_file.fopen(dp_dir, exp_log_file, 'r');
         UTL_FILE.NEW_LINE (log_file);
    UTL_FILE.PUT_LINE(log_file,' content of export logfile................');
         loop
    begin
         utl_file.get_line(err_log_file,v_sqlerrm);
         if v_sqlerrm is null then
         exit;
         end if;
         UTL_FILE.PUT_LINE(log_file,v_sqlerrm);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    EXIT;
    END;
         end loop;
              utl_file.fclose(err_log_file);
    utl_file.fclose(log_file);
    END;
    I'm getting following error when DBMS_DATAPUMP.OPEN is called in procedure:
    SQL> exec sp_tts_export('TEST');
    BEGIN sp_tts_export('TEST'); END;
    ERROR at line 1:
    ORA-31626: job does not exist
    ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
    ORA-06512: at "SYS.DBMS_DATAPUMP", line 938
    ORA-06512: at "SYS.DBMS_DATAPUMP", line 4566
    ORA-06512: at "PRESTG.SP_TTS_EXPORT", line 78
    ORA-06512: at line 1
    ==============================================================================================
    This procedure is part of user ABC. I'm getting the above when I'm running this under ABC schema. However I have tested the same procedure under sys schema. When I'm creating same procedure in SYS schema it is running fine. I am clueless on this. Pls help
    Thanks
    Shailesh
    Edited by: shaileshM on Jul 28, 2010 11:15 AM

    Privileges acquired via ROLE do NOT apply within named PL/SQL procedures.
    Explicit GRANT is required to resolve this issue.

  • Hashset Object Setting in Stored procedure

    I have a store Procedure:
    CREATE PROCEDURE TESTING_SET(TEST_SET SET(CHAR(100) NOT NULL))
    RETURNING CHAR(100);
    DEFINE element CHAR(100);
    FOREACH SELECT * INTO element FROM TABLE(TEST_SET)
    RETURN element WITH RESUME;
    END FOREACH;
    END PROCEDURE;
    I am trying to call a stored procedure using CallableStetement. The stored procedure accepts a SET object. So I am setting the Hasset as CallableStatement.setObject(HashSet);
    But when the CallableStatement.execte() is called I am getting the following error:
    java.sql.SQLException: Routine (testing_set) can not be resolved.
    at com.informix.jdbc.IfxSqli.a(IfxSqli.java:3631)
    at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3963)
    at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2693)
    at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2609)
    at com.informix.jdbc.IfxSqli.a(IfxSqli.java:1828)
    at com.informix.jdbc.IfxSqli.executeExecute(IfxSqli.java:2521)
    at com.informix.jdbc.IfxSqli.executeExecute(IfxSqli.java:2461)
    at com.informix.jdbc.IfxResultSet.b(IfxResultSet.java:393)
    at com.informix.jdbc.IfxStatement.a(IfxStatement.java:1326)
    at com.informix.jdbc.IfxPreparedStatement.d(IfxPreparedStatement.java:449)
    at com.informix.jdbc.IfxCallableStatement.execute(IfxCallableStatement.java:331)
    at com.west.wic.test.HashSetTest.main(HashSetTest.java:40)
    Caused by: java.sql.SQLException
    at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:413)
    at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3968)
    ... 10 more
    error message:Routine (testing_set) can not be resolved.
    error code:-674
    Please help me in this regard.

    >
    I wasn't directly replying to you
    >
    Well maybe that wasn't your intention but that is what this line in the reply means:
    >
    Posted: May 3, 2013 12:19 PM in response to: rp0428
    >
    That means you are responding to 'rp0428'; that's me. So when you say this
    >
    But first make sure that the database user you're using
    >
    And because your comments are 'in response to: rp0428' the word "you're" is generally going to be interpreted to mean 'rp0428' unless you indicate otherwise.
    If you had responded to OP that word "you're" would mean you are telling OP to
    >
    first make sure that the database user you're using
    >
    It isn't a question of 'right'; it is a question of how to address your remarks to the proper person so that that person KNOWS the remarks are meant for them.
    Here's an easy way for you to remember who to reply to: it is the same person you would LOOK at if you were in the same room with them.
    You would be looking at me while you were listening to my comments. Then you would turn and look at OP when you made yours. In the forum you accomplish that by using the 'reply' link on one of OP's comments.
    If, for some reason, you did want to make comments to both of us in your one reply then pick one to reply to, even me, and then preface your comment to OP like this:
    >
    -- comment here for rp0428 - but you didn't make any
    OP: first make sure that the database user you're using . . .
    >
    See how that 'OP:' prefix makes it clear that, even though your comments are 'in response to: rp0428' that particular comment is meant for OP?
    It might be aarkward at first but once you try it a few times you'll get the hang of it. ;)

  • Error creating Stored procedure

    Hello All,
    I am logged in as “system” user and trying to run the below script.
    create or replace procedure verify_job_not_running (my_job_name IN varchar2)
    AS
    my_job_count NUMBER;
    BEGIN
    select count(*) into my_job_count from dba_datapump_jobs where job_name = my_job_name;
    IF my_job_count > 0 THEN
    raise_application_error(-20010, 'data pump job already running');
    END IF;
    END verify_job_not_running;
    The above procedure is created with compilation errors. Please see the error message below.
    SQL> show errors;
    Errors for PROCEDURE VERIFY_JOB_NOT_RUNNING:
    LINE/COL ERROR
    5/3 PL/SQL: SQL Statement ignored
    5/42 PL/SQL: ORA-00942: table or view does not exist
    FYI - I am able to query “dba_datapump_jobs” table as “system”.
    Any help will be appreciated.
    Thank you,

    Hi,
    user504183 wrote:
    Hello All,
    I am logged in as “system” user and trying to run the below script.Very, very bad idea.
    Never create objects in Oracle-supplied schemas like SYSTEM, SYS, even HR.
    Create your own schema (you can call it my_system) for your own SYSTEM-like objects.
    create or replace procedure verify_job_not_running (my_job_name IN varchar2)
    AS
    my_job_count NUMBER;
    BEGIN
    select count(*) into my_job_count from dba_datapump_jobs where job_name = my_job_name;
    IF my_job_count > 0 THEN
    raise_application_error(-20010, 'data pump job already running');
    END IF;
    END verify_job_not_running;
    The above procedure is created with compilation errors. Please see the error message below.
    SQL> show errors;
    Errors for PROCEDURE VERIFY_JOB_NOT_RUNNING:
    LINE/COL ERROR
    5/3 PL/SQL: SQL Statement ignored
    5/42 PL/SQL: ORA-00942: table or view does not exist
    FYI - I am able to query “dba_datapump_jobs” table as “system”.Roles don't count in stored procedures. SYSTEM probably has privileges on dba_datapubp_jobs only because it has the role SELECT_CATALOG_ROLE.
    Log in as SYS and give the necessary privilges directly to the procedure owner (whcih, once again, should NOT be SYSTEM);
    GRANT SELECT ON dba_datapump_jobs TO my_system;

  • Error with stored procedure block datasource

    Hi all,
    I tried to base a datablock on a stored procedure in order to get better runtime performance. I work with Forms Builder 6i with patch 17 , and our database is oracle 8.1.7.1.4
    But when compiling I got errors.
    Here are what I did :
    create or replace type TSourceObject as object(name varchar2(30), propname varchar2(200));
    create or replace type TSourceTable is table of TSourceObject;
    create or replace procedure p_query_ntwk_chnl_mirror(p_tab IN OUT NOCOPY TSourceTable, p_action varchar2, p_lien number)
    is
    begin
    if p_action = 'VISU' then
    select TSourceObject(B.bdw_name, P.prop_bdw_name)
    bulk collect into p_tab
    from T_NETWORK_CHANNEL N, t_bdw_mw B, t_prop_bdw_mw P
    where B.comp_bdw = P.comp_bdw and P.comp_prop_bdw = N.comp_prop_bdw
    and EXISTS (SELECT 1
    FROM t_channel_element C
    WHERE N.comp_network_channel = C.comp_network_channel and comp_lien = p_lien);
    else
    select TSourceObject(B.bdw_name, P.prop_bdw_name)
    bulk collect into p_tab
    from T_NETWORK_CHANNEL N, t_bdw_mw B, t_prop_bdw_mw P
    where B.comp_bdw = P.comp_bdw and P.comp_prop_bdw = N.comp_prop_bdw;
    end if;
    end;
    Then I created the datablock with the wizard , I entered correctly the value of the arguments for the table type name, the argument p_action and the argument p_lien.
    And when compiling there was this alert error :
    Compiling QUERY-PROCEDURE trigger on NETWORK_CHANNEL_MIRROR data block...
    Compilation error on QUERY-PROCEDURE trigger on NETWORK_CHANNEL_MIRROR data block:
    PL/SQL ERROR 960 at line 5, column 9
    RPCs cannot use variables with schema level user-defined types in this release
    PL/SQL ERROR 0 at line 5, column 9
    Item ignored
    PL/SQL ERROR 320 at line 7, column 26
    the declaration of the type of this expression is incomplete or malformed
    PL/SQL ERROR 0 at line 7, column 1
    Statement ignored
    PL/SQL ERROR 320 at line 8, column 28
    the declaration of the type of this expression is incomplete or malformed
    PL/SQL ERROR 0 at line 8, column 1
    Statement ignored
    Compilation errors have occurred.
    So what should I do ?
    Thank you very much indeed.

    I create the package , and when creating the body then there was an error.
    Here is the package :
    create or replace package pkg_query_ntwrk_chnl_mirror
    is
    type TSourceObject is record(name varchar2(30), propname varchar2(200));
    type TSourceTable is table of TSourceObject index by binary_integer;
    procedure p_query_ntwk_chnl_mirror(p_tab IN OUT NOCOPY pkg_query_ntwrk_chnl_mirror.TSourceTable, p_action varchar2, p_lien number);
    end;
    create or replace package body pkg_query_ntwrk_chnl_mirror
    is
    procedure p_query_ntwk_chnl_mirror(p_tab IN OUT NOCOPY pkg_query_ntwrk_chnl_mirror.TSourceTable, p_action varchar2, p_lien number)
    is
    begin
    if p_action = 'VISU' then
         select B.bdw_name, P.prop_bdw_name
         bulk collect into p_tab
         from T_NETWORK_CHANNEL N, t_bdw_mw B, t_prop_bdw_mw P
         where B.comp_bdw = P.comp_bdw and P.comp_prop_bdw = N.comp_prop_bdw
         and EXISTS (SELECT 1
         FROM t_channel_element C
         WHERE N.comp_network_channel = C.comp_network_channel and comp_lien = p_lien);
    else
         select B.bdw_name, P.prop_bdw_name
         bulk collect into p_tab
         from T_NETWORK_CHANNEL N, t_bdw_mw B, t_prop_bdw_mw P
         where B.comp_bdw = P.comp_bdw and P.comp_prop_bdw = N.comp_prop_bdw;
    end if;
    end;
    end;
    And here is the error :
    7/2 PL/SQL: SQL Statement ignored
    8/20 PLS-00597: expression 'P_TAB' in the INTO list is of wrong type
    15/2 PL/SQL: SQL Statement ignored
    16/20 PLS-00597: expression 'P_TAB' in the INTO list is of wrong type
    And what is the problem here ? I think it is right!

  • Empty strings when passing a Java object to a Stored Procedure

    Hi,
    I'm using the interface SQLData to pass Java objects to StoredProcedures. All the object's attributes 'arrive' to the Stored Procedure ok, except the strings, which are empty.
    Here is my Oracle object:
    TYPE OBJ_ASJFF_OBJ1 IS OBJECT (
    ARG1 CHAR(3),
    ARG2 NUMBER(4),
    ARG3 CHAR(4),
    ARG4 NUMBER(7),
    ARG5 NUMBER(13,2),
    ARG6 CHAR(1));
    The nested table of that object:
    TYPE TAB_ASJFF_OBJ1 AS TABLE OF OBJ_ASJFF_OBJ1;
    The procedure declaration:
    PROCEDURE Pup_Instaura_Processo (                              x_crCert IN TAB_ASJFF_OBJ1,
    x_cResult OUT CHAR(4)
    My SQLData implementation:
    public void writeSQL(SQLOutput stream) throws SQLException {
                   stream.writeString(getArg1());     
                   stream.writeInt(getArg2().intValue());
                   stream.writeString(getArg3());          
                   stream.writeLong(getArg4().longValue());     
                   stream.writeBigDecimal(getArg5());
                   stream.writeString(getArg6());
    Can anybody help me?
    Thanks in advance
    Rui Gonçalves

    not exactly what you wanted but ingredients can be found at
    - JPublisher's docuemntation (especially "Type Mapping Support Through PL/SQL Conversion Functions")
    - http://otn.oracle.com/sample_code/tech/java/jsp/Oracle9iJSPSamples.html (Best Hotels PL/SQL Sample )
    - http://otn.oracle.com/tech/xml/xdk_sample/xdksample_093001i.html
    hope this helps
    Kuassi
    I have a Java Stored procedure which takes an instance of a different java object as its parameter.
    I need to do this from a pl/sql package - can anyone point me to a sample etc (looked on the website but don't see one) ?
    Andrew

  • Invalid object error while migrating oracle forms 6i to APEX

    Hi,
    I have a form name abc.fmb and I did converted to xml and imported using application migration in APEX
    With these I have nine PL/SQL libraries (PLL). converted it to PLD using rwconvertor and imported in APEX. Also, I have 4 tables i.e data base block in forms.
    Now, when i m migrating forms to APEX it is giving an error message saying invalid objects and shows the table name and column name. But the column name that it shows is a text box in the form that is also a database item ...
    eg:- addr is the block name in forms
    item name dsp_name
    error: invalid object
    Please suggest.
    Thanks,
    AP.

    Hi AP
    i would suggest this...
    Oracle Application Express (APEX)
    Regards,
    Abdetu...

  • Error executing Stored Procedure that returns a recordset in Visual Basic 6

    Hello, i tried to use the example in the link posted as a response to my question in a previous thread, and in Visual Basic 6, when i execute the Stored procedure it gives me the following error:
    This is the package created as indicated in the example FAQ you posted.
    package types
    as
    type cursorType is ref cursor;
    end;
    This is the procedure created as indicated in the example FAQ you posted.
    PROCEDURE SP_TITUVALO(T_BR IN VARCHAR2,
    P_Cursor OUT TYPES.cursorType )
    AS
    BEGIN
    OPEN P_Cursor FOR
    SELECT * FROM TASAS WHERE BR=T_BR AND TASA > 0;
    END;
    This is the code used to execute the Stored Procedure in VB6:
    Dim objConn As New ADODB.Connection
    Dim connString
    Dim cmdStoredProc As New ADODB.Command
    Dim param1 As New ADODB.Parameter
    Dim RS As ADODB.Recordset
    Set param1 = cmdStoredProc.CreateParameter("T_BR", adVarChar, adParamInput, 255, "97")
    cmdStoredProc.Parameters.Append param1
    objConn.Open strconex
    Set cmdStoredProc.ActiveConnection = objConn
    cmdStoredProc.CommandText = "SP_TITUVALO"
    cmdStoredProc.CommandType = adCmdStoredProc
    Set RS = cmdStoredProc.Execute
    This is the error returned:
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'SP_TITUVALO'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    ****************************************************************

    Juan,
    Not sure about FAQ you are referring to, but it seems that you need to set PLSQLRSet property of ADODB.Command to TRUE. Because if you fail to do so - errors with refcursors are likely to happen.
    Consider:
    Set objConn = CreateObject("ADODB.Connection")
    objConn.ConnectionString = "Provider=OraOLEDB.Oracle;Persist Security Info=False;Data Source=test9ora;User ID=max;Password=blabla"
    objConn.Open
    'Dim cmdStoredProc
    Set cmdStoredProc = CreateObject("ADODB.Command")
    Dim param1
    Set param1 = cmdStoredProc.CreateParameter("T_BR", adVarChar, adParamInput, 255, "97")
    param1.Value = "X"
    cmdStoredProc.Parameters.Append param1
    'Dim RS
    Set cmdStoredProc.ActiveConnection = objConn
    'The following line was missed out
    cmdStoredProc.Properties("PLSQLRSet") = True
    cmdStoredProc.CommandText = "SP_TITUVALO"
    cmdStoredProc.CommandType = adCmdStoredProc
    Set RS = cmdStoredProc.ExecuteThis works fine, at least for me.
    Cheers.

  • Invalid object error, for @CURRMBRRANGE

    Hi,
    I have been getting the error invalid object in line 1, when trying to retrieve the member using smartview 11.1.2.1.
    The formula in the member is:
    @SUMRANGE (9999,@CURRMBRRANGE (Period,Gen,4, ,0 ));
    I have tried changing it to:
    @SUMRANGE (9999,@CURRMBRRANGE (Period,LEV,0, ,0 ));
    Can anyone suggest any other changes I can try out?
    Thanks in advance.
    Anindyo

    I guess the first question is: does the member formula (I am guessing a member formula) verify in EAS?
    If yes, are you trying to write a YTD member formula?
    When I put this formula into a new member in My Very Favorite BSO Database In The Whole Wide World, aka Sample.Basic:
    @SUMRANGE("Sales", @CURRMBRRANGE("Year", LEV, 0, , 0)) ;It works on retrieval as below:
          Product       Market       Scenario                                                   
          Jan       Feb       Mar       Apr       May       Jun       Jul       Aug       Sep       Oct       Nov       Dec       Year
    Sales       31,538       32,069       32,213       32,917       33,674       35,088       36,134       36,008       33,073       32,828       31,971       33,342       400,855
    YTDSales       31,538       63,607       95,820       128,737       162,411       197,499       233,633       269,641       302,714       335,542       367,513       400,855       2,589,510 You can see how the months sum up -- is that what you want?
    Regards.
    Cameron Lackpour

  • Error calling stored procedure from MFC using odbc

    Hello,
    I am using MFC to call a stored procedure written in PL/SQL, but when I make the call I get the next error in Spanish:
    "No se enlazaron columnas antes de llamar a SQLFetchScroll o SQLExtendedFetch", which more or less in English means:
    "No rows were binded before calling SQLFetchScroll or SQLExtendedFetch".
    I am using a CRecordset derived class to access the stored procedure. I am unable to find the error.
    THE STORED PROCEDURE'S HEADER:
    Sp_Int_Ot_Ordendetrabajoalta ( lineatrabajo NUMBER, lv_orden NUMBER, usuario
    VARCHAR2, idvehiculo NUMBER, fechamax1 VARCHAR2, resumen VARCHAR2, detalle
    VARCHAR2,
    coderp VARCHAR2, numtrabrecibidos NUMBER, lv_CODOT VARCHAR2, retorno OUT
    INTEGER)
    THE .H FOR THE CRECORDSET DERIVED CLASS (Visual Studio 6 comments removed)
    class CRecSP : public CRecordset
    public:
    CRecSP(CDatabase* pDatabase = NULL);
    DECLARE_DYNAMIC(CRecSP)
    CString m_szSQL;
    long m_RETORNO;
    virtual CString GetDefaultConnect();
    virtual CString GetDefaultSQL();
    virtual void DoFieldExchange(CFieldExchange* pFX);
    THE .CPP FOR THE CLASS (VS6 comments removed)
    IMPLEMENT_DYNAMIC(CRecSP, CRecordset)
    CRecSP::CRecSP(CDatabase* pdb) : CRecordset(pdb)
    m_RETORNO = 0;
    m_nParams = 1;
    m_nDefaultType = snapshot;
    CString CRecSP::GetDefaultConnect()
    return T( DBCONNECTION_STRING );
    CString CRecSP::GetDefaultSQL()
    return m_szSQL;
    void CRecSP::DoFieldExchange(CFieldExchange* pFX)
    pFX->SetFieldType(CFieldExchange::outputParam);
    RFX_Long(pFX, _T("[retorno]"), m_RETORNO );
    USING THE CRECORDSET DERIVED CLASS: (Vars read from EditBoxes as CStrings
    and formatted in the SQL)
    CRecSP *rec = new CRecSP(&db);
    szSQL.Format( "{CALL
    FGROT2005.SP_INT_OT_ORDENDETRABAJOALTA(%s,%s,'%s',%s,'%s','%s','%s','%s',%s,'%s',?)}",
    szLinea, szOrden, "USER", szIdVeh, szFechaMax, szResumen,
    szDetalle, "ERP", "0", szCodOT
    rec->m_szSQL = szSQL;
    //rec->Open( CRecordset::forwardOnly,szSQL,CRecordset::readOnly );
    rec->Open( );
    iError = rec->m_RETORNO;
    rec->Close();

    This forum is meant for discussions about OTN content/site and services.
    Questions about Oracle products and technologies will NOT be answered in this forum. Please post your product or technology related questions in the appropriate product or technology forums, which are monitored by Oracle product managers.
    Product forums:
    http://forums.oracle.com/forums/index.jsp?cat=9
    Technology forums:
    http://forums.oracle.com/forums/index.jsp?cat=10

  • Error Calling Stored Procedure Receiver adapter

    Hi Guys,
    I am trying to send data to a stored procedure SQL server R2 2008 from SAP PI7.11.
    Transport Protocol: JDBC2.0
    Message Protocol : XMLSQLFORMAT
    I am able to read from same database using sender adapter.
    Name of SP:  InderTest
    Paramters in SP :      @Carrier Varchar(20), @Location Varchar(20), @Product Varchar(20), @Zone Varchar(20),
         @dteStart date, @dteEnd date, @strType Varchar(1),     @intRate Float
      <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:MT_FreightPricing xmlns:ns0="http://na.holcim.com/pi/o2c/pricingmaster">
    - <StatementName1>
    - <InderTest action="EXECUTE">
      <table>InderTest</table>
      <Carrier isInput="true" type="VARCHAR">4000004</Carrier>
      <Location isInput="true" type="VARCHAR">3600</Location>
      <Product isInput="true" type="VARCHAR">3553</Product>
      <Zone isInput="true" type="VARCHAR">Zone1</Zone>
      <dteStart isInput="true" type="DATE">20110704</dteStart>
      <dteEnd isInput="true" type="DATE">20120704</dteEnd>
      <strType isInput="true" type="VARCHAR">A</strType>
      <intRate isInput="true" type="FLOAT">10.00</intRate>
      </InderTest>
      </StatementName1>
      </ns0:MT_FreightPricing>
    Error in JDBC Receiver
    Message processing failed. Cause: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'InderTest' (structure 'StatementName1'): java.lang.IllegalArgumentException
    Any clue...
    I was reading this help document. They have mentioned 5 configuration step, i have worked on JDBC earlier but never did anything like that.... Any idea ?
    http://help.sap.com/saphelp_nw70/helpdata/en/b0/676b3c255b1475e10000000a114084/content.htm
    Regards
    Inder

    <table> element is optional in the structure. In that case you can try:
    <?xml version="1.0" encoding="UTF-8" ?>
    <ns0:MT_FreightPricing xmlns:ns0="http://na.holcim.com/pi/o2c/pricingmaster">
    <StatementName1>
    <InderTest action="EXECUTE">
    <Carrier isInput="true" type="VARCHAR">4000004</Carrier>
    <Location isInput="true" type="VARCHAR">3600</Location>
    <Product isInput="true" type="VARCHAR">3553</Product>
    <Zone isInput="true" type="VARCHAR">Zone1</Zone>
    <dteStart isInput="true" type="DATE">20110704</dteStart>
    <dteEnd isInput="true" type="DATE">20120704</dteEnd>
    <strType isInput="true" type="VARCHAR">A</strType>
    <intRate isInput="true" type="FLOAT">10.00</intRate>
    </InderTest>
    </StatementName1>
    </ns0:MT_FreightPricing>
    Regards
    Raj

  • Error calling stored procedure from MFC.

    Hello,
    I am using MFC to call a stored procedure written in PL/SQL, but when I make the call I get the next error in Spanish:
    "No se enlazaron columnas antes de llamar a SQLFetchScroll o SQLExtendedFetch", which more or less in English means:
    "No rows were binded before calling SQLFetchScroll or SQLExtendedFetch".
    I am using a CRecordset derived class to access the stored procedure. I am unable to find the error.
    THE STORED PROCEDURE'S HEADER:
    Sp_Int_Ot_Ordendetrabajoalta ( lineatrabajo NUMBER, lv_orden NUMBER, usuario
    VARCHAR2, idvehiculo NUMBER, fechamax1 VARCHAR2, resumen VARCHAR2, detalle
    VARCHAR2,
    coderp VARCHAR2, numtrabrecibidos NUMBER, lv_CODOT VARCHAR2, retorno OUT
    INTEGER)
    THE .H FOR THE CRECORDSET DERIVED CLASS (Visual Studio 6 comments removed)
    class CRecSP : public CRecordset
    public:
    CRecSP(CDatabase* pDatabase = NULL);
    DECLARE_DYNAMIC(CRecSP)
    CString m_szSQL;
    long m_RETORNO;
    virtual CString GetDefaultConnect();
    virtual CString GetDefaultSQL();
    virtual void DoFieldExchange(CFieldExchange* pFX);
    THE .CPP FOR THE CLASS (VS6 comments removed)
    IMPLEMENT_DYNAMIC(CRecSP, CRecordset)
    CRecSP::CRecSP(CDatabase* pdb) : CRecordset(pdb)
    m_RETORNO = 0;
    m_nParams = 1;
    m_nDefaultType = snapshot;
    CString CRecSP::GetDefaultConnect()
    return T( DBCONNECTION_STRING );
    CString CRecSP::GetDefaultSQL()
    return m_szSQL;
    void CRecSP::DoFieldExchange(CFieldExchange* pFX)
    pFX->SetFieldType(CFieldExchange::outputParam);
    RFX_Long(pFX, _T("[retorno]"), m_RETORNO );
    USING THE CRECORDSET DERIVED CLASS: (Vars read from EditBoxes as CStrings
    and formatted in the SQL)
    CRecSP *rec = new CRecSP(&db);
    szSQL.Format( "{CALL
    FGROT2005.SP_INT_OT_ORDENDETRABAJOALTA(%s,%s,'%s',%s,'%s','%s','%s','%s',%s,'%s',?)}",
    szLinea, szOrden, "USER", szIdVeh, szFechaMax, szResumen,
    szDetalle, "ERP", "0", szCodOT
    rec->m_szSQL = szSQL;
    //rec->Open( CRecordset::forwardOnly,szSQL,CRecordset::readOnly );
    rec->Open( );
    iError = rec->m_RETORNO;
    rec->Close();

    I am trying to pass parameter to test my procedure but it is giving this error : ORA-06531: Reference to uninitialized collection
    ORA-06512: at line 12
    Here is example for my test procedure:
    declare
    v_session_id_tab SESSION_ID_TAB_TYPE;
    v_service_type_tab SERVICE_TYPE_TAB_TYPE ;
    v_service_location_tab SERVICE_LOCATION_TAB_TYPE ;
    v_service_call_name_tab SERVICE_CALL_NAME_TAB_TYPE;
    v_service_call_start_time_tab SERVICE_CALL_ST_TAB_TYPE;
    v_service_call_end_time_tab SERVICE_CALL_ET_TAB_TYPE;
    v_service_call_duration_tab SERVICE_CALL_DUR_TAB_TYPE;
    v_status_tab STATUS_TAB_TYPE;
    v_notes_tab NOTES_TAB_TYPE;
    begin
    v_session_id_tab(1) := 1;
    v_service_type_tab(1) := 'db';
    v_service_location_tab(1) := 'local';
    v_service_call_name_tab(1) := 'Name of call';
    v_service_call_start_time_tab(1) := SYSDATE;
    v_service_call_end_time_tab(1) := SYSDATE;
    v_service_call_duration_tab(1) := 100;
    v_status_tab(1) := 'Z';
    v_notes_tab(1) := 'NOTES';
    BULK_INSERTS (v_session_id_tab,v_service_type_tab, v_service_location_tab,v_service_call_name_tab,v_service_call_start_time_tab,v_service_call_end_time_tab,
    v_service_call_duration_tab, v_status_tab, v_notes_tab);
    end;
    I declare all types at schema level.
    Please give your comments.
    Thank you

  • Newbie question on how to return java objects from java stored procedures

    Hi,
    As you may guess, i'm new to this.
    I have a stored procedure that does some calculations and creates a list of java objects as the result of the query.
    How would I return the list from the database to the client application?
    Would I have to create an Oracle type that maps to the java object?
    Please help.
    Jag

    Hi Jag,
    Your question is very vague (to me). Perhaps you could post what you have done so far? Have you tried looking through the Sample Code page of the Technet Web site, or tried searching the Ask tom Web site, or MetaLink?
    Good Luck,
    Avi.

Maybe you are looking for