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.

Similar Messages

  • Stored procedure by using EXECUTE at the sender JDBC

    We have Scenario from JDBC to RFC (ASYNCH).We are using Oracle DB,at the database side we have a stored Procedure and inside the Procedure we are accessing multiple table.
    My query is how can we excecute update sql statement a stored procedure by using EXECUTE at the sender JDBC?
    EXECUTE SP_STUDENT_UPDATE
    ERROR: 'java.sql.SQLException: ORA-00900: invalid SQL statement '. For details, contact your database server vendor.

    Hi. Peter.
    yes , is possible to update your rows in your sp.
    If you want the data determined from the Query SQL Statement to remain in the database unchanged after being sent successfully, enter <TEST>.This is recommended if the data has not only been read, but also changed by a stored procedure entered under Query SQL Statement.
    http://help.sap.com/saphelp_nw73/helpdata/en/7e/5df96381ec72468a00815dd80f8b63/content.htm?frameset=/en/48/465581929734d9e10000000a42189d/frameset.htm&current_toc=/en/ca/b977f1c7814201954f20bb87ad7aab/plain.htm&node_id=64
    Could you put your sp? Maybe something is  wrong .
    Regards
    Lucho

  • Can we define cursors from in procedure while using .procedure file?

    Hi Team,
    Can we define cursors from in procedure while using .procedure file?
    I have a catalog procedure in which am using cursors and it is working fine. But while trying to create the same procedure using .procedure , the validation is failing with "An error occurred while parsing your procedure".
    Request your suggestions.
    Regards,
    Krishna Tangudu

    Hi Krishna,
    I also tried to find the validation for procedure and failed. What was on my mind when I posted earlier was related to Window -> Properties -> SAP HANA -> Modeler -> Validation Rules but this is not the same for procedure.
    Also the validation error seems to not being raised by Studio but the server, so it's not a frontend validation anyway.
    Trying to replicate your error I create two procedures here and both worked fine with cursor.
    The behavior you found was the same I found, the .procedure goes to repository and _SYS_BIC after activation and .hdbprocedure goes to catalog only.
    As far as I understood as you are moving from catalog (manually) and it worked on catalog (.hdbprocedure), I could check the declaration of table types of header as it's the main difference.
    Despite this investigation of declaration, you can try create it on modeler direct and see what you found on .procedure created. This can speed up investigation.
    Regards, Fernando Da Rós
    BTW: I'm faced an very strange behavior that each caracter I type on .procedure or .hdbprocedure freezes studio by around 15 seconds ?!?!?!?! (studio rev73)

  • SQLJ error in stored procedure

    Okay I'm kind of new to this stuff so this is probably an easy
    question but I can't fix my current problem. Know I have been
    creating and compiling several java stored procedures in my
    oracle 8.1.7.0.0 enterprise edition database. So far everything
    is create I have created about a dozen and done all of their
    call specs and everything works without a hitch.
    The problem I have came into being when I tried to create a
    stored procedure that uses SQLJ. When I create my stored
    procedures I compile my java code straight into the database
    using the
    CREATE OR REPLACE AND COMPILE JAVA SOURCE named "myClass" AS
    source
    this has always worked from me except when I place my
    #sql ; lines at which point it issues a the following error
    SP2-7034 : unknown command beginning
    at which point is it ignores the line of code and continues to
    compile my java source. Does this mean the SQLJ is not enabled
    in my database or what? I have checked out the SQLJ developer&#8217;s
    hand book and it did not help me with this problem. Oh please
    wont some wise oracle god help me!

    user21354 wrote:
    i am creating the collection in my Stored procedure it is giving me this error
    declare
    type t_number is table of number;
    v_numbers t_number;
    begin
    select VISIT_ID
    bulk collect into v_numbers
    from visit
    where VISITTYPEID = 2;
    select VISIT_ID from v_numbers;
    end;
    error
    PL/SQL: ORA-00942: table or view does not exist
    please tell me this why this happeningcouple of things...
    context switching - Your second 'select visit_id' query is actually parsed outside plsql, in the 'sql engine'. This sql engine has no knowledge of what v_numbers is, it's expecting an actual table name but it can't find anything called v_numbers in it's metadata. So it bombs out with that error. Google 'context switching plsql' for more info. :o)
    - as v_numbers is a collection, you could just loop through the results:
      for n in 1..v_numbers.count
      loop
        dbms_output.put_line(v_numbers(n));
      end loop;- as stated above, a 'select' without 'into' won't work in plsql anyway.
    - there is a way of getting round the context switch, by creating your Type in sql rather than plsql and 'casting' it to a table. Let us know if you want to know the steps to do it, but try reading up on context switch first.
    cheers.

  • Issue with a stored procedure that uses a sys refcursor to output dataset..

    Hi All:
    I create a stored procedure that uses an in out sys ref cursor:
    create or replace procedure FIRE_SALES_100_CALLS_REPORT
    ( p_cursor in out sys_refcursor)
    IS
    BEGIN
    --Insert into the temp table the records for the rep sales
    EXECUTE IMMEDIATE '
    INSERT INTO TMP_SALES_CNT_BY_USER
    TOTALPRODUCTSSOLD,
    NUMBEROFCALLS,
    SALESPER100CALLS,
    SERVICEORDERNUM,
    PRODUCT,
    LOGIN,
    FST_NAME,
    LAST_NAME,
    NAME,
    POSITIONHELD,
    CURRENTPARPARTYID,
    QUERY_DATE,
    CREATED_BY
    SELECT e.TotalProductsSold,
    e.NumberOfCalls,
    ((e.TotalProductsSold/e.NumberOfCalls)*100) AS SalesPer100Calls,
    e.ServiceOrderNum,
    e.Product,
    e.login,
    e.fst_name,
    e.last_name,
    e.name,
    e.PositionHeld,
    e.CurrentParPartyID,
    e.query_date,
    e.created_by
    FROM (
    SELECT COUNT(o.order_num) over ( partition by u.login
    order by u.login) AS TotalProductsSold,
    SUM(NVL(x.n_inbound,1) + NVL(x.n_outbound,1)) over (partition by u.login
    order by u.login) AS NumberOfCalls,
    o.order_num AS ServiceOrderNum,
    pi.name as Product,
    u.login,
    c.fst_name,
    c.last_name,
    postn.name,
    c.pr_held_postn_id as PositionHeld,
    p.par_party_id as CurrentParPartyID,
    NVL(x.query_date,NVL(o.last_upd, null)) AS query_date,
    o.created_by
    FROM firestg.SEB_S_order o
    INNER join firestg.seb_s_order_item oi ON o.row_id = oi.order_id
    INNER join firestg.seb_s_prod_int pi ON oi.prod_id = pi.row_id
    INNER join firestg.SEB_s_contact c on c.Row_Id = o.created_by
    INNER join firestg.SEB_s_user u on u.row_id = o.created_By
    INNER join firestg.SEB_s_party p on p.row_id = c.pr_held_postn_id
    INNER join firestg.SEB_s_postn postn on postn.row_id = c.pr_held_postn_id
    LEFT OUTER JOIN (
    SELECT taw.QUERY_DATE,
    vaw.n_inbound,
    vaw.n_outbound,
    oaw.object_name, oaw.object_id
    FROM GEN_T_AGENT_WEEK taw
    INNER JOIN GEN_V_AGENT_WEEK vaw ON taw.time_key = vaw.time_key
    INNER JOIN GEN_O_AGENT_WEEK oaw ON oaw.object_id = vaw.object_id) x
    ON u.cti_acd_userid = x.object_name
    WHERE NVL(x.query_date,NVL(o.last_upd, null)) BETWEEN (TRUNC (next_day (sysdate, ''SUN''))-14)
    AND (TRUNC (next_day (sysdate, ''SUN''))-8)
    AND o.status_cd IN (''Complete''))e';
    --Lookup the first level to see if there is a higher level person
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET (ParPartyID_1ST, LOGIN_1ST,FST_NAME_1ST,LST_NAME_1ST,TITLE_1ST) =
    (SELECT pa.par_party_id,
    U.Login,
    C.FST_NAME,
    C.Last_Name,
    p.name
    FROM firestg.seb_s_postn p
    inner join firestg.seb_s_user U on u.Row_Id = p.pr_emp_id
    inner join firestg.seb_s_contact c on c.Row_Id = p.pr_emp_id
    INNER join firestg.SEB_s_party pa on pa.row_id = c.pr_held_postn_id
    WHERE p.row_id = a.currentparpartyid)
    WHERE CurrentParPartyID IS NOT NULL';
    --Lookup the second level to see if there is a higher level person
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET (ParPartyID_2ND, LOGIN_2ND,FST_NAME_2ND,LST_NAME_2ND,TITLE_2ND) =
    (SELECT pa.par_party_id,
    U.Login,
    C.FST_NAME,
    C.Last_Name,
    p.name
    FROM firestg.seb_s_postn p
    inner join firestg.seb_s_user U on u.Row_Id = p.pr_emp_id
    inner join firestg.seb_s_contact c on c.Row_Id = p.pr_emp_id
    INNER join firestg.SEB_s_party pa on pa.row_id = c.pr_held_postn_id
    WHERE p.row_id = a.ParPartyID_1ST)
    WHERE a.ParPartyID_1ST IS NOT NULL';
    --Lookup the third level to see if there is a higher level person
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET (ParPartyID_3RD, LOGIN_3RD,FST_NAME_3RD,LST_NAME_3RD,TITLE_3RD) =
    (SELECT pa.par_party_id,
    U.Login,
    C.FST_NAME,
    C.Last_Name,
    p.name
    FROM firestg.seb_s_postn p
    inner join firestg.seb_s_user U on u.Row_Id = p.pr_emp_id
    inner join firestg.seb_s_contact c on c.Row_Id = p.pr_emp_id
    INNER join firestg.SEB_s_party pa on pa.row_id = c.pr_held_postn_id
    WHERE p.row_id = a.ParPartyID_2ND)
    WHERE a.ParPartyID_2ND IS NOT NULL';
    --Lookup the fourth level to see if there is a higher level person
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET (ParPartyID_4TH, LOGIN_4TH,FST_NAME_4TH,LST_NAME_4TH,TITLE_4TH) =
    (SELECT pa.par_party_id,
    U.Login,
    C.FST_NAME,
    C.Last_Name,
    p.name
    FROM firestg.seb_s_postn p
    inner join firestg.seb_s_user U on u.Row_Id = p.pr_emp_id
    inner join firestg.seb_s_contact c on c.Row_Id = p.pr_emp_id
    INNER join firestg.SEB_s_party pa on pa.row_id = c.pr_held_postn_id
    WHERE p.row_id = a.ParPartyID_3RD)
    WHERE a.ParPartyID_3RD IS NOT NULL';
    --Lookup the fifth level to see if there is a higher level person
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET (ParPartyID_5TH, LOGIN_5TH,FST_NAME_5TH,LST_NAME_5TH,TITLE_5TH) =
    (SELECT pa.par_party_id,
    U.Login,
    C.FST_NAME,
    C.Last_Name,
    p.name
    FROM firestg.seb_s_postn p
    inner join firestg.seb_s_user U on u.Row_Id = p.pr_emp_id
    inner join firestg.seb_s_contact c on c.Row_Id = p.pr_emp_id
    INNER join firestg.SEB_s_party pa on pa.row_id = c.pr_held_postn_id
    WHERE p.row_id = a.ParPartyID_4TH)
    WHERE a.ParPartyID_4TH IS NOT NULL';
    -- If there was no 1st place then the rep is a VP
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET a.vp = a.last_name || '', '' || a.fst_name,
    a.vp_login = a.login
    WHERE a.login_1st IS NULL';
    --If there is no second place then the rep has a VP and is a Director
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET a.vp = a.lst_name_1st || '', '' || a.fst_name_1st,
    a.vp_login = a.login_1st,
    a.director = a.last_name || '', '' || a.fst_name,
    a.director_login = a.login
    WHERE a.login_1st IS NOT NULL
    AND a.login_2ND IS NULL';
    --IF there is no third place then the rep has a VP, Director & is a Manager
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET a.vp = a.lst_name_2ND || '', '' || a.fst_name_2ND,
    a.vp_login = a.login_2ND,
    a.director = a.lst_name_1st || '', '' || a.fst_name_1st,
    a.director_login = a.login_1st,
    a.manager = a.last_name || '', '' || a.fst_name,
    a.manager_login = a.login
    WHERE a.login_1st IS NOT NULL
    AND a.login_2ND IS NOT NULL
    AND a.login_3rd IS NULL';
    --If there is no fourth place then the rep has a VP, Dir, Manager, and is a Supervisor
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET a.vp = a.lst_name_3RD || '', '' || a.fst_name_3RD,
    a.vp_login = a.login_3RD,
    a.director = a.lst_name_2ND || '', '' || a.fst_name_2ND,
    a.director_login = a.login_2ND,
    a.manager = a.lst_name_1st || '', '' || a.fst_name_1st,
    a.manager_login = a.login_1st,
    a.supervisor = a.last_name || '', '' || a.fst_name,
    a.supervisor_login = a.login
    WHERE a.login_1st IS NOT NULL
    AND a.login_2ND IS NOT NULL
    AND a.login_3rd IS NOT NULL
    AND a.login_4th IS NULL';
    --If there is no fifth plance then the rep has a VP, Dir, Mgr, Supervisor, and is a Team Lead
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET a.vp = a.lst_name_4TH || '', '' || a.fst_name_4TH,
    a.vp_login = a.login_4TH,
    a.director = a.lst_name_3RD || '', '' || a.fst_name_3RD,
    a.director_login = a.login_3RD,
    a.manager = a.lst_name_2ND || '', '' || a.fst_name_2ND,
    a.manager_login = a.login_2ND,
    a.supervisor = a.lst_name_1st || '', '' || a.fst_name_1st,
    a.supervisor_login = a.login_1st,
    a.teamlead = a.last_name || '', '' || a.fst_name,
    a.teamlead_login = a.login
    WHERE a.login_1st IS NOT NULL
    AND a.login_2ND IS NOT NULL
    AND a.login_3rd IS NOT NULL
    AND a.login_4th IS NOT NULL
    AND a.login_5th IS NULL';
    --If there is a fifth place then the rep has a VP, Dir, Mgr, Supervisor, Team Lead and is a rep
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET a.vp = a.lst_name_5TH || '', '' || a.fst_name_5TH,
    a.vp_login = a.login_5TH,
    a.director = a.lst_name_4TH || '', '' || a.fst_name_4TH,
    a.director_login = a.login_4TH,
    a.manager = a.lst_name_3RD || '', '' || a.fst_name_3RD,
    a.manager_login = a.login_3RD,
    a.supervisor = a.lst_name_2ND || '', '' || a.fst_name_2ND,
    a.supervisor_login = a.login_2ND,
    a.teamlead = a.lst_name_1st || '', '' || a.fst_name_1st,
    a.teamlead_login = a.login_1st
    WHERE a.login_1st IS NOT NULL
    AND a.login_2ND IS NOT NULL
    AND a.login_3rd IS NOT NULL
    AND a.login_4th IS NOT NULL
    AND a.login_5th IS NOT NULL';
    open p_cursor for
    SELECT tsc.vp,
    tsc.director,
    tsc.manager,
    tsc.supervisor,
    tsc.teamlead,
    (tsc.last_name || ', ' || tsc.fst_name) AS Rep,
    tsc.product,
    tsc.totalproductssold,
    tsc.numberofcalls,
    tsc.salesper100calls
    FROM TMP_SALES_CNT_BY_USER tsc;
    END FIRE_SALES_100_CALLS_REPORT;
    The table I use is a Global temp table.
    This runs just fine in oracle but when I try to build a data foundation in Business Objects I get the error that says you cannot insert/update/delete in a READ ONLY Transaction.
    I really need some advice on what to do since I really dont have access to a scheduled script and table that would store my data ahead of time.

    Well, AFAIK, BO is a reporting tool, so it si read-only by nature. I do not know if it possible to "tell" BO table is GTT and it is OK to write to it. You need to post this in BO forum.
    SY.

  • How to create a stored procedure and use it in Crystal reports

    Hi All,
    Can anyone explain me how to create a stored procedure and use that stored procedure in Crystal reports. As I have few doubts in this process, It would be great if you can explain me with a small stored proc example.
    Thanks in advance.

    If you are using MSSQL SERVER then try creating a stored procedure like this
    create proc Name
    select * from Table
    by executing this in sql query analyzer will create a stored procedure that returns all the data from Table
    here is the syntax to create SP
    Syntax
    CREATE PROC [ EDURE ] procedure_name [ ; number ]
        [ { @parameter data_type }
            [ VARYING ] [ = default ] [ OUTPUT ]
        ] [ ,...n ]
    [ WITH
        { RECOMPILE | ENCRYPTION | RECOMPILE , ENCRYPTION } ]
    [ FOR REPLICATION ]
    AS sql_statement [ ...n ]
    Now Create new report and create new connection to your database and select stored procedure and add it to the report that shows all the columns and you can place the required fields in the report and refresh the report.
    Regards,
    Raghavendra
    Edited by: Raghavendra Gadhamsetty on Jun 11, 2009 1:45 AM

  • How to create stored procedures and use those in Crystal reports

    Hi All,
    Can anyone explain me how to create a stored procedure and use that stored procedure in Crystal reports. As I have few doubts in this process, It would be great if you can explain me with a small stored proc example.
    Thanks in advance.

    Hello,
    There is a document explainining how to use Oracle stored proc with Crystal reports.
    Check at:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/1084c536-711e-2b10-e48a-924a60745253
    It is for older version but it should work and you can refer to it to get general idea how to start with it. It has a sample oracle stored proc and how to connect it from Crystal Reports.

  • Invoking Stored procedures without using CallableStatement

    I have a piece of code:
    import java.sql.*;
    public class Somenath{
    public static void main(String args[])throws ClassNotFoundException,SQLException{
    String abc;
    String query="{ call PR_EXAMPLE_I(?,?) }";
    String name="TEST FUND 2";
    Connection con = null;
    Class.forName("oracle.jdbc.driver.OracleDriver");
    con=DriverManager.getConnection("jdbc:oracle:thin:@172.16.31.120:1521:ora9db","gs2","gs2");
    Statement statement=con.createStatement();
    CallableStatement cs = con.prepareCall(query);
    cs.registerOutParameter(2,Types.VARCHAR);
    cs.setString(1,name);
    cs.execute();
    String nameval=cs.getString(2);
    System.out.println("Name"+nameval);
    try{
    finally{
    cs.close();
    This code works fine.
    I would like to know wheather its possible to execute a stored procedure using the
    statement.execute()/statement.executeQuery().Please note as per Java's documentation statement.execute() may be used execute any unknown SQL String.So is it possible to execute a stored procedure thats already existing(say PR_EXAMPLE_I in the current example).

    Thank you Digital Dreamer for ur help.I will explain the problem in detail.
    Well I wish to invoke a stored procedure that uses a in paramater but no out parameter.Assume that the stored procedure (say abc) already exists in the system.We execute a Select statement inside the Stored procedure and copy the value in a block-variable(a local one) within the Stored Procedure.
    Usually we execute the stored procedure in the SQL Prompt using
    SQL> exec Proc_Name(In Paramter)
    I would like to know how do I do it in JDBC using Statement.(Please note that we are not using Callable Statement)
    Can u help me out with an example?

  • Calling Stored procedure which uses Bulk Collect

    Hi All, I have Oracle stored procedure which uses Bulk Collect and returns table type parameter as output. Can anyone please help me how Can I call this kind of stored procedures which returns table type output using VB and Oracle's Driver. (I am successfully able to call using MS ODBC driver, but I want to use OraOLEDB driver.)

    861412 wrote:
    how Can I call this kind of stored procedures which returns table type output using VB and Oracle's Driver. This forum deals with the server-side languages SQL and PL/SQL.
    Your question deals with the client side and Visual Basic language.

  • How to call a stored procedure that use a type defined in a package?

    Hi all,
    this is stored procedure:
    GET_GIORNATAEVENTO( in_nome_servizio IN VARCHAR2,
    out_dati_aggiornati OUT TAB_VARCHAR2);
    TAB VARCHAR2 is defined in the package specification:
    TYPE tab_varchar2 IS TABLE OF VARCHAR2(5) INDEX BY BINARY_INTEGER;
    and this is the name of the package: PKG_SERVIZI_MMSPUSH.
    This is my php script:
    <?php
    // Connect to database...
    $c=OCILogon("venus_vfl", "venus_vfl", "venvi");
    if ( ! $c ) {
    echo "Connessione non riuscita: " . var_dump( OCIError() );
    die();
    echo "<br>PKG_SERVIZI_MMSPUSH.GET_GIORNATAEVENTO</br> ";
    echo "<br> </br>";
    // Call database procedure...
    $in_servizio = "MOTO";
    $s = OCIParse($c, "begin PKG_SERVIZI_MMSPUSH.GET_GIORNATAEVENTO(:bind1, :bind2); end;");
    OCIBindByName($s, ":bind1", $in_servizio);
    OCIBindByName($s, ":bind2", $out_esito);
    OCIExecute($s,OCI_DEFAULT);
    echo "OUT_DATI_AGGIORNATI= " . $out_esito;
    // Logoff from Oracle
    OCILogoff($c);
    ?>
    How to test stored procedure to get the output parameter?
    Thanks in advance.

    Thanks,
    but I need to test stored procedures that uses type defined in the package.
    e.g.
    if I have s.p.
    PROCEDURE get_risultati_squadra
    ( in_squadra IN VARCHAR2,
    out_serie OUT tab_varchar2_5,
    out_tiporisultato OUT tab_varchar2_5,
    out_n_giornata OUT tab_varchar2_5,
    out_squadre OUT tab_varchar2_200,
    out_risultato OUT tab_varchar2_10,
    out_marcatore OUT tab_varchar2_50,
    out_punti OUT tab_varchar2_3,
    out_rimbalzista OUT tab_varchar2_50,
    out_rimbalzi OUT tab_varchar2_3,
    out_esito OUT tab_varchar2_2);
    I have to define every type external to the package, in this case five new TYPE !!
    Is there another way to solve this problem?
    Thanks

  • Creating a Oracle 10g stored procedure as a datasource for  crystal 9 repor

    Can someone direct me to instructions or information on how to create a Oracle 10g stored procedure as a datasource for  my Crystal  Reports 9.0  report?

    i've found this example for you
    http://www.pdssoftware.com/newsletter/mar07/page6.htm
    and you could be able to get the guides from the SAP guide website for the products
    http://help.sap.com/businessobject/product_guides/
    hope this was helpful
    good luck
    Amr

  • After the most recent iPhoto update, I keep getting the following error: "iPhoto quit unexpectedly while using the Sonix SN9c201 webcam plugin."  This seems to happen after *every* iPhoto update.  Is there a fix on the way?

    After the most recent iPhoto update, I keep getting the following error: "iPhoto quit unexpectedly while using the Sonix SN9c201 webcam plugin."  This seems to happen after *every* iPhoto update.  Is there a fix on the way?

    As you can see below, when I right click, I have no such option.  In the User Account Settings, I'm operating as the "System Administrator".
    Any other suggestions?

  • How to improve the load performance while using Datasources for the Invoice

    HI All,
    How to improve the  load performance while using Datasources for the Invoice . Actually my invoice load (Appx. 0.4 M records) is taking very long time nearly ~16 to 18 hrs  to update data from R/3 to 0ASA_DS01.
    If I load through flat file it will load with in ~20 Min for the same amount of data.
    Please suggest how to improve load performance.
    PS: I have done the Inpo package settings as per the OSS note.
    Regads
    Srininivasarao.Namburi.

    Hi Srinivas,
    Please refer to my blog posting [/people/divyesh.jain/blog/2010/07/20/package-size-in-spend-performance-management-extraction|/people/divyesh.jain/blog/2010/07/20/package-size-in-spend-performance-management-extraction] which gives the details about the package size setting for extractors. I am sure that will be helpful in your case.
    Thanks,
    Divyesh
    Edited by: Divyesh Jain on Jul 20, 2010 8:47 PM

  • Blank spaces while using GUI_DOWNLOAD for Chinese characters

    Hi,
    While using GUI_DOWNLOAD for chinese characters I have used a code page option of 8300 for Chinese.
    The file which is getting downloaded in a notepad has some Chinese characters coming under some headings.
    After that columns other columns are getting shifted towards the right.
    This is working correctly for English characters.
    Can someone please help me.
    Now I am using CL_GUI_FRONT_END_SERVICES=>GUI_DOWNLOAD.
    What special options should I pass now.
    Regards,
    Subhashini

    Hi,
    I only solved my problem by using different code pages 8400 and 8300 for Chinese and Taiwanese characters.
    I fixed the lengths of the fields by converting them to hexadecimal string and back to string using these function modules as below.
    DATA:lv_xstring TYPE xstring,
           lv_temp TYPE string.
      DATA: lv_conv TYPE REF TO cl_abap_conv_in_ce.
      lv_temp = p_name.
      CALL FUNCTION 'HR_KR_STRING_TO_XSTRING'
        EXPORTING
          codepage_to      = p_codepage
          unicode_string   = lv_temp
          out_len          = p_outlen
        IMPORTING
          xstring_stream   = lv_xstring
        EXCEPTIONS
          invalid_codepage = 1
          invalid_string   = 2
          OTHERS           = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
       EXPORTING
         from_codepage = p_codepage
         in_xstring    = lv_xstring
         out_len       = p_outlen
       IMPORTING
         out_string    = p_string.
    Create a Conversion Instance
    lv_conv = cl_abap_conv_in_ce=>create(
    encoding = p_codepage
    input = lv_xstring ).
    v_conv->read( IMPORTING data = p_string ).
    Regards,
    Subhashini

  • 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

Maybe you are looking for

  • Problem with queue and context change JAVA udf

    Hi all, MY scenorio is from source i get multiple instances and each instance i need to pass to different fields od target in one source instance i may get multiple values which i have to create multple nodes under one target instance. my source xml

  • 3D Vision via bootcamp on Mac mini (continued)

    Hi Before I read this archived thread, 3D Vision via bootcamp on Mac mini https://discussions.apple.com/thread/2545736?start=0&tstart=0 I downloaded the latest NVIDIA driver 285.62 for my Mac mini server (2010,GeForce 320M graphic chip) for testing h

  • GRC AC 5.3 Logging strategy in multi server nodes

    Hello Experts, We have GRC AC 5.3 SP6 and 5.2 10 landscapes and PRD system are running with multiple server nodes. SAP recomends to use SAP Logger instead of Java Logger in multi server environment, but i am not able to find out complete documentatio

  • Purchase Order - No details for medium PRN in master record

    Hi together, we implement SRM 7.0 with Netweaver Portal 7.0. I'd like to create a purchase order with a user who has the role /SAPSRM/OP_Purchaser and is assigned to purchase organisation and purchasing group in the organizational structure. If I cre

  • Setting field/control "required" property with script

    Am using LiveCycle 8.2.1x and Acrobat Pro Extended 9.1.2. I want to change one control's "required" property based upon the user's input in/on another control (a drop-down list selection).  Can it be done with FormCalc or Javascript?  If so, how?