Procedure of rewriting

Hello

I have a PL_CAL table

create table pl_cal (keyid number, fact_id number, date of from_date, till_date date, number, number of week_no ref_id);

insert into pl_cal values (1, 1, to_date('01-jan-2015'), to_date('31-jan-2015'), 1000,1);

insert into pl_cal values (2,1, to_date('01-jan-2015'), to_date('31-jan-2015'), 1001,1)

insert into pl_cal values (3,1, to_date('15-jan-2015'), to_date('31-jan-2015'), 1003,2)

insert into pl_cal values (4.1, to_date('15-jan-2015'), to_date('31-jan-2015'), 1004,4)

insert into pl_cal values (5.2, to_date('10-jan-2015'), to_date('31-jan-2015'), 1005,1)

insert into pl_cal values (6.2, to_date('10-jan-2015'), to_date('31-jan-2015'), 1006,2)

Table PL_CAL, I need to insert data into two tables: WO_MST and WO_DTL

create table wo_mst (keyid number, fact_id number, date of from_date, till_date date, num_act number, status (1) tank)

create table wo_dtl (keyid number, womst_keyid number, plcal_keyid number, ref_id number, number of week_no)

Already, there is a procedure and it works perfectly. EXAMPLE of existing procedure is as below:

create or replace procedure existing_proc

is

number of l_fact_id;

number of l_from_date;

number of l_till_date;

number of l_num_act;

l_status char (1);

number of womstid;

number of l_ref_id;

number of l_cal_id;

number of l_week_no;

cursor cur_mst is select SEQNO.nextval wokeyid, fact_id, from_date, till_date, num_act, status of 'P '.

Of

(

Select distinct fact_id, from_date, till_Date, count (*) num_act

of pl_cal

Fact_id group, from_date, till_Date

);

cursor cur_dtl (p_fact_id varchar2, date, date of the p_till_date p_from_date) is

Select pl_calkeyid, ref_id, week_no

of pl_cal

where fact_id = p_fact_id

and from_date = p_from_date

and till_date = p_till_date;

Start

for c_mst in cut_mst

loop

l_fact_id: = c_mst.fact_id;

l_from_date: = c_mst.from_date;

l_till_date: = c_mst.till_date;

l_num_act: = c_mst.num_act;

l_status: = c_mst.status;

PLMKEYID: = NULL;

womstid: = SEQNO.nextval;

insert into values of wo_mst (womstid, l_fact_id, l_from_date, l_till_date, l_num_act, l_status);

for c_dtl in cur_dtl (l_fact_id, l_from_date, l_till_date)

loop

l_cal_id: = c_dtl.pl_calkeyid;

l_ref_id: = c_dtl.refid;

l_week_no: = c_dtl.week_no;

insert into wo_dtl(SEQNO.nextval,womstid,l_cal_id,l_ref_id,l_week_no);

end loop;

end loop;

commit;

end;

Since the existing procedure with CURSOR of LOOPS, I however, I can rewrite this way.

create or replace procedure current_proc

is

type wo_mst_records is record (l_id number, l_fact_id number, l_from_date number, l_till_date number, number of l_num_act, l_status char (1));

type wo_mst_table is table of the wo_mst_records;

wo_data wo_mst_table;

Start

insert into wo_mst

Select SEQNO.nextval, wokeyid, fact_id, from_date, till_date, num_act, status of 'P '.

Of

(

Select distinct fact_id, from_date, till_Date, count (*) num_act

of pl_cal

Fact_id group, from_date, till_Date

)

fact_id, from_date, till_date, num_act, wokeyid, return status

bulk collect into wo_data;

ForAll i in 1.wo_data.count

insert into wo_dtl

Select SEQNO.nextval, wokeyid, pl_calkeyid, ref_id, week_no

of pl_cal

where fact_id = wo_data (i) .fact_id

and from_date = wo_data (i) .from_date

and till_date = wo_data (i) .till_date;

commit;

end;

But I hit here since I'm unable to use the POLL... HERE with INSERT... SELECT and even COLLECT LOOSE.

Can you please guide a better way to do it.

You need to get out of the mentality of a loop in a row of tables at once. SQL works best when dealing with sets of records. If this SQL statement is insert several records in wo_mst. It is what it is supposed to do.

The second statement, I wrote back queries the lines that were written just for wo_mst (complete with their newly created keyids), joins them to pl_cal and writes all the results on wo_dtl.

The only complication is making sure that the only rows that are retrieved in the second query are those created in the first. I just use the field status, but maybe it's not enough - you know your situation better than me. If there may be other wo_mst with the already existing State records when you perform this task, you will need to do something different. Maybe something like this:

INSERT INTO wo_mst

(keyid fact_id from_date, till_date, num_act, status)

SELECT SEQNO.nextval, fact_id, from_date, till_date, num_act, ' ~'-temporary value for the State, which is not used anywhere else

Of

(

Select distinct fact_id, from_date, till_Date, count (*) num_act

of pl_cal

Fact_id group, from_date, till_Date

);

INSERT INTO wo_dtl

(keyid, womst_keyid, plcal_keyid, ref_id, week_no)

SELECT SEQNO.nextval, m.keyid, p.pl_calkeyid, p.ref_id, p.week_no

Pl_cal p, wo_mst m

WHERE p.fact_id = m.fact_id

and p.from_date = m.from_date

and p.till_date = m.till_date

and m.status = ' ~';

UPDATE wo_mst SET status = 'P' WHERE State = ' ~'; -its correct value the status value

COMMIT;      -Only engage at the end of the process.

Tags: Database

Similar Questions

  • Links to internet e-mail direct e-mail

    I can't use links in an e-mail message to connect to the internet. I think it's a setting blocking access in direct-mail. How do I change this?

    Try this:
    The following procedure will rewrite the default protocol
    assignments in the registry:
    Open the start / applet default programs, and then click on "Set program.
    access and computer by default". Extend the selection of custom, and
    under 'Choose a default browser', select Internet Explorer.
    Click OK.

    I hope this helps.

    Good luck.

    Lorien - MCSA/MCSE/network + / has + - if this post solves your problem, please click the 'Mark as answer' or 'Useful' button at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

  • Maybe it's to rewrite the BIOS with crisis recovery mode?

    Hey everybody,

    my laptop 'freezes' during BIOS 'PHOENIX' updated 2 years ago.
    SERVICE told to change the motherboard, the price as new pc, so I bought new laptop.

    I keep looking at the toshiba forum always, so I read a lot of information on the MODE of RECOVERY from CRISIS.
    so I tried to check my laptop died after 2 years.

    My satellite M100 starts in crisis recovery mode Fn + B.
    my laptop starts up to CRISIS MODE, but do not read the USB STICK
    I did the flash with the CRISDISK 1.0.0.4 USB key program, but I'm not sure I did it way right!

    My question is:
    is it really possible to REWRITE the bios with crisis recovery mode, where I can read more information on how to do it.

    I want back my M100 :)))

    Hey,.

    As Akuma writes that you should try a USB FDD instead a USB key. Key USB is supported only on new models of laptops, but as far as I know USB FDD will be always supported.

    In any case, just for your information: you should know what you're doing. It is a delicate and risky procedure and in the worst cases you might destroy the whole ROM module but if you already have a new laptop I think that it s a problem for you. ;)

  • Satellite L40 - proceedings of BIOS rewrite

    Toshiba Satellite L40-14B (catalogue number: PSL4CE - 004005G 3)

    I got my laptop for Windows XP (from Vista) and I wanted to update BIOS version for XP Toshiba (5.50). I did everything right but still 2 seconds after you click the .bat file to start the process, Windows has interfered with a critical message and restart my computer.

    It restarted, (*) entered 'Recovery of the ROM BIOS utility V1.16 crisis', a progress bar indicates that old bios was erased; After that an another progress bar indicating the flash process stopped after 2 seconds (1 cm); flash error message appeared; the utility tried to erase the BIOS (first step bar once again); clear the error message appeared. The post OFFICE will continue or something like that is displayed, and all is blocked and disabled. After a long time of prayer useless, I removed the battery of my laptop and moving forward again (voltage). And everything is identical (new) brand above (*).

    It was a bit strange, especially since, after the reboot, I could access BIOS. No hard drive, the laptop closed in 3 seconds.

    I analyzed the contents of the hard drive and found a new file, called T20. BIN (1 M - no doubt with the BIOS image) in C:\.

    I think that when the laptop is turned on, it does not find the BIOS, it looks for image file of the BIOS in the root of the active partition on the hard drive, load it (T20. (BIN), begins 'The BIOS utility ROM V1.16 crisis recovery' and you know the rest

    After loading the BIOS from the HARD drive and start rewriting, all frozen and I can't do anything: "Recovering the BIOS utility ROM V1.16 crisis" occurs during the POST and POST gel before closing, so I can't get to the point where I can start.

    Meanwhile, I've changed the T20. BIN file with other bios (given by the Toshiba Site for Vista) and everything goes the same thing (with the difference that the BIOS for hard drive shows another version number).

    I know that some laptops have a service procedure so that you can rewrite the BIOS after the crash. I tried different methods indicated on the forums for other L series, but nothing works.
    I could t find the service manual for L40.
    I found even when Maintenance manuals for other Toshiba models where are presented procedures for maintenance for the rewriting of the BIOS (usually using a diskette).
    Didn t work for L40, floppy USB drive died before entering the BIOS and after that it's too late for me.

    Any idea? (Not ASP. I hear good ideas).
    Is someone a L40 manual or single BIOS rewrite maintenance procedures?

    Hi lonutS,

    That s a pretty long story, but I think the case is clear: something was wrong because the BIOS update and now the ROM module has to be reflashed. Normally the BIOS will be updated in Windows and not after a reboot or something else so probably the ROM module is deleted now but no new version has been flashed.

    > Any idea? (Not ASP. I hear good ideas).
    Is someone a L40 manual or single BIOS rewrite maintenance procedures?
    Why not ASP? That's the best idea and may ask you what kind of response you expect? Here he s in only a forum from user to user, so no one here can give you the technical manual or a special BIOS recovery tool for this laptop. These utilities only have an ASP and Toshiba itself.

    Here in the forum are similar topics on recovering the BIOS then perhaps you should read, but don t forget that everything happens on your own risk! If you have n t successful, I think that the only option is in contact with a ;) ASP.

  • Procedure of checking of letters in a collum

    Hi,I have a table called "check_in_time"

    I have columns

    Integer ID

    client_name varchar2 (10 BTYES)

    check_in_time (5 BTYES)

    check_out_time varchar2 (5 BTYES)

    Because this scheme is managed by someone else I can't change the data type for him.

    The question is now that this system users some featuring letters in the 'check_in_time' instead of 12:00 by one example

    and for this reason another application in looking at 'check_in_time' appears an error and it's beginning of the different issues because

    you are not sure what time the guest access to your room.

    to stop this I want to rewrite a pl/sql procedure that runs every 12 hours and then send me and send me. If the check_in_time column

    as a letter or something other than time as 00:00 to 23:59.

    is this possible? If Yes please can you show me and example.

    Thank you

    You can add a constraint to the table?

    In this case, you can check for the correct format. Of course, you will need to change all the defective data first.

    Example:

    SQL > create table test_time (check_in_time varchar2 (5));

    Table created.

    SQL > alter table test_time Add (constraint ck_check_in_time1

    2 check (regexp_like (check_in_time, ' ^ ([0-1].)) ([0-9] | 2 [0-3]):[0-5][0-9]$')));

    Modified table.

    SQL > insert into test_time values (12:34 ');

    1 line of creation.

    SQL > insert into test_time values (23:59 ');

    1 line of creation.

    SQL > insert into test_time values (2:34 ');

    1 line of creation.

    SQL > insert into test_time values (24:21 ');

    insert into test_time values (24:21 ')

    *

    ERROR on line 1:

    ORA-02290: check constraint (P1ECOM. CK_CHECK_IN_TIME1) violated

    SQL > insert into test_time values (' ab: 14 ");

    insert into test_time values (' ab: 14 ')

    *

    ERROR on line 1:

    ORA-02290: check constraint (P1ECOM. CK_CHECK_IN_TIME1) violated

    SQL > select * from test_time;

    CHECK

    -----

    12:34

    23:59

    02:34

    SQL > drop table test_time;

    Deleted table.

    But of course, it is always better to keep the time as a time of (date), and not as a string.

  • Rewriting query clause error

    Hi all;

    I did not finish the rewrite of the query (M.view) clause, trying to activate I get the error message
    and I asked this question "https://forums.oracle.com/forums/thread.jspa?threadID=2543789".
    Question incorrectly displayed data communication model. -If this isn't a duplicate thread.

    Please answer me what was missing here?

    SQL > alter system set query_rewrite_enabled = 'TRUE' scope = SPFILE;
    SQL > grant query rewrite in *;
    Grant succeeded.
    conn xxx/xxxx@xxxxxx
    1 SQL > ALTER SESSION SET OPTIMIZER_MODE = FIRST_ROWS.
    Altered session.
    2 SQL > alter session set query_rewrite_enabled = true;
    Altered session.
    3 SQL > execute dbms_stats.gather_table_stats ('rose', 'mv1');
    PL/SQL procedure successfully completed.
    4 SQL > exec dbms_mview.explain_rewrite ("select * sales ', but 'MV1'");
    BEGIN dbms_mview.explain_rewrite ("select from sales, 'MV1'"); END; *
    * ERROR at line 1:
    ORA-30380: REWRITE_TABLE does not exist
    ORA-06512: at "SYS." DBMS_SNAPSHOT", line 3085
    ORA-06512: at "SYS." DBMS_SNAPSHOT", line 3206
    ORA-06512: at line 1
    thanks in advance...

    Hello

    Run utlxrw.sql to create the table.

    concerning

  • How to convert MS SQL Server 2008 Stored Procedures of Oracle 11 g SPs?

    We have an application from MS SQL Server 2008. We want to migrate to Oracle 11 g.

    What is the recommended Oracle method for
    (1) migration of data (Tables, triggers, sequences, views etc..)
    (2) the stored Procedure migration.

    What is the recommended tool or method pls?

    We have 100s of MS Sql Server stored procedures. Then, needing a tool or method. We can rewrite all of them from scratch.

    Hello

    Let me clarify some of the issues that you mention. But I advise you to get some professional help with migration because:

    1. you must understand the architectural differences between SQL Server and Oracle. They are of different databases.
    2. understand data type mappings.
    3. understand the complete migration process. Just using the OTN article as a migration guide won't help because it just shows how use SQL Developer to this task.
    4. understand that 100% of successful Oracle conversion is not possible with all the tools. There will always be gaps, gaps in functionality, bugs etc. So there will be some amount of manual work involved.
    5. There are many other tasks involved in the migration that cannot be accomplished with SQL Developer.

    Get now your questions:

    1. in 3.1, there is migration option for the "capture of database in offline mode". It is under the Tools option. So in 3.1 we do not have a separate tab, called "Migration."
    2. use 3.1 because it is much better than 2.1 in terms of capabilities.
    3 migration Wizard is the easiest way to migrate. Where are you getting confused?
    4 "column data" seems to be a stored procedure in SQL Server. If it is not there in the underlying table, why he uses in the SQL statement in the procedure then? I think that we have a problem of "reserved word" with the name of column "Data". Will have to check that.
    5 VARCHAR (@max) must be mapped to VARCHAR2 (4000) in Oracle. It may be a bug in SQL Developer. So during the mapping of data type in the migration wizard, you can change the default mappings.

    Concerning

    Prakash

  • Function Index and Query Rewrite

    Hi members,


    I just stumbled on something that I've never thought of before.

    It has to do with the function according to index and (possibly re - write query)

    Here is my configuration:
    SQL> create table tab1 (
      2    x   varchar2 (1)   default 'N' not null check (x in ('Y', 'N')),
      3    y   varchar2 (100) not null
      4  );
    
    Table created.
    
    SQL> create index tab1ix on tab1 (NULLIF(x,'N'));
    
    Index created.
    
    SQL> insert into tab1 (y)
      2    (select rpad (level,100,'x') from dual connect by level <= 1000);
    
    1000 rows created.
    
    SQL> insert into tab1 (x,y) values ('Y', 'Hello there');
    
    1 row created.
    
    SQL> commit
      2  /
    
    Commit complete.
    
    SQL> exec dbms_stats.gather_table_stats(user, 'tab1', cascade => true)
    
    PL/SQL procedure successfully completed.
    So, I created a small table with a FBI.

    Now, let's use it.
    The first is a query that obviously do not use it.
    Second, one is a query that corresponds to the FBI.
    SQL> explain plan
      2     set statement_id = 'st1'
      3     into plan_table
      4  for
      5  select * from tab1 where x = 'Y';
    
    Explained.
    
    SQL> 
    SQL> select plan_table_output
      2    from table(dbms_xplan.display('PLAN_TABLE', 'st1','TYPICAL'));
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    
    ----------------------------------------------------------
    | Id  | Operation         | Name | Rows  | Bytes | Cost  |
    ----------------------------------------------------------
    |   0 | SELECT STATEMENT  |      |   501 | 51603 |     5 |
    |   1 |  TABLE ACCESS FULL| TAB1 |   501 | 51603 |     5 |
    ----------------------------------------------------------
    
    
    SQL> explain plan
      2     set statement_id = 'st2'
      3     into plan_table
      4  for
      5  select * from tab1 where NULLIF(x,'N') = 'Y';
    
    Explained.
    
    SQL> 
    SQL> select plan_table_output
      2    from table(dbms_xplan.display('PLAN_TABLE', 'st2','TYPICAL'));
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    
    ----------------------------------------------------------------------
    | Id  | Operation                   | Name   | Rows  | Bytes | Cost  |
    ----------------------------------------------------------------------
    |   0 | SELECT STATEMENT            |        |     1 |   103 |     1 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| TAB1   |     1 |   103 |     1 |
    |   2 |   INDEX RANGE SCAN          | TAB1IX |     1 |       |     1 |
    ----------------------------------------------------------------------
    
    SQL> 
    No worries, right?
    Everything works as expected, when my predicate corresponds to the FBI, the index is used.


    But here's what surprises me. It seems that the index expression is rewritten then it is created:
    SQL> select column_expression from user_ind_expressions
      2  where index_name = 'TAB1IX';
    
    COLUMN_EXPRESSION
    --------------------------------------------------------------------------------
    CASE "X" WHEN 'N' THEN NULL ELSE "X" END
    
    SQL>
    Questions are now, is this safe? -Does still work?

    Can I trust the optimizer always did a rewrite such as performed when the index was created?


    This index might live throughout the years and many versions of the optimizer. But the expression stays (I guess)

    This is going into production this weekend, so I wanted to hear,
    ideas / comments?


    Best regards
    Peter
    SQL> select *from v$version;
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for Linux: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    PS: NULLIF is nothing else than a syntactic sugar for the CASE expression equivalent?
    docs say:
    The NULLIF function is logically equivalent to the following CASE expression:

    CASE WHEN expr1 = END expr1 expr2 THEN NULL ELSE
    edited by: Peter on February 9, 2012 05:32

    Hi Peter

    In the docs for NULLIF, he said

    The NULLIF function is logically equivalent to the following CASE expression:

    CASE WHEN expr1 = expr THEN ELSE NULL expr1 END 2

    http://docs.Oracle.com/CD/B10501_01/server.920/a96540/functions85a.htm
    http://docs.Oracle.com/CD/B19306_01/server.102/b14200/functions102.htm
    http://docs.Oracle.com/CD/E11882_01/server.112/e26088/functions116.htm

    Which would explain the behavior you saw. As you pointed out, it is possible that the transformation of NULLIF expression BOX equivalent is likely to change? It seems unlikely - indeed, it seems to be an alias or a macro for the instruction box unless there is some way technically superior to implement this logic, it seems to be here to stay. Certainly, it has remained unchanged since the 9i.

    Not sure how that helps.

    David

  • passing parameters to a procedure of url

    Hello

    I use the Express 4 Application, in which my requirement is as follows:
    (a) conduct a redirection to a url by using pl/sql procedure "authenticate" when the page loads
    as follows:
    return_to_uri varchar2 (2000): = ' http://mysite.com: < port_no > /apex/ < my_schema >. < package_name >. < procedure_name > ';
    openid_uri varchar2 (100): = 'https://www.google.com/accounts/o8/id;
    build_uri: = '? NS = http://something.com'
    || '& id2 = http://something2.com'
    || '& id3 = http://something3.com'
    || '& return_to =' | UrlEncode (return_to_uri);
    v_redirect_url: = openid_uri | build_uri;
    owa_util. REDIRECT_URL (v_redirect_url);

    The above procedure performs a redirect url to Google successfully and send some parameters added to
    return_to_uri' so ' http://mysite.com: < port_no > /apex/ < my_schema >. < package_name >. < procedure_name >? NS = http://something.com & param_id = AQRST1299STR4 & param_id2 = 1QPL86GBN4JK55F';

    However, it always gives me error BAD URL.

    I get the params individually as follows in the procedure:

    procedure get_redirect (p1 in varchar2, p2 in varchar2, p3 in varchar2)
    Start
    < redirect here once again to a valid apex application >
    end;

    I gave approval to run on APEX_PUBLIC_USER and the PUBLIC procedure.
    I don't know if something like this is possible. Is it the signs '&' in the url that is the problem. I tried searching for it but I'm still not able to get any useful resource.
    Any help would be greatly appreciated.
    Thank you

    possibly an apache rewrite rule can help, something that identifies the query based on the name of your procedure and converts the URL for procedure parameter names. You can even google Server provide a dummy URL that can handle your HTTP server using a rewrite rule redirect to the URL and real procedure
    Here are some links that may help you get started in this direction

    Oracle Application Express (APEX)
    http://httpd.Apache.org/docs/1.3/mod/mod_rewrite.html

  • Wrong execution of a package within a procedure stored

    Oracle version: 10.2.0.4 RAC

    I posted the below problem in REPLICATION forum but I think he needs to be here. I think I'm having a problem with some "shade" of Oracle, which relates to the appellant a package in a regulation and immunities.

    Here is the original post:
    ================================================================================================

    Get an ora-12048 and ora - 942 when executing dbms_refresh.refresh in a stored procedure. When I invoke dbms_refresh.refresh directly from SQLPlus things work very well.

    Here is the header and the relevant code in the stored procedure:

    create or replace PROCEDURE p_mv_refresh (p_refgrp IN VARCHAR2) AS

    v_refgrp all_refresh_children.rname%TYPE;

    BEGIN
    v_refgrp: = UPPER (p_refgrp);
    DBMS_REFRESH. Refresh (v_refgrp);
    end;

    Here is the definition of the refresh Group:

    exec dbms_refresh.make (name = > 'BENEFITS_REFGRP',-)
    list = > 'MV_INDIVIDUAL_CUR, MV_CCR_CUR, MV_BUSINESS_DBA_CUR, -.
    next_date = > sysdate;
    interval = > NULL,--
    implicit_destroy = > FALSE;
    Lax = > FALSE;
    rollback_seg = > NULL,--
    push_deferred_rpc = > FALSE;
    refresh_after_errors = > FALSE;
    purge_option = > NULL,--
    parallelism = > 8, -.
    heap_size = > NULL);

    I run in SQLPLUS by passing the name of the refresh Group in the stored procedure:

    SQL > exec p_mv_refresh ('BENEFITS_REFGRP');

    And I get this:

    Error: ORA-12048: error in materialized view Refresh
    'UIMVIEWS '. "" MV_BUSINESS_DBA_CUR ".
    ORA-00942: table or view does not exist

    When I have exec dbms_refresh.refresh('BENEFITS_REFGRP') directly in SQLPlus, everything runs without failure.

    Here is the definition of MV:

    CREATE THE MV_BUSINESS_DBA_CUR MATERIALIZED VIEW
    ON PREBUILT TABLE
    COMPLETE REFRESH
    DISABLE THE QUERY REWRITE AS
    (SELECT *)
    OF xxxxxxxx...) ;

    There is no newspaper of MV on the source (no fast refresh) table.

    Table source and MV are same DB, different schemas.

    Just to be safe in tests, I attributed select privileges on the source table to the MV schema via a role and directly. Does not solve.

    New - the MV refreshes thin when done directly from a SQLPlus prompt. It fails only when I run it from within the stored proc.

    Thanks in advance for your suggestions...

    TonyG

    Here are additional info I posted:
    =========================================================================
    Here is an update - I tried the same procedure only this time replaced the call to dbms_refersh with a call to dbms_mview, just to see if he would run.

    This isn't. I am quite sure, I hit a kind of question of privilege that has to do with a package requiring a package, but I don't know enough with what it might be. dbms_mview works fine from the command line, just like the fact dbms_refresh.

    Here's what happened when I called the proc dbms_mview

    Error: ORA-12008: error in the path of refresh materialized view
    ORA-00942: table or
    view does not exist
    =========================================================================

    Thanks in advance for any help.

    A stored procedure does not inherit from grants of role, you must make grants directly to the relevant tables/views/mast views and can not give these permissions to the roles of througth.

    Date of arrival:
    http://download.Oracle.com/docs/CD/B10500_01/server.920/a96524/c24privs.htm#4770--> blocks named with copyright

    Published by: Pedro_gloria on 10-Dec-2010 07:54

  • need help to convert this procedure used and call in coldfusion

    Hi I'm new to coldfusion and I haed of the code with me and I need it to convert in the stored procedure and will call back within coldfusion. Can someone help me how to make these data to the stored procedure and calling in coldfusion.

    Here is the code of my

    SET NOCOUNT ON

    DECLARE
    @cpt_dpt_cd char (2)
    @cpt_com_cd char (3)
    @sub_com_cd char (5)
    @con_upc_no char (13)
    , @pid_lng_dsc_tx varchar (100)
    , @pid_sht_dsc_tx varchar (100)
    , @rev_by varchar (8)
    @rev_dt datetime


    DECLARE upc_cursor CURSOR FOR
    SELECT *.
    OF di_audit_corp_upc_ldr_tbl
    WHERE con_upc_no IN ((in English only)
    SELECT con_upc_no, COUNT (*)
    TABLE [dbo]. [di_audit_corp_upc_ldr_tbl]
    GROUP BY con_upc_no
    HAVING COUNT (*) > 1
    )
    ORDER BY con_upc_no

    OPEN upc_cursor

    -It is performed while the previous extraction is successful.
    FETCH NEXT from upc_cursor
    IN
    @cpt_dpt_cd
    @cpt_com_cd
    @sub_com_cd
    @con_upc_no
    @pid_lng_dsc_tx
    @pid_sht_dsc_tx
    @rev_by
    @rev_dt

    -Check @FETCH_STATUS to see if he has more lines to fetch.
    WHILE @FETCH_STATUS = 0
    BEGIN
    -If not exists
    IF NOT EXISTS)
    SELECT con_upc_no
    OF dbo.di_audit_corp_upc_tbl
    WHERE con_upc_no = @con_upc_no
    )
    BEGIN
    -Insert record
    PRINT "insert UPC: ' + @con_upc_no"

    INSERT INTO dbo.di_audit_corp_upc_tbl)
    rcp_dpt_cd
    cpt_dpt_cd
    cpt_com_cd
    sub_com_cd
    cas_upc_no
    con_upc_no
    con_upc_tx
    pid_lng_dsc_tx
    pid_sht_dsc_tx
    aut_vld_cd
    rev_by
    rev_dt
    ) (VALUES
    '07'
    @cpt_dpt_cd
    @cpt_com_cd
    @sub_com_cd
    '0000000000000'
    @con_upc_no
    @pid_lng_dsc_tx
    @pid_lng_dsc_tx
    @pid_sht_dsc_tx
    , 'N'
    @rev_by
    @rev_dt
    )
    END
    ON THE OTHER


    BEGIN
    -to jump
    PRINT ' UPC to jump: "+ @con_upc_no
    END
    < cftransaction action = "commit" / >
    -It is performed while the previous extraction is successful.
    FETCH NEXT from upc_cursor
    IN
    @cpt_dpt_cd
    @cpt_com_cd
    @sub_com_cd
    @con_upc_no
    @pid_lng_dsc_tx
    @pid_sht_dsc_tx
    @rev_by
    @rev_dt

    END

    CLOSE Upc_cursor
    DEALLOCATE upc_cursor

    If I understand your SQL code you select some records in the di_audit_corp_upc_ldr_tbl table.  For each record in the results, you insert di_audit_corp_upc_tbl if a matching record does not already exist in di_audit_corp_upc_tbl.  If this summary is correct, you could try rewriting your query to avoid using a cursor.

    Something like the example below might work (I have not tested this code).

    INSERT di_audit_corp_upc_tbl (rcp_dpt_cd, cpt_dpt_cd, cpt_com_cd, sub_com_cd, cas_upc_no, con_upc_no, con_upc_tx, pid_lng_dsc_tx, pid_sht_dsc_tx, aut_vld_cd, rev_by, rev_dt)
    SELECT ' 07', cpt_dpt_cd, cpt_com_cd, sub_com_cd, ' 0000000000000', con_upc_no, pid_lng_dsc_tx, pid_lng_dsc_tx, pid_sht_dsc_tx, "n", rev_by, rev_dt
    From di_audit_corp_upc_ldr_tbl
    WHERE THERE IS NO
    (
    SELECT *.
    OF di_audit_corp_upc_tbl AS B
    WHERE B.con_upc_no = A.con_upc_no
    ) - check to see if the folder already exists in the destination table
       
    AND
    (
    SELECT COUNT (*)
    FROM di_audit_corp_upc_ldr_tbl AS C
    WHERE C.con_upc_no = A.con_upc_no
    ) > 1 - replaces the HAVING clause in the original query used to select cursor

    Note that I assume you are using Microsoft SQL Server.

    For questions about the improvement of SQL queries you could be better off the coast to post this kind of question on a specific forum for the database server you are using.

  • Value of aggrigate of procedure - Get Oracle on the comparison of two-column based

    Hi all
    I've written a procedure that accepts an input parameter and returns a refcursor.
    The logic used in the procedure is:
    The procedure is used to display the summary and the report in detail. When the input parameter has more than one saperated comma then it will act as a synthesis report, and when there is just a value as input, then it will act like a detailed report.
    The input parameter is as "AA12345, BB45434, HJ89736," the first two characters is Brand_id and the rest of the 5 character is the propery_id.
    The aggrigation of aggrigation query is:
    Select Month_name, Year, sum (REVPAR), Sum (ADR) in the FIS_KPI_TREND where
    Brand_id = 'AA' and SIte_id = '12345' Month_name group, year;
    The above query will worke fine for detail report when there is just a value for the entry as 'AA12345 '.

    The problem is coming to the summary report when I need to get the value of aggrigated for all the brand and the site which is entered in the input parameter.
    So I changed the query in the form:
    Select Month_name, Year, sum (REVPAR), Sum (ADR) in the FIS_KPI_TREND where
    Brand_id | SIte_id in ('AA12345', 'BB45434', 'HJ89736') of the Group of Month_name, year;
    (I use parser function to parse a comma saperated values.)

    By doing this, I get the desired result, but the performance has decrised that the Index is based on Brand_id and Site_id but I'm using Brand_ID | Site_id for my research.

    The one you suggest another way to rewrite this query so that it can take the index and not give me the output of sesired.

    Database used: Oracle 10 g

    Thanks in advance.
    Sumit Narayan

    Published by: Sumit Narayan, 11 April 2010 22:00

    I'd be inclined to do something like that to analyze the list separated by commas, that allows you to join without the concatenation of the columns as you do now.

    ME_XE?select
      substr(column_value, 1, 2)            as brand_id,
      substr(column_value, 3, length(column_value))   as site_id
    from table(sys.ODCIVARCHAR2LIST('AA12345','BB45434','HJ89736'));
      2    3    4
    BRAND_ID   SITE_ID
    ---------- ----------
    AA         12345
    BB         45434
    HJ         89736
    
    3 rows selected.
    
    Elapsed: 00:00:00.20
    ME_XE?
    
    ME_XE?select * from v$version;
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE  10.2.0.1.0  Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    
    5 rows selected.
    
    Elapsed: 00:00:00.39
    ME_XE?
    

    So for your case...

    Select
      f.Month_name,
      f.Year,
      sum(f.REVPAR),
      Sum(f.ADR)
    from FIS_KPI_TREND f, table(sys.ODCIVARCHAR2LIST('AA12345','BB45434','HJ89736')) t
    where f.Brand_id = t.brand_id
    and   f.SIte_id  = t.site_id
    group by f.Month_name, f.Year;
    

    Published by: Tubby 11 April 2010 22:12

  • Check the package/procedure for a user level privileges

    Hi gurus,
    How to check the package/procedure for a user-level privileges? as dba_tab_privs for the tables.

    for example: grant execute on User1 dbms_scheduler.
    now I must verify that user1 has run on dbms_scheduler privilege or not.

    What is the advice for this?

    Thanks in advance,
    Charles
    SQL> select privilege, count(*) from dba_tab_privs group by privilege order by 1;
    
    PRIVILEGE                       COUNT(*)
    ---------------------------------------- ----------
    ALTER                               19
    DEBUG                              256
    DELETE                              131
    DEQUEUE                            3
    EXECUTE                           19315
    FLASHBACK                          52
    INDEX                               14
    INSERT                              137
    MERGE VIEW                          36
    ON COMMIT REFRESH                     52
    QUERY REWRITE                          52
    
    PRIVILEGE                       COUNT(*)
    ---------------------------------------- ----------
    READ                                7
    REFERENCES                          54
    SELECT                                3752
    UNDER                                3
    UPDATE                              111
    WRITE                                5
    
    17 rows selected.
    

    DBA_TAB_PRIVS is more than simple tables.

  • Normal rewrite of query with views of database

    Hi all

    I'm trying to make my programmer life easier by creating a view of database for them to query the data, so they don't have to worry about joining tables. However, query rewriting does not work no matter how I set the MV and the view. Here is an example:

    I have the Sales tables with columns: amount of the update, CustCode,.

    and the Customer table with columns: CustCode, CustDesc

    I create a SALES_V view with columns: update, CustCode, CustDesc, amount by joining the Sales table with the Customer table as follows:
    -----
    create or replace view SALES_V as
    Select Update, c.CustCode, c.CustDesc, amount
    s sales
    Join customer c on (s.CustCode = c.CustCode);
    -----

    In the interest of speed, I create a materialized view SALES_TOT_MV with columns: update, with the following SQL:
    -----
    create a materialized view SALES_TOT_MV
    activate the query rewriting
    What to choose PDate, flat amount from the sale
    Group update;
    -----

    When I run the following query, I expect to be rewritten to use SALES_TOT_MV:
    -----
    Select updating, flat SALES_V
    Group update;
    -----

    However, to explain the plan to always tell me that he uses the table SALES , not the SALES_TOT_MV.

    Can someone tell me this is a limitation of the Oracle optimizer or am I missing just something for this?

    Thanks in advance!

    -Andrew

    Published by: blackhole001 on January 28, 2010 12:34

    blackhole001 wrote:
    Hi all

    I'm trying to make my programmer life easier by creating a view of database for them to query the data, so they don't have to worry about joining tables.

    That sounds like a horrible idea. I say this because you will find yourself finally with programmers who know nothing about your data model and how to interact properly with it.

    In addition, what you will get is a developer who uses one of your views and see 20 columns inside, there 4 it needs. If all these 4 columns comes from a 2 simple table join, but the view has 8 tables, you lose a ton of resources using the view (and God forbid that they should join this view to another view to get 4 of the 20 columns of this other view as well).

    Ideally, you should write stored procedures that satisfy exactly what is needed (if you are the resource database and these other java programmers, .net, basic etc...) and the front-end developers call these routines customized for a specific object.

    Creating views is not bad, but it is not an appropriate solution that developers not learn or understand SQL or the data model.

  • 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

  • HP 15 ac149 tx: placement of 15 HP ac149tx

    Can someone tell me where are the speakers of 15 HP ac149tx located? Are they strong enough?

  • Satellite C660-17J does not start

    My nephew of friends has a C660 which, once you turn on shows the home screen Toshiba with a Panel down showing the next "press F2 to start, press F12 to the menu of boot options. How can you define to be able to boot directly from the HARD drive wit

  • I received a call from PCFIX someone claiming to have access to my PC

    I received two phone calls from the above named 'company', claiming that someone has been access to my IP address, the first phone call told me someone in Birmingham in the United Kingdom has access to my IP address, and the second was informing me t

  • remove the sign-on windows xp

    I have 1 account on my computer, why Windows XP makes me "choose" I want to open a session to the user?  How can I get rid of this nonsense?  Why MicroSoft makes it so difficult?

  • Windows vista service pack 2 (?) virus

    When I tried to install windows vista service pack 2 (from Windows Update), my AV (Webroot Antivirus) software popped up twice messages saying that it detected the virus ' evil/mdrop-gen. " The first time that I blocked the second time it timed out (