Help With SQL Script
Hi All ,
Here is my usecase. I have a table of following structure (History table):
Column A - Unique key
Column B - Foreign Key
Start Date
End Date.
My Data is corrupted due to some reason . Its supposed to be
StartDate End Date
1 MyID 2010-04-01 2013-10-07
2 MyID 2013-10-07 3000-12-31
It got corrupted and now it is
StartDate End Date
1 MyID 2010-04-01 2013-10-07
2 MyID 2010-04-01 3000-12-31
Basically I want end date of first row to be updated as start date of second row. Because of some coding issue this corruption happened.
Now i want to find out all the cases for which this happened.
I could find out all the rows for which multiple entries are there using :
Select * from table where B in (
Select B from table group by b having count(*) >1)
But i need only corrupted records. Can some one help me ??
Thanks in advance.
B1
Since you have not provided proper data, hope below table format matches your record set.
WITH T1 AS
( SELECT 1 COL1, 1 COL2, TO_DATE('2010-04-01','YYYY-MM-DD') START_DATE, TO_DATE('2013-10-07','YYYY-MM-DD') END_DATE FROM DUAL UNION ALL
SELECT 2, 1,TO_DATE('2013-10-07','YYYY-MM-DD'),TO_DATE('2013-11-30','YYYY-MM-DD') FROM DUAL UNION ALL
SELECT 3,1, TO_DATE('2013-10-07','YYYY-MM-DD'),TO_DATE('3000-12-31','YYYY-MM-DD') FROM DUAL UNION ALL
SELECT 4,2,TO_DATE('2014-01-01','YYYY-MM-DD'), TO_DATE('2014-03-31','YYYY-MM-DD') FROM DUAL UNION ALL
SELECT 5,2,TO_DATE('2014-01-01','YYYY-MM-DD'), TO_DATE('2014-12-31','YYYY-MM-DD') FROM DUAL)
SELECT * FROM T1;
OUTPUT:
COL1 COL2 START_DAT END_DATE
1 1 01-APR-10 07-OCT-13
2 1 07-OCT-13 30-NOV-13
3 1 07-OCT-13 31-DEC-00
4 2 01-JAN-14 31-MAR-14
5 2 01-JAN-14 31-DEC-14
Seems like you look for records whose START_DATE is not matching with the previous record's END_DATE. The logic I have used is (according to your data), the START_DATE of RECORD1=START_DATE of RECORD2. This is what you are looking for. Below is the query.
WITH T1 AS
( SELECT 1 COL1, 1 COL2, TO_DATE('2010-04-01','YYYY-MM-DD') START_DATE, TO_DATE('2013-10-07','YYYY-MM-DD') END_DATE FROM DUAL UNION ALL
SELECT 2, 1,TO_DATE('2013-10-07','YYYY-MM-DD'),TO_DATE('2013-11-30','YYYY-MM-DD') FROM DUAL UNION ALL
SELECT 3,1, TO_DATE('2013-10-07','YYYY-MM-DD'),TO_DATE('3000-12-31','YYYY-MM-DD') FROM DUAL UNION ALL
SELECT 4,2,TO_DATE('2014-01-01','YYYY-MM-DD'), TO_DATE('2014-03-31','YYYY-MM-DD') FROM DUAL UNION ALL
SELECT 5,2,TO_DATE('2014-01-01','YYYY-MM-DD'), TO_DATE('2014-12-31','YYYY-MM-DD') FROM DUAL)
SELECT COL1,COL2,START_DATE,END_DATE FROM(
SELECT COL1,COL2,START_DATE,END_DATE,
LEAD(START_DATE) OVER(PARTITION BY COL2 ORDER BY COL1,COL2) LEAD_COL
FROM T1)
WHERE
START_DATE = LEAD_COL
OR LEAD_COL IS NULL;
OUTPUT:
COL1 COL2 START_DAT END_DATE
2 1 07-OCT-13 30-NOV-13
3 1 07-OCT-13 31-DEC-00
4 2 01-JAN-14 31-MAR-14
5 2 01-JAN-14 31-DEC-14
Method 2 is also considering the condition END_DATE of record1 NOT EQUAL TO START_DATE OF record2.
WITH T1 AS
( SELECT 1 COL1, 1 COL2, TO_DATE('2010-04-01','YYYY-MM-DD') START_DATE, TO_DATE('2013-10-07','YYYY-MM-DD') END_DATE FROM DUAL UNION ALL
SELECT 2, 1,TO_DATE('2013-10-07','YYYY-MM-DD'),TO_DATE('2013-11-30','YYYY-MM-DD') FROM DUAL UNION ALL
SELECT 3,1, TO_DATE('2013-10-07','YYYY-MM-DD'),TO_DATE('3000-12-31','YYYY-MM-DD') FROM DUAL UNION ALL
SELECT 4,2,TO_DATE('2014-01-01','YYYY-MM-DD'), TO_DATE('2014-03-31','YYYY-MM-DD') FROM DUAL UNION ALL
SELECT 5,2,TO_DATE('2014-01-01','YYYY-MM-DD'), TO_DATE('2014-12-31','YYYY-MM-DD') FROM DUAL)
SELECT COL1,COL2,START_DATE,END_DATE FROM(
SELECT COL1,COL2,START_DATE,END_DATE,LAG(END_DATE)OVER(PARTITION BY COL2 ORDER BY COL1,COL2) LAG_COL,
LEAD(START_DATE) OVER(PARTITION BY COL2 ORDER BY COL1,COL2) LEAD_COL
FROM T1)
WHERE
START_DATE!=LAG_COL
OR START_DATE = LEAD_COL
OR LAG_COL IS NOT NULL
OR LEAD_COL IS NULL;
OUTPUT:
COL1 COL2 START_DAT END_DATE
2 1 07-OCT-13 30-NOV-13
3 1 07-OCT-13 31-DEC-00
4 2 01-JAN-14 31-MAR-14
5 2 01-JAN-14 31-DEC-14
Similar Messages
-
query #1
can anyone helpme set up two scripts.
1 i need to list all users that belong to a single role or for all roles,which would be grouped by role,the number of users in the role,when the role was granted,what options went with the grant and who granted it to them.
i need a sample or the the views that need to be involved to extract that information.
query #2
another script that i need is the following:
i need to list object privileges by user or all users,
appropriately grouped,given to the user,the name and type of the object,when the grant was given and with what options they were granted,and who granted them the privilege.
so if any body could help in these two scripts i 'll be very appreciative.
thanks in advance.You want to run reports at least for intervals of an hour. A whole day's report wouldn't contain anything that would stand out because everything levels out when looking at everything that occurred over a long period of time. AWR snapshots are automatically scheduled to be taken every hour because that's the ideal range to look at reports for.
-
Hi there,
What I`m trying to accomplish here is the following guys;
This would be the pseudo code that I`m trying to convert into proper SQL;
Declare @Parameter varchar(50)
now I`m trying to find out how to find whatever is in the @Parameter in the values of table column. something like this;
If @Parameter exists in (select column from table) then do something here else something else....
Thanks very much in advance for your help.do you want some thing like below
Declare @Parameter varchar(50)
If exists (select column from table where column = @Parameter)
begin
--do something here
END
else
Begin
--something
END
Thanks
Saravana Kumar C -
Need help with SQL Query with Inline View + Group by
Hello Gurus,
I would really appreciate your time and effort regarding this query. I have the following data set.
Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*20.00*-------------19
1234567----------11223--------------7/5/2008-----------Adjustment for bad quality---------44345563------------------A-----------------10.00------------19
7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765--------------------I---------------------30.00-------------19
Please Ignore '----', added it for clarity
I am trying to write a query to aggregate paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, 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_Number, Invoice_Type, Vendor_Number. When there are no multiple 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-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*10.00*------------19
7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765-------------------I---------------------30.00--------------19
The following is my query. I am kind of lost.
select B.Description, A.sequence_id,A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
from (
select sequence_id,check_date, check_number, invoice_number, sum(paid_amount) amount, vendor_number
from INVOICE
group by sequence_id,check_date, check_number, invoice_number, vendor_number
) A, INVOICE B
where A.sequence_id = B.sequence_id
Thanks,
NickIt looks like it is a duplicate thread - correct me if i'm wrong in this case ->
Need help with SQL Query with Inline View + Group by
Regards.
Satyaki De. -
I need help with this script please ASAP
So I need this to work properly, but when ran and the correct answer is chosen the app quits but when the wrong answer is chosen the app goes on to the next question. I need help with this ASAP, it is due tommorow. Thank you so much for the help if you can.
The script (Sorry if it's a bit long):
#------------Startup-------------
display dialog "Social Studies Exchange Trviva Game by Justin Parzik" buttons {"Take the Quiz", "Cyaaaa"} default button 1
set Lolz to (button returned of the result)
if Lolz is "Cyaaaa" then
killapp()
else if Lolz is "Take the Quiz" then
do shell script "say -v samantha Ok starting in 3…2…1…GO!"
#------------Question 1-----------
display dialog "Around age 11, many boys left their fathers to become…" buttons {"Scholars", "Warriors", "Apprentices"}
set A1 to (button returned of the result)
if A1 is "Apprentices" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#----------Question 2--------
display dialog "Most children were taught
to read so that they could understand the…" buttons {"Music of Mozart", "Bible", "art of cooking"}
set A2 to (button returned of the result)
if A2 is "Bible" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#------------Question 3---------
display dialog "In the 1730s and 1740s, a religious movement called the_______swept through the colonies." buttons {"Glorius Revolution", "Great Awakening", "The Enlightenment"}
set A3 to (button returned of the result)
if A3 is "Great Awakening" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#-----------Question 4--------
display dialog "_______ was
a famous American Enlightenment figure." buttons {"Ben Franklin", "George Washington", "Jesus"}
set A4 to (button returned of the result)
if A4 is "Ben Franklin" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#----------Question 5-------
display dialog "______ ownership gave colonists political rights as well as prosperity." buttons {"Land", "Dog", "Slave"}
set A5 to (button returned of the result)
if A5 is "Land" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#---------Question 6--------
display dialog "The first step toward guaranteeing these rights came in 1215. That
year, a group of English noblemen forced King John to accept the…" buttons {"Declaration of Independence", "Magna Carta", "Constitution"}
set A6 to (button returned of the result)
if A6 is "Magna Carta" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#----------Question 7--------
display dialog "England's cheif lawmaking body was" buttons {"the Senate", "Parliament", "King George"}
set A7 to (button returned of the result)
if A7 is "Parliament" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#--------Question 8-----
display dialog "Pariliament decided to overthrow _______ for not respecting their rights" buttons {"King James II", "King George", "King Elizabeth"}
set A8 to (button returned of the result)
if A8 is "King James II" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#--------Question 9------
display dialog "Parliament named ___ and ___ as England's new monarchs in something called ____." buttons {"William/Mary/Glorius Revolution", "Adam/Eve/Great Awakening", "Johhny/Mr.Laphalm/Burning of the hand ceremony"}
set A9 to (button returned of the result)
if A9 is "William/Mary/Glorius Revolution" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#---------Question 10-----
display dialog "After accepting the throne William and Mary agreed in 1689 to uphold the English Bill of _____." buttons {"Money", "Colonies", "Rights"}
set A10 to (button returned of the result)
if A10 is "Rights" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#---------Question 11------
display dialog "By the late 1600s French explorers had claimed the ___ River Valey" buttons {"Mississippi", "Ohio", "Hudson"}
set A11 to (button returned of the result)
if A11 is "Ohio" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#------Question 12---------
display dialog "______ was sent to ask the French to leave 'English Land'." buttons {"Johhny Tremain", "George Washington", "Paul Revere"}
set A12 to (button returned of the result)
if A12 is "George Washington" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#---------Question 13-------
display dialog "_____ proposed the Albany Plan of Union" buttons {"George Washingon", "Ben Franklin", "John Hancock"}
set A13 to (button returned of the result)
if A13 is "Ben Franklin" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#--------Question 14------
display dialog "The __________ declared that England owned all of North America east of the Mississippi" buttons {"Proclomation of England", "Treaty of Paris", "Pontiac Treaty"}
set A14 to (button returned of the result)
if A14 is "" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#-------Question 15-------
display dialog "Braddock was sent to New England so he could ______" buttons {"Command an attack against French", "Scalp the French", "Kill the colonists"}
set A15 to (button returned of the result)
if A15 is "Command an attack against French" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#------TheLolQuestion-----
display dialog "____ is the name of the teacher who runs this class." buttons {"Mr.White", "Mr.John", "Paul Revere"} default button 1
set LOOL to (button returned of the result)
if LOOL is "Mr.White" then
do shell script "say -v samantha Congratulations…you…have…common…sense"
else
do shell script "say -v alex Do…you…have…eyes?"
#------END------
display dialog "I hope you enjoyed the quiz!" buttons {"I did!", "It was horrible"}
set endmenu to (button returned of the result)
if endmenu is "I did!" then
do shell script "say -v samantha Your awesome"
else
do shell script "say -v alex Go outside and run a lap"
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end ifUse code such as:
display dialog "Around age 11, many boys left their fathers to become…" buttons {"Scholars", "Warriors", "Apprentices"}
set A1 to (button returned of the result)
if A1 is "Apprentices" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
return
end if
#----------Question 2--------
display dialog "Most children were taught to read so that they could understand the…" buttons {"Music of Mozart", "Bible", "art of cooking"}
set A2 to (button returned of the result)
if A2 is "Bible" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
return
end if
(90444) -
Where to find help with SQL Developer installation?
Hi,
I just want to try out SQL Developer and compare its capabilities to TOAD's. Unfortunately, I am not PC software savvy and now am stuck with a SQL Developer (sqldeveloper-1.2.2998) installation problem. When I clicked on the .exe file, I got a blank SQL Developer screen - there is nothing in the screen except a heading that reads 'Oracle SQL Developer'...
Does anyone know of a blog or a site that I can get some help with problems like mine?
Any help is much appreciated!Hi,
SQL Developer forum link:
"http://forums.oracle.com/forums/forum.jspa?forumID=260"
There are 2 versions of SQL Developer, with/without JRE.
Try out the full install version with JRE.
HTH
Zack -
Need help with SQL*Loader not working
Hi all,
I am trying to run SQL*Loader on Oracle 10g UNIX platform (Red Hat Linux) with below command:
sqlldr userid='ldm/password' control=issue.ctl bad=issue.bad discard=issue.txt direct=true log=issue.log
And get below errors:
SQL*Loader-128: unable to begin a session
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
Can anyone help me out with this problem that I am having with SQL*Loader? Thanks!
Ben PrusinskiHi Frank,
More progress, I exported the ORACLE_SID and tried again but now have new errors! We are trying to load an Excel CSV file into a new table on our Oracle 10g database. I created the new table in Oracle and loaded with SQL*Loader with below problems.
$ export ORACLE_SID=PROD
$ sqlldr 'ldm/password@PROD' control=prod.ctl log=issue.log bad=bad.log discard=discard.log
SQL*Loader: Release 10.2.0.1.0 - Production on Tue May 23 11:04:28 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL*Loader: Release 10.2.0.1.0 - Production on Tue May 23 11:04:28 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Control File: prod.ctl
Data File: prod.csv
Bad File: bad.log
Discard File: discard.log
(Allow all discards)
Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array: 64 rows, maximum of 256000 bytes
Continuation: none specified
Path used: Conventional
Table TESTLD, loaded from every logical record.
Insert option in effect for this table: REPLACE
Column Name Position Len Term Encl Datatype
ISSUE_KEY FIRST * , CHARACTER
TIME_DIM_KEY NEXT * , CHARACTER
PRODUCT_CATEGORY_KEY NEXT * , CHARACTER
PRODUCT_KEY NEXT * , CHARACTER
SALES_CHANNEL_DIM_KEY NEXT * , CHARACTER
TIME_OF_DAY_DIM_KEY NEXT * , CHARACTER
ACCOUNT_DIM_KEY NEXT * , CHARACTER
ESN_KEY NEXT * , CHARACTER
DISCOUNT_DIM_KEY NEXT * , CHARACTER
INVOICE_NUMBER NEXT * , CHARACTER
ISSUE_QTY NEXT * , CHARACTER
GROSS_PRICE NEXT * , CHARACTER
DISCOUNT_AMT NEXT * , CHARACTER
NET_PRICE NEXT * , CHARACTER
COST NEXT * , CHARACTER
SALES_GEOGRAPHY_DIM_KEY NEXT * , CHARACTER
value used for ROWS parameter changed from 64 to 62
Record 1: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 2: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 3: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 4: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 5: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 6: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 7: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 8: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 9: Rejected - Error on table ISSUE_FACT_TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 10: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 11: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 12: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 13: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 14: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 15: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 16: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 17: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 18: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 19: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 20: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 21: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 22: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 23: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 24: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 39: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
MAXIMUM ERROR COUNT EXCEEDED - Above statistics reflect partial run.
Table TESTLD:
0 Rows successfully loaded.
51 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
Space allocated for bind array: 255936 bytes(62 rows)
Read buffer bytes: 1048576
Total logical records skipped: 0
Total logical records read: 51
Total logical records rejected: 51
Total logical records discarded: 0
Run began on Tue May 23 11:04:28 2006
Run ended on Tue May 23 11:04:28 2006
Elapsed time was: 00:00:00.14
CPU time was: 00:00:00.01
[oracle@casanbdb11 sql_loader]$
Here is the control file:
LOAD DATA
INFILE issue_fact.csv
REPLACE
INTO TABLE TESTLD
FIELDS TERMINATED BY ','
ISSUE_KEY,
TIME_DIM_KEY,
PRODUCT_CATEGORY_KEY,
PRODUCT_KEY,
SALES_CHANNEL_DIM_KEY,
TIME_OF_DAY_DIM_KEY,
ACCOUNT_DIM_KEY,
ESN_KEY,
DISCOUNT_DIM_KEY,
INVOICE_NUMBER,
ISSUE_QTY,
GROSS_PRICE,
DISCOUNT_AMT,
NET_PRICE,
COST,
SALES_GEOGRAPHY_DIM_KEY
) -
Hi,
I found this Apple script online and here's how it works:
tell application "QuickTime Player"
activate
try
if not (exists document 1) then display dialog "Please open a QuickTime movie." buttons {"Cancel"} default button 1 with icon 1
set thefile to (choose file name)
save document 1 in thefile
close document 1
end try
end tell
+I run the Apple script+
*1. It prompts me to open a movie file in Quicktime*
+I open a movie in Quicktime+
*2. It prompts me for an name and directory to save the new file in*
+I enter a name and directory+
*3. It saves a new reference movie in said directory with said name*
This is useful if I want to customize every file, but unfortunately, I just want to mass create reference movies for a whole bunch of files.
What I am looking for is for an Apple script that is a drag and drop application, so I can drop say 100 movie files or so, and have the Apple script create reference movie files with the same name and in the same directory automatically with no prompts.
Since I am unfamiliar with Apple script I was wondering if someone would be able to edit my existing script to do what I want.
Thanks so much for your help!Use Automator. It's great for repetitious tasks (like the one you've described), and it's very user-friendly. Open Automator, create a new workflow that executes the action you want, and you can apply that action to the resources you wish to edit.
Good resource here:
http://bit.ly/ -
I was wondering if someone could help me with a simple bit of action script 3. I need to make a movie clip (single_mc) disappear when the user clicks on the mouse (stop_btn). Here’s what I have so far.
function setProperty(event:MouseEvent):void
single_mc.alpha=0;
stop_btn.addEventListener(MouseEvent.CLICK, setProperty);
Also I was wonder if you could recommend an Action script 3 book for me. I would like one that is not a training book, but has situations and then the script written out. For example: I click a button and a movie symbol disappears from the stage. I am a graphic artist, that from time to time, needs simple interaction in flash, but cant justify the time to learn the script.
Thanks for your timeuse the snippets panel to help with you with sample code for basic tasks.
function setProperty(event:MouseEvent):void
single_mc.visible=false;
stop_btn.addEventListener(MouseEvent.CLICK, setProperty); -
I found a script online that turns my images into a square (by extending the canvas size of the short side to match the length of the long side) which is awesome, but I would like to do an additional step and I have no scripting experience so hopefully someone can help.
now that my images are square I want to set a maximum dimension of 2500x2500 px, i have found scripts to set a resolution to a specific size but what I want to make sure I avoid is upsampling, so I just want any image larger than 2500x2500 px to down sample to 2500x2500 px
any knowledge on the code for this would be much appreciated.
When I am at the machine with the script I currently use I will paste it here in the meantime if you know something about scaling images down but preventing scaling them up I could probably chimp with the code I have and make it work.Photoshop shipts with a plug-in script that will do that for you. its found under menu File>Automate>Fit Image. Set both width and height to 2500 and check do not resize images that fit so your small square images will not be resized up in size. You could also just create an action that uses both scripts
step 1 menu File>Scripts>Make canvas Square.
setp 2 menu File>Automate>Fit Image. The 2500 x 2500 no upsize option settings will be recorded into the step and when the action is used its dialog will be bypassed and the recorded settings will ne used.
You can then batch the action using menu file>Automate>Batch or menu File>Scripts>Image Processor. -
Would anyone be willing to help me with a script? I need to Find the first table using "ERTStyle1" table style, convert it to text, change the text style to "Tabfix" paragraph style, then convert it back into a table using the table style "ERTStyle2" convert the top row to a header. It needs to repeat this process until there are no tables left using the "ERTStyle1" table style.
I think I could almost do this myself using VBScript, but I am relatively new to scripting, and to be honest, I am hoping I can use this script to jump start my knowledge of VB in Indesign.So all of this is just to set the column widths to the sizes pre-defined in a paragraph style, i.e., always the same?
I feel like I almost could do that in VB!
But in Javascript, all it needs is sth in the ilk of
var myWidths = [ 10, 50, 100, 50, 12 ]; // in whatever units you fancy
var myTable = app.activeDocument.stories[0].tables[0]; // (just grabbing some table)
for (i=0; i<myTable.columns.length; i++)
myTable.columns[i].width = myWidths[i % myWidths.length];
.. and the most interesting thing here (written from top of my head) is the "myWidths" lookup: it doesn't matter how many columns there are in this table, 'cause the widths array wraps around. (But you won't need this because you know all of your widths in advance.) -
Please help with SQL amount calulation
-- Results
with t as (
select 'P11877' Mstr_Program, 1 Year_of_study, 'BUSI1490' program_module, 20 no_of_stud, 1 rank, 30 program_credits, 30 cumm_credits from dual union all
select 'P11877', 1, 'COMP1365', 20, 2, 30, 60 from dual union all
select 'P11877', 1, 'BUSI1375', 20, 3, 30, 90 from dual union all
select 'P11877', 1, 'COMP1363', 20, 4, 30, 120 from dual union all
select 'P11877', 2, 'MARK1174', 8, 1, 30, 30 from dual union all
select 'P11877', 2, 'FINA1068', 8, 2, 15, 45 from dual union all
select 'P11877', 2, 'INDU1062', 8, 3, 30, 75 from dual union all
select 'P11877', 2, 'BUSI1329', 8, 4, 15, 90 from dual union all
select 'P11877', 2, 'MARK1138', 8, 5, 30, 120 from dual)
select * from t;-- Each MSTR_PROGRAM can have 1 or many program_module
-- MSTR_PROGRAM's can run for 1 or 2 years (case above is two years) so some modules run in year 1 and some in year 2
-- NO_OF_STUD is the number of students on the module
-- RANK basically ranks the modules by the number of students on them grouped by program and year
-- e.g.row_number() OVER (PARTITION BY Mstr_Program, Year_of_study) ORDER BY COUNT(STUDENT_ID) DESC) rank
-- PROGRAM_CREDITS: each module has a fixed number of credits
-- CUMM_CREDITS: Increments the credit count of modules
-- SUM(program_credits * 10) OVER (PARTITION BY Mstr_Program, Year_of_study
-- ORDER BY count(STUDENT_ID) desc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) cumm_credits
-- I want to trim of any modules once the CUM_CREDITS hits 120. As seen above. I achieve this by wrapping the main query is another SELECT then LIMIT
-- that WHERE cum_credit <=120.
-- But what I need is:
-- In some cases the the cumm_credit maybe on lets say 90credits then the next module is worth 40 credits. This next module will not show as it
-- will be greater than 120 credits, so i need to pro-rata it:
-- So if credit_count > 120, then the last module is counted pro-rata as follows: 1- ((credit count - 120) / credits from last module
-- Can anyone help with how I can incorporate this into my current code: The SELECT portion of the Original SQL is below: I simplified column names
-- e.t.c in the above so they wont be the same
SELECT * FROM (
SELECT
,SR_PROGRAM Mstr_Program
,DECODE (SORLCUR_YEAR, 1, 1,
2, 2,
3, 3,
4, 3, SR_YEAR) year_of_study
,SCT_SUBJ_CODE||SCT_CRSE_NUMB program_module
,COUNT(student_ID) no_of_stud
,row_number() OVER (PARTITION BY sr_program,
DECODE (sr_year, 1, 1,
2, 2,
3, 3,
4, 3, SR_YEAR) ORDER BY COUNT(student_id) DESC, scbcrse_title asc) rank
,(SCT_CREDIT_HRS * 10) program_credits
,SUM(SCT_CREDIT_HRS * 10) OVER (PARTITION BY sr_program, DECODE (sorlcur_year, 1, 1,
2, 2,
3, 3,
4, 3, SR_YEAR)
ORDER BY count(student_id) desc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) cumm_credits
WHERE cumm_credit <=120
ORDER BY Mstr_Program, YEAR_OF_STUDY, RANK asc;Maybe
SELECT Mstr_Program,year_of_study,program_module,no_of_stud,rank,program_credits old_program_credits,cumm_credits old_cumm_credits,
case when cumm_credits > 120
then program_credits - cumm_credits + 120
else program_credits
end new_program_credits,
case when cumm_credits > 120
then 120
else cumm_credits
end new_cumm_credits
FROM (SELECT SR_PROGRAM Mstr_Program,
DECODE(SORLCUR_YEAR,1,1,2,2,3,3,4,3,SR_YEAR) year_of_study,
SCT_SUBJ_CODE||SCT_CRSE_NUMB program_module,
COUNT(student_ID) no_of_stud,
row_number() OVER (PARTITION BY sr_program,DECODE(sr_year,1,1,2,2,3,3,4,3,SR_YEAR)
ORDER BY COUNT(student_id) DESC,scbcrse_title) rank,
10 * SCT_CREDIT_HRS program_credits,
10 * SUM(SCT_CREDIT_HRS) OVER (PARTITION BY sr_program,DECODE(sorlcur_year,1,1,2,2,3,3,4,3,SR_YEAR)
ORDER BY count(student_id) desc
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) cumm_credits
WHERE 0 <= case when cumm_credits > 120
then program_credits - cumm_credits + 120
else program_credits
end
ORDER BY Mstr_Program,YEAR_OF_STUDY,RANKRegards
Etbin
Edited by: Etbin on 16.12.2011 8:50
with
t as /* simulating the result achieved */
(select 'P11877' Mstr_Program,1 Year_of_study, 'BUSI1490' program_module,20 no_of_stud,1 rank,30 program_credits,30 cumm_credits from dual union all
select 'P11877', 1, 'COMP1365', 20, 2, 40, 70 from dual union all
select 'P11877', 1, 'BUSI1375', 20, 3, 30, 100 from dual union all
select 'P11877', 1, 'COMP1363', 20, 4, 40, 140 from dual union all
select 'P11877', 2, 'MARK1174', 8, 1, 30, 30 from dual union all
select 'P11877', 2, 'FINA1068', 8, 2, 50, 80 from dual union all
select 'P11877', 2, 'INDU1062', 8, 3, 30, 110 from dual union all
select 'P11877', 2, 'BUSI1329', 8, 4, 50, 160 from dual union all
select 'P11877', 2, 'MARK1138', 8, 5, 30, 190 from dual
select Mstr_Program,Year_of_study,program_module,no_of_stud,rank,program_credits old_credits,cumm_credits old_cumm,
case when cumm_credits > 120
then program_credits - cumm_credits + 120
else program_credits
end new_program_credits,
case when cumm_credits > 120
then 120
else cumm_credits
end new_cumm_credits
from t
where 0 <= case when cumm_credits > 120
then program_credits - cumm_credits + 120
else program_credits
end -
Help with two scripts - Mounting remote DMG and Checking which network I'm connected to
Hey guys, I need some help with two separate scripts:
1. The first script I'm trying to create to mount a DMG stored remotely on another Mac using an AppleScript or shell script. Using the following:
set cmd to "hdiutil mount 'afp://username:[email protected]/Lion/Users/username/Desktop/Test.sparseim age'"
do shell script cmd
results in the following error:
error "hdiutil: mount failed - not recognized" number 1
I'm not very experienced regarding AppleScript or using hdiutil, could somebody point out what's wrong with my script?
2. The second script I'm working on to try and essentially prevent the 'Could Not Find Server' Finder dialog when a network mount is unavailable. I guess what I'd like it to do is detect which network I'm connected to, and if I'm connected to the correct network, then mount the shares, otherwise just fail silently without any errors. From the searching I've done, using try statements should do this, but they do not, and I'm still presented with an error dialog after the server cannot be found.
Does anybody have any suggestions on this script? Also, I've seen some tips regarding detecting which wireless network the Mac is connected to, which could work, but what about when connected via Ethernet?
Thanks!Edit: I need to clarify on my first script request:
I need to mount the DMG on the remote Mac, not on the Mac I'm running the script from. -
Can anyone help with the scripting on this file?
Hi, I hope someone with a bigger brain can help me out here.
I've got an existing Flash CS3 file that makes up the result at http://www.infusion-set.com/flash/Elearning/Inset30/inset30_eguide.html.
The client has asked if I could add an extra tab at the top after 'Reconnecting' called 'Contact Us' with link to an extra page. All the design has been done in ActionScript 2 with references to XML files for the dynamic content because it's been done in other languages as well.
I've amended the existing XML file with the correct references for a new page and an accompanying .swf file to play in the animation area.
I've attempted a .fla version where I duplicated one of the existing tabs script, changed the XML references and changed the variables where necessary to 'con or 'Con' (representing Contact Us). Unfortunately it made the tab menu go completely off the page and was obviously wrong in some way.
Can anyone give me a clue as to what to change here on the original file as I'm a bit of a novice with ActionScripts, hence me asking.
For reference I've attached HTML files with the original file scripts and my incorrect version. The timeline is 103 frames with the scripts placed at frame 1 and 102
Thanks.
GarryThe buttons are all created using the same library object (but MC), except for the code you have in the revised file does not call on that for the con button.
You have it calling on something with a linkage name of "con", which a quick check tells me doesn't exist--so it is undefined in the code when you try to use it. I found this by using trace(newConBut._x); after its _x value was assigned, as I mentioned you should try. So the first thing you want to do is change the following line from...
var newConBut = _root.attachMovie("con", "conbut", _root.getNextHighestDepth());
To
var newConBut = _root.attachMovie("but", "conbut", _root.getNextHighestDepth());
so that it uses the but MC that serves that purpose in the library. Then you want to correct the _x assignment of the buttons to what I think you had earlier...
newConBut._x = 650-newConBut._width;
newRecBut._x = newConBut._x-newRecBut._width;
Here is a picture of what those changes do (note, without the XML file I had to finagle things just to work, so the biutton labels aren't what they will be)... -
Help With dynamic scripting for Dervied Property
Hi,
I am trying to get the the list of child nodes and then loopthorugh those nodes to do some calculation in a derived propety using dynamic scripting. I tried with below script.
var childEnumerator = node.GetChildEnumerator();
while(childEnumerator.MoveNext())
var propValue = childEnumerator.GetCurrent().PropValue("Custom.Salary");
print(propValue);
While Evaluating this script I am getting below mentioned error. Any idea what i am missing here?
DRM-16008: There was an error calculating Script property Custom.TotalSalaryExp for EMP_Zone/Emp/PPD1: TypeError: 'GetChildEnumerator' is not a function
Please help me out. thanks fr your co-operation
Regards,
SudiptaTry this instead...
var childEnumerator = node.GetChildEnumerator();
childEnumerator.MoveNext();
while(childEnumerator.GetCurrent() != null)
var propValue = childEnumerator.GetCurrent().PropValue("Custom.Salary");
print(propValue);
childEnumerator.MoveNext();
Maybe you are looking for
-
How do you archive completed tasks in Ical in Lion?
-
PDF files won' t open in Adobe Acrobat
My Adobe Acrobat reader software on my Macbook Pro will not open any PDF file saved from the internet. I have tried re-installing the software but no joy..? OS X 10.9.4
-
Getting error message "Could not open a scratch file...
...because the file is locked. Use the "Properties" command in Windows explorer to unlock the file" I cannot open PS because of this error message. I changed the scratch disk within Photoshop in the "Preferences" section and next time I opened PS (C
-
How do I get rid of the memory being used by "other" on my hard drive?
I have 120 gigs being used up on my hard drive by "other" and I want to have some of it back. What do I do?
-
all seems good above