Back-referencing data using MODEL
Not sure how possible this is...
with t as (select 1 as id, 'blah blah' as txt from dual union all
select 2, '# header 1' from dual union all
select 3, '41 text line 1' from dual union all
select 4, '22 text line 2' from dual union all
select 5, '17 text line 3' from dual union all
select 6, 'garbage' from dual union all
select 7, '# header 2' from dual union all
select 8, '77 text line 4' from dual union all
select 9, '80 text line 5' from dual union all
select 10, '#80 old text line 5' from dual union all
select 11, '14 text line 6' from dual union all
select 12, 'more garbage' from dual)In an ordered sequence of data, "Header" details need determining for all subsequent rows that begin with a <numeric> or #<numeric> value,
such that the output of the above data would appear as below:
ID TXT HEADER
1 blah blah
2 # header 1
3 41 text line 1 # header 1
4 22 text line 2 # header 1
5 17 text line 3 # header 1
6 garbage
7 # header 2
8 77 text line 4 # header 2
9 80 text line 5 # header 2
10 #80 old text line 5 # header 2
11 14 text line 6 # header 2
12 more garbageIs there a way to do this purely in SQL, with the model clause, perhaps using iterations?
select id, txt, header
from t
model dimension by (id)
measures (txt txt, CAST(NULL AS VARCHAR2(30)) header)
rules
header[id is any] = ?
)I'm still trying to get my head around the usage of the model clause, especially trying to reference backwards with iterations and the until clause.
Cheers
Blu
edit: just in case it's not obvious... "header" details are lines beginning with #<non numeric>
Message was edited by:
BluShadow
Just for fun, a model clause solution:
SQL> with t as (select 1 as id, 'blah blah' as txt from dual union all
2 select 2, '# header 1' from dual union all
3 select 3, '41 text line 1' from dual union all
4 select 4, '22 text line 2' from dual union all
5 select 5, '17 text line 3' from dual union all
6 select 6, 'garbage' from dual union all
7 select 7, '# header 2' from dual union all
8 select 8, '77 text line 4' from dual union all
9 select 9, '80 text line 5' from dual union all
10 select 10, '#80 old text line 5' from dual union all
11 select 11, '14 text line 6' from dual union all
12 select 12, 'more garbage' from dual)
13 -- end of test data
14 select id
15 , txt
16 , header
17 from t
18 model
19 dimension by (id)
20 measures (txt, cast(null as varchar2(30)) header, cast(null as varchar2(30)) tmp)
21 rules
22 ( tmp[any] order by id
23 = case
24 when txt[cv()] like '# header%' then txt[cv()]
25 else tmp[cv()-1]
26 end
27 , header[any] order by id
28 = case
29 when txt[cv()] not like '# header%'
30 and translate(ltrim(substr(txt[cv()],1,instr(txt[cv()]||' ',' ')-1),'#'),'_0123456789','_') is null
31 then tmp[cv()]
32 end
33 )
34 /
ID TXT HEADER
1 blah blah
2 # header 1
3 41 text line 1 # header 1
4 22 text line 2 # header 1
5 17 text line 3 # header 1
6 garbage
7 # header 2
8 77 text line 4 # header 2
9 80 text line 5 # header 2
10 #80 old text line 5 # header 2
11 14 text line 6 # header 2
12 more garbage
12 rijen zijn geselecteerd.Regards,
Rob.
Similar Messages
-
Unable to display data no entry in the table without using Model clause
Hi,
I've an urgent requirement described below :
The previously posted Question has been answerted using Model Clause:
Is there any way out to solve it without using Model clause:
I've a table named as "sale" consisting of three columns : empno, sale_amt and sale_date.
(Please ref. The table script with data as given below)
Now if I execute the query :
"select trunc(sale_date) sale_date, sum(sale_amt) total_sale from sale group by trunc(sale_date) order by 1"
then it displays the data for the dates of which there is an entry in that table. But it does not display data for the
date of which there is no entry in that table.
If you run the Table script with data in your schema, then u'll see that there is no entry for 28th. Nov. 2009 in
sale table. Now the above query displays data for rest of the dates as its are in sale table except for 28th. Nov. 2009.
But I need its presence in the query output with a value of "sale_date" as "28th. Nov. 2009" and that of "total_sale" as
"0".
Is there any means to get the result as I require?
Please help ASAP.
Thanks in advance.
Create table script with data:
CREATE TABLE SALE
EMPNO NUMBER,
SALE_AMT NUMBER,
SALE_DATE DATE
SET DEFINE OFF;
Insert into SALE
(EMPNO, SALE_AMT, SALE_DATE)
Values
(100, 1000, TO_DATE('12/01/2009 10:20:10', 'MM/DD/YYYY HH24:MI:SS'));
Insert into SALE
(EMPNO, SALE_AMT, SALE_DATE)
Values
(100, 1000, TO_DATE('11/30/2009 10:21:04', 'MM/DD/YYYY HH24:MI:SS'));
Insert into SALE
(EMPNO, SALE_AMT, SALE_DATE)
Values
(100, 1000, TO_DATE('11/29/2009 10:21:05', 'MM/DD/YYYY HH24:MI:SS'));
Insert into SALE
(EMPNO, SALE_AMT, SALE_DATE)
Values
(100, 1000, TO_DATE('11/26/2009 10:21:06', 'MM/DD/YYYY HH24:MI:SS'));
Insert into SALE
(EMPNO, SALE_AMT, SALE_DATE)
Values
(100, 1000, TO_DATE('11/25/2009 10:21:07', 'MM/DD/YYYY HH24:MI:SS'));
Insert into SALE
(EMPNO, SALE_AMT, SALE_DATE)
Values
(200, 5000, TO_DATE('11/27/2009 10:23:06', 'MM/DD/YYYY HH24:MI:SS'));
Insert into SALE
(EMPNO, SALE_AMT, SALE_DATE)
Values
(200, 4000, TO_DATE('11/29/2009 10:23:08', 'MM/DD/YYYY HH24:MI:SS'));
Insert into SALE
(EMPNO, SALE_AMT, SALE_DATE)
Values
(200, 3000, TO_DATE('11/24/2009 10:23:09', 'MM/DD/YYYY HH24:MI:SS'));
Insert into SALE
(EMPNO, SALE_AMT, SALE_DATE)
Values
(200, 2000, TO_DATE('11/30/2009 10:23:10', 'MM/DD/YYYY HH24:MI:SS'));
Insert into SALE
(EMPNO, SALE_AMT, SALE_DATE)
Values
(300, 7000, TO_DATE('11/24/2009 10:24:19', 'MM/DD/YYYY HH24:MI:SS'));
Insert into SALE
(EMPNO, SALE_AMT, SALE_DATE)
Values
(300, 5000, TO_DATE('11/25/2009 10:24:20', 'MM/DD/YYYY HH24:MI:SS'));
Insert into SALE
(EMPNO, SALE_AMT, SALE_DATE)
Values
(300, 3000, TO_DATE('11/27/2009 10:24:21', 'MM/DD/YYYY HH24:MI:SS'));
Insert into SALE
(EMPNO, SALE_AMT, SALE_DATE)
Values
(300, 2000, TO_DATE('11/29/2009 10:24:22', 'MM/DD/YYYY HH24:MI:SS'));
Insert into SALE
(EMPNO, SALE_AMT, SALE_DATE)
Values
(300, 1000, TO_DATE('11/30/2009 10:24:22', 'MM/DD/YYYY HH24:MI:SS'));
COMMIT;
Any help will be needful for me
Regards,select sale_date,sum(sale_amt) total_sale
from
select empno,0 sale_amt,(sale_date + ao.rn) sale_date
from
select empno,sale_amt,sale_date ,(t.nxt_dt - t.sale_date) diff
from
select empno
,sale_amt,trunc(sale_date) sale_date
,trunc(nvl(lead(sale_date) over (partition by 1 order by sale_date),sale_date)) nxt_dt
from sale
) t
where (t.nxt_dt - t.sale_date) >1
) rec,(select rownum rn from user_objects where rownum<=200) ao
where ao.rn <=(rec.diff-1)
union all
select empno,sale_amt,trunc(sale_date) sale_date
from sale
group by sale_date
order by 1;
~~~~Guess this will serve the purpose...
Cheers Arpan -
How do I use Display Dialog to get back a date?
Can anyone tell me how to use Display Dialog to get back a date?
I am using the following code that does not work. It does not accept anything. And I have searched high and low for an answer to my question and found nothing.
repeat
display dialog "When should I remind you (date)?" default answer ""
try
if the text returned of the result is not "" then
set the requested_text to the date returned of the result as date
exit repeat
end if
on error
beep
end try
endrepeat
display dialog requested_text
The code is based on what I found in AppleScript 1-2-3 (page 300). It shows examples for getting text and numbers but not one for dates.
For what it is worth, my goal is to create a script that will convert an email from Evernote into an iCal Reminder. To do so, I want to ask the user (myself) for the reminder's date and time. I am assuming I need to ask for each separately. I also assume that once I get the date and time for the reminder, it should be relatively straightforward to 'make' a 'todo' with an alarm.
Thanks in advance.
-DavidHi David,
Try this:
repeat
set theCurrentDate to current date
display dialog "When should I remind you (date)?" default answer (date string of theCurrentDate & space & time string of theCurrentDate)
set theText to text returned of result
try
if theText is not "" then
set theDate to date theText -- a date object
exit repeat
end if
on error
beep
end try
end repeat
display dialog (date string of theDate & space & time string of theDate)
You might also have a look at this page of the AppleScript Language Guide.
Message was edited by: Pierre L. -
TM backup: can I use two drives to back up data on two other drives?
Hi to all!
I have with me a 1 TB/ Thunderbolt EHD [external hard drive], a Lacie 2 TB/FW, EHD, a Seagate 2 TB/ 2 USB, EHD, a Seagate 3 TB/ 2 USB, EHD and [to be purchased] a Seagate 2 TB/ 2 USB, EHD.
I mainly use my Mac for making HD videos using FCPX.
I am planning to use these drives in the following manner as indicated by the table below:
Drive:
a
1 TB,
Thunderbolt,
Buffalo
b
2 TB/ FW
LaCie
c
2 TB/ 2 usb
Seagate
d
3 TB/ 2 usb
Seagate
e
2 TB/ 2 usb
Seagate backup
[to be purchased]
f
500 GB, internal
Macintosh HD
Partitions
1
1
1
2
1
USAGE:
editing videos, one
active project at a time
mainly for camera
archives, music files,
FCP events, projects
and exported movies
same as the LaCie,
as a backup of data
intend to have 2
partitions of 1.5 TB each;
one partition for personal
data and the other partition
to back up data on the
Thunderbolt [current project]
intend to use this for
TM back up of my
Mac's internal HD
applications, documents etc.
backed up by:
one partition of 'd'
by the 2 TB Seagate
backup 'e'
I would like to know whether I could do these things:
Can I use the TM backup feature in this manner of using 2 separate drive/partition [e/d] to back up data on 2 other drives [f and a]?
Further, I am manually copying files from 'b' drive to 'c' drive; without incurring further expense, can I ensure that whatever I write onto the LaCie [b] gets copied to the 'c' drive automatically?
Any thoughts, suggestions and instructions in these matters are welcome.EXT. DRIVES:
a
1 TB
Thunderbolt
b
2 TB/FW
[LaCie]
c
2 TB/ USB
[Seagate]
d
3 TB/USB
[Seagate]
e
2 TB/USB
[Seagate]
USAGE:
scratch disk
[planning to have
only one active
project at a time]
camera footage
FCPX events, projects
and completed movies
Same as the LaCie,
as it's backup
To be used as TM
backup for my Mac's
internal and also to
the scratch disk.
Planning to have it in
2 partitions: to have
a 'secondary' copy of
my Mac's IHD on one
partition and to have
personal 'net retrievable'
data on the other partition.
'MY
OBSERVATIONS'
my projects are usually
less than 10 minutes
and hence I trust that
work would be fast and in
case of drive failure, I
would be losing only
one project.
I am importing camera footage
primarily into this drive and
being FW, data transfer is
fast.
Am manually copying
files from the LaCie
onto this.
This drive is not a
brand new one, but
has been given to me
by the company's
agent as a replacement
to my earlier 2 TB drive
which had failed.Hope
this also will not fail!
Because of the 'uncertain'
performance of the
3 TB Seagate, I intend
to have a copy of my
Mac's IHD in one
partition. I intend to place only
such data upon the other
partition that I will not be
greatly affected should the
drive fail.
If you can analyse this plan and give your insight upon this matter, I will be immensely happy.
Further, if this proposed use of the 3 TB Seagate is okay with you, I need to know how to remove the Thunderbolt from doing it's temporary role of TM backup and how to coronate the 3TB Seagate as its successor.
FYI, I would be switching off TM from functioning whenever I am editing video; I would be switching it on only after a full editing session.
Another question on my mind is this: do I need to partition the drive 'e' at all?
Message was edited by: somanna -
Can I use two different devices with different apple ID for backing up data on one machine without losing any data that was backed up with one device earlier?
The link is to a discussion started on 12/18 in the FiOS Internet forum. Here's the link I get now, however it is different than the link I pulled a few hours ago. If this system changes the link again, it may not work.
http://forums.verizon.com/t5/FiOS-Internet/Frustration-and-just-confused-with-internet-help-please/t...
You can also look for the topic, "frustration and just confused" in the FiOS Internet forum.
Here's a link that is in the thread that gives more detail.
https://secure.dslreports.com/faq/15984
Good Luck!
P.S. "Copper Contributor" is my "rank." gs0b is my user name.
If a forum member gives an answer you like, give them the Kudos they deserve. If a member gives you the answer to your question, mark the answer as Accepted Solution so others can see the solution to the problem. -
how do you remove back up data from the memory storage? my storage data states that i have over 80gb of data used for back ups and i dont know why as i use a external hard drive as a time machine .now my 250gb flash storage is nearly full.. HELP!
When Time Machine backs up a portable Mac, some of the free space will be used to make local snapshots, which are backup copies of recently deleted files. The space occupied by local snapshots is reported as available by the Finder, and should be considered as such. In the Storage display of System Information, local snapshots are shown as Backups. The snapshots are automatically deleted when they expire or when free space falls below a certain level. You ordinarily don't need to, and should not, delete local snapshots yourself. If you followed bad advice to disable local snapshots by running a shell command, you may have ended up with a lot of data in the Other category. Ask for instructions in that case.
See this support article for some simple ways to free up storage space. -
Can we use Time Machine to back up data on Time Capsule from the outside of network?
I have Time Capsule at home. Can I use Time Machine to back up data of portable nootebook when I am working at office?
If you mean over the internet, you can but it will be so slow and more than likely so unreliable it is a poor method to use. Remember all internet is limited to upload speed.
Lion does a temporary backup onto local hard disk.. which is useless of course if the hard drive is damaged.. but helps if you delete an important file. Then when you go back home and it discovers the TC is available it will then backup again from where it left off.
I think it is only a major issue if you are away from home for major lengths of time, weeks or months. -
Problems reading my backed up data on hard drive after using Time Machine
I have a MacBookPro and had to take it in for servicing. I backed up all my data using Time machine. They had to replace my battery, hard drive, and logic board, basically wiping my slate clean. When I got my computer back and plugged in my hard drive time machine came up asking if I wanted to restore a back up. I chose the drive. Then that drive disappeared from the desktop and changed the disk name from "BACKUP" to "disk1s4" and is unreadable. Cannot get anything off the hard drive.
Any idea how I can read my data off my hard drive. I have 3+ years of pictures of my 2 kids and all my music. The rest I could take or leave. But I would be devastated to lose my pictures.
Please help
Thank you
Message was edited by: Jlk51496
Message was edited by: Jlk51496Jlk51496 wrote:
When I got my computer back and plugged in my hard drive time machine came up asking if I wanted to restore a back up.
Hi, and welcome to the forums.
Do you mean this window?
or this one?
They are very different, obviously.
Try repairing the drive, per #A5 in [Time Machine - Troubleshooting|http://web.me.com/pondini/Time_Machine/Troubleshooting.html] (or use the link in *User Tips* at the top of this forum).
Why was your Mac seviced? What did they replace? -
I just transferred data using migration assistant from a macbook pro to a macbook. I am trying to log back into the user that was on the pro but is now on the macbook with the same password as before, and it says my password is incorrect?
Suggest you try the password for the Macbook, not the previous one.
-
HT1766 Is there way of accessing your back up data without the use of an i-phone?
Is there a way of accessing your back up data from the computor without the use of an i-phone?
If it wasnt activated prior icloud wont help now. Did you ever use the save and print option to "send it itunes"? I did that all the time prior to icloud to back up my docs. Then you can "copy from itunes" in the new document dialog.
I still recommend doing the export to iTunes to create a local back up copy on ocassion.
For future reference, To activate icloud for documents, go into the main settings app, tap icloud, then documents and data, and turn it on. Then go to the app (maybe numbers) further down the main settings list, tap it and turn on "use icloud".
Jason -
I am trying to back up and sync my iPhone 4 and it keeps telling me the iPhone is refusing the request to back up on the latest back up date that I want to use. I can only use an older backup that is not recent. Anyone know what is up?
Have you downloaded and installed an App Store app that you downloaded free from some website instead of from the App Store? If so, that's a stolen app, and you need to delete it.
-
RESETTING THE RESTRICTIONS PASSCODE - Even after restoring the iphone and bringing back the data from icloud you cannot reset your restrictions passcode as it is stored in the icloud backup.
Hello risenhauer,
Thanks for using Apple Support Communities.
To reset your Apple ID password without knowing your security questions or have access to the email account, you will need to contact Apple Account Security in your country. Links to contact can be found in the article below.
Apple ID: Contacting Apple for help with Apple ID account security
Take care,
Alex H. -
ADF View - Updated key values not updating referenced data in view (JSP)
I have a many-to-many relationship that links 2 tables (2 mandatory and 1 optional).
Relationship 1 is created via a view link.
Relationship 2 is selected from a view.
The optional relationship (3) is required based on a flag in the corresponding row for relationship 2.
To achieve this I have a page with 2 steps, step 1 selects relationship 2 and then the page decides whether relationship 3 is required or not.
The many-to-many relationship is created via a VO that contains the many-to-many table and references and includes some attributes from the other tables.
When I first select the relationship 2, the attributes from the referenced table are then set within the VO and by looking at these I can make my decision.
Now here's the problem....
If I go back and select and different relationship 2, the Id attribute (for the many-to-many table) is updated but the attributes are unchanged, this means that the flag I need to check is invalid.
Also, when I then select the appropriate value for relationship 3 (if required), the associated Id attribute is set but the referenced attributes from this table are not set (these are needed for other purposes).
Is there some setting I'm missing?
Is there some call I need to make to update the referenced data?
I know I could make all of my decisions based on the VOs that I am selecting from but it's much simpler (and less code) to just use the 1 view (less chance of bugs) - plus i'd like to understand why this is not working.
Thanks
AlI don't need to check it for data integrity reasons, I need to check the contents of certain values to determine what to do next, before i commit the data.
For example, if flag a is set then ask for extra information 'X' otherwise ask for extra information 'Y'. -
Model: Curve 8900
Provider: At&t
Platform: 4.2.0.108
I'm ready to throw this phone in the blender.... if I could only back up my data first. A couple of months ago the What's App application required an update. I updated it and ever since my phone has steadily had more and more issues. First, I kept getting this uncaught error message, shortly thereafter the 2 email accounts (both gmail) that I have linked to the account disappeared. The message icon shows that I have messages, but icons not there (I have tried the show all option). At one point the message icon started exponentially adding the number of messages until it got up to over 86,000. When I reboot the phone it goes back down and then steadily increases again... usually though it's more to 400 - 500 rather then tens of thousands. I have been trying to install updates and do a wipe of the BB so that I can start from scratch, unfortunately the application loader is unable to back up data. The desktop manager is unable to connect to the blackberry and indicates that an upgrade is required. I have tried doing the upgrade both directly from the phone and connected to the desktop manager, but nothing seems to work. If I try to upgrade the software directly from the BB, I get to the start download button and when I click, nothing happens. I have removed all applications except bberry app world and one game that I play, Pixelated Plus. Still nothing. Any ideas?Do you want to save the messages?
If not (and I think they are the problem) open the Desktop Software > Device > Delete Data and click the "select Data" option. Select the Messages to remove. Complete the prompts and finish.
Then, return to backup the entire device, and see if that is possible to complete this time with no messages.
Now, once the back up is done and you have your data, you can disconnect the device.
Now, use BBSAK to wipe the device and subsequently load the new operating system.
**If you cannot complete the backup again above, you might have to do without it, OR you can use the Desktop Software to sync your Address book, calendar, memos and tasks to Outlook. OR, you can easily install and use BlackBerry Protect to backup your device over the air to RIM servers, then once wiped and the new OS reloaded, you can use Protect to restore the data back to the 8900. << This you should do regardless.
Good luck, post back here as you have questions.
1. If any post helps you please click the below the post(s) that helped you.
2. Please resolve your thread by marking the post "Solution?" which solved it for you!
3. Install free BlackBerry Protect today for backups of contacts and data.
4. Guide to Unlocking your BlackBerry & Unlock Codes
Join our BBM Channels (Beta)
BlackBerry Support Forums Channel
PIN: C0001B7B4 Display/Scan Bar Code
Knowledge Base Updates
PIN: C0005A9AA Display/Scan Bar Code -
Help with reloading back up data
I had to restore my bb pearl 8120 the other day. Backed up all data and then had a few problems with it. I have now managed to sort it all but cant reload all my backed up data, I have lost a lot of phone number that I really need.
Any help with this would be fab.
ThanksHello,
Please provide more details, such as:
Specific BB Model (8120)
Specific BB OS level (all 4 octets)
Specific Desktop Software level (also 4 octets)
Carrier
Country
The specific symptoms you witnesses -- "cant reload all my backed up data" doesn't tell us much. Specific details of exactly the steps you attempt and exactly the results you see would be helpful.
Thanks!
Occam's Razor nearly always applies when troubleshooting technology issues!
If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
Join our BBM Channels
BSCF General Channel
PIN: C0001B7B4 Display/Scan Bar Code
Knowledge Base Updates
PIN: C0005A9AA Display/Scan Bar Code
Maybe you are looking for
-
How do I add a signature/watermark to my pictures without using Digimark?
I want to add my name on my pictures but I don't need to track them or follow them. If someone edits my name out oh well. I just want it for when I put it on the internet or give it to my friends and family.
-
Sun Oner Application Server 7 Admin Console doesn't start
When I start the Admin Console for Sun One Application Server 7, and after I login, the admin console doesn't display in the browser. I have tried starting the admin console with IE and Netscape browser, but the admin console has failed to start in e
-
How Can i deactivate a computer in itunes if i no longer have the computer?
How can I deactivate a computer in I Tunes if I no longer have the computer?
-
Why is there increased overhead(performance) in NAV than DISPLAY attribute?
Hi, I understand that navigational attibutes lead to increased overhead because of the additional joins: The join between Fact table and dimension table ( I guess on DIM ID) and then the additional join between the Dimension and the Master Data table
-
Replaced hard drive in Mac book pro now what
I just replaced the hard drive now what?