Can I use a cursor like this ...
I have 10 columns that are named block_1 through block_10. I want to carry out some validation on the 10 columns but I do not want to use 10 separate conditional statements to process them. So what I would like to do is use a FOR LOOP to return a number into the variable COL_NUM, I will then use this value to numerically increment the column names from 1 to 10. Then hope to use the concatenated results which include the cursor variable to form an IF THEN statement that will be looped through. WHat I have does not work, Is this because using cursor in this way cant be done or is it for some other reason?
OPEN get_invalid_cur;
LOOP
FETCH get_invalid_cur INTO p_rec;
EXIT
WHEN get_invalid_cur%NOTFOUND;
upl_id_num := p_rec.upl_id;
FOR col_num IN 1..10
LOOP
fk_chk_blk_id := 'p_rec.fk_chk_blk_id_' || col_num;
block := 'p_rec.block_' || col_num;
IF fk_chk_blk_id IS NULL AND block > 0 THEN
p_error_desc := p_error_desc || ' (FK violated BLOCK)';
UPDATE fmbsite.fbt_doc_bulk_upload SET error_desc = p_error_desc WHERE upl_id = p_rec.upl_id AND created_by = user;
END IF;
END LOOP;
END LOOP; -- Loop for get_invalid_cur
CLOSE get_invalid_cur;I want to do the above so that I don't have to do the following:
OPEN get_invalid_cur;
LOOP
FETCH get_invalid_cur INTO p_rec;
EXIT
WHEN get_invalid_cur%NOTFOUND;
upl_id_num := p_rec.upl_id;
IF p_rec.fk_chk_blk_id_1 IS NULL AND p_rec.block_1 > 0 THEN
p_error_desc := p_error_desc || ' (FK violated BLOCK_1)';
UPDATE fmbsite.fbt_doc_bulk_upload SET error_desc = p_error_desc WHERE upl_id = p_rec.upl_id AND created_by = user;
END IF;
IF p_rec.fk_chk_blk_id_2 IS NULL AND p_rec.block_2 > 0 THEN
p_error_desc := p_error_desc || ' (FK violated BLOCK_2)';
UPDATE fmbsite.fbt_doc_bulk_upload SET error_desc = p_error_desc WHERE upl_id = p_rec.upl_id AND created_by = user;
END IF;
and so on another 8 times ...
END LOOP; -- Loop for get_invalid_cur
CLOSE get_invalid_cur;Cheers
Benton
Edited by: Benton on Nov 22, 2010 11:59 AM
Benton wrote:
I have 10 columns that are named block_1 through block_10. I want to carry out some validation on the 10 columns but I do not want to use 10 separate conditional statements to process them. So what I would like to do is use a FOR LOOP to return a number into the variable COL_NUM, I will then use this value to numerically increment the column names from 1 to 10. Then hope to use the concatenated results which include the cursor variable to form an IF THEN statement that will be looped through. WHat I have does not work, Is this because using cursor in this way cant be done or is it for some other reason?
OPEN get_invalid_cur;
LOOP
FETCH get_invalid_cur INTO p_rec;
EXIT
WHEN get_invalid_cur%NOTFOUND;
upl_id_num := p_rec.upl_id;
FOR col_num IN 1..10
LOOP
fk_chk_blk_id := 'p_rec.fk_chk_blk_id_' || col_num;
block := 'p_rec.block_' || col_num;
IF fk_chk_blk_id IS NULL AND block > 0 THEN
p_error_desc := p_error_desc || ' (FK violated BLOCK)';
UPDATE fmbsite.fbt_doc_bulk_upload SET error_desc = p_error_desc WHERE upl_id = p_rec.upl_id AND created_by = user;
END IF;
END LOOP;
END LOOP; -- Loop for get_invalid_cur
CLOSE get_invalid_cur;I want to do the above so that I don't have to do the following:
OPEN get_invalid_cur;
LOOP
FETCH get_invalid_cur INTO p_rec;
EXIT
WHEN get_invalid_cur%NOTFOUND;
upl_id_num := p_rec.upl_id;
IF p_rec.fk_chk_blk_id_1 IS NULL AND p_rec.block_1 > 0 THEN
p_error_desc := p_error_desc || ' (FK violated BLOCK_1)';
UPDATE fmbsite.fbt_doc_bulk_upload SET error_desc = p_error_desc WHERE upl_id = p_rec.upl_id AND created_by = user;
END IF;
IF p_rec.fk_chk_blk_id_2 IS NULL AND p_rec.block_2 > 0 THEN
p_error_desc := p_error_desc || ' (FK violated BLOCK_2)';
UPDATE fmbsite.fbt_doc_bulk_upload SET error_desc = p_error_desc WHERE upl_id = p_rec.upl_id AND created_by = user;
END IF;
and so on another 8 times ...
END LOOP; -- Loop for get_invalid_cur
CLOSE get_invalid_cur;Cheers
Benton
Edited by: Benton on Nov 22, 2010 11:59 AMUse tag
Regards,
Sayan M.
ps. i'm going to lunch... will read and answer later
Similar Messages
-
Can I use the breakpoints like this?
I try to use the modulo breakpoints and the relative breakpoints together to create a row by row scan .
Can I design like that
昨天是今天的昨天
明天是今天的明天
今天是昨天的明天
是明天的昨天
Attachments:
mytry.vi 114 KBHello,
Yes, modulus breakpoints can be used to generate pulses at even intervals through your moves. To do this, you would load your initial breakpoint position to determine what position value will be used for the first breakpoint and then set the breakpoint modulus to determine the position interval for subsequent breakpoints to be set. If your motion will be occurring in a grid, you can reset your breakpoint position for each line and then reload the modulus for the reverse direction.
Try this and let me know if you have any additional questions on this issue.
Regards,
Scott R.
Applications Engineer
National Instruments -
The "apple ID Password" box along with the keyboard pops up when I turn the iPad on and it stays there. I have changed my email address on my iMac and also changed my password. The old email address is still on the iPad. Anyway, I can't use the iPad because can't get the apple id password box to go away. Thanks for any help!
This is an older photo but the sleep and home buttons are still in the same place on all iPads. The home button is the round button at the bottom of the iPad and the sleep button is also called the on/off button and it is at the top right corner of the iPad.
-
How can I use a class like this?
public class Test<N, T extends Test<N, T>> {
public static void main(String[] args) {
Test<String, Test<String, Test>> test = null; //compile failed...
}I could suggest the following example:public class Test<N, T extends Test<N, T>> {
public void op(T t){
System.out.println("T: " + t.getClass().getName());
public static void main(String[] args) {
SubTest<String> subTest = new SubTest<String>();
subTest.op(subTest);
class SubTest<N> extends Test<N, SubTest<N>>{
}The problem is that T parameter should be a descendant of Test class -
I have a Macbook Air that had some coffee spilled on the keyboard and as a result the plus/equals key is no longer functioning. Can I use a program like Ukelele to re-program another key to do that function? Can I re-program a function key to do this function?
Water + electronics do not mix. Something was damaged insode, and the logic board may be corroding as is.
Take it to a Genius Bar for an evaluation and repair estimate.
This is accidental damage and not covered by warranty. -
I want to place an image in my InDesign document that can work with an address like this (\Resources\Thumb) rather than this (C:\Users\JSmith\Desktop\InDesign thumbnail Test\001\Resources\Thumb) is this possible? In a nutshell I want to point the link to an image in a directory that uses just part of the address.
I know this is something you can do in Maya with linked files. I guess InDesign just isn't there yet.
MW Design - Yeah I think "Relative paths" is the right term! I want to create a Layout with an image in the center of the page - and then duplicate my folder structure with that file. With that, I want to replace the Linked image file with a diferent image file of the same name. In effect having multiple files of the same layout with different images. I hope that made sense. -
How can I use lead/lag in this query
I have written this query which gives me the comparative data based on this week and next week. How can I use Lead/Lag in this query.
WITH CURRENT_WEEK
AS ( SELECT QPAQ.YEAR YEAR,
QPAQ.SEASON SEASON,
REGEXP_SUBSTR (QPAQ.SERIES_NAME, '[^/]+') ACC_SERIES,
TO_NUMBER (QPAQ.WEEK) WEEK,
MAX (QPAQ.FAILURES) FAILURES
FROM QAR_PLAN_ACC_QTY QPAQ, QAR_PLAN_THRESHOLD_LST QPTL
WHERE QPTL.CATEGORY_ID = 7
AND QPAQ.YEAR = QPTL.YEAR
AND QPAQ.SEASON = QPTL.SEASON
AND QPAQ.SERIES_NAME = QPTL.MODEL_SERIES
GROUP BY QPAQ.YEAR,
QPAQ.SEASON,
REGEXP_SUBSTR (QPAQ.SERIES_NAME, '[^/]+'),
TO_NUMBER (QPAQ.WEEK)
ORDER BY REGEXP_SUBSTR (QPAQ.SERIES_NAME, '[^/]+')),
LAST_WEEK
AS ( SELECT QPAQ.YEAR YEAR,
QPAQ.SEASON SEASON,
REGEXP_SUBSTR (QPAQ.SERIES_NAME, '[^/]+') ACC_SERIES,
TO_NUMBER (QPAQ.WEEK + 1) WEEK,
MAX (QPAQ.FAILURES) FAILURES
FROM QAR_PLAN_ACC_QTY QPAQ, QAR_PLAN_THRESHOLD_LST QPTL
WHERE QPTL.CATEGORY_ID = 7
AND QPAQ.YEAR = QPTL.YEAR
AND QPAQ.SEASON = QPTL.SEASON
AND QPAQ.SERIES_NAME = QPTL.MODEL_SERIES
GROUP BY QPAQ.YEAR,
QPAQ.SEASON,
REGEXP_SUBSTR (QPAQ.SERIES_NAME, '[^/]+'),
TO_NUMBER (QPAQ.WEEK)
ORDER BY REGEXP_SUBSTR (QPAQ.SERIES_NAME, '[^/]+'))
SELECT CURRENT_WEEK.YEAR,
CURRENT_WEEK.SEASON,
CURRENT_WEEK.ACC_SERIES,
CURRENT_WEEK.WEEK,
CURRENT_WEEK.FAILURES,
(CURRENT_WEEK.FAILURES - LAST_WEEK.FAILURES) FAILURES_COMPARE
FROM LAST_WEEK, CURRENT_WEEK
WHERE CURRENT_WEEK.WEEK = LAST_WEEK.WEEK(+)
ORDER BY CURRENT_WEEK.WEEK;Output is like this.
YEAR SEASON MODEL WEEK FAILURES Failures_COMPARE
1 2011 SUMMER VGP-BMS15 49 10
2 2011 SUMMER VGP-BMS15 50 28 18
3 2011 SUMMER VGP-BMS15 51 30 2
4 2011 SUMMER VGP-BMS15 52 40 10Edited by: BluShadow on 06-Jan-2012 13:26
added {noformat}{noformat} tags. Please read {message:id=9360002} to learn to do this yourself in future.You would jettison the entire LAST_WEEK subquery. Then replace your failure calculation with
current_week.failure - lag(current_week.failure) over (order by current_week.year, current_week.week) as failures_compareI suppose you might want to think about renaming the sub-query as well ....
Cheers, APC
Edited by: APC on Jan 6, 2012 1:41 PM -
How to use parrallel cursor in this code
hi can anyone expalin me how to use parallel cursor for this code ...
loop at itabkpf.
read table ibsegpar_fu with key
belnr = itabkpf-belnr
gjahr = itabkpf-gjahr
bschl = '25' .
Start insert by Pradeep 20082008
sort: itabkpf by belnr,
itabsegpar by belnr.
End insert by Pradeep 20082008
if sy-subrc = 0. "Deleted by pradeep 20082008
select bukrs belnr gjahr bschl koart lifnr wrbtr
wskto pswbt zfbdt augbl augdt sgtxt rebzg rebzj
into corresponding
fields of table ibsegpar_fu_1 from bseg
where bukrs = itabkpf-bukrs and
belnr = itabkpf-belnr and
gjahr = itabkpf-gjahr and
augbl <> itabkpf-belnr and
rebzg <> space and
bschl = '25'.
loop at ibsegpar_fu_1.
Start insert by Pradeep 20082008
sort ibsegpar_fu_1 by belnr.
End insert by Pradeep 20082008
move-corresponding ibsegpar_fu_1 to itabseg.
move ibsegpar_fu_1-belnr to itabseg-augbl.
move ibsegpar_fu_1-rebzg to itabseg-belnr.
move ibsegpar_fu_1-rebzj to itabseg-gjahr.
*********to include code to pick the description for partical payment
select single * from bseg where
bukrs = ibsegpar_fu_1-bukrs and
belnr = ibsegpar_fu_1-belnr and
gjahr = ibsegpar_fu_1-gjahr and
augbl <> ibsegpar_fu_1-belnr and
rebzg = space and
bschl <> '25'.
move bseg-sgtxt to itabseg-sgtxt.
clear bseg.
*********end of code
itabseg-wrbtr = itabseg-wrbtr * -1.
itabseg-pswbt = itabseg-pswbt * -1.
select single budat into lsdat from
bkpf where bukrs = ibsegpar_fu_1-bukrs and
belnr = ibsegpar_fu_1-rebzg and
gjahr = ibsegpar_fu_1-rebzj.
if sy-subrc = 0.
move lsdat to itabseg-zfbdt.
endif.
append itabseg.
endloop.
endif. "Deleted by Pradeep 20082008
endloop.
loop at ibsegpar_fu.
sort ibsegpar_fu by belnr. " insert by pradeep
move-corresponding ibsegpar_fu to itabseg.
select bukrs belnr gjahr bschl koart lifnr wrbtr
rebzg rebzj sgtxt into corresponding
fields of table ibsegpar_fu_1 from bseg
where bukrs = ibsegpar_fu-bukrs and
gjahr = ibsegpar_fu-gjahr and
augbl = ibsegpar_fu-belnr and " Pradeep 20082008 Delete
augbl <> ibsegpar_fu-belnr and " Pradeep 20082008 Insert
rebzg = space and
bschl = '25'.
if sy-subrc = 0.
loop at ibsegpar_fu_1.
move ibsegpar_fu_1-rebzg to itabseg-rebzg.
move ibsegpar_fu_1-rebzj to itabseg-rebzj.
endloop.
move ibsegpar_fu-belnr to itabseg-augbl.
move itabseg-rebzg to itabseg-belnr.
move itabseg-rebzj to itabseg-gjahr.
itabseg-wrbtr = itabseg-wrbtr * -1.
itabseg-pswbt = itabseg-pswbt * -1.
select single budat into lsdat from
bkpf where bukrs = ibsegpar_fu-bukrs and
belnr = itabseg-rebzj and
gjahr = itabseg-rebzj.
if sy-subrc = 0.
move lsdat to itabseg-zfbdt.
endif.
append itabseg.
read table itabseg with key
belnr = itabseg-rebzg
gjahr = itabseg-rebzj
bschl = '31' .
if sy-subrc = 0.
delete itabseg index sy-tabix. "Deleted by Pradeep 20082108
endif.
endif.
endloop.
Start insert by Pradeep 20082008
loop at itabseg.
if itabseg-belnr = itabseg-augbl.
delete itabseg.
elseif itabseg-belnr = ' '.
delete itabseg.
endif.
endloop.
End insert by Pradeep 20082008hi can anyone expalin me how to use parallel cursor for this code ...
loop at itabkpf.
read table ibsegpar_fu with key
belnr = itabkpf-belnr
gjahr = itabkpf-gjahr
bschl = '25' .
Start insert by Pradeep 20082008
sort: itabkpf by belnr,
itabsegpar by belnr.
End insert by Pradeep 20082008
if sy-subrc = 0. "Deleted by pradeep 20082008
select bukrs belnr gjahr bschl koart lifnr wrbtr
wskto pswbt zfbdt augbl augdt sgtxt rebzg rebzj
into corresponding
fields of table ibsegpar_fu_1 from bseg
where bukrs = itabkpf-bukrs and
belnr = itabkpf-belnr and
gjahr = itabkpf-gjahr and
augbl <> itabkpf-belnr and
rebzg <> space and
bschl = '25'.
loop at ibsegpar_fu_1.
Start insert by Pradeep 20082008
sort ibsegpar_fu_1 by belnr.
End insert by Pradeep 20082008
move-corresponding ibsegpar_fu_1 to itabseg.
move ibsegpar_fu_1-belnr to itabseg-augbl.
move ibsegpar_fu_1-rebzg to itabseg-belnr.
move ibsegpar_fu_1-rebzj to itabseg-gjahr.
*********to include code to pick the description for partical payment
select single * from bseg where
bukrs = ibsegpar_fu_1-bukrs and
belnr = ibsegpar_fu_1-belnr and
gjahr = ibsegpar_fu_1-gjahr and
augbl <> ibsegpar_fu_1-belnr and
rebzg = space and
bschl <> '25'.
move bseg-sgtxt to itabseg-sgtxt.
clear bseg.
*********end of code
itabseg-wrbtr = itabseg-wrbtr * -1.
itabseg-pswbt = itabseg-pswbt * -1.
select single budat into lsdat from
bkpf where bukrs = ibsegpar_fu_1-bukrs and
belnr = ibsegpar_fu_1-rebzg and
gjahr = ibsegpar_fu_1-rebzj.
if sy-subrc = 0.
move lsdat to itabseg-zfbdt.
endif.
append itabseg.
endloop.
endif. "Deleted by Pradeep 20082008
endloop.
loop at ibsegpar_fu.
sort ibsegpar_fu by belnr. " insert by pradeep
move-corresponding ibsegpar_fu to itabseg.
select bukrs belnr gjahr bschl koart lifnr wrbtr
rebzg rebzj sgtxt into corresponding
fields of table ibsegpar_fu_1 from bseg
where bukrs = ibsegpar_fu-bukrs and
gjahr = ibsegpar_fu-gjahr and
augbl = ibsegpar_fu-belnr and " Pradeep 20082008 Delete
augbl <> ibsegpar_fu-belnr and " Pradeep 20082008 Insert
rebzg = space and
bschl = '25'.
if sy-subrc = 0.
loop at ibsegpar_fu_1.
move ibsegpar_fu_1-rebzg to itabseg-rebzg.
move ibsegpar_fu_1-rebzj to itabseg-rebzj.
endloop.
move ibsegpar_fu-belnr to itabseg-augbl.
move itabseg-rebzg to itabseg-belnr.
move itabseg-rebzj to itabseg-gjahr.
itabseg-wrbtr = itabseg-wrbtr * -1.
itabseg-pswbt = itabseg-pswbt * -1.
select single budat into lsdat from
bkpf where bukrs = ibsegpar_fu-bukrs and
belnr = itabseg-rebzj and
gjahr = itabseg-rebzj.
if sy-subrc = 0.
move lsdat to itabseg-zfbdt.
endif.
append itabseg.
read table itabseg with key
belnr = itabseg-rebzg
gjahr = itabseg-rebzj
bschl = '31' .
if sy-subrc = 0.
delete itabseg index sy-tabix. "Deleted by Pradeep 20082108
endif.
endif.
endloop.
Start insert by Pradeep 20082008
loop at itabseg.
if itabseg-belnr = itabseg-augbl.
delete itabseg.
elseif itabseg-belnr = ' '.
delete itabseg.
endif.
endloop.
End insert by Pradeep 20082008 -
Since I updated to iOs Mavericks I can't use some apps like Adobe Illustrator or Office. Why? What can I do? I need both of them for my work...
Need help on this too
-
Why doesn't my iTunes Radio give me the option to customize stations using "play more like this" and "never play this" in the star menu?
You can only "play more like this" on your custom stations. The pre-programmed ones cannot be altered, at least to my understanding
-
My wife just got this iPad mini and I want to copy the address book on my iPad 2 over to the mini. Can I use iCloud to do this and what are the steps. The 2 devices have different Apple IDs.
Download the "My Contacts Backup" app from App Store to your iPad 2. Make a backup and send it by email to your wife's address. Open this email from iPad mini and tap the attachment to import the contacts into iPad mini Contacts app.
Message was edited by: cheonweb -
CAn we write a query like this
CAn we write a query like this?
If not how can this be changed?
select col1,col2,col3.col4
from table 1
where col1,col2 in(select col1,col2 from table2)Or it may be identical:
SQL> CREATE TABLE t1 (c INT NOT NULL);
Table created.
SQL> CREATE TABLE t2 (c INT NOT NULL);
Table created.
SQL> INSERT ALL
2 INTO t1 VALUES (rn)
3 INTO t2 VALUES (rn)
4 SELECT rownum AS rn FROM user_tables WHERE rownum <= 15;
30 rows created.
SQL> BEGIN
2 DBMS_STATS.GATHER_TABLE_STATS(user,'T1');
3 DBMS_STATS.GATHER_TABLE_STATS(user,'T2');
4 END;
5 /
PL/SQL procedure successfully completed.
SQL> SELECT * FROM t1
2 WHERE EXISTS
3 ( SELECT 1 FROM t2 WHERE c = t1.c )
4
SQL> @xplan
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | 15 | 90 | 5 |
|* 1 | HASH JOIN SEMI | | 15 | 90 | 5 |
| 2 | TABLE ACCESS FULL | T1 | 15 | 45 | 2 |
| 3 | TABLE ACCESS FULL | T2 | 15 | 45 | 2 |
Predicate Information (identified by operation id):
1 - access("T2"."C"="T1"."C")
SQL> SELECT * FROM t1
2 WHERE c IN
3 ( SELECT c FROM t2 )
4
SQL> @xplan
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | 15 | 90 | 5 |
|* 1 | HASH JOIN SEMI | | 15 | 90 | 5 |
| 2 | TABLE ACCESS FULL | T1 | 15 | 45 | 2 |
| 3 | TABLE ACCESS FULL | T2 | 15 | 45 | 2 |
Predicate Information (identified by operation id):
1 - access("T1"."C"="T2"."C") -
Can I use my ipad2 like a laptop with word proseser . I want to do a cv
Yes. Of course you will need to get a word processor app.
-
How can I use a song like ringtone in IPhone5?
How can I use a song like ringtone in IPhone5?
http://techtips.salon.com/use-itunes-music-ringtones-iphone-3547.html
more hits for you
https://www.google.dk/search?client=opera&q=use+song+as+ringtone+on+iphone&sourc eid=opera&ie=utf-8&oe=utf-8&channel=suggest -
You can't use Contribute to edit this type of file
I've updated a few pages from a website, so they're just
variations of pages that used to work with Contribute. Now I'm
getting a message--on some of them--that "you can't used Contribute
to edit this type of file." These are html files with the extension
htm. They contain tables. They are based on templates. They don't
seem to have any other distinguishing properties. Exactly what kind
of files don't work? What might I be doing wrong? I teach this at a
college & my students are as puzzled as I am.Ancient thread, but if anyone else is googling this phrase I thought I might respond with a possible answer. I encountered the same error but could not find anything wrong with the page in question. Turned out the page getting the error message was fine! The issue was actually with a simple typo on the page that linked to that page--it was missing the extension (e.g., linking to "page2" instead of "page2.php". The web server (and Contribute's browser) were pulling up the page even though the extension was missing but Contribute didn't know what kind of file it was so it refused to allow editing.
Maybe you are looking for
-
My serial for my lightroom v5 dont work anymore... i am on win 8.1
Hi, i installed a new system , win 8.1, i downloaded lightroom 5.5 trial, and i put my v5 serial i have on my adobe account. It seems it doesnt work anymore. Do i have to make an upgrade ? Thanks for your help
-
Creating Forms (Text Fields)
I am using Class Room in a Book "Adobe Acrobat X ISBN-13 978-0-321-75125-6.In lesson 10 page 253, I completed all the properties for the "Order_Start.pdf." when I entered data in the "price" and "quantity" the "total" for that line updated as usual;
-
Can I use any acquistion card with Labview?
I have got a non NI acquistion card, how can I use LabVIEW to program it?
-
Hi, We are moving into the SAP ECC enviroment and need to understand the difference between the 2 Support Packs Release 600, Level 11 (support pack SAPKGPAD11) vs Release 604, Level 03 (support pack SAPK-60403INEAAPPL). Can anyone give us an indicati
-
Hi, I am trying to create an app in SP 2013 using a list template obtained from SP2010. First i did download the list template from SP2010 and uploaded that list template to the List Template Gallery of SP2013. Now, I am trying to create an App from