Need help with PL/SQL so and then select

Hello guys, I am new to the PL/SQl programming (only Java experience) and I'm pretty stuck to my task. It would be great if you could help me. I am in programming with Oracle SQL * Plus Version 10.2.0.3.0

Whenever a user logs on to the server a database entry is created with information about the logged-on user. I need to create a PL/SQL command that selects all the information from last month. Unfortunately, the date_stamp column has a certain weird format: 1131210 for December 10, 2013


My idea so far:


DECLARE

v_today NUMBER;

BEGIN

v_today: = TO_NUMBER (TO_CHAR (SYSDATE, 'MM'));       -Save the number of the month (e.g.12) in v_today

IF v_today = 01 THEN

SELECT * from audittrl

WHERE the date_stamp between 1131201 AND the 1131231;

ELSIF v_today = 02 THEN

SELECT * from audittrl

WHERE the date_stamp between the 1130131 AND 1130101;

.......

END IF;

END;

/

Error code: "an INTO clause in this SELECT statement.

I do not want to save the result to select a variable, hope you can help me. Thanks in advance.

Hello

6a4d1bcd-c00e-4dac-AB64-9b6bdb1652d1 wrote:

Thanks, I'll try that, if still get caught once, I'll be back. Anway I'm not sure of the solution of Chris227, because I can't test it right now. From my point of view it gives you information the current month (e.g., December) and not the month previous (-online November), or have I missed something. ?

You are right.  In addition, it does not for a given year.  If you have data from several years in the table, it will select lines for the month of December 2012, 2011, 2010,... but also of 2013.

Here's a way to get around that:

DECLARE

prev_month_start PLS_INTEGER: = TO_NUMBER (TO_CHAR (ADD_MONTHS (SYSDATE-1)

, "YYMM"1' "01"

)

);

this_month_start PLS_INTEGER: = TO_NUMBER (TO_CHAR (SYSDATE

, "YYMM"1' "01"

)

);

BEGIN
FOR (IN) rec
SELECT *.
Of audittrl
WHERE the date_stamp > = prev_month_start
AND date_stamp< >
ORDER BY user_id, date_stamp - or other

)
LOOP
dbms_output.put_line (rec.date_stamp);
dbms_output.put_line (rec.event);
dbms_output.put_line (rec.user_id)
dbms_output.put_line (rec.host_name);
END LOOP;
END;

This should also be more effective, because it will allow the optimizer to use an index on date_stamp.  Even if there is no index, it will be more effective because it avoids calling any function (for example, SUBSTR) on each line of the table.

You needn't PL/SQL to get these results.  Just use SQL, you might say:

SELECT event, host_name, user_id and date_stamp
Of audittrl
WHERE the date_stamp > = TO_NUMBER (TO_CHAR (ADD_MONTHS (SYSDATE-1)
, "YYMM"1' "01"
)
)
AND date_stamp<  to_number="" (="" to_char="" (="" sysdate="" to_number="" (="" to_char="" (="">


, "YYMM"1' "01"
)
)

ORDER BY user_id, date_stamp - or other

;

Your front end will provide column headers and touch the data so that the columns line up.  It can also set the output to a file.  (For example, if your front-end is SQL * Plus, you can use the command of the COIL.)

I guess date_stamp is a NUMBER.  If it is a string, the solutions above can be simplified a bit.

This problem (and many other problems) would be so much simpler if date_stamp was a DATE column.  Using numbers or strings to store the date information is simply asking for trouble.

Tags: Database

Similar Questions

  • Need help with a SQL query

    Hello

    I have a data in table (raj_table) with columns (char11) raj_id, raj_number (varchar2 (15)), raj_format (NUMBER), Primary_ID (identity with the values of the primary key column)

    Primary_ID raj_id Raj_number Raj_format

    1                            raj                 rajvend                      1

    2                            raj                 rajvend                      1

    3                            raj                 rajvendor1                 2

    4                            raj                 rajvendor1                 2

    5                            raj                 rajvendor1                 2

    6                            raj                 rajvendor2                 3

    I used under SQL to get query output as below, but has not achieved the required result:

    Select client_id vendor_number, vendor_format, primary_id, row_number() on sl_no (client_id partition, primary_id, vendor_format order of client_id primary_id, vendor_format, vendor_number, vendor_number)

    from raj_table by sl_no asc

    SL_NO raj_id raj_number raj_format primary_id

    1                   1                   raj              rajvendor                 1

    1                   2                  raj              rajvendor                 1

    2                   3                   raj              rajvendor1                2

    2                   4                   raj              rajvendor1                2

    2                   5                  raj               rajvendor1                2

    3                   6                    raj              rajvendor2                3

    I need help with a SQL query to get the result as above without using the group by clause. I want to bring together the combination of separate line of the three columns (raj_id, raj_number, raj_format) and add a unique serial number for each online game (SL_NO column below). So, above there are 3 unique set of (raj_id, raj_number, raj_format) I can get in a group by clause, but I can not add prmiary_id, SL_NO values if I group by clause. I used the analytical functions like row_number() but no luck. Need solution for this.

    with t as)

    Select 'raj' raj_id, 'rajvend' raj_number, 1 raj_format, 1 primary_id Union double all the

    Select option 2, 'raj', 'rajvend', 1 double Union all

    Select 3, 'raj', 'rajvendor1', 2 double Union all

    Select 4, 'raj', 'rajvendor1', 2 double Union all

    Select 5, 'raj', 'rajvendor1', 2 double Union all

    Select 6, 'raj', 'rajvendor2', 3 double

    )

    Select dense_rank() over (order of raj_id, raj_number, raj_format) sl_no,

    t.*

    t

    order by primary_id

    /

    PRIMARY_ID RAJ RAJ_NUMBER RAJ_FORMAT SL_NO
    ---------- ---------- --- ---------- ----------
    1 1 raj rajvend 1
    1 2 raj rajvend 1
    2 3 raj rajvendor1 2
    2 4 raj rajvendor1 2
    2 5 raj rajvendor1 2
    3 6 raj rajvendor2 3

    6 selected lines.

    SQL >

    SY.

  • Need help with query SQL Inline views + Group

    Hello gurus,

    I would really appreciate your time and effort on this application. I have the following data set.

    Reference_No---Check_Number---Check_Date---description---Invoice_Number---Invoice_Type---Paid_Amount---Vendor_Number
    1234567 11223 - 05/07/2008 -paid for cleaning- 44345563-I-* 20.00 *---19
    1234567 11223 - 05/07/2008 - 44345563 -a--10,00---19 ofbad quality adjustment
    7654321 11223 - 05/07/2008 - setting the last billing cycle - 23543556 - A - 50.00 - 19
    4653456 11223 - 05/07/2008 - paid for cleaning - 35654765 - I - 30, 00-19

    Please ignore '-' added for clarity

    I'm writing a paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, aggregate query Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Type, Invoice_Number, Vendor_Number. When there are no more records I want to display the respective Description.

    The query should return the following data set

    Reference_No---Check_Number---Check_Date---description---Invoice_Number---Invoice_Type---Paid_Amount---Vendor_Number
    1234567 11223 - 05/07/2008 -paid for cleaning- 44345563-I-* 10.00 *---19
    7654321 11223 - 05/07/2008 - setting the last billing cycle - 23543556 - A - 50.00 - 19
    4653456 11223 - 05/07/2008 - paid for cleaning - 35654765 - I - 30, 00-19
    Here's my query. I'm a little lost.

    Select b., A.sequence_id, A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
    de)
    Select sequence_id, check_number, check_date, invoice_number, sum (paid_amount) sum, vendor_number
    of the INVOICE
    Sequence_id group check_date, check_number, invoice_number, vendor_number
    ) A, B OF INVOICE
    where A.sequence_id = B.sequence_id


    Thank you
    Nick

    It seems that this is a duplicate thread - correct me if I am wrong in this case->

    Need help with query SQL Inline views + Group

    Kind regards.

    LOULOU.

  • Need help with PL/SQL query complex

    I need help with a query that need access to data from 3 tables. That's what I did

    I created 3 tables

    CREATE TABLE post_table
    (
    post_id varchar (20),
    datepost DATE,
    KEY (post_id) elementary SCHOOL
    ) ;

    CREATE TABLE topic
    (
    TOPIC_ID varchar (20),
    name varchar (20),
    PRIMARY KEY (topic_id)
    );

    CREATE TABLE blogpost_table
    (
    TOPIC_ID varchar (20),
    post_id varchar (20),
    PRIMARY KEY (topic_id, post_id);
    FOREIGN KEY (topic_id) REFERENCES topic (topic_id) ON DELETE CASCADE,
    FOREIGN KEY (post_id) REFERENCES post_table (post_id) ON DELETE CASCADE
    );


    Now, I inserted a few values in these tables as

    INSERT INTO post_table VALUES ('p1', to_date ('2009-09-14 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p2', to_date ('2009-07-18 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p3', to_date ('2009-07-11 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p4', to_date ('2009-03-11 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p5', to_date ('2009-07-13 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p6', to_date ('2009-06-12 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p7', to_date ('2009-07-11 18:00 "," MM/DD/YYYY mi:ss'));))

    INSERT INTO VALUES subject ("t1", "baseball");
    INSERT INTO category VALUES ('t2', 'football');

    INSERT INTO blogpost_table VALUES ("t1", "p1");
    INSERT INTO blogpost_table VALUES ('t1', 'p3');
    INSERT INTO blogpost_table VALUES ("t1", "p4");
    INSERT INTO blogpost_table VALUES ('t1', 'p5');
    INSERT INTO blogpost_table VALUES ('t2', 'p2');
    INSERT INTO blogpost_table VALUES ('t2', 'p6');
    INSERT INTO blogpost_table VALUES ("t2", "p7");


    I'm launching SQL queries on the table in this topic.

    I want to write a SQL query that returns me the name of a topic (s) and the number of blog_post (s) associated with the topic in descending order of the number of blog posts created in July.

    Can someone please help me to write this query?

    Thank you

    Published by: user11994430 on October 9, 2009 07:24

    Thanks for the test of the configuration!

    SQL>SELECT   t.NAME, COUNT(*)
      2      FROM topic t, blogpost_table b, post_table p
      3     WHERE b.topic_id = t.topic_id
      4       AND p.post_id = b.post_id
      5       AND p.datepost >= DATE '2009-07-01'
      6       AND p.datepost < DATE '2009-08-01'
      7  GROUP BY t.NAME
      8  ORDER BY COUNT(*) desc;
    
    NAME                   COUNT(*)
    -------------------- ----------
    baseball                      2
    soccer                        2
    

    HTH, Urs

  • Need help with Exchange 2010 Diag and implementation

    I NEED HELP FOR EXCHANGE 2010 DAG AND THE IMPLEMENTATION THAT CAN HELP-IM I IN THE RIGHT SUPPORT GROUP?

    Hello HectorLopez_790,

    Microsoft Communities is for consumer issues with Windows 8, Windows 7, Windows Vista and Windows XP. Your question with Exchange would be better supported in the TechNet forums.
    Click here for a link to transfer your question in the forums of Exchange.

    Thank you

    Marilyn

  • Need help with Oracle SQL merge records according to date and term dates

    Hi all

    I need help to find this little challenge.

    I have groups and flags and effective dashboards and dates of term against these indicators according to the following example:

    GroupName Flag_A Flag_B Eff_date Term_date
    Group_ATHERETHERE2011010199991231
    Group_ANN2010010120101231
    Group_ANN2009010120091231
    Group_ANN2006010120081231
    Group_ANTHERE2004010120051231
    Group_ATHERETHERE2003010120031231
    Group_BNTHERE2004010199991231
    Group_BNTHERE2003010120031231

    As you can see, group_A had the same combination of (N, N) flag for three successive periods. I want to merge all the time periods with the same indicators in one. Where entry into force will be the most early (underlined) time period and end date will be later (underlined)

    So the final result should look like this:

    GroupName Flag_A Flag_B Eff_date Term_date
    Group_ATHERETHERE2011010199991231
    Group_ANN2006010120101231
    Group_ANTHERE2004010120051231
    Group_ATHERETHERE2003010120031231
    Group_BNTHERE2003010199991231

    Thanks for your help

    Here's the DDL script

    drop table TMP_group_test;

    create table TMP_group_test (groupname varchar2 (8))

    , flag_a varchar2 (1)

    , flag_b varchar2 (1)

    , eff_date varchar2 (8)

    , term_date varchar2 (8)

    );

    insert into TMP_group_test values ('Group_A', 'Y', 'Y', ' 20110101 ', ' 99991231');

    insert into TMP_group_test values ('Group_A', 'n', ' n ', ' 20100101 ', ' 20101231');

    insert into TMP_group_test values ('Group_A', 'n', ' n ', ' 20090101 ', ' 20091231');

    insert into TMP_group_test values ('Group_A', 'n', ' n ', ' 20060101 ', ' 20081231');

    insert into TMP_group_test values ('Group_A', 'n', 'Y', ' 20040101 ', ' 20051231');

    insert into TMP_group_test values ('Group_A', 'Y', 'Y', ' 20030101 ', ' 20031231');

    insert into TMP_group_test values ('Group_B', 'n', 'Y', ' 20040101 ', ' 99991231');

    insert into TMP_group_test values ('Group_B', 'n', 'Y', ' 20030101 ', ' 20031231');

    commit;

    Post edited by: user13040446

    It is the closest, I went to the solution


    I create two rows;

    Rnk1: partition by group name, order of eff_date / / desc: this grade will sort the records of the most recent and handed to zero for each group\

    Rnk2: (dense) partition by group name, flag_A, flagb: this grade for each combination of group\flag gives a number so that they are classified as "families".

    Then I use the function analytic min

    Min (eff_date) more (partition of GroupName, rnk2): the idea is that, for each Member of the same family, the new date is the min of the family (and the max for the date of the term), at the end I just need separate so that the duplicates are gone

    Now the problem. As you can see from the query below, records of 1 and 6 (as identified by rownum) are identified in the same family, because they have the same combination of flag, but they are not successive, so everyone must keep its own date of entry into force.

    If only I can make the distinction between these two that would solve my problem


    Query:


    Select rowNum,GroupName, flag_a, flag_b, eff_date, term_date, rnk1, rnk2

    , min (eff_date) more than (partition by GroupName rnk2( ) min_eff

    Of

    (

    Select rowNum,

    GroupName , flag_a , flag_b , eff_date , term_date

    rank() more than (partition by GroupName stopped by eff_date desc) rnk1

    DENSE_RANK() more than (partition by GroupName order by flag_A flag_B ( ) rnk2

    de dsreports . tmp_group_test

    ) order by rowNum

    Hello

    user13040446 wrote:

    Hi KSI.

    Thanks for your comments, you were able to distinguish between these lines highlight, but lost lines 2,3,4 which are supposed to have the same date min = 20060101.

    Please see the table wanted to see the final result I want to reach

    Thanks again

    This first answer is basically correct, but in the main query, you want to use the function MIN, not the analytical function aggregation and GROUP BY columns with common values, like this:

    WITH got_output_group AS

    (

    SELECT GroupName, flag_a, flag_b, eff_date, term_date

    ROW_NUMBER () OVER (PARTITION BY GroupName

    ORDER BY eff_date

    )

    -ROW_NUMBER () OVER (PARTITION BY GroupName, flag_a, flag_b)

    ORDER BY eff_date

    ) AS output_group

    OF tmp_group_test

    )

    SELECT GroupName, flag_a, flag_b

    MIN (eff_date) AS eff_date

    MAX (term_date) AS term_date

    OF got_output_group

    GROUP BY GroupName, flag_a, flag_b

    output_group

    ORDER BY GroupName

    eff_date DESC

    ;

    The result I get is

    GROUP_NA F F EFF_DATE TERM_DAT

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

    Group_A Y 20110101 99991231 Y

    N Group_A 20101231 20060101 N

    Group_A N 20051231 20040101 Y

    Group_A Y Y 20031231-20030101

    Group_B N Y 99991231 20030101

    which is what you asked for.

  • Need help with the OSB Assign and replace the

    I have a proxy service that receives the SOAP message:

    " < = xmlns:soapenv soapenv:Envelope ' http://schemas.xmlsoap.org/SOAP/envelope/ "xmlns:SOAP - ENC =" " http://schemas.xmlsoap.org/SOAP/encoding/ "container =" " http://www.w3.org/1999/XMLSchema ">

    " < = xmlns:soapenv soapenv:Header ' http://schemas.xmlsoap.org/SOAP/envelope/ ">

    < / soapenv:Header >

    < soapenv:Body >

    " < pidx:OrderChange pidx:transactionPurposeIndicator = 'Replace' xmlns:pidx = ' http://www.API.org/pidXML "xmlns =" http://www.API.org/pidXML "" xmlns: xsi = " http://www.w3.org/2001/XMLSchema-instance "xsi:schemaLocation="C:\shareIt\OrderChange_1-2.xsd" > ""

    ...

    < / pidx:OrderChange >

    " < = Xmlns:ocp DeliveryInformation ' http://www.digitaloilfield.com/OCP ">

    ...

    < / DeliveryInformation >

    < / soapenv:Body >

    < / soapenv:Envelope >

    I need to take the OrderChange element and place it in a SOAP body and the DeliveryInformation element and place it in the SOAP of the same SOAP message header.

    The SOAP message is then sent to a business service that makes an HTTP POST of the SOAP XML.

    I created the service of the company and he sent some data test SOAP and it works very well, but cannot create a bridge between the Proxy and the Business Service.

    In the stream of messages of Proxy I tried to do an assignment in a routing. I tried to do the following:

    1. an XQuery query transform to generate the XML SOAP just described

    2. not the entitlement where the "Expression" is the transformation and the Variable is a variable based on a schema for SOAP.

    I can see that the company is trying to be invoked, but the SOAP data does not have to be formatted or passed.

    It is the right approach or is their a better way of

    1. create the SOAP wrapped XML

    2. call the Business Service.

    Any suggestions are appreciated. I can provide more detail if necessary.

    Kind regards.

    Thank you Vlad...

    I think I'm getting in that direction now. Just do some debugging.

    Appreciate the input. I will update with final results.

    Again, your help is greatly appreciated.

    Kind regards.

  • Need help with keyframes for start and stop an effect

    I use a mask and blurred for a few seconds. I understand that I must use keyframes to indicate when to start and stop this effect in the video, so that the same area is not trimmed for video full.

    The problem is, I can't find help by correctly setting the keyframes. When I opened the menu keyframes in the effect, it seems that I must together for both the mask took and the blur effect. I did... to start and stop at specific times, but the rest indeed throughout the video, so of course miss me something by using keyframes. The manual to create effects is not useful. I need assistance with keyframes as what I'm doing is clearly not working. Help!

    If the mask does not move that you don't have to set the keyframe. For the blur, click the stopwatch next to 'bluriness' add keyframes as below, the Reds don't blur and blue those maximum blur this fade effect.

  • Need help with transfer of FrameMaker and Adobe Professional License

    One of my colleagues when you leave uninstalled society Frame 9 and Adobe Professional 8 on its system without disabling the license. Now, we would like to reuse the license for newly hired personnel but are unable to do so because the license is not yet «released»

    It's flexible licenses, not canned versions. When we contacted Adobe Support, we were told to send the copy of license PDF, we now not responding more (even if we have the license number in our records). Is there a way we can reuse this license?

    Thank you

    nishmvk

    Hi, it is certainly possible to move the Adobe between computers , but do not turn off first

    If you have not done this, perhaps a simple solution would be just to reinstall the software on the same computer, and then disable and uninstall

    Otherwise, only Adobe customer support can reset an inaccessible activation, to my knowledge

  • IP number looking for PSI - need help with a sql solution better and faster

    Hello

    I have a table (one) with more 1 000 000 IP addresses and numbers (the digital equivalent of the IP address)

    I have a second table (b) which contains a mapping between the ranges of the ISP and IP. The table looks like this and more contains 150 000 entries:

    BEGIN_IP_RANGE END_IP_RANGE ISP_NAME

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

    600000000 700000000 ISP_X

    800000000 900000000 ISP_Y

    I'm creating a third table (c) which connects (a) IP numbers to identify the ISP from (B). The query looks like this:

    CREATE TABLE c

    AS

    Select a.IP_ADDRESS

    b.ISP_NAME

    IP_NUMBERS a, ISP_LOOKUP b lkp

    where a.IP_NUMBER between b.BEGIN_IP_RANGE and b.END_IP_RANGE

    ;

    There is no key join between the 2 tables and so I use TO search for the access provider. The performace of it's terrible and table (c) takes several hours to create.

    Does anyone have any thoughts/ideas/suggestions on how this research can be achieved by using a solution better and faster?

    Thank you very much

    Shah

    The performace of it's terrible and table (c) takes several hours to create.

    Hours what do you say?

    See if the following can help.

    Cardinalities are similar to yours. The ETG takes 7sec. :

    SQL> create table ip_numbers (ip_address, ip_number) as
      2  select cast(to_char(level,'fm099G999G999G999', 'nls_numeric_characters=,.') as varchar2(15))
      3       , level
      4  from dual
      5  connect by level <= 1000000 ;
    
    Table created.
    
    SQL> select * from ip_numbers where rownum <= 10;
    
    IP_ADDRESS       IP_NUMBER
    --------------- ----------
    000.000.000.001          1
    000.000.000.002          2
    000.000.000.003          3
    000.000.000.004          4
    000.000.000.005          5
    000.000.000.006          6
    000.000.000.007          7
    000.000.000.008          8
    000.000.000.009          9
    000.000.000.010         10
    
    10 rows selected.
    
    SQL>
    SQL> create table isp_lookup (begin_ip_range, end_ip_range, isp_name) as
      2  select 1 + (level-1)*5
      3       , level*5
      4       , cast('ISP_'||to_char(level,'fm099999') as varchar2(10))
      5  from dual
      6  connect by level <= 200000 ;
    
    Table created.
    
    SQL> select * from isp_lookup where rownum <= 10;
    
    BEGIN_IP_RANGE END_IP_RANGE ISP_NAME
    -------------- ------------ ----------
                 1            5 ISP_000001
                 6           10 ISP_000002
                11           15 ISP_000003
                16           20 ISP_000004
                21           25 ISP_000005
                26           30 ISP_000006
                31           35 ISP_000007
                36           40 ISP_000008
                41           45 ISP_000009
                46           50 ISP_000010
    
    10 rows selected.
    
    SQL> create index ip_address_number_ix on ip_numbers (ip_number);
    
    Index created.
    
    SQL> set timing on
    SQL>
    SQL> create table ip_mappings as
      2  select /*+ use_nl(a b) */
      3         a.ip_address
      4       , b.isp_name
      5  from isp_lookup b
      6       join ip_numbers a on a.ip_number between b.begin_ip_range
      7                                            and b.end_ip_range
      8  ;
    
    Table created.
    
    Elapsed: 00:00:06.94
    SQL> select count(*) from ip_mappings;
    
      COUNT(*)
    ----------
       1000000
    
    Elapsed: 00:00:01.22
    
  • Help with code to insert, and then update the form table.

    I have a form where a user can add a new record in a table. Here is the procedure for recording button that works very well. But I call another procedure for updating the table with an "if" statement "The SQL code that I use works fine to get the data I'm looking for when I run it in SQL, but the 'if' statement updates all records in the table to ' n ' when some should be"Y". I am new to Oracle forms development (3 months) so it's probably very simple, but I'm stuck and need to get this finished form. Any help is greatly appreciated.


    SAVE BUTTON TRIGGER PROCEDURE:*.

    PROCEDURE SAVE_MM_1099_ADD IS

    MM1099_NO NUMBER (10);
    NUMBER OF THE YEAR (4);
    NUMBER OF NOTICE_SEQ_NO (10);
    NOTICE_NAME VARCHAR2 (30);
    TIN_FROM_DB VARCHAR2 (23);
    TSDI_DB VARCHAR2 (1);
    IRS_NTYPE VARCHAR2 (10);
    IRS_NDATE VARCHAR2 (10);
    BU_WH VARCHAR2 (1);
    NO_TIN_NAME VARCHAR2 (1);
    DUP_IRS_NOTICE VARCHAR2 (1);
    G1_IRS_NOTICE_3YR_2BS VARCHAR2 (1);

    B_SAVE_ADD boolean;

    Start

    IF MM1099_NO IS NOT NULL THEN

    insert into MM_1099
    (
    MM1099_NO,
    YEAR,
    NOTICE_SEQ_NO,
    NOTICE_NAME,
    TIN_FROM_DB,
    TSDI_DB,
    IRS_NTYPE,
    IRS_NDATE,
    BU_WH,
    NO_TIN_NAME,
    DUP_IRS_NOTICE,
    G1_IRS_NOTICE_3YR_2BS
    )
    values
    (
    MM1099_NO,
    YEAR,
    NOTICE_SEQ_NO,
    NOTICE_NAME,
    TIN_FROM_DB,
    TSDI_DB,
    IRS_NTYPE,
    IRS_NDATE,
    BU_WH,
    NO_TIN_NAME,
    DUP_IRS_NOTICE,
    G1_IRS_NOTICE_3YR_2BS
    );


    : system.message_level: = '5';
    Commit_FORM;
    : system.message_level: = '0';

    END IF;

    UPDATE_NUMOCCURTIN;

    END;

    PROCEDURE CALLED:*.

    PROCEDURE UPDATE_NUMOCCURTIN IS

    CURSOR c1 (NUMBER NUMOCCURTIN) IS
    SELECT THE YEAR, TIN_FROM_DB, COUNT (TIN_FROM_DB) AS NUMOCCURTIN
    OF MM_1099
    TIN_FROM_DB GROUP, YEAR
    SEEN (COUNT (TIN_FROM_DB) > 0);

    CR1 c1% ROWTYPE;
    number of v_recs;
    NUMBER OF NUMOCCURTIN;

    BEGIN
    v_recs: = 0;

    OPEN c1 (NUMOCCURTIN);

    loop

    Fetch c1 into cr1;
    When the % notfound c1 or c1% rowcount output > v_recs;

    IF cr1. NUMOCCURTIN > 1 THEN

    UPDATE MM_1099
    SET DUP_IRS_NOTICE = 'Y ';

    ON THE OTHER

    UPDATE MM_1099
    SET DUP_IRS_NOTICE = 'N';

    : system.message_level: = '5';
    commit;
    : system.message_level: = '0';

    END IF;

    v_recs: = v_recs + 1;

    END LOOP;

    CLOSE c1;

    END;

    For any help or suggestion will be greatly appreciated.

    IF cr1. NUMOCCURTIN > 1 THEN

    UPDATE MM_1099
    SET DUP_IRS_NOTICE = 'Y ';

    ON THE OTHER

    UPDATE MM_1099
    SET DUP_IRS_NOTICE = 'N';

    : system.message_level: = '5';
    commit;
    : system.message_level: = '0';

    END IF;

    There is no WHERE condition in your update, so always update you all THE RECORDS in your table. I guess it must be something like:

    UPDATE MM_1099 SET
      DUP_IRS_NOTICE = 'Y';
     WHERE TIN_FROM_DB=cr1.TIN_FROM_DB
       AND YEAR=cr1.YEAR
    

    Some general order questions about your code:
    Where your variables for your insert statement are filled? looking at your code they will always be NULL.
    Be careful when using the variable exactly as the names of column names. This may cause unexpected behavior (for example when it is used in the UPDATE statements).
    Why engage in the other branch, but not in the branch so?

  • Need help with PL/SQL code

    Hi I am writing this code in pl/SQL:

    create or replace
    PROCEDURE 'TESTPRI '.
    (NUMBER pCYC_DT)
    AS
    vTGT_TABL VARCHAR2 (25);
    vSTG_TABL varchar2 (30);
    vsql varchar2 (200);
    BEGIN
    vTGT_TABL: = 'TESTTABL ';
    vSTG_TABL: = vTGT_TABL | » _'|| pCYC_DT;
    vsql: = 'TRUNCATE TABLE ' | vTGT_TABL;
    EXECUTE IMMEDIATE vsql;
    RUN IMMEDIATELY "INSERT" | vTGT_TABL | ' SELECT * FROM '. vSTG_TABL;
    COMMIT;
    -IMMEDIATE 'TRUNCATE TABLE ' | vSTG_TABL;
    END TESTPRI;

    When executing this procedure it gives me following error:
    ORA-03290: Invalid command truncate - lack of key word TABLE or CLUSTER
    ORA-06512: at "DBR. TESTPRI', line 11
    ORA-06512: at line 6

    But I think that the TRUNCATE TABLE statement is correct. Is there a problem with the variable?

    Any help would be appreciated.
    Thank you.

    vsql: = 'TRUNCATE TABLE ' | vTGT_TABL;

    You need space after the TABLE

    vsql:= 'TRUNCATE TABLE ' ||vTGT_TABL ; 
    

    EXECUTE IMMEDIATE vsql;
    RUN IMMEDIATELY "INSERT" | vTGT_TABL | ' SELECT * FROM '. vSTG_TABL;

    Sapce here after INTO, before SELECT and FROM

    EXECUTE IMMEDIATE 'INSERT INTO '|| vTGT_TABL||' SELECT * FROM '|| vSTG_TABL;
    
  • HP 15 - ac043tu: need help with the key feature and WiFi Drivers

    Hi team,

    I try to activate the key feature and WiFi in my new HP 15 - ac043tu laptop.

    I use Windows 7 Ultimate 32 operating system.

    I installed all the drivers available on the site Web of HP (http://support.hp.com/us-en/drivers/selfservice/HP-15-ac000-Notebook-PC-series/7771404/model/8326116... for my product.

    To activate the function key, I installed driver: HP System Event Utility - sp71716, but it doesn't seem to work.

    In Device Manager, network controller shows exclamation as shown below. I tried to install Broadcom and Realtek WLAN drivers, tried to turn on/off, uninstalled/reinstalled drivers referring to other positions, but that did not work.

    I also tried to install HP SoftPaq Download Manager, but it did not help. Tool does not show my product described.

    I went through a similar question posted by other members, but failed to get the solution. This question gave me hard times.

    Appreciate your help in this regard.

    Thank you

    Kishan

    Hello:

    You need these drivers wireless and bluetooth driver 64-bit file should have the 32-bit drivers too.

    Network controller (wireless card):

    FTP://FTP.HP.com/pub/SoftPaq/sp71501-72000/sp71528 .exe

    Bluetooth:

    This package contains the Broadcom bluetooth driver and software for the laptop models running a supported operating system. Broadcom Bluetooth 4.0 driver is required to activate the bluetooth 4.0 Broadcom devices and is compatible with Broadcom bluetooth 3.0 and earlier versions.

    File name: sp71440.exe

    Unfortunately, I can't help you with the next question.  The system of the event utility would be the only software I can think that would have worked.

    You can try the software HP Quick Launch, but I doubt it will work.

    http://h20565.www2.HP.com/hpsc/SWD/public/detail?swItemId=ob_112835_1

  • BlackBerry Z10 need help with the facebook chat and notifications

    Hey, guys.

    Since I updated to version 10.2.1.2102 of the software I was not able to receive messages from the hub of blackberry facebook chat. Before the update whenever I had my phone connected to a wireless network it was automatically getting messages facebook on the hub. Now, although I can send messages and receive messages if this contact is online, once I close the conversation hub is gone and I don't get the messages, only the "new messages of * person *" e-mail after a certain time.

    In addition, I don't get notifications about birthdays of the people. I get the "next event" x hours notification on the lock screen, if I go in the calendar I see the notification at the top of the page, but it does not sound to warn me of my birthdays from the contacts.

    Can someone help me with this two problems? Thank you!

    Fact. I needed to update the facebook app.

  • Need help with an Export-CSV and ForEach loop

    Hi guys, I'm total NOOB in CLI so please forgive the stupid question.

    I need your expert advice for the very large environment and will award points.

    I have a working script that alerts to our logout ESXi hosts, maintenance and NotResponidng mode

    His job well, but need to send a mail to all three of our VCenters

    Current script only works for a VC at a time. How do I ForEach and always the hose of the same body CSV and HTML

    It would be nice to have an HTML and CSV output that looks like this (assuming that there are currently disconnected etc.)

    I have a set of credentials, that work on all 3 of my VC

    VC1

    Host1 disconnected

    Host2 NotResponding

    VC2

    Host3 disconnected

    Host4 NotResponding

    VC3

    No disconnected/maintemance/notresponding hosts for VC3

    Here is my current code, etc. of the hidden passwords >

    # Clear old sessions
    Disconnect VIServer VC01-confirm: $false

    # VC01 VC check for disconnection and Maintenance mode and does not
    SE connect-VIServer-Server VC01 - FakeUSer username-password FakePassword

    $Report = get-VMhost-State disconnected, maintenance, NotResponding | SELECT name, connectionstate

    # scan info to be html and give him a date stamp

    $ReportHtml = $report | ConvertTo-Html | Out-string

    # Write CSV file and give it a character of data

    $filePath = "C:\PS\Output".
    $filename = "VC01disconnectedHosts".
    $CurrentDate = get-Date
    $CurrentDate = $CurrentDate.ToString ('MM-dd-yyyy_hh-mm-ss')

    $Report | Export-Csv "C:\PS\Output\VC_$Currentdate.csv".

    # Send the info by Mail

    Send-MailMessage-to [email protected] - subject VMwareMorningcheckVC01$ CurrentDate '
    SmtpServer - mail.sanlam.co.za - from [email protected] '
    -BodyAsHtml-body $reportHtml - accessories 'C:\PS\Output\VC_$CurrentDate.csv '.

    Thank you in advance for help.

    You could use a ForEach loop through all vCenters and combine the results in a $1 report.

    Something like that

    $vCenters = "VC01","VC02","VC03"
    
    # Clear old sessionsDisconnect-VIServer $vCenters -Confirm:$false
    
    $report = @()# Check VC VC01 for Disconnects and Maintenance mode and Not Respondingforeach($vc in $vCenters){  Connect-VIServer -Server $vc -User FakeUSer -Password FakePassword
    
      $Report += (Get-VMhost -State Disconnected,Maintenance,NotResponding | Select @{N="VC";E={$vc}},name ,connectionstate)  Disconnect-VIServer $vc -Confirm:$false}
    
    # parse info to be html ,and give it date stamp
    
    $ReportHtml = ($report | ConvertTo-Html | out-String)
    
    # Write out CSV file and give it a Data Stamp
    
    $CurrentDate = Get-Date -Format 'MM-dd-yyyy_hh-mm-ss'$filename = "C:\PS\Output\DisconnectedHosts-$($CurrentDate).csv"
    
    $Report | Export-Csv -Path $filename -NoTypeInformation -UseCulture
    
    # Send info with Mail
    
    Send-MailMessage -To [email protected] -Subject VMwareMorningcheck$CurrentDate `-SmtpServer mail.sanlam.co.za -From [email protected] `-BodyAsHtml -Body $reportHtml -Attachments "C:\PS\Output\DisconnectedHosts-$($CurrentDate).csv"
    

    I added the property vCenter for each line in the report

Maybe you are looking for