Help with the insert statement

Hello

I was wondering if someone could help write me a sql statement.

Here is my table:
CREATE TABLE "TEMP_INVOICE" 
   ("INVOICE" VARCHAR2(100 BYTE),
     "DATE_OF_DOCUMENT" DATE, 
     "DATE_OF_PAY_DAY" DATE, 
     "D" NUMBER, 
     "K" NUMBER
   );
Here are the instructions for correct insertion. This time, I posted 2 examples with 2 numbers different otherwise.
insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k)  values (1000,to_date('01.02.2012','dd.mm.yyyy'),to_date('01.03.2012','dd.mm.yyyy'),5000,0);
 
insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k)  values (1000,to_date('01.04.2012','dd.mm.yyyy'),'','',1000);
 
insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k)  values (1000,to_date('01.05.2012','dd.mm.yyyy'),'','',3000);
 
insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k)  values (1000,to_date('01.06.2012','dd.mm.yyyy'),'','',1000);

insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k)  values (2000,to_date('01.07.2012','dd.mm.yyyy'),to_date('01.09.2012','dd.mm.yyyy'),8000,0);
 
insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k)  values (2000,to_date('01.10.2012','dd.mm.yyyy'),'','',5000);
 
insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k)  values (2000,to_date('01.11.2012','dd.mm.yyyy'),'','',2000);
 
insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k)  values (2000,to_date('01.12.2012','dd.mm.yyyy'),'','',1000);
I want to do is make an insert allows you to table another call is MADE:
CREATE TABLE "INVOICE" 
   ("INVOICE" VARCHAR2(100 BYTE),
    "DATE_OF_DOCUMENT" DATE, 
     "DATE_OF_PAY_DAY" DATE,
     "DATE_OF_PAYMENT_REC" DATE,
     "VALUE" NUMBER,
     "VALUE_DEDUCT" NUMBER,
    "DATE_FROM" DATE,     
     "DATE_TO" DATE
     );
Statements in the INVOICE table should be like this:


........ The Bill... date_of_document... date_of_pay_day... date_of_payment_rec... value... value_deduct... Date_from... Date_to
1......     1000...............1.1.2012.................1.3.2012................NULL............................ 5000... NULL... 1.3.2012...1.4.2012
2......     1000...............1.4.2012.................NULL..................... 1.4.2012...1000... 4000... 2.4.2012... 1.5.2012
3......     1000...............1.5.2012.................NULL..................... 1.5.2012...3000... 1000... 2.5.2012... 1.6.2012
4......     1000...............1.6.2012.................NULL..................... 1.6.2012...1000


Can someone help me with the sql statement that would insert data from table to table Bill temp_invoice as in the example?

Thank you!

PS

I would try to explain.
(1) the first statement that is to be inserted is original imply that at which is different DATE_OF_PAY_DAY to NULL.
To this inserted negative of the original imply, we must add date_from that is exatly the same date_of_pay_day and date_to which is exactly the same as the date of the first payment. Payment which came first!
(2) we have now in the second insert statement. It will be the first payment of lease with date_of_document and date_pf_payment_rec, which is the same as date_fo_document. Value field will be populated with the amount of payment received and value_deduct field will be the value of the original imply - value of the first payment. Date is date_of_document + 1 and date_to is the date of the next payment.
(3) Insert us the next installment. Date_od_payment_rec is the same as date_of_document... value is the amount of the second payment and value_deduct's previous value_deduct which was of 4000 - value of this second payment. date_from date_of_payment_rec + 1 and date_to is the date of the next payment

So we continue this same pattern until we reached the final payment when we finish insert with the statement:
Date of the document (date of the last payment received) and even for date_of_payment_rec and field value with the amount of the payment receieved. The rest (value_deduct, date_from, date_to) is null.

I really hope you understand what I'm trying to do here.

If you have any other questions please.

Published by: user13071990 on November 22, 2012 04:16

Published by: user13071990 on November 22, 2012 04:16

Hello

user13071990 wrote:
... Here are the instructions for correct insertion. This time, I posted 2 examples with 2 numbers different otherwise.

Ok!
Be sure to post the results you want new data.

You probably need to add "PARTITION BY the Bill" to all analytical clauses in my solution:

INSERT INTO invoice
( invoice, date_of_document, date_of_pay_day, date_of_payment_rec
, value,   value_deduct,     date_from,           date_to
)
SELECT       invoice
,       date_of_document
,       date_of_pay_day
,       CASE
           WHEN  k > 0
           THEN  date_of_document
       END          AS date_of_payment_rec
,       NVL (d, k)     AS value
,       NVL2 ( date_of_pay_day
            , NULL
            , SUM (d) OVER ( PARTITION BY  invoice
                                      ORDER BY      date_of_document
                     )
            - SUM (k) OVER ( PARTITION BY  invoice
                                      ORDER BY      date_of_document
                     )
            )     AS value_deduct
,       NVL ( date_of_pay_day
           , date_of_document + 1
           )          AS date_from
,       LEAD (date_of_document) OVER ( PARTITION BY  invoice
                                        ORDER BY      date_of_document
                           )
                      AS date_to
FROM       temp_invoice
;

Because I'm not an English speaker nativ, that I just posted what it should look like after the insert is successful.

OK, so you can't explain as you want, but you still need to explain.

... @Frank Kulash: you are very close, but still not quite what I'm looking for.

Point out where my solution is the production of incorrect results, and explain (as you can) how to get good results in these places.

Tags: Database

Similar Questions

  • Need help with the insert statement

    Hello

    I have a question on how to write a SQL statement.

    This is the table of "base":
    CREATE TABLE TEMP_TBL
    (
    id_nr NUMBER,
    DATE_DOK DATE,
    DATE_DUE DATE,
    DATE_DOK_PAY DATE,
    DEB NUMBER,
    KRD NUMBER
    );
    
    insert into temp_tbl (ID_NR,DATE_DOK,DATE_DUE,DATE_DOK_PAY,DEB,KRD)values('1',TO_DATE('11.01.2011','DD.MM.YYYY'),TO_DATE('25.02.2011','DD.MM.YYYY'),NULL,'423,24','0');
    insert into temp_tbl(ID_NR,DATE_DOK,DATE_DUE,DATE_DOK_PAY,DEB,KRD)values('2',TO_DATE('16.12.2011','DD.MM.YYYY'),TO_DATE('13.06.2011','DD.MM.YYYY'),NULL,'91270,15','0');
    insert into temp_tbl(ID_NR,DATE_DOK,DATE_DUE,DATE_DOK_PAY,DEB,KRD)values('3',TO_DATE('27.09.2011','DD.MM.YYYY'),TO_DATE('27.09.2011','DD.MM.YYYY'),NULL,'0','2000');
    and it comes to resoult in the target table. SQL statement must take care of the insert in a base of the target table table (example below is already provided with test data).
    create table table_sod
    (
    
          id_nr number
         ,date_from date
         ,date_to date
         ,deb_krd number
    
    );
    
    One thing to note here :  values in column deb_krd under insert 1 and 4 must be summarized in insert 4.
    
    insert into table_sod (id_nr,date_from,date_to,deb_krd) values('1',null,to_date('25.02.2011','dd.mm.yyyy'),'423,24');
    insert into table_sod(id_nr,date_from,date_to,deb_krd) values('2',to_date('26.02.2011','dd.mm.yyyy'),to_date('13.06.2011','dd.mm.yyyy'),'423,24');
    insert into table_sod(id_nr,date_from,date_to,deb_krd)values('3',null,to_date('13.06.2011','dd.mm.yyyy'),'91270,15');
    insert into table_sod(id_nr,date_from,date_to,deb_krd)values('4',to_date('14.06.2011','dd.mm.yyyy')to_date('27.09.2011','dd.mm.yyyy'),'91693,39');
    insert into table_sod(id_nr,date_from,date_to,deb_krd)values('5',null,to_date('27.09.2011','dd.mm.yyyy'),'2000');
    If someone could give me a helping hand how write correct insert statement I would be really gratefull.

    Thank you for your time!

    I came here with my own assumptions with this

    SQL> select rownum id_nr
      2       , date_from
      3       , date_to
      4       , case when date_from is null then deb
      5              else sum(case when date_from is not null then deb else 0end) over(order by id_nr, no)
      6         end deb_krd
      7    from (
      8            select id_nr
      9                 , case when lg_dt is null or ld_dt = date_due then  null else lg_dt+1 end date_from
     10                 , ld_dt date_to
     11                 , case when deb = 0 then krd else deb end deb
     12                 , no
     13              from (
     14                      select t1.*
     15                           , lead(t1.date_due) over(order by t1.id_nr, t2.no) ld_dt
     16                           , lag(t1.date_due) over(order by t1.id_nr, t2.no) lg_dt
     17                           , t2.no
     18                        from temp_tbl t1
     19                       cross
     20                       join (select 1 no from dual union all select 2 no from dual) t2
     21                       order by id_nr, no
     22                   )
     23             where ld_dt is not null
     24         )
     25  /
    
         ID_NR DATE_FROM DATE_TO      DEB_KRD
    ---------- --------- --------- ----------
             1           25-FEB-11      42324
             2 26-FEB-11 13-JUN-11      42324
             3           13-JUN-11    9127015
             4 14-JUN-11 27-SEP-11    9169339
             5           27-SEP-11       2000
     
    
  • need help with the Update statement

    Hello
    I received a question in a course and I tried my best to respond, and now my brain is giving. I would really appreciate help with the update statement. I don't mind if you do not validate a solution, a little nudge in the right direction would be really useful. I'll post that I got.

    THE QUESTION
    / * For these agents disabled on more than seven missions, change their date of deactivation of the first date of deactivation of all the agents that have been activated in the same year as the agent that you update currently.
    */

    I have it divided into parts, here is my select statement to agents disabled on more than 7 missions, which produces the deactivation_dates in the agents table that I want to update...
    SELECT
    s.deactivation_date
    FROM
    (
    SELECT
    a.deactivation_date,
    count(m.mission_id) as nomissions
    FROM
    agents a
    INNER JOIN
    missions_agents m
    on
    a.agent_id=m.agent_id
    GROUP BY
    a.deactivation_date
    ) s
    WHERE
    s.nomissions>7 AND s.deactivation_date IS NOT NULL
    .. .and the code for the first date of deactivation for each year of activation agent
    select 
    a2.deactivation_date
    from
    agents a2
    where a2.deactivation_date= 
    (
    select min(a.deactivation_date)
    from 
    agents a
    where to_number(to_char(a.activation_date,'YYYY'))=to_number(to_char(a2.activation_date,'YYYY'))
    )
    ..... I am not real to marry these two statements together in the Update statement. I can't extract each date of deactivation produced in the first select statement and their match against the first date of deactivation in the year they have been activated for the second select statement.

    Any help greatly appreciated... :))

    I began to wonder how things would :)

    user8695469 wrote:
    First of all why he chooses the date the earliest of all agents

    UPDATE  AGENTS_COPY AC /* (1) */
    SET     DEACTIVATION_DATE = (
    SELECT  MIN(AGS.DEACTIVATION_DATE)
    FROM    AGENTS_COPY  AGS
    ,       AGENTS_COPY AC /* (2) */
    WHERE   TRUNC(AGS.ACTIVATION_DATE,'YEAR') = TRUNC(AC.ACTIVATION_DATE,'YEAR') /* (3) */
    )
    

    He recovers as soon as the subquery has not been correctly set in the SET clause. It seems you are trying to update a correlated, but we are still having a conceptual shift. I have added a few comments to your code above and below will explain.

    (1): when you do a correlated update it is useful to the table alias that you did right here.

    (2): this table statement is not necessary and is the reason why the FIRST deactivation date is selected. The alias that you use (3) refers to THIS table, not the one defined in the update statement. Remove the line indicated by (2) in the FROM clause and a correlated update will happen.

    and secondly why is it to update each row, when I thought that I'm just the lines where the agents are disabled and missions > 7? Pointers on where I'm wrong would be very appreciated. (SQL = stupid query language!) :)

    user8695469 wrote: then why is it to update each row, when I thought that I'm just the lines where the agents are disabled and missions > 7? Pointers on where I'm wrong would be very appreciated. (SQL = stupid query language!) :)

    
    WHERE EXISTS
    (
    SELECT
    a.agent_id,
    count(m.mission_id)
    FROM
    agents a
    /* INNER JOIN AC ON AC.AGENT_ID = A.AGENT_ID */
    INNER JOIN
    missions_agents m
    ON
    a.agent_id=m.agent_id
    GROUP BY
    a.agent_id,
    a.deactivation_date
    HAVING
    count(m.mission_id)>7 AND a.deactivation_date IS NOT NULL
    )
    

    Once again this problem is similar to the question above that a correlation update doesn't work. Test existence of lines in an EXISTS subquery. Since your subquery is not related to the table that you are trying to update, it will be always return a line and, therefore, it returns true for EACH LINE in the AGENTS table. To limit the game to only agents > 7 missions results, you need to add a join condition that references the table in your update statement. I added one above (with comments) as a sample.

    I recommend you look over all material that you have associated with correlated subqueries, including documents that I posted above. This seems to be what you're having the problem more with. If you need me to explain the concept of correlated queries any better please let me know.

    Thank you!

  • High logical reads with the INSERT statement

    Hello

    I have an INSERT query that is having a very high reading statspack logical reads. I've seen go Asktom announcement that this is due to the index. Link: [http://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:6643159615303]

    Can you please help to explain exactly what Oracle do and why you should read so the e/s logic. It's the that oracle must read the structure of the index for all (bundle branch block + all blocks of sheet) for each insertion line?

    Thanks & appreciate the insight.

    Rgds
    Ung

    Only 5 bound for first INSERTION and only 1 for the next INSERTION.

    This is false.

    "db block ' is ALSO to the e/s logic." This is gets them in CURRENT mode. Oracle reads the Index blocks in the current mode to update the index blocks.

    Your last statement is in direct contradiction with the previous paragraph

    As Tom mentioned, oracle must change the index as well when records are inserted in > (or updated or deleted from) the table. This means oracle must first read the index blocks (in > compatibility mode (LIO) as well as in current mode) in addition to the blocks of the turntable when inserting new > records. So this must explain why LIOs are more when inserting in an indexed table from > inserting into a table not indexed.

    What is correct.

    Hemant K Collette
    http://hemantoracledba.blogspot.com

  • need help with the Merge statement

    I'm on: Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production

    I'm currently an UPDATE statement and then it works and is accurate, it takes 30 minutes. I heard that MERGE
    can do the same thing and is just as accurate and much faster!

    Here's the query I want to convert into a MERGE INTO statement. I tried to do it myself, but I get errors and don't know simply, since it's new for me.

    Basically I want to update table your on a corresponding condition in the table tt for 2 columns (GTP and UPDATE_DT), for UPDATE_DT I want to insert the Date current system.
    UPDATE /*+ PARALLEL (16) */  OLDER_Table ta
    
    SET (ta.GTP, ta.UPDATE_DT) = 
    
                    (SELECT /*+ PARALLEL (16) */ tt.GTP, SYSDATE
                     FROM NEWER_Table tt
                     WHERE ta.cust_id = tt.cust_id
                     AND ta.STAMP_DATE = tt.STAMP_DATE
                     AND ROWNUM = 1)
    
                     WHERE EXISTS (SELECT 1
                                   FROM NEWER_Table tt
                                   WHERE ta.cust_id = tt.cust_id
                                   AND ta.STAMP_DATE = tt.STAMP_DATE
                                   AND (NVL(ta.GTP, 'X') != NVL(tt.GTP, 'X'))); 
    Thank you!

    Hello

    Whenever you have a problem, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) of all of the tables involved.
    Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
    If you ask on a DML statement, such as UPDATE, CREATE TABLE and INSERT statements need to re - create the tables as they are before the DML, and results will be the content of the or the tables changed when it's all over.
    See the FAQ forum {message identifier: = 9360002}

    MERGE peut be much faster than update; Sometimes, there is no significant difference in speed.
    Tables in multiple situations like this, I've never seen a case where the MERGER has been slower than the UPDATE, even if the UPDATE is sometimes easier to code and just as fast.

    Maybe that's what you want:

    MERGE INTO  older_table            dst
    USING  (
               SELECT  n.cust_id
            ,        n.stamp_date
            ,        n.gtp
            ,        ROW_NUMBER () OVER ( PARTITION BY  n.cust_id
                                               ,           n.stamp_date
                             ORDER BY      n.gtp
                              )                    AS r_num
            FROM        newer_table  n
            JOIN        older_table     o  ON   n.cust_id     = o.cust_id
                                 AND     n.stamp_date     = o.stamp_date
                           AND     NVL ( n.gtp
                                    , 'X'
                                 )          != NVL ( o.gtp
                                                  , 'X'
                                              )
    
           )                 src
    ON     (    src.cust_id            = dst.cust_id
           AND  src.stamp_date     = dst.stamp_date
           AND  src.r_num            = 1
           )
    WHEN MATCHED THEN UPDATE
    SET    dst.gtp          = src.gtp
    ,      dst.update_date     = SYSDATE
    ;
    

    As I can't test it, I can't be sure.

  • problem with the insert statement

    Hi all

    I'm trying to insert data into xxops_forecast_extract.
    There are two additional territory_id, position_id columns.
    How can I insert data into xxops_forecast_extract with the update instructions below.
           Columns of XXOPS_FORECAST_EXTRACT 
    
            PERIOD_ORDER,           
            SHR_NODE_ID,         
            FORECAST_DEFN_ID,       
            X_SALES_REP_NUM,        
            X_SALES_REP_REF,        
            POSITION_NAME,          
            TERRITORY_NAME,         
            AM_ID,              
            POSITION_LEVEL,         
            FORECAST_ID,            
            PERIOD_ID,              
            FISCAL_PERIOD,         
            PERIOD_START_DATE,      
            PERIOD_END_DATE,        
            TOTAL_COMMIT_PRODUCT,   
            TOTAL_JUDGMENT_PRODUCT,
            TOTAL_COMMIT_SERVICE,   
            TOTAL_JUDGMENT_SERVICE,
            TOTAL_UPSIDE_PRODUCT,   
            TOTAL_UPSIDE_SERVICE, 
            TERRITORY_ID,
            POSITION_ID
        INSERT INTO xxfdev.xxops_forecast_extract(
            PERIOD_ORDER,           
            SHR_NODE_ID,         
            FORECAST_DEFN_ID,       
            X_SALES_REP_NUM,        
            X_SALES_REP_REF,        
            POSITION_NAME,          
            TERRITORY_NAME,         
            AM_ID,              
            POSITION_LEVEL,         
            FORECAST_ID,            
            PERIOD_ID,              
            FISCAL_PERIOD,         
            PERIOD_START_DATE,      
            PERIOD_END_DATE,        
            TOTAL_COMMIT_PRODUCT,   
            TOTAL_JUDGMENT_PRODUCT,
            TOTAL_COMMIT_SERVICE,   
            TOTAL_JUDGMENT_SERVICE,
            TOTAL_UPSIDE_PRODUCT,   
            TOTAL_UPSIDE_SERVICE )
        SELECT 
            PERIOD_ORDER,           
            NODE_REFERENCE,         
            FORECAST_DEFN_ID,       
            X_SALES_REP_NUM,        
            X_SALES_REP_REF,        
            POSITION_NAME,          
            TERRITORY_NAME,         
            AM_NAME1,               
            POSITION_LEVEL,         
            FORECAST_ID,            
            PERIOD_ID,              
            FISCAL_PERIOD,          
            PERIOD_START_DATE,      
            PERIOD_END_DATE,        
            TOTAL_COMMIT_PRODUCT,   
            TOTAL_JUDGMENT_PRODUCT,
            TOTAL_COMMIT_SERVICE,   
            TOTAL_JUDGMENT_SERVICE,
            TOTAL_UPSIDE_PRODUCT,   
            TOTAL_UPSIDE_SERVICE   
        FROM ESALESFCST.OMF_FORECAST_DATA_FDEV@XXG2C_ECRMS_FDEV_ADMIN.COMPANY.COM;
    
          
         UPDATE xxops_forecast_extract b SET territory_id = (SELECT a.territory_id
             FROM fdev_hier_node_mv a
             WHERE a.shr_node_id = b.shr_node_id
              AND NVL(end_dt,SYSDATE) > SYSDATE) ;
        COMMIT; 
        
        UPDATE xxops_forecast_extract b SET position_id = (SELECT a.row_id 
            FROM s_postn a
            WHERE a.name = 'TD-'||UPPER(b.am_id))
            WHERE position_level = 7
            AND b.am_id IS NOT NULL; 
        COMMIT; 
        
        UPDATE xxops_forecast_extract b SET position_id = (SELECT a.row_id
            FROM s_postn a
            WHERE UPPER(a.desc_text) = UPPER(TRIM(B.POSITION_NAME)))
            WHERE position_level = 7
            AND b.am_id IS NULL;
        COMMIT;
    Thanks in advance.

    You can try with the merger?

  • Helps with the UPDATE statement

    Hello

    I have a table like this:
    create table test
    (id number,
    stat number,
    id_num number);
    data in the table:
    insert into table test (id,stat,id_num) values (1,112,'');
    insert into table test (id,stat,id_num) values (1,123,'');
    insert into table test (id,stat,id_num) values (2,134,'');
    insert into table test (id,stat,id_num) values (2,111,'');
    insert into table test (id,stat,id_num) values (3,112,'');
    insert into table test (id,stat,id_num) values (4,111,'');
    insert into table test (id,stat,id_num) values (4,12,'');
    insert into table test (id,stat,id_num) values (4,11,'');
    I want to update the column id_num with serial number under the same ID.
    Below is the table with coloumn successfully updated.
    insert into table test (id,stat,id_num) values (1,112,1);
    insert into table test (id,stat,id_num) values (1,123,2);
    insert into table test (id,stat,id_num) values (2,134,1);
    insert into table test (id,stat,id_num) values (2,111,2);
    insert into table test (id,stat,id_num) values (3,112,1);
    insert into table test (id,stat,id_num) values (4,111,1);
    insert into table test (id,stat,id_num) values (4,12,2);
    insert into table test (id,stat,id_num) values (4,11,3);
    Can someone give me a hint how to remove this?

    Thank you very much for your help!

    user13071990 wrote:
    Manik which is not a good solution because dat_document can also be duplicated.

    Alberto is no uniq key in the table, which is the main problem.

    It is not a good way to get the table without unique keys.

    To work around the problem, I suggest that, despite the fact that I do not use virtual ROWID.

    I did a test by inserting a date twice for the same id

    insert into test (id,dat_document,id_num) values (4,to_date('01.07.2012','dd.mm.yyyy'),'');
    

    Now, I used:

    MERGE INTO test a
         USING (SELECT rowid
                     , ROW_NUMBER () OVER (PARTITION BY id ORDER BY dat_document) AS val
                  FROM test) b
            ON (a.rowid = b.rowid)
    WHEN MATCHED
    THEN
       UPDATE SET id_num = val;
    
    SELECT *
      FROM test
    ORDER BY id, dat_document;
    
            ID DAT_DOCUMENT              ID_NUM
    ---------- --------------------- ----------
             1 01-01-2012 00:00:00            1
             1 01-02-2012 00:00:00            2
             2 01-03-2012 00:00:00            1
             2 01-04-2012 00:00:00            2
             3 01-05-2012 00:00:00            1
             4 01-06-2012 00:00:00            1
             4 01-07-2012 00:00:00            2
             4 01-07-2012 00:00:00            3
             4 01-08-2012 00:00:00            4
    

    Kind regards.
    Al

  • Need help with the IF statement.

    I am trying to write an IF statement using FormCalc in LiveCycle. I have the "tpe" cell that captures the total number of points. I would attribute levels based on the number of points obtained. For example, level I = 1001-1985; level II = 851-1000; level III = 551-850; level IV = < 551. I want to 'level' of cell to show I, II, III or IV, based on the points in the cell "tpe". How can I do this? I have zero familiarity with FormCalc or scripts in general. Can someone help me with this please? Would appreciate any help! Thank you!

    Just put the script in the field calculate level instead:

    If (tpe tpe and > 1000<= 1985)="">

    $ = "I"

    ElseIf (tpe > 850 and tpe<= 1000)="">

    $ = « II »

    ElseIf (tpe > 550 and tpe<= 850)="">

    $ = 'III'

    ElseIf (tpe<= 550)="">

    $ = « IV »

    else $ = «»

    endif

    Also just have a glance to your form - for the next time that you could save yourself a lot of time in your configuration through the use of tables for all of these fields, rather than making each a numeric field separated.

  • Need help with the conditional statement.

    I have a conditional configuration to check the 6 values, and I don't know how to put in place.  I know that the way I have it Setup is wrong, but I'm stuck here after several attempts of other variants.

    LINE OF CODE IN QUESTION:

    If (eventObject.info.name! = "marker2" |) "marker4" | "marker5" | "marker6" | "marker7" | "marker8")

    FULL CODE BLOCK:

    var listenerObject:Object = new Object();
    listenerObject.cuePoint = {function(eventObject:Object):Void}
    If (eventObject.info.name! = "marker2" |) "marker4" | "marker5" | "marker6" | "marker7" | {"marker8")}
    var listenerObject:Object = new Object();
    listenerObject.stateChange = {function(eventObject:Object):Void}
    trace (_root.theVideo.State);
    If {(_root.theVideo.paused)
    mclContinue._visible = true;
    var myTween:TweenLite = new TweenLite (mclContinue,.35, {_alpha:100, ease:Back.easeOut, onComplete:contBtn});})
    } else {}
    var myTween:TweenLite = new TweenLite (mclContinue,.35, {_alpha:0, ease:Back.easeOut, onComplete:contBtn});})
    }
    }
    _root.theVideo.addEventListener ("stateChange", listenerObject)
    }
    }
    _root.theVideo.addEventListener ("cuePoint", listenerObject)


    Thank you.

    You are welcome.

  • Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?

    Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?

    Hello

    2796614 wrote:

    Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?

    Of course, it is possible.  According to what the text file looks like to, you can create an external table that treats the text file as if it were a table.  Otherwise, you can always read the file in PL/SQL, using the utl_file package and INSERT of PL/SQL commands.

    You have problems whatever you wantt?  If so, your zip code and explain what the problem is.

    Whenever you have any questions, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the exact results you want from these data, so that people who want to help you can recreate the problem and test their ideas.  In this case, also post a small sample of the text involved file.

    If you ask about a DML operation, such as INSERT, then INSERT statements, you post should show what looks like the tables before the DML, and the results will be the content of the table changed after the DML.

    Explain, using specific examples, how you get these results from these data.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: Re: 2. How can I ask a question on the forums?

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

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

    Currently on trial...

    SQL > create table abc (num number);

    Table created.

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

    Table created.

    SQL > ed
    A written file afiedt.buf

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

    200 rows created.

    And the result...

    SQL > select * from abc;

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

    100 selected lines.

    SQL > select * from xyz;

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

    100 selected lines.

  • need help to create the insert statement

    I have customer_priv of table which has 4 columns (login, privilize_id, adate, added_by)

    the stmt insert like "insert into customer_priv values('JDOE',951.sysdate,admin);

    I have 100 users and for each user, I need to add to the 15 privilize_id

    I have the list of connections and roles, what is the best way to create a massive insert for all those users statement and

    any help is very appreciated

    Thank you

    user11984714 wrote:
    Thanks Frank

    I get the below now.what Miss. Also is it possible to reel in a file insert rather directly the data.am I missing values?

    Sorry, I don't understand what you want.
    You say you want to write something in a HOLD file instead of insert? Of course, you can do it. Change the INSERT statement in a SELECT statement and add commands to the COIL.

    SQL > @c:\insert_many.sql
    33 old: SELECT ' & 1' priv_id, 'admin', sysdate)
    33 News: SELECT sysdate, "BNELSON", "admin", priv_id)

    Of all_priv_id
    *
    ERROR on line 34:
    ORA-00923: THE KEYWORD not found where expected
    Thank you

    Published by: user11984714 on August 9, 2010 18:40

    Sorry, there was a typing error in my previous post.
    Remove the ')' the end of the

    SELECT     '&1', privilze_id, SYSDATE, 'admin')
    

    I hope that you have more problems, but if you do, post your code, even if you think that you just copied it from this site.

  • can someone help with the following code plsql errors...

    Hello

    If anyone can help with the following code... to get a successful outing.

    create or replace package lib_01 as

    procedure lib_proc01 (p_user_id in numbers, p_user_name in varchar2);

    end lib_01;

    create or replace package body lib_01 as

    procedure lib_proc01 (p_user_id in numbers, p_user_name in varchar2) as

    number of v_user_id;

    v_user_name varchar2 (50);

    number of v_avl_books;

    number of v_avl_days;

    date of v_end_date;

    date of v_return_date;

    Start

    dbms_output.put_line ('Enter User Name');

    dbms_output.put_line (' username :'|| p_user_name);

    Select user_id, user_name in v_user_id v_user_name of user_registration where user_name = p_user_name;

    If v_user_name <>p_user_name then

    dbms_output.put_line (' username is not.) Please submit full name ');

    end if;

    If v_user_id is null or v_user_name is null then

    dbms_output.put_line ("' user not found");

    validate_userLogin;

    on the other

    validate_issuedbooks (p_issuecount);

    end if;

    If v_issuecount < v_avl_books then

    issuebooks;

    on the other

    Number of return of late_fee (p_mem_id, p_extradays, p_latefee_total);

    end if;

    If paid_flag = "Y" then

    issuebooks;

    on the other

    dbms_output.put_line ("' book may be issued due to its maximum reached late fees");

    end if;

    end lib_proc01;

    procedure validate_userLogin is

    procedure reg_proc is

    procedure user_validate (p_id_proof in varchar2, p_id_no out varchar2) is

    v_id_proof varchar2 (20);

    v_id_no varchar2 (20);

    Start

    Select user_name, id_proof, id_no, v_user_name, v_id_proof, v_id_no of user_registration where id_proof = p_id_proof;

    If v_id_proof = "Adhar_Card" then

    dbms_output.put_line ('user a valid proof of ID');

    dbms_output.put_line (' and the id no. :'|| is p_id_no).

    on the other

    dbms_output.put_line ('Invalid ID evidence.) Please submit valid proof of ID ');

    end if;

    exception

    When no_data_found then

    dbms_output.put_line ('No Data found');

    end user_validate;

    procedure member_validate (p_mem_id series)

    v_mem_flag char (1);

    curr_date date: = sysdate;

    date of v_mem_enddate;

    Start

    dbms_output.put_line('Mem_flag:'|| v_mem_flag);

    Select mem_flag in the v_mem_flag of user_login where user_id = v_user_id;

    If v_mem_flag = 'n' or v_mem_flag is null then

    dbms_output.put_line ('The User do not have membership');

    on the other

    Select mem_id in the v_mem_id of user_login where user_id = v_user_id;

    dbms_output.put_line ('the user has membership');

    v_mem_id: = p_mem_id;

    Select mem_enddate in the member_login v_mem_enddate where mem_id = v_mem_id;

    If v_mem_enddate < curr_date then

    dbms_output.put_line ('Membership has expired' | v_mem_id |' on ' | v_mem_enddate);

    on the other

    dbms_output.put_line ('User a validity again' | v_mem_enddate);

    end if;

    end if;

    exception

    When no_data_found then

    dbms_output.put_line ("' no data found");

    while others then

    dbms_output.put_line (' another error.) Please find");

    end member_validate;

    Start

    insert into user_registration values ('& first_name ',' & last_name', null, ' & user_type',)

    address_ty ("& bldg_no",

    '& bldg_name',

    '& Street',

    ' & city ",

    '& State',

    '& zip'

    ),

    user_phone ',' & user_mail ',' mem_idproof', ' & id_no');

    Dbms_output.put_line ('user is properly registered');

    exception

    When no_data_found then

    dbms_output.put_line ("' data not found");

    end reg_proc;

    Start

    Dbms_output.put_line (' enter ID or user name ');

    Dbms_output.put_line (' username: ' | p_user_name);

    If v_user_name is null then

    Dbms_output.put_line ('user not found');

    reg_proc;

    Insert user_login SELECT user_id_seq. NEXTVAL, user_name, NULL, mem_id_seq. NEXTVAL, user_type FROM user_registration WHERE user_name is lower (p_user_name);

    Dbms_output.put_line (' because the user wants to have the membership? ");

    Dbms_output.put_line ('If Yes, please pay dues");

    INSERT INTO member_login SELECT mem_id_seq. CURRVAL, SYSDATE, SYSDATE + avl_days, 500, 'Y' of user_login ul, bl book_loan WHERE ul.mem_type = bl.mem_type AND user_name = p_user_name;

    END IF;

    exception

    When no_data_found then

    dbms_output.put_line ("' no data found");

    When too_many_rows then

    dbms_output.put_line (' too many lines).

    END validate_userLogin;

    procedure validate_issuedbooks (p_issuecount series)

    number of v_issuecount;

    Start

    Select user_login u, bl book_loan, avl_days, avl_books in v_avl_days, v_avl_books where bl.mem_type = u.mem_type and user_id = p_user_id;

    SELECT count (case when end_date < end return_date then p_mem_id) as invalidcount in v_issuecount from book_count where mem_id = p_mem_id;

    v_issuecount: = p_issuecount;

    dbms_output.put_line (' no. books that the user contains the :'|| p_issuecount);

    end validate_issuedbooks;

    procedure issuebooks is

    procedure book_avl (p_avl_now_flag in p_avl_date Boolean, date) is

    v_avl_now_flag char (1);

    date of v_avl_date;

    procedure reader_bookissue is

    Start

    insert into values drive (p_user_id, v_book_id, sysdate, sysdate, null);

    insert into book_count values(p_mem_id,v_book_id,sysdate,sysdate,null);

    Update book_availability set issued_to is "Reader" where book_id = v_book_id;.

    end reader_bookissue;

    Start

    Select book_name, b.book_id avl_now_flag v_book_name, v_book_id, v_avl_now_flag of the book b, book_availability b where b.book_id = ba.book_id and ba.book_id = p_book_id;

    If v_avl_now_flag = "Y" then

    dbms_output.put_line ('the book is available for issuance' | v_book_id);

    on the other

    Select mem_type in the v_mem_type of user_login where user_id = (select user_id from book_availability where avl_now_flag = 'n' and book_id = p_book_id);

    If v_mem_type = "Reader" then

    reader_bookissue;

    dbms_output.put_line (' the book is with Reader.) Please try tomorrow.') ;

    on the other

    dbms_output.put_line ('the book is member');

    end if;

    Select avl_date in the book_availability v_avl_date where book_id = p_book_id;

    v_avl_date: = p_avl_date;

    dbms_output.put_line (' the available date is: ' | p_avl_date);

    end if;

    end book_avl;

    Start

    insert into book_count values(p_mem_id,p_book_id,sysdate,sysdate+v_avl_days,v_return_date);

    Update book_availability set book_id = p_book_id, avl_now_flag = 'n', avl_date is to_date (sysdate + v_avl_days,' dd-mm-yyyy ""), issued_to = v_mem_type, user_id = p_user_id where mem_id = p_mem_id;

    commit;

    dbms_output.put_line ("' the book published successfully");

    end issuebooks;

    Number of function return late_fee (p_mem_id in number, p_extradays series, p_latefee_total number) is

    number of v_extradays;

    number of v_latefee_total;

    number of v_latefee_per_book;

    number of v_latefee_per_day;

    number of v_book_count;

    Start

    Select trunc (sysdate) - v_end_date in v_extradays from book_received where mem_id = p_mem_id and book_id = p_book_id;

    p_extradays: = v_extradays;

    v_latefee_per_book: = v_latefee_per_day * v_extradays;

    v_latefee_total: = v_latefee_per_book * v_book_count;

    p_latefee_total: = v_latefee_total;

    dbms_output.put_line ('The total AMT for not returned books' | p_latefee_total);

    end late_fee;

    end lib_01;

    Hello

    I checked the first 10 lines after the beginning and I could count already several errors.

    Is it an exercise or a real code, you must provide?

    Kind regards.

    Alberto

  • Help with the query to select only one record from the result set in double

    Hello

    Please help with the query. Version of Oracle database we use is 10g R2.

    I have a vision that is duplicated IDS, but they are used across the different functions. See below examples of data. Please help me with a query to select only one record (based on ID regardless of the area) from the bottom of the result set of duplicate records. For what is the point of view is there unique records, given the combination of the fields ID, Org, DF, dry, Sub-Sec

    ID
    Org
    DF
    Sec Sub-Sec

    (163)CQCPDMCPDMHD(163)PCENGENGENG(163)CQASICASICIS8888TSTACTACTAC(163)TSHEHESW6789CQINFOINFOFOS6789PCSECSYSSECSYSINFO16789TSSECSYSSECSYSINFO29009PCBMSBMSBMS1

    My result set must eliminate the duplicate identifiers regardless of whoever we choose of the result set. (I mean without distinction Org, DF, s, Sub-s). My expected result set should be.

    ID
    DSB

    DF
    SEC
    Sub-Sec
    (163)CQCPDMCPDMHD8888TSTACTACTAC6789CQINFOINFOFOS9009PCBMSBMSBMS1


    Thank you

    Orton

    Hello

    This sounds like a job for ROW_NUMBER:

    WITH got_r_num AS

    (

    SELECT id, DSB, df, s, sub_sec org

    ROW_NUMBER () OVER (PARTITION BY ID.

    ORDER BY org

    ) AS r_num

    OF view_x

    )

    SELECT id, DSB, df, sub_sec s,

    OF got_r_num

    WHERE r_num = 1

    ;

    He is a Top - N query example, where you choose the elements of N (N = 1 in this case) from the top of an ordered list.

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and INSERT, only relevant columns instructions) to your sample data and the results desired from these data.  (I know that you said that you were a view selection.  Just for this thread, pretending it is a picture and post simple CREATE TABLE and INSERT statements to simulate your point of view).
    Point where the above query is to produce erroneous results, and explain, using specific examples, how you get the right results from data provided in these places.  (I didn't quite understand the explanation above.  I don't know why you want to

    ID ORG DF DRY SUB_SEC

    --      ---     --      ---     -------

    1234 CQ DPRK DPRK HD

    and is not

    1234 IS CQ ASIC, ASIC

    or

    TS 1234 IT IT SW

    or

    1234 CQ ASIC ASIC HD

    )
    If you change the query at all, post your modified version.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002

  • NEED HELP WITH THE PROCEDURE

    Hi, earlier I had a doubt using the function or procedure function or procedure? Thanks to all who helped. but I found a way to use task2e with procedure. I would like to insert the issue.

    Cumulative 2nd task spends point procedure
    You create a stored procedure called spRollupExpenseItem. This procedure updates
    the corresponding line in the BudgetItem table given a report of expenses and the expense category number
    number. The procedure contains three input parameters, the value of ERNo, the value of ECNO.
    and the amount of cumulative, as well as a single parameter of Boolean result.
    This is the logic of the procedure.
    · If the corresponding ExpenseReport line (ERStatus) status is DENIED or
    MEANWHILE, an application error is triggered. The output parameter is set to False.
    · Otherwise, the corresponding BudgetItem line is updated. The actual amount (BIActual) in the
    line corresponding BudgetItem are incremented by the input of the cumulative amount parameter.
    o the output parameter is set to True after running the update
    operation.


    good task2e can be used using procedure by housing 'OUT' in parameters.here is the code

    CREATE OR REPLACE PROCEDURE spRollupExpenseIetm
    (P_ERNO IN FULL, P_ECNO ENTIRE, WHOLE ROLLUP_AMOUNT, BOOLEAN P_OUTPUT) IS

    ERSTATUS_ERROR EXCEPTION;
    V_ERSTATUS EXPENSEREPORT. TYPE % ERSTATUS;
    BEGIN
    SELECT ERSTATUS FROM V_ERSTATUS
    OF EXPENSEREPORT
    WHERE ERNO = P_ERNO;

    IF (V_ERSTATUS = 'PENDING' OR 'DENIED' = V_ERSTATUS) THEN
    P_OUTPUT: = FALSE;
    RAISE ERSTATUS_ERROR;
    ON THE OTHER
    UPDATE BUDGETITEM
    SET BIACTUAL = BIACTUAL + ROLLUP_AMOUNT
    WHERE ECNO = P_ECNO;
    P_OUTPUT: = TRUE;
    END IF;
    EXCEPTION
    WHEN ERSTATUS_ERROR THEN
    RAISE_APPLICATION_ERROR (-20564, ' ERROR: ERSTATUS is either pending or DENIED ');
    END spRollupExpenseIetm;




    his compiled without errors. My next question is

    2f task create Rollup fees trigger
    You create a trigger called TR_RollupExpAmt. This trigger fires after the power to the
    approved expenses amount (ExpApprAmt) or the deletion of a row in the table ExpenseItem. The
    following points explain the logic of this trigger:
    · If updating the ExpApprAmt column, the cumulative amount should be the difference
    of the New.ExpApprAmt under the Old.ExpApprAmt.
    · If the deletion of a row of the table of ExpenseItem, the cumulative amount should be the
    the Old.ExpApprAmt negative.
    · To run the update rollup, you must call the spRollupExpenseItem procedure
    described in the 2nd special.
    · If the output of the spRollupExpenseItem procedure parameter is true, insert a line
    in the table (Log_Table) exception log.
    o the ExcText (message explaining the error) value should indicate the
    operation (update or delete) and the cumulative amount.
    o If the output of the spRollupExpenseItem procedure parameter is false,
    do nothing.


    to do this I found on the internet http://it.toolbox.com/blogs/oracle-guide/learn-plsql-procedures-and-functions-13030 where he explained in the example he adds the output in the "my_first_proc" procedure parameter
    p_an_out_parameter DATE

    Then, he calls this procedure like this
    () my_first_proc
    p_name = > v_employee,
    p_an_in_out_parameter = > v_number,
    p_an_out_parameter = > T_DATE);

    IAM so intend to do the same by task2f task2e call and check the P_OUTPUT value. If iam wrong please let me know.

    and iam confused with task2f is
    If updating the ExpApprAmt column, the cumulative amount should be the difference
    of the New.ExpApprAmt under the Old.ExpApprAmt.
    · If the deletion of a row of the table of ExpenseItem, the cumulative amount should be the
    the Old.ExpApprAmt negative.

    How do I know if it is updated or deleted?
    I hace an idea but don't know if its valid or does not check EXPAMT to null as
    if(:New.) EXPAMT = NULL)
    ........
    can I do that. I know confectioners question sorry to make u read the whole story.

    Hello

    Whenever you write code, you should lower lines to see the where to begin blocks BEGIN and end, what are multiline statements and things like that.
    Whenever you post the text on this site, type these 7 characters:

    {code}

    (small letters only, inside curly braces) before and after sections of formatted text.
    After exactly what is causing the error message. The line of the error message numbers are too high; have you not after a few empty lines?

    Section causing errors seems to be:

    ...
        IF (UPDATING) THEN
            UPDATE EXPENSEITEM
                SET EXPAPPRAMT = :NEW.EXPAPPRAMT - :OLD.EXPAPPRAMT    -- No semicolon here
                WHERE ECNO = :NEW.ECNO;
            spRollupExpenseIetm(V_ERNO, V_ECO, ROLLUP_AMOUNT, P_POUTPUT);
            IF(V_OUTPUT = TRUE) THEN
                insert into log_table
                    (excno, exctrigger, exctable, exckeyvalue, excdate, exctext)
                    values
                    (LOG_SEQ.NEXTVAL,
                    'TR_ROLLUPEXPAMT',
                    'EXPENSEITEM',
                    V_ECNO,
                    v_timestamp,
                    'ERROR WHILE UPDATING, ROLLUP AMOUNT = ' || ROLLUP_AMOUNT    -- Is this what you want?
                    );
            END IF;
        END IF;
    

    You had a semicolon in the middle of the UPDATE statement.
    I see no 14 lines obvoius error later. The first error risk fi END does not correctly interpret.

    I also changed the end of the INSERT statement.

    Don't forget to put a colon in the record names: NEWS and: OLD.

    Published by: Frank Kulash, 28 January 2010 06:42

Maybe you are looking for