Help with insert

Hi friends,

I create a new post since the other discussion is long... I need to insert data of products in the rules table.

SOURCE TABLE:

create table product)

prod_id varchar2 (20).

prod_grp varchar2 (20).

from_amt number (10),

to_amt number (10),

share_amt number (10)

);

Insert into product (prod_id, prod_grp, from_amt, share_amt) Values ('10037', "STK", 1, 18);

Insert into product (prod_id, prod_grp, from_amt, share_amt) Values ('10037', "NSTK", 1: 16.2);

Insert into product (prod_id, prod_grp, from_amt, to_amt, share_amt) Values ('10038', "NSTK", 1, 5000, 12);

Insert into product (prod_id, prod_grp, from_amt, to_amt, share_amt) Values ('10038', "STK", 5001, 10000, 16);

Insert into product (prod_id, prod_grp, from_amt, share_amt) Values ('10038', "STK", 10001, 20);

Insert into product (prod_id, prod_grp, from_amt, to_amt, share_amt) Values ('10039', "NSTK", 1, 8000, 10);

Insert into product (prod_id, prod_grp, from_amt, share_amt) Values ('10039', "STK", 8001, 12);

SQL > select * from product;

PROD_ID PROD_GRP FROM_AMT TO_AMT SHARE_AMT

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

10037                          STK                              1                                                        18

10037                          NSTK                           1                                                        16

10038                          NSTK                           1                         5000                      12

10038                          STK                         5001                     10000                      16

10038                          STK                        10001                                                     20

10039                          NSTK                           1                        8000                       10

10039                          STK                         8001                                                      12

TARGET table:

create table rules)

rule_id varchar2 (30),

rule_grp varchar2 (10),

rate_1 number (10),

point_1 number (10),

rate_2 number (10),

point_2 number (10),

rate_3 number (10),

point_3 number (10)

);

Result in rules should look like:

SQL > select rule_id, rate_1, point_1, rate_2, point_2, rate_3, point_3 of the order of the rules by rule_id;

RULE_ID RATE_1 POINT_1 RATE_2 POINT_2 RATE_3 POINT_3

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

RL10037 18

RL10037 16

RL10038 12, 16 5000 10000 20

10000 20 RL10038

RL10038

10-8000-12 RL10039

RL10039

I have problems inserting it into Rate_2, Point_2, Rate_3 and Point_3... It's criteria:

rule_id - "RL" | Product.prod_id

rule_grp - product.prod_grp

rate_1 - product.share_amt where from_amt = 1

point_1 - product.to_amt

rate_2 - if product.to_amt in point_1 is not NULL, then find the next with the same rule_id/prod_id record product.share_amt

where from_amt (of the next record) = (current record-point_1) + 1 to_amt

point_2 - if product.to_amt in point_1 is not NULL, then find the next with the same rule_id/prod_id record product.to_amt

where from_amt (of the next record) = (current record-point_1) + 1 to_amt

rate_3 - if product.to_amt in point_2 is not NULL, then find the next with the same rule_id/prod_id record product.share_amt

where from_amt (of the next record) = (current record-point_2) + 1 to_amt

point_3 - if product.to_amt in point_2 is not NULL, then find the next with the same rule_id/prod_id record product.to_amt

where from_amt (of the next record) = (current record-point_2) + 1 to_amt

I tried inserting below, to get the data in RES and usage load on the rule table

Insert in the rules)

rule_id,

rate_1,

point_1,

rate_2,

point_2,

rate_3,

point_3

)

with res in the

(

Select

"RL" | PR.prod_id RULE_ID,

CASE WHEN pr.from_amt is 1 THEN pr.share_amt END RATE_1.

PR.to_amt POINT_1,

(select pr.from_amt

(

Select LEAD(pr.from_amt,1) over (ORDER BY pr.prod_id) of product pr

) next_from_amt

),

PR.to_amt TO_AMT,

PR.share_amt SHARE_AMT

product pr

)

Select

rule_id,

rate_1,

point_1,

... - CASE WHEN res.point_1 is NOT NULL and res.next_from_amt = res .to_amt + 1 THEN res.share_amt END RATE_2.

... - CASE WHEN res.point_1 is NOT NULL and res.next_from_amt = res .to_amt + 1 THEN res.to_amt END POINT_2.

... so check point_2 in above line is not null and pr.from_amt = pr.to_amt + 1 THEN pr.share_amt END RATE_3.

... check if point_2 is not null and pr.from_amt = pr.to_amt + 1 THEN pr.to_amt END POINT_3

RES

/

IF you can show it please how to check if point_1 (value inserted for previous column) is not null... Thank you all very much.

1 get the rate_1:

Insert in the rules (rule_grp, rate_1, rule_id, point_1)

Select "RL" | prod_id, prod_grp,

-case when from_amt = 1 then share_amt no other end, to_amt

product

;

2, download rate_2:

update rules t

package (rate_2, point_2) = (select share_amt, to_amt

s product

where t.point_1 is not null

and t.rule_id = 'RL ' | s.prod_id

- and t.rule_grp = s.prod_grp

and to_number (t.point_1) + 1 = s.from_amt)

where exists (select 'x'

s2 product

where t.point_1 is not null

and t.rule_id = 'RL ' | S2.prod_id

- and t.rule_grp = s2.prod_grp

and to_number (t.point_1) + 1 = s2.from_amt)

;

3, rate_3:

update rules t

package (rate_3, point_3) = (select share_amt, to_amt

s product

where t.point_2 is not null

and t.rule_id = 'RL ' | s.prod_id

- and t.rule_grp = s.prod_grp

and to_number (t.point_2) + 1 = s.from_amt)

where exists (select 'x'

s2 product

where t.point_2 is not null

and t.rule_id = 'RL ' | S2.prod_id

- and t.rule_grp = s2.prod_grp

and to_number (t.point_2) + 1 = s2.from_amt)

;

4, results:

RULE_ID RULE_GRP RATE_1 POINT_1 RATE_2 POINT_2 RATE_3 POINT_3

RL10037 STK 18

RL10037 NSTK 16

RL10038 NSTK 12, 16 5000 10000 20

RL10038 STK 10000 20

RL10038 STK

RL10039 NSTK 10 8000 12

RL10039 STK

Tags: Database

Similar Questions

  • need help with insert sitemap in the footer with the adobe site map muse

    Hi I need help, to know how to insert a site map link in the footer of a page Web in muse Adobe.

    a quick google search just shows how to create a site map, but no mention of how to get a clickable link to a sitemap on a Web footer.

    any help would be appreciated.

    Hello

    You can try to front page of the site hyperlink to any text that would open the sitemap on the mouse action.

    For example, domain.com/sitemap.xml, enter in this format in hyperlink with any text or image that you can place on the page footer area.

    Thank you

    Sanjit

  • Help with inserting image! It does not appear...

    Hello. I am a newbie and really wrong with the basics. Please can someone help me?

    All I'm doing is to insert a logo at the bottom of the page (or as much as really!) I inserted the file on the page that shows fine in dreamweaver, but it doesn't seem to 'put' and when I check the page online that shows simply that the name of the image.

    You're prob. saying "duhhh" in your head right now! but I'm used to photoshop and illustrator, I find dreamweaver so complicated!

    You can see what I mean on my topic page - www.sarahray.co.uk/about.htm (down under in Scripture it says logo AOI. This is what I'm trying to put.)

    Any help MUCH appreciated! XX

    Still, you define a local site folder in Dreamweaver?

    Sites > Manage Sites > new...

    If you ignore this critical first step all your links will be broken.

    Start here:

    http://www.Adobe.com/devnet/Dreamweaver/articles/first_website_pt1.html

    Nancy O.
    ALT-Web Design & Publishing
    Web | Graphics | Print | Media specialists
    http://ALT-Web.com/
    http://Twitter.com/ALTWEB

  • Need help with insertion of records

    I am new to develop dynamic web pages. I followed the instructions step by step in the files using Dreamweaver 8, but for some reason any this code does not work. I have links to the database. I have the set of records and and the insert record everything correct, or at least I thought I had. Can someone help me please. I'm losing my mind. Thanks in advance.

    I took a break from that and when I came back to it I realized it was a problem with my database, not my code. Thanks anyway.

  • Need help with insert

    Hello
    When inserting records into the table, I get the below error. I tried a few options, but its not solving my problem, could u pls help me on this.

    Table script:
    -------------
    create table test
    (
    datadate number (12).
    sla_met_time varchar2 (40),
    location varchar2 (20));

    My sql:
    --------
    Insert in the test
    values (&,(&2) 1 & 3);

    commit;
    "exit";

    Values:
    -------
    & 1-> 20101205
    & 2-> 12/06 03.20.31AM
    & 3-> US

    Calling script:
    --------------
    sqlplus-s user/pwd@db @/home/tes/test.sql $usdate, $ustime $usloc

    Error:
    ------
    old 2: values (1, 2 & 3)
    new 2: values (20101205,12/06,03.20.31AM,US)
    values (20101205,12/06,03.20.31AM,US)
    *
    ERROR on line 2:
    ORA-00917: lack of comma


    Also, I'm passing "12/06 03.20.31AM" for "and 2", but in the new value his impression that the "12/06,03.20.31AM".»
    I did not understand how extra comma came after "12/06.

    Please help me on this. Thank you.

    Hello

    You must pass the VARCHAR values in quotes and should not include a comma between the two.

    &1 --> 20101205
    &2 ---> '12/06 03.20.31AM'
    &3 ---> 'US'
    

    See you soon

    VT

  • Help with insert or import swf file in the model of the open fla file

    Can someone show me how insert or import a swf file in the template fla file.

    I have a FLA open temple and after importing a SWF file, run the test and the swf file does not work.

    Did I miss something?

    Thank you

    Import a swf in a fla is not the way to get to each other.  Any actionscript in a swf file is lost.  You need to load the file swf dynamically either or you must copy the timeline of the FLA that the swf is made from to the other fla.

  • I need help with an installation failure to interpret and troubleshoot a Setup log.

    Background: A few years ago, many editors of cinema used Final Cut Pro 6 (also contained in Final Cut Studio 2) for their editing projects.  Shared Apple Final Cut X uses a different format that is not compatible with FCP6.  Sometimes, these editors are called to work on a few historical projects that have been published in FCP6 and need this version to run now.

    Starting with OS X Lion, FCP6 would install not in Lion and thereafter.

    According research by Jeremy Johnston as noted on his blog, he discovered that Apple has inserted a file in the folder CoreServices in the Library folder of the system folder that causes versions the version Final Cut Pro X (and other older Apple programs in the same situation) do not settle.  He suggested changes to this file that would seek to prevent interfering with the installation of FCP6 in Lion, many users of final cut PRO 6 were successful in their efforts to install in Lion and work with it.

    Later in a discussion update on installing FCP6 in Mavericks, HawaiianHippie determined that the simplest way to perform the installation of FCP6 was simply copy this file and remove it from the system folder, install FCP6 and then restore the copied file:

    https://discussions.Apple.com/message/26309669#26309669

    I used this method with success to install FCS2 in Yosemite:

    [click on images to enlarge]

    However, in my attempts to install FCS2 in El Capitan, it fails in the last 5% to install the first DVD:

    First of all, I need advice on how to display an extremely large Setup log in this thread (on MacRumors, it is a method to insert a 'code' in a small box that can be the object of a scrollbar if necessary to read all along).  I am unable to find such a method to post here.

    Then once approved, I need help to determine which component is causing the installation to fail and perhaps this element can be omitted from the installation:

    If this element is not required, then maybe FCP6 can be installed successfully without it.  And if that omitted element is necessary, perhaps a manual method to install it can be determined by pacifists.

    It is my goal to help those who need to install and use FCP6 on their new Macs running El Capitan.

    Here is the post on MacRumors with pre-installed Setup log:

    http://forums.MacRumors.com/threads/i-need-help-with-an-installation-failure-to-interpret-and-troubleshoot-an-Installer-log.1954786/#post-22541389

  • EliteBook 8730w: need help with reset password BIOS HP Elitebook 8730w

    Dear community, I have a HP Elitebook 8730w and I forgot the BIOS password. I tried everything I could remember, I slept several days above to remind him, but I'm lost. I contacted HP support and they said that they would not help with a file of type smc.bin (which has been mentioned in many forums). No idea how to fix? I need to change the HARD disk but do not dare to do so that I can not configure the new HDD or SSD in BIOS.

    Help would be appraciated. I do not directly post P/N and S/N, due to privacy regulations in this forum. But if anyone can help me, please send a message and I'll post all the necessary details.

    I am a student and have small budget so I was willingly using this Elitebook old but fine. But now I'm really in trouble.

    @cecilia78

    Download these files.

    https://www.dropbox.com/sh/zu4kdgxm052l87d/AAAMi-k fX4AVH8oTCbsOM4X9a? DL = 0

    Insert a clean USB flash drive.

    Then run USB Image tool.

    Choose the flash drive, and then click RESTORE.

    Remove the flash drive after the restore.

    Insert a locked in a portable flash drive and boot. "If the HARD drive is installed remove before start".

    At C:\OUTPUT, type CD...   "And then press ENTER.

    HPBR of type "and then press ENTER.

    First thing is to save your settings.

    Select 3 # re-program.

    Press "S" to save the system information.

    Type HPBR and press ENTER.

    Select 'of FIRST BROADCAST.

    Then select the model.

    After the restart to repeat, same as above but this time SELECT 'SECOND RUN.

    Some instructions here. "If you can't boot from USB there are instructions for making a bootable HARD drive."

    http://mazzifsoftware.blogspot.com/2014/01/HP-BIOS-d ebloquer-for - dos.html

    More details here.

    http://forums.mydigitallife.info/threads/49497-HP-Probook-Elitebook-BIOS-password-reset-utility

    REO

    I must inform you that these services are not endorsed by HP, and that HP is not responsible for any damages that may occur to your system using these services. Please be aware that you do so at your own risk.

  • Help with service pack 3 to install - "" the component that you are trying to use is on a CD-ROM... "."

    original title: help with service pack 3 installation

    I get the message to update and install service pack 3, but every time I try it can not be installed. "the component that you are trying to use is on a CD-ROM or removable disk that is not in vain. Insert the microsoft excel 2002 disc, and then click ok' I have no disk, what do I do

    Hello

    Try to install the stand-alone version of the Service Pack by this link:

    http://www.Microsoft.com/download/en/details.aspx?displaylang=en&ID=24

  • Need help with windows defender. all my files folders pictures everythiing disappeared and I find myself with this black screen and it is not all good: o)

    Need help with windows defender. all my files folders pictures everythiing disappeared and I find myself with this black screen and it is not all good: o)

    I don't know why vista windows no longer charge, or when the files and folders disappeared

    How Windows Defender is on this problem?

    Follow these steps to try to solve your problems of boot.

     

     

    Restore point:

    Try typing F8 at startup and in the list of Boot selections, select Mode safe using ARROW top to go there > and then press ENTER.

    Try a restore of the system once, to choose a Restore Point prior to your problem...

    Click Start > programs > Accessories > system tools > system restore > choose another time > next > etc.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

     

    If restore work not and you do not have a Vista DVD from Microsoft, do a repair disc to do a Startup Repair:

    Download the ISO on the link provided and make a record of repair time it starts.

    Go to your Bios/Setup, or the Boot Menu at startup and change the Boot order to make the DVD/CD drive 1st in the boot order, then reboot with the disk in the drive.

    At the startup/power on you should see at the bottom of the screen either F2 or DELETE, go to Setup/Bios or F12 for the Boot Menu.

    When you have changed that, insert the Bootable disk you did in the drive and reboot.

    http://www.bleepingcomputer.com/tutorials/tutorial148.html

    Link above shows what the process looks like and a manual, it load the repair options.

    NeoSmart containing the content of the Windows Vista DVD 'Recovery Centre', as we refer to him. It cannot be used to install or reinstall Windows Vista, and is just a Windows PE interface to recovering your PC. Technically, we could re-create this installation with downloadable media media freely from Microsoft (namely the Microsoft WAIK, several gigabyte download); but it is pretty darn decent of Microsoft to present Windows users who might not be able to create such a thing on their own.

    Read all the info on the website on how to create and use:

    http://NeoSmart.net/blog/2008/Windows-Vista-recovery-disc-download/

    ISO Burner:http://www.snapfiles.com/get/active-isoburner.html

    It's a very good Vista startup repair disk.

    You can do a system restart tool, system, etc it restore.

    It is NOT a disc of resettlement.

    And the 32-bit is what normally comes on a computer, unless 64-bit.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Data recovery:

    1. slave of your hard drive in another computer and read/save your data out there.

    2. put your Hard drive in a USB hard drive case, plug it into another computer and read/save from there.

    3 Alternatively, use Knoppix Live CD to recover data:

    http://www.Knopper.NET/Knoppix/index-en.html

    Download/save the file Knoppix Live CD ISO above.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    http://isorecorder.alexfeinman.com/isorecorder.htm

    Download the Vista software from the link above.

    After installing above ISO burning software, right click on the Knoppix ISO file > copy the Image to a CD.

    Knoppix is not installed on your PC; use only the resources of your PC, RAM, graphics etc.

    Change the boot order in YOUR computer/laptop to the CD/DVD Drive 1st in the boot order.

    Plug a Flash Drive/Memory Stick, BOOT with the Live CD, and you should be able to read the hard drive.

    When the desktop loads, you will see at least two drive hard icons on the desktop (one for your hard drive) and one for the USB key.

    Click on the icons of hard drive to open and to understand which drive is which.

    Click the icon for the USB drive and click on "Actions > Change the read/write mode" so you can write to disk (it is read-only by default for security reasons).

    Now to find the files you want to back up, just drag and drop them on the USB. When you're done, shut down the system and remove the USB key.

    See you soon.

    Mick Murphy - Microsoft partner

  • 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

  • Need help with refresh region Skillbuilders Modal report

    Oracle, Oracle 11g EE 11.2.0.4.0

    Oracle APEX 4.2.5.00.08

    I have a page (Page 1) that has a button to open a modal (Page 2) based on the Skillbuilders Modal plugin using dynamic measurements.  The guide below was a great help in getting my features you want partially working.  As for the guide, I have a region report (non-IR), which has a link icon column to open a modal for updates of Records.  Also in this part of the report, I have a button that appears only for when there is no record to update, and only a new record can be created (IE insert).  Both the report link column and open button the same modal page however as on updates is a value for P1_GRANT_ID passed on to Page 2.  For news, region 1 Page report will refresh to reflect the updated after closing the modal values.  However, when I create a new record in the modal, the new record does not appear on Page 1 after its closure.

    http://ruepprich.WordPress.com/2013/07/11/skillbuilders-modal-page-instructions/

    Region report:

    SELECT g.*,
           'Q'||TO_CHAR(g.begin_date,'Q') quarter
      FROM lti_grants g
    WHERE grant_id = :P1_GRANT_ID
    
    

    Page, article to submit:  P1_GRANT_ID

    Element on the page:

    Name: P1_GRANT_ID

    Display in the form:  Hidden

    Protected value: NO.

    Source:  Still, replacing value that exists in session state

    Type of source:  Database column

    Source of value or an expression:  GRANT_ID

    The session state protection: Without restriction

    Page 2 has automated line (DML) treatment to manage the insertion/updates already and will return the new record PK in P2_GRANT_ID.  After the process of DML (seq n ° 5), I have a process after submit (seq #10) in an attempt to set the State of session using P1_GRANT_ID.

    BEGIN
      APEX_UTIL.SET_SESSION_STATE('P1_GRANT_ID',:P2_GRANT_ID);
    END;
    
    

    Appears not to effect in obtaining registration appears when updating of Page 1 report region thus immediately Page 2 I have also created a branch (Page 2 stays)

    Set these points:  P1_GRANT_ID

    With these values: & P2_GRANT_ID.

    This did not help either.  My understanding is that P1_GRANT_ID should be sent as a result of partial page refresh.  I watched during the debugging session state and the use of Firebug, but I do not understand why P1_GRANT_ID takes a value with inserts Records in Page 2.  Any suggestions?


    Given that your report has defined "Submit element Page = P1_GRANT_ID', each update that examines the value of page on the P1_GRANT_ID and by submitting via Ajax for the update. Remove this attribute and I think you'll have a chance.

    If this does not work, I would check P2_GRNT_ID to make sure that it is. Straight out of the wizard process DML return the primary key in an element.

    Greg

    [email protected]

  • Need help with SQL/PL/SQL for Dates

    Hi Experts - need help with a SQL query.

    I need to insert some date fields in a table called CALENDAR_PERIOD.

    Current data in CALENDAR_PERIOD table with their data types:

    STARTPERIOD (DATE) YEAR (NUMBER) PERIOD_LABEL (Varchar2 255)

    02/11/2014 2014 2014/02/11 SUN

    03/11/2014 2014 14/03/11 MON

    04/11/2014 2014 11/04/14 MAR

    I have to increment above values up to the year 2025. I don't know how to write SQL and increment of these values.

    Ex: My next value should insert: 05/11/2015 2014 11/05/14 WED like that I need to insert data until 12 31, 2025.

    Can you please help me with PL/SQL block?

    Really appreciate your help!

    DB version:

    Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    PL/SQL Release 11.2.0.3.0 - Production

    CORE Production 11.2.0.3.0

    AMT for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production

    NLSRTL Version 11.2.0.3.0 - Production

    Thank you
    Sandy

    Hello Sandy,

    Maybe something like

    INSERT INTO calendar_period (startperiod, year, period_label)

    SELECT DATE '' 2014-11-04 + LEVEL

    , TO_NUMBER (TO_CHAR (DATE '' 2014-11-04 + LEVEL, "YYYY"))

    , TO_CHAR (DATE '' 2014-11-04 + LEVEL, "MM/DD/YY DY")

    OF the double

    CONNECT BY LEVEL<= date="" '2025-12-314="" -="" date="">

    ;

    ((mais je ne comprends pas pourquoi nous créons une telle table "année" et "period_label" peuvent être calculé à partir de startperiod))

    Best regards

    Bruno Vroman.

  • help with this thread using oracle 7.3

    Dear expert;

    On this thread, I am using

    Help with this

    but I'll need help more with additional information in this regard. see examples of data below

    Hello experts.

    I use oracle 7.3. Therefore, I have the sample data below

    create the table table_one

    (

    req_week varchar (1000).

    Username varchar (1000).

    sale number (30),

    place varchar (1000).

    break_sales number (30)

    );

    insert into table_one values ("week 1", 'John', 100, "NY", 2 ").

    insert into table_one values (' week 1', 'Chris', 20, "TX", 3 ')

    insert into table_one values ("week 1", "Melissa", 80, 'GOES', 4 ')

    insert into table_one values (' week 2', 'Katy', 40 'SC', 1 ")

    insert into table_one values (' week 2', 'Angle', 10, 'NC', 2 ')

    insert into table_one values (' week 2', "Vick", 30, 'CA', 3 ')

    insert into table_one values (' week 3', 'Zack', 60 'CA', 1 ")

    insert into table_one values (' week 3', 'Deb', 60 'NM', 2 ')

    insert into table_one values (' week 3', 'Antoine,"60,"TX", 3 ')

    necessary results

    I need the top 2 sales in a place a week

    expected results

    req_week username place sales

    Week1 John 100 NY

    Week1 Melissa 80'S

    Semaine2 Katy 40 SC

    Semaine2 Vick 30 CA

    Semaine3 Zack 60 TX

    Semaine3 Deb 60 NM

    Note, in this particular case, if there is equality in sales, then use the break_sales column as a case. The break_sales was never a tie... it is so far the query and it does not work as expected

    SELECT    d.req_week, d.username, d.sales, d.place
    FROM      nikeus_report.dbo.table_one  d
    ,        nikeus_report.dbo.table_one  o
    WHERE    d.req_week  = o.req_week
    AND      d.sales    <=  o.sales   
    GROUP BY  d.req_week, d.username, d.sales, d.place
    HAVING    COUNT (*)  <= 2         
    ;
    
    

    Any help is appreciated. Thank you

    Hello

    It seems that your existing query is very good, he's going; Just add the conditions for breaking in the WHERE clause:

    SELECT d.req_week

    d.username

    d.sales

    d.place

    FROM table_one d

    table_one o

    WHERE d.req_week = o.req_week

    AND (d.sales< >

    OR (d.sales = o.sales

    AND d.break_sales > = o.break_sales

    )

    )

    GROUP BY d.req_week

    d.username

    d.sales

    d.place

    HAVING COUNT (*)<=>

    ORDER BY d.req_week

    COUNT (*)

    ;

    Thanks for posting the CREATE TABLE and INSERT statements; that really helps.

  • 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

Maybe you are looking for