Code Error with Case Statement
Hi everyone,
I'm new to PL/SQL and APEX and I'm trying to get this code to work. It is supposed to insert an sysdate if the named fields are changed and then update the fields.
This is the code:
BEGIN
SELECT ATS_CLS_NAME, ATS_CEL_NAME, ATS_END_DATE,
CASE
WHEN
ATS_CLS_NAME <> :P6_ATS_CLS_NAME
AND ATS_CLS_NAME <> :P6_ATS_CEL_NAME
AND ATS_END_DATE is Null
THEN
UPDATE ATS_ALLOCATION
SET
ATS_ALLOCATION_ID = :P6_ATS_ALLOCATION_ID,
ATS_START_DATE = :P6_ATS_START_DATE,
ATS_END_DATE = SYSDATE,
ATS_CLS_NAME = :P6_ATS_CLS_NAME,
ATS_CEL_NAME = :P6_ATS_CEL_NAME,
ATS_EMP_ID = :P6_EMP_EMP_ID
ELSE
UPDATE ATS_ALLOCATION
SET
ATS_ATS_ALLOCATION = :P6_ATS_ALLOCATION,
ATS_START_DATE = :P6_ATS_START_DATE,
ATS_END_DATE = :P6_ATS_END_DATE,
ATS_CLS_NAME = :P6_ATS_CLS_NAME,
ATS_CEL_NAME = :P6_ATS_CEL_NAME,
ATS_EMP_ID = :P6_EMP_EMP_ID
FROM ATS_ALLOCATION
END CASE;
END;
And I get this error:
1 error has occurred
ORA-06550: line 12, column 7: PL/SQL: ORA-00936: missing expression ORA-06550: line 5, column 1: PL/SQL: SQL Statement ignored
BEGIN
UPDATE ATS_ALLOCATION
SET
ATS_ATS_ALLOCATION = :P6_ATS_ALLOCATION,
ATS_START_DATE = :P6_ATS_START_DATE,
ATS_END_DATE = CASE
WHEN ATS_CLS_NAME <> :P6_ATS_CLS_NAME
AND ATS_CLS_NAME <> :P6_ATS_CEL_NAME
AND ATS_END_DATE is Null
THEN SYSDATE
ELSE :P6_ATS_END_DATE
END,
ATS_CLS_NAME = :P6_ATS_CLS_NAME,
ATS_CEL_NAME = :P6_ATS_CEL_NAME,
ATS_EMP_ID = :P6_EMP_EMP_ID
END;
1 error has occurred
ORA-06550: line 18, column 3: PL/SQL: ORA-00933: SQL command not properly ended ORA-06550: line 4, column 1: PL/SQL: SQL Statement ignored ORA-06550: line 21, column 21: PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: begin case declare end exception exit for goto if loop mod null pragma raise return select update while with
Similar Messages
-
11g outer join with case statement - strange results.
Hello All,
I am experiencing a strange issues in 11g while using case statement.
I am not able to reproduce this using sample data. Not sure what is wrong.
I am not narrowing it to say the usage of case statemnt is giving wrong results, but that is my observation when I am doing trail and error testing.
Here are the details.
My Version
SQL> select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
SQL> My Query
SELECT *
FROM (SELECT DISTINCT mf.schedule,
mf.cptcode,
NVL (mf.modifier, '00') modifier2,
CASE
WHEN mf.feetype = 'H'
AND mf.multiplier IS NOT NULL THEN
' 0.00'
WHEN (mf.feetype != 'H'
OR mf.feetype IS NULL)
AND mf.rbrvsvalue IS NOT NULL
AND mf.multiplier IS NOT NULL THEN
LPAD ( TRIM (TO_CHAR ( (mf.rbrvsvalue * mf.multiplier) / 100, 9999999.99)), 10)
ELSE
NULL
END
fee
FROM provider.mpifee mf, mpi_udffee.udffeeactivecptcodes vld
WHERE mf.schedule = 'SAPG1'
AND mf.cptcode = vld.cptcode
AND NVL (mf.modifier, 'NULL') = NVL (vld.modifier, 'NULL')) inline_fee,
(SELECT arc.schedule col1, arc.procedurecode col2, NVL (arc.modifier, '00') AS col3
FROM mpi_udffee.udffeeancfeedata arc
WHERE monthofextract = '201202'
AND arc.schedule = 'SAPG1'
AND TRUNC (SYSDATE - 10) BETWEEN arc.recordeffectivedate AND arc.recordterminationdate) inline_data
WHERE inline_fee.schedule = inline_data.col1(+)
AND inline_fee.cptcode = inline_data.col2(+)
AND inline_fee.modifier2 = inline_data.col3(+);
In the above query the inline view inline_data returns zero rows. but NVL is still getting applied for col3 and I am getting 00 in the results( strange ).
Results:
SCHEDULE CPTCO MODIFIER2 FEE COL1 COL2 COL3
SAPG1 49590 00 667.32 00
SAPG1 49611 00 781.03 00
SAPG1 49905 00 443.79 00
SAPG1 50205 00 883.56 00
SAPG1 50220 00 1315.15 00
SAPG1 50230 00 1638.74 00
SAPG1 50234 00 1666.16 00
SAPG1 50250 00 1566.14 00
SAPG1 50327 00 262.04 00
SAPG1 50541 00 1183.31 00
SAPG1 50620 00 1156.88 00
SAPG1 50650 00 1321.96 00
497 rows selected.
Just the inline view inline_data,
SQL> SELECT arc.schedule col1, arc.procedurecode col2, NVL (arc.modifier, '00') AS col3
2 FROM mpi_udffee.udffeeancfeedata arc
3 WHERE monthofextract = '201202'
4 AND arc.schedule = 'SAPG1'
5 AND TRUNC (SYSDATE - 10) BETWEEN arc.recordeffectivedate AND arc.recordterminationdate;
no rows selectedMuch unusual thing is when I just remove the case statement from the inline view "inline_fee", I am getting right results,
SELECT *
FROM (SELECT DISTINCT mf.schedule,
mf.cptcode,
NVL (mf.modifier, '00') modifier2 <-- Removed Case statement here
FROM provider.mpifee mf, mpi_udffee.udffeeactivecptcodes vld
WHERE mf.schedule = 'SAPG1'
AND mf.cptcode = vld.cptcode
AND NVL (mf.modifier, 'NULL') = NVL (vld.modifier, 'NULL')) inline_fee,
(SELECT arc.schedule col1, arc.procedurecode col2, NVL (arc.modifier, '00') AS col3
FROM mpi_udffee.udffeeancfeedata arc
WHERE monthofextract = '201202'
AND arc.schedule = 'SAPG1'
AND TRUNC (SYSDATE - 10) BETWEEN arc.recordeffectivedate AND arc.recordterminationdate) inline_data
WHERE inline_fee.schedule = inline_data.col1(+)
AND inline_fee.cptcode = inline_data.col2(+)
AND inline_fee.modifier2 = inline_data.col3(+);
SCHEDULE CPTCO MODIFIER2 COL1 COL2 COL3
SAPG1 46730 00
SAPG1 46735 00
SAPG1 46748 00
SAPG1 46760 00
SAPG1 46942 00
SAPG1 46945 00
SAPG1 47015 00
SAPG1 47125 00
SAPG1 47350 00
SAPG1 47505 00
SAPG1 47553 00interestingly explain plan for both the statements are exactly same,
SELECT STATEMENT ALL_ROWSCost: 138 Bytes: 1,078,274 Cardinality: 11,471
9 HASH JOIN RIGHT OUTER Cost: 138 Bytes: 1,078,274 Cardinality: 11,471
2 PARTITION RANGE EMPTY Cost: 2 Bytes: 150 Cardinality: 3
1 TABLE ACCESS FULL TABLE MPI_UDFFEE.UDFFEEANCFEEDATA Cost: 2 Bytes: 150 Cardinality: 3
8 VIEW MPI_UDFFEE. Cost: 135 Bytes: 504,724 Cardinality: 11,471
7 HASH UNIQUE Cost: 135 Bytes: 539,137 Cardinality: 11,471
6 HASH JOIN Cost: 134 Bytes: 539,137 Cardinality: 11,471
3 TABLE ACCESS FULL TABLE MPI_UDFFEE.UDFFEEACTIVECPTCODES Cost: 13 Bytes: 177,345 Cardinality: 25,335
5 PARTITION LIST SINGLE Cost: 120 Bytes: 600,600 Cardinality: 15,015 Partition #: 8
4 INDEX RANGE SCAN INDEX (UNIQUE) REPRICE.PK_MPIFEE Cost: 120 Bytes: 600,600 Cardinality: 15,015 Partition #: 9 Partitions accessed #11Is there anything wrong with the query? If not have anyone come across this issue or posted it as a bug or is there a patch?
Update:
when I set the parameter "_complex_view_merging"=false I am getting the right results even with case statement. But I don want to do some thing unsupported.
Are there any other viable solutions?
I appreciate the help.
Thanks,
G.
Edited by: Ganesh Srivatsav on Apr 10, 2012 12:37 PMHi Tubby,
Right, the query transformation is going wrong. Following is from trace,
SELECT "INLINE_FEE"."SCHEDULE" "SCHEDULE",
"INLINE_FEE"."CPTCODE" "CPTCODE",
"INLINE_FEE"."MODIFIER2" "MODIFIER2",
"INLINE_FEE"."FEE" "FEE",
"ARC"."SCHEDULE" "COL1",
"ARC"."PROCEDURECODE" "COL2",
CASE
WHEN "ARC".ROWID IS NOT NULL THEN NVL ("ARC"."MODIFIER", '00')
ELSE NULL
END
"COL3"
FROM (SELECT DISTINCT "MF"."SCHEDULE" "SCHEDULE",
"MF"."CPTCODE" "CPTCODE",
NVL ("MF"."MODIFIER", :B2) "MODIFIER2",
CASE
WHEN ("MF"."FEETYPE" = :B3
AND "MF"."MULTIPLIER" IS NOT NULL) THEN
:B4
WHEN ( ("MF"."FEETYPE" <> :B5
OR "MF"."FEETYPE" IS NULL)
AND "MF"."RBRVSVALUE" IS NOT NULL
AND "MF"."MULTIPLIER" IS NOT NULL) THEN
LPAD ( TRIM (TO_CHAR ( "MF"."RBRVSVALUE" * "MF"."MULTIPLIER" / :B6, :B7)), :B8)
ELSE
NULL
END
"FEE"
FROM "PROVIDER"."MPIFEE" "MF", "MPI_UDFFEE"."UDFFEEACTIVECPTCODES" "VLD"
WHERE "MF"."SCHEDULE" = 'SAPG1'
AND "MF"."CPTCODE" = "VLD"."CPTCODE"
AND NVL ("MF"."MODIFIER", 'NULL') = NVL ("VLD"."MODIFIER", 'NULL')) "INLINE_FEE",
"MPI_UDFFEE"."UDFFEEANCFEEDATA" "ARC"
WHERE "INLINE_FEE"."SCHEDULE" = "ARC"."SCHEDULE"(+)
AND "INLINE_FEE"."CPTCODE" = "ARC"."PROCEDURECODE"(+)
AND "INLINE_FEE"."MODIFIER2" = CASE
WHEN ("ARC".ROWID(+) IS NOT NULL) THEN NVL ("ARC"."MODIFIER"(+), '00')
ELSE NULL
END
AND "ARC"."MONTHOFEXTRACT"(+) = '201202'
AND "ARC"."SCHEDULE"(+) = 'SAPG1'
AND TRUNC (SYSDATE-10) >= "ARC"."RECORDEFFECTIVEDATE"(+)
AND TRUNC (SYSDATE-10) <= "ARC"."RECORDTERMINATIONDATE"(+)Does this refer to a specific bug?
Thanks,
G. -
Using Presentation variables..along with case statements..
Hi All.
I have a issue using presentation variable along with CASE statements. My approach is
1) I have a dashboard prompt, which is being set as Presentation variable.
Based on the value selected in prompt, for ex the values of prompt can be 'ABC' and 'DEF'.
I have a calculated column, the calculation goes this way...
The forumal is
CASE WHEN @{Presentation Variable Name} = 'ABC' THEN xxxxxxxxxx ELSE IF @{Presentation Variable Name} = 'DEF' END. It gives error of "no table being referenced"..
Is this is the right approach??
Can i get the values of variable in a column formula, so that a column can have values selected in prompt?
Can anybody pls help me here..
Thanks in advance...Hi
Thanks for the quick response..
I agree to ur point..
But the requirement is
Based on the value of the prompt I need to switch the calculation in one of the formula area of one column..
If Prompt value is ABC then one kind of calculation in Fx and If the prompt value is DEF then one kind of calculation in the same Fx..
How can I acheive this?
Thanks in advance.. -
CLOB with case statement not working getting error
Can anyone help on this
I write this sql
select Case when to_clob(PROPERTY) = 'is_intradesk=Y' then 'Internal' end
from JPM_CP;
Where PROPERTY column is clob column and its giving the error "ORA-00932: inconsistent datatypes: expected - got CLOB"
Is it not possible to use clob columns with case or decode !Its working but it does not fulfill my purpose
In you answer it is looking for position right! means, does the column contain the value('Intradesk=Y' ) or not. means
I am looking for exact match with CLOB column values, that is Clob column(PROPERTY) contains the exact value that value which I am comparing with i.e 'Intradesk=Y'
I need this
select * from table where clob_column = 'value' (exact).
Edited by: sajalkdas on Feb 4, 2011 3:28 PM -
Applescript 'Contacts' code error with Maverick
After upgrading from MacOSX 10.6.8 to Maverick my applescripts are creating errors. One example is the following script which works fine if you run it from within the 'Applescript Editor.app' (v 2.6.1) under Maverick but creates a "Data paste section" error -1743 from the 'Contacts' app if you run the script indpendently. Any hints anyone on how I might return this script to full indpendent functionality?
Script to load a raw address for conversion and inserting into Address Book
Wish list
1. Check if 'New Address' Group already exists and if it doesn't then create one.
2. Provide a dialog that enables the user to specify which group to attach the new address to.
3. Find the new address and show it in Address Book.
4. Create a list of existing Groups to chose from to reduce keyboard error. --> done but the resultant window is not complete - no scroll bar becomes active.
Problem code:
set theFiles to (every file of folder addressesFolder) as alias list
global ABactive, aExists
property testText : "http://address-parser.com"
property newGroup : "New Addresses" --> Default group for new address additions
property aPrefix : ""
property aFirstName : ""
property aMiddleName : ""
property aLastName : ""
property aSuffix : ""
property aPosition : ""
property aDepartment : ""
property aCompany : ""
property aCompany2 : ""
property aStreet : ""
property aStreet2 : ""
property aPostbox : ""
property aPlace : ""
property aPostPlace : ""
property aState : ""
property aZip : ""
property aPostboxCode : ""
property aCountry : ""
property aPhone : ""
property aPhone2 : ""
property aMobile : ""
property aFax : ""
property aEmail : ""
property aWebsite : ""
property aNote : ""
set newline to ASCII character 10
-- Select the desired file
try
set addressFile to (choose file with prompt "Choose an address file:" of type {"public.text"} without invisibles) as text
-- set addressFile to (choose file with prompt "Choose an address file:" of type {"public.text"} default location addressesFolder without invisibles) as text
-- note the data type set for 'addressFile' is 'text'
on error number -128
-- User pressed 'Cancel' button
return
end try
set AppleScript's text item delimiters to {":"}
set fileName to last text item of addressFile
set AppleScript's text item delimiters to {""}
(* If there is an error while processing the address file, delay it just long enough to close the file access. Otherwise continue. *)
set addressFileReference to open for access addressFile
-- 'addressFileReference' is the 'returned access number'
-- Check first to see whether the file was created with output from the expected source
try
set wholeFile to read addressFileReference as text
if (offset of testText in wholeFile) is equal to 0 then
display dialog "File chosen is:" & return & fileName & return & return & "This file does not appear to contain output from the 'http://www.address-parser.com' demo page." buttons {"Cancel"} default button 1 with title "Error!" with icon stop
end if
on error number -128
-- User pressed 'Cancel' button
close access addressFileReference
set wholeFile to ""
return
end try
close access addressFileReference
set wholeFile to ""
-- Reopen file (need to clarify why EOF error if two read calls made with file open).
set addressFileReference to open for access addressFile
try
set AppleScript's text item delimiters to {""}
-- Read address file contents in 'addressFileContents' as a list delimited by paragraph and tab.
set x to paragraphs of (read addressFileReference as text)
set addressFileContents to {}
set AppleScript's text item delimiters to tab
repeat with i from 1 to count x
set addressFileContents's end to x's item i's text items
end repeat
set AppleScript's text item delimiters to {""}
repeat with i from 1 to count of addressFileContents
if (item i of addressFileContents) is not {} then
--Every line must be checked as there is no set order
if text item 1 of (item i of addressFileContents) is "Prefix= " then ¬
set aPrefix to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "First name= " then ¬
set aFirstName to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "Middle name= " then ¬
set aMiddleName to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "Last name= " then ¬
set aLastName to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "Suffix= " then ¬
set aSuffix to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "Position= " then ¬
set aPosition to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "Department= " then ¬
set aDepartment to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "Company= " then ¬
set aCompany to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "Company - line 2= " then ¬
set aCompany2 to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "Street address= " then ¬
set aStreet to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "Street address - line 2= " then ¬
set aStreet2 to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "Postbox address= " then ¬
set aPostbox to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "Place name= " then ¬
set aPlace to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "Post place name= " then ¬
set aPostPlace to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "State/Region/Province= " then ¬
set aState to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "ZIP/Postal code= " then ¬
set aZip to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "Postal code of postbox= " then ¬
set aPostboxCode to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "Country= " then ¬
set aCountry to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "Phone= " then ¬
set aPhone to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "Phone 2= " then ¬
set aPhone2 to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "Mobile phone= " then ¬
set aMobile to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "Fax= " then ¬
set aFax to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "Email= " then ¬
set aEmail to text item 2 of (item i of addressFileContents)
if text item 1 of (item i of addressFileContents) is "Web site= " then ¬
set aWebsite to text item 2 of (item i of addressFileContents)
--Collect unrecognised elements and place them in the 'Note' field
if text item 1 of (item i of addressFileContents) contains "Unrecognized values:" then
set i to i + 1
set aNote to "Additional address bits:"
repeat with i from i to count of addressFileContents
--display dialog "Note text reads:" & return & "aNote:" & tab & "'" & aNote & "'" & return & "Line #:" & tab & i & return & (item i of addressFileContents) as text default button 1 with title "Debug Dialog"
if (item i of addressFileContents) is not {} then
if item 1 of (item i of addressFileContents) is "" and ¬
item 2 of (item i of addressFileContents) is not "" then
set aNote to aNote & newline & text item 2 of (item i of addressFileContents)
end if
end if
end repeat
end if
end if
end repeat
on error errMsg number errNum
close access addressFileReference
-- do some sort of error processing here
display dialog "An error occurred with the following number and description: " & return & errNum & return & errMsg & return & return & "Item " & (i as string) & tab & "'" & (item i of addressFileContents) & "'" with title "Data load section."
error errMsg number errNum
end try
close access addressFileReference
--Debug dialogs
--display dialog (item 1 of addressFileContents as text) & return & return & (item 2 of addressFileContents as text) & return & return & (item 3 of addressFileContents as text) & return & return & (item 4 of addressFileContents as text)
--display dialog "title:" & tab & tab & tab & aPrefix & return & "first name:" & tab & tab & aFirstName & return & "middle name:" & tab & tab & aMiddleName & return & "last name:" & tab & tab & aLastName & return & "suffix:" & tab & tab & tab & aSuffix & return & "job title:" & tab & tab & tab & aPosition & return & "department:" & tab & aDepartment & return & "organization:" & tab & aCompany with title "Just prior to new record insertion:" with icon note
--check if Contacts application is active
tell application "System Events"
if exists application process "Contacts" then
set ABactive to true
else
set ABactive to false
end if
end tell
--display dialog "title:" & tab & tab & tab & aPrefix & return & "first name:" & tab & tab & aFirstName & return & "middle name:" & tab & tab & aMiddleName & return & "last name:" & tab & tab & aLastName & return & "suffix:" & tab & tab & tab & aSuffix & return & "job title:" & tab & tab & tab & aPosition & return & "department:" & tab & aDepartment & return & "organization:" & tab & aCompany with title "Just prior to create new entry:" with icon note
--create new address entry
tell application "Contacts"
try
--if the aCompany2 variable is filled append its contents to the aCompany variable
if aCompany2 is equal to "" then
set thePerson to make new person with properties ¬
{title:aPrefix, first name:aFirstName, middle name:aMiddleName, last name:aLastName, suffix:aSuffix, job title:aPosition, department:aDepartment, organization:aCompany}
else
set aCompany to aCompany & newline & aCompany2
set thePerson to make new person with properties ¬
{title:aPrefix, first name:aFirstName, middle name:aMiddleName, last name:aLastName, suffix:aSuffix, job title:aPosition, department:aDepartment, organization:aCompany}
end if
--set the Company view binary if no First and Last name
if (first name of thePerson is equal to "") and (last name of thePerson is equal to "") then ¬
set the company of thePerson to true
tell thePerson
if aPhone is not equal to "" then ¬
make new phone at end of phones with properties ¬
{label:"work", value:aPhone}
if aPhone2 is not equal to "" then ¬
make new phone at end of phones with properties ¬
{label:"other", value:aPhone2}
if aMobile is not equal to "" then ¬
make new phone at end of phones with properties ¬
{label:"mobile", value:aMobile}
if aFax is not equal to "" then ¬
make new phone at end of phones with properties ¬
{label:"fax", value:aFax}
if aEmail is not equal to "" then ¬
make new email at end of emails with properties ¬
{label:"Work", value:aEmail}
if aWebsite is not equal to "" then ¬
make new url at end of urls with properties ¬
{label:"Work", value:aWebsite}
if aStreet is not equal to "" then
if aStreet2 is equal to "" then
make new address at end of addresses with properties ¬
{label:"work", street:aStreet, city:aPlace, state:aState, zip:aZip, country:aCountry}
else
make new address at end of addresses with properties ¬
{label:"work", street:aStreet & ", " & aStreet2, city:aPlace, state:aState, zip:aZip, country:aCountry}
end if
end if
if aPostPlace is equal to "" then set aPostPlace to aPlace
if aPostbox is not equal to "" then
if aPostboxCode is not equal to "" then
make new address at end of addresses with properties ¬
{label:"postal", street:aPostbox, city:aPostPlace, state:aState, zip:aPostboxCode, country:aCountry}
else
make new address at end of addresses with properties ¬
{label:"postal", street:aPostbox, city:aPlace, state:aState, zip:aZip, country:aCountry}
end if
end if
if aNote is not equal to "" then set note to aNote
end tell
-- place the new entry into a group
set myGroups to name of every group
set theGroup to (choose from list myGroups with prompt "Attach to which group?" without multiple selections allowed and empty selection allowed) as text
--If user selects 'Cancel' button the value of the result variable is 'false'
if theGroup is not "false" then
add thePerson to group theGroup
else
-- create a default group and place the entry in there; first testing to see whether the default group already exists
try
if group newGroup exists then ¬
display dialog "newGroup exists" with icon 1
add thePerson to group newGroup
on error number -1728
-- newGroup does not exist so create it
display dialog "newGroup does not exist. Make new group with newGroup" with icon 1
set theGroup to make new group with properties {name:newGroup}
add thePerson to group newGroup
end try
end if
save application "Contacts"
set selection to (thePerson)
activate
--set flag that new address entry was successful by seeking
if the selection is equal to properties ¬
{title:aPrefix, first name:aFirstName, ¬
middle name:aMiddleName, last name:aLastName, ¬
suffix:aSuffix, job title:aPosition, ¬
department:aDepartment, organization:aCompany} then ¬
set aExists to true
on error errMsg number errNum
-- do some sort of error processing here
display dialog "An error occurred with the following number and description: " & return & errNum & return & errMsg with title "Data paste section."
error errMsg number errNum
end try
--if we opened the AB, we'll close it
if not ABactive then quit
end tell
--clear address variables content in case of repeat use
set aPrefix to ""
set aFirstName to ""
set aMiddleName to ""
set aLastName to ""
set aSuffix to ""
set aPosition to ""
set aDepartment to ""
set aCompany to ""
set aCompany2 to ""
set aStreet to ""
set aStreet2 to ""
set aPostbox to ""
set aPlace to ""
set aState to ""
set aZip to ""
set aPostboxCode to ""
set aCountry to ""
set aPhone to ""
set aPhone2 to ""
set aMobile to ""
set aFax to ""
set aEmail to ""
set aWebsite to ""
set aNote to ""
-- Delete original file if contents have been successfully added
if aExists then
try
tell application "Finder"
if exists file addressFile then
delete file addressFile --moves it to the trash
end if
end tell
on error errMsg number errNum
display dialog "Inserting new address was successfiul, however an error occurred while deleting the original file:" & return & addressFile buttons {"Cancel"} default button 1 with title "Error!" with icon stop
display dialog ""
end try
end if
-- End of 'add address' scriptWell, after a few days of restoring my cellphone (The C6-01 I mentioned before), I came to this:
- After Hard resetting, the Lock Code is still erroneous;
- After firmware reinstalling, Lock Code is erroneous;
- Pulling out the battery, leaving the cellphone with no power for several hours, give the same result;
- Downgrading firmware (previous version) did not fix the problem;
Interesting thing is, after power on, the cellphone asks for the code lock: entering ANY number, returns "Code Error", and simply goes back to normal operation.
Everything is working, except I can no use de Lock Code, or any function related to it.
Of course, is pretty annoying to enter the lock code every time I power-on the cell. -
Insert data with Case Statement
Good Morning,
I created table:
CREATE TABLE DWG_LOG
( DL_ID_PK NUMBER NOT NULL ENABLE,
DL_DRWNG_ID_FK"NUMBER,
DL_REQUESTOR VARCHAR2(400 BYTE),
DL_PHONE VARCHAR2(40 BYTE),
DL_DATE_COPIED DATE,
DL_APPROVER VARCHAR2(400 BYTE),
DL_NOTES VARCHAR2(100 BYTE),
DL_REQ_EMAIL VARCHAR2(60 BYTE),
DL_DATE_DUE DATE,
DL_PAST_DUE VARCHAR2(400 BYTE))
The goal is to populate the DL_PAST_DUE field with a 1 if the date is greater than 90 days else leave NULL. With the help of other more senior developers from OTN I have narrowed my logic to using a CASE Statement instead of a FUNCTION. Below is the projected CASE statement that I am trying to use:
DECLARE
v_copied_date DWG_LOG.DL_DATE_COPIED%TYPE;
v_curr_date SYSDATE;
BEGIN
SELECT DL_DATE_COPIED INTO v_copied_date
FROM DWG_LOG
CASE
WHEN (v_curr_date - v_copied_date) > 90 THEN
INSERT INTO DWG_LOG (DL_PAST_DUE) VALUES ('1');
ELSE
INSERT INTO DWG_LOG (DL_PAST_DUE) VALUES ('0');
END CASE;
END;
I am getting the following errors when I run this code in SQL*PLus:
ERROR at line 10:
ORA-06550: line 10, column 4:
PL/SQL: ORA-00933: SQL command not properly ended
ORA-06550: line 7, column 4:
PL/SQL: SQL Statement ignored
ORA-06550: line 12, column 4:
PLS-00103: Encountered the symbol "ELSE" when expecting one of the following:
begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
<an identifier> <a double-quoted delimite
ORA-06550: line 14, column 8:
PLS-00103: Encountered the symbol "CASE" when expecting one of the following:
if
PLEASE, point me in the right direction I know my syntax is off I just don't know where. I will continue to research and refine my script.
HUMBLY SUBMITTED
MarkusI APOLOGIZE
Good Morning, I created table:
CREATE TABLE DWG_LOG (
DL_ID_PK NUMBER NOT NULL ENABLE,
DL_DRWNG_ID_FK"NUMBER,
DL_REQUESTOR VARCHAR2(400 BYTE),
DL_PHONE VARCHAR2(40 BYTE),
DL_DATE_COPIED DATE,
DL_APPROVER VARCHAR2(400 BYTE),
DL_NOTES VARCHAR2(100 BYTE),
DL_REQ_EMAIL VARCHAR2(60 BYTE),
DL_DATE_DUE DATE,
DL_PAST_DUE VARCHAR2(400 BYTE))
[pre/]
The goal is to populate the DL_PAST_DUE field with a 1 if the date is greater than 90 days else leave NULL. With the help of other more senior developers from OTN I have narrowed my logic to using a CASE Statement instead of a FUNCTION. Below is the projected CASE statement that I am trying to use:
DECLARE
v_copied_date DWG_LOG.DL_DATE_COPIED%TYPE;
v_curr_date SYSDATE;
BEGIN
SELECT DL_DATE_COPIED INTO v_copied_date
FROM DWG_LOG;
CASE
WHEN (v_curr_date - v_copied_date) > 90 THEN
INSERT INTO DWG_LOG (DL_PAST_DUE) VALUES ('1');
ELSE
INSERT INTO DWG_LOG (DL_PAST_DUE) VALUES ('0');
END CASE;
END;
I am getting the following errors when I run this code in SQL*PLus: ERROR at line 10: ORA-06550: line 10, column 4: PL/SQL: ORA-00933: SQL command not properly ended ORA-06550: line 7, column 4: PL/SQL: SQL Statement ignored ORA-06550: line 12, column 4: PLS-00103: Encountered the symbol "ELSE" when expecting one of the following: begin case declare end exception exit for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimite ORA-06550: line 14, column 8:
PLS-00103: Encountered the symbol “CASE” when expecting one of the following:
if -
Update statement with case statement
Hi
The following code is thorwing an error like
=====CODE==========
BEGIN
UPDATE emp SET SAL = CASE
WHEN ENAME = 'SCOTT' THEN SAL = 300
ELSE NULL;
END CASE;
END;
=====ERROR=======
ORA-06550: line 3, column 32:
PL/SQL: ORA-00905: missing keyword
ORA-06550: line 2, column 2:
PL/SQL: SQL Statement ignored
ORA-06550: line 5, column 6:
PLS-00103: Encountered the symbol "CASE" when expecting one of the following:
; 1.
2. BEGIN
3. UPDATE emp SET SAL = CASE
4. WHEN ENAME = 'SCOTT' THEN SAL = 300
5. ELSE NULL;
Any suggession?
Regards
BalajiHi,
Yes you are right, but it is not working for the multiple case statement like the following code
BEGIN
UPDATE emp SET SAL = CASE
WHEN ENAME='JONES' THEN '4';
WHEN ENAME='BLAKE' THEN '5'
WHEN ENAME='CLARK' THEN '6'
WHEN ENAME='TURNER' THEN '7'
WHEN ENAME='MILLER' THEN '8'
WHEN ENAME='MARTIN' THEN '9'
WHEN ENAME='WARD' THEN '10'
WHEN ENAME='ADAMS' THEN '11'
WHEN ENAME='JAMES' THEN '12'
WHEN ENAME='SMITH' THEN '13'
ELSE NULL END;
END;
The above code show the following error
===========ERROR==========
ORA-06550: line 3, column 29:
PL/SQL: ORA-00905: missing keyword
ORA-06550: line 2, column 2:
PL/SQL: SQL Statement ignored
ORA-06550: line 4, column 2:
PLS-00103: Encountered the symbol "WHEN" when expecting one of the following:
( begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
1. BEGIN
2. UPDATE emp SET SAL = CASE
3. WHEN ENAME='JONES' THEN '4';
4. WHEN ENAME='BLAKE' THEN '5'
5. WHEN ENAME='CLARK' THEN '6'
Regards
Balaji
Edited by: 904493 on Jan 13, 2012 4:18 AM -
SQL Expression Field - Combine Declared Variable With Case Statement
Hello All, I have been using Crystal & Business Objects for a few months now and have figured out quite a bit on my own. This is the first real time I have struggled with something and while I could do this as a Formula Field I would like to know how to do this as a SQL Expression. Basically I want to create a SQL Expression that uses a CASE statement but I wanted to make the code a little more efficient and employ a variable to hold a string and then use the variable in the CASE statement. The expression editor accepts the CASE statement OK but I don't know how to declare the variable. Please assist with the syntax?
This is what I have:
CASE
WHEN u201CDatabaseu201D.u201DFieldu201D = u2018Hu2019 THEN u2018Hedgeu2019
WHEN u201CDatabaseu201D.u201DFieldu201D = u2018Pu2019 THEN u2018PVIu2019
ELSE u2018Noneu2019
END
This is what I want:
DECLARE strVar AS VARCHAR(25)
strVar = u201CDatabaseu201D.u201DFieldu201D
CASE
WHEN strVar = u2018Hu2019 THEN u2018Hedgeu2019
WHEN strVar = u2018Pu2019 THEN u2018PVIu2019
ELSE u2018Noneu2019
ENDHi Todd,
Please use the following for loop; your problem will be solved.
Local StringVar str := "";
Local NumberVar strLen := Length ({Database.Field});
Local NumberVar i;
For i := 1 To strLen Do
if {Database.Field} <i> = "H" then str := "Hedge"
else if {Database.Field} <i> = "P" then str := "PVI"
else str := "None"; exit for
str
Let me know once done!
Thank you,
Ashok -
Handling Exceptions with case statement - convert Exception to int value
Hi,
I'm developing a web app, with servlets.
I'm catching Exceptions in my servlets, for example I would like a user to insert data into a form. If the data cannot be converted into a integer value a java.lang.NumberormatException is thrown.
I would like to catch this and then create a message giving a more specific clue to what happened. Unfortunatly it's possible that other exceptions could be caught, so I want to be able to check which type of Exception has been caught.
I started writing a getErrorMessage(int Code) class. The method has a case statement which just checks the code and return the appropriate message.
This worked well for SQL exceptions as they provide a getErrorCode method. But I was wondering is there any way to convert other Exceptions such as
java.lang.NumberormatException into an integer value?
CheersExceptions have their types (classes) and messages (and maybe an embedded exception). That is, they have much richer internal status then an integer.
Why should they be "converted" to integers?
FLAME on
Gone are the days of good old errno.
FLAME off -
VBA Code error with Adobe Acrobat 10 Type Library
Hi,
I have some code I created in Word VBA to combine several separate PDFs into a single PDF. The code works fine with the Adobe Acrobat 9.0 Type Library and Adobe Reader 9.0 installed.
But, with the Adobe Acrobat 10 Type Library and Adobe Reader 10 installed, the code fails at the marked code below. Any suggestions??
Dim acrobatApp As Acrobat.acroApp
Set acrobatApp = CreateObject("AcroExch.App")
Dim mainPDF As Acrobat.AcroPDDoc
Set mainPDF = CreateObject("AcroExch.PDDoc") ****THIS IS WHERE THE CODE STOPS WITH A "TYPE MISMATCH" ERROR****
Dim nextPage As Acrobat.AcroPDDoc
Set nextPage = CreateObject("AcroExch.PDDoc")
Dim numPages As Integer
'Loop through all selected VLS, and add each one to the end of the main PDF
For i = 0 To lstSelected.ListCount - 1
mainPDF.Open CurDir & "\" & Replace(ThisDocument.Name, ".doc", "") & ".pdf"
numPages = mainPDF.GetNumPages
nextPage.Open lstSelected.List(i)
If mainPDF.InsertPages(numPages - 1, nextPage, 0, nextPage.GetNumPages, True) = False Then
MsgBox "Cannot insert pages"
End If
If mainPDF.Save(PDSaveFull, CurDir & "\" & Replace(ThisDocument.Name, ".doc", "") & ".pdf") = False Then
MsgBox "Cannot save"
End If
'MsgBox lstSelected.List(i)
nextPage.Close
Next iWhat if you start with a really simple VBA example? Take a look at this:
Private Sub CommandButton1_Click()
Dim AcroApp As Acrobat.CAcroApp
Dim theDocument As Acrobat.CAcroPDDoc
Dim bm As Acrobat.AcroPDBookmark
Dim thePath As String
thePath = "c:\temp\test.pdf"
Set AcroApp = CreateObject("AcroExch.App")
Set theDocument = CreateObject("AcroExch.PDDoc")
theDocument.Open (thePath)
MsgBox "Number of pages: " & theDocument.GetNumPages
theDocument.Close
AcroApp.Exit
Set AcroApp = Nothing
Set theDocument = Nothing
Set bm = Nothing
MsgBox "Done"
End Sub
If this still does not work, I would reinstall Acrobat to make sure that
the TLB is not corrupt.
Karl Heinz Kremer
PDF Acrobatics Without a Net
[email protected]
http://www.khkonsulting.com -
Syntax Error with EXPORT statement in ECC 6
Hi All,
I have one issue with EXPORT statement syntax.
I have declared data like below:
DATA: BEGIN OF mem_id,
mandt LIKE sy-mandt,
uname LIKE sy-uname,
modno LIKE sy-modno,
END OF mem_id.
export the memory id
EXPORT E_VBKOK XANZPK TEXTTAB XBOLNR TO MEMORY ID MEM_ID.
When I am checking the syntax error i am getting like "MEM_ID" must be a character-type field (data type C, N, D or T). by "INTERFACE". by "INTERFACE". "INTERFACE". by "INTERFACE". by "INTERFACE".
I know this statement would be like IMPORT ITAB TO JTAB FROM MEMORY ID 'table'. So I have written like below
EXPORT E_VBKOK XANZPK TEXTTAB XBOLNR TO MEMORY ID 'MEM_ID'. But still it is throwing an error.
Can you please let me know how can I resolve this?
Regards,
Jyothi CH.Hi Jyothi,
data: l_var type string.
concatenate '6' '8' into l_var separated by space.
export l_var to memory id 'BB'.
Here we have to declare the type(structure) for l_var not for BB
and in another program
data:l_var type string.
import l_var from memory id 'BB'.
write : l_var. -
Error in CASE statement used in Reports query
My query has lots of selection criteria. I'm trying to use CASE for that.
This is a part of my query with parameters:
AND ad.location IN (CASE &p_location
WHEN 1 THEN
(SELECT TRIM(code_nbr) FROM code_detail
WHERE code_nbr like 'LC%')
WHEN 2 THEN -- then the user can type in more than 1 locations
&p_location1|| p_location2
END)
AND --- there are more conditions after this
The query fails that invalid relational operator in this CASE statement.
Any suggestions...is there any other way to do it...Thanks in advanceI would recommend the use of lexical parameters in the before report trigger
Set up a parameter SQL_WHERE - text, 4000 chars.
In your datamodel get rid of the case statement and just put &SQL_WHERE
In the before report trigger modify your case statement to be something like:
&SQL_WHERE:=' and ad.location in ';
case when :p_location = 1 then
&SQL_WHERE:=&SQL_WHERE||' select trim(code_nbr) from code_detail etc';
end
This way you can debug and test your case statement in the pl/sql environment. Plus the query should run faster as you are moving the complex where statement into a separate part of the report -
I friends,
I am using a case statement for a number field like this
case when (customer_no is null or customer_no ='') then t.customer_no else gv.customer_no end as customer_no
When i complie this i get an errror ORa-00932 inconsistent data types expected char got number....
when i remove the case statement the query runs fine so i am sure its the case statement thats wrong here..Am i checking it the wrong way...
Thank you in advance874167 wrote:
I friends,
I am using a case statement for a number field like this
case when (customer_no is null or customer_no ='') then t.customer_no else gv.customer_no end as customer_no
When i complie this i get an errror ORa-00932 inconsistent data types expected char got number....
when i remove the case statement the query runs fine so i am sure its the case statement thats wrong here..Am i checking it the wrong way...
Thank you in advancewith Oracle strings are enclosed in single quote marks
so Oracle is confused & unhappy with line below
customer_no =''
since CUSTOMEER_NO is a NUMBER
why do you compare number to a string? -
How to use Substring function with Case statement.
Hello Everyone,
I have one requirement where I have to use substring function on the field for report criteria.
E.G.
I have Branch Name Field where I have all branch names information, Now some of the branch names are too big with some extension after the name .
now i want to substing it but the character length varies for each branch.
so is there any way where we can use case statement where we can define that if branch name character are exceeding some value then substing it with this length.Try something like this:
CASE WHEN LENGTH(tablename.Branch_Name) > n THEN SUBSTRING(...) ELSE tablename.Branch_Name END
where n is the number of characters you want to start the break. -
Update with case statement problem.
Hi,
I have this statement
update tab_tr set col_rate =
case
when col_ern_type in ('031','035','036') then (1.5 * col_rate)
when col_ern_type in ('041','045','046') then (2 * col_rate)
end;this statement updated some 2 million rows in the table tab_tr. But the total count of rows for col_ern_type in ('031','035','036', '041','045','046') yeild only around 222642 rows.
select count(*) from tab_tr where col_ern_type in ('031','035','036', '041','045','046'); --> 222642 rowswhat is the problem with the above update statement.
Thank you,Hi,
DBA_1976 wrote:
... I thought the case statement conditions are counted as the where condition. But ......A CASE expression just takes the place of some other expression, such as a literal, a function, or a column.
For example, which rows do you think this should update?
UPDATE tab_tr
SET col_rate = 100;It would update all rows, of course.
How about this statement?
UPDATE tab_tr
SET col_rate = column_x;Will it only change the rows where column_x are a certain value, or not NULL, or in any way depend on column_x? No, of course not. It will update all rows.
How about this statement?
UPDATE tab_tr
SET col_rate = function_y (col_ern_type);Will it only change the rows where the fucntion returns a certain value? Will it depend on the value in col_ern_type? No, of course not. It calls the function for each row, and whatever the function returns (even if the function returns NULL), that's what goes into col_rate on each row.
A CASE expression is just something that you can substitute in place of any other expression, such as the literal 100, or the column column_x, or the function function_y in the statements above. Naturally, the value that gets put into col_rate will depend on what the CASE expression returns, but the behavior of the UPDATE statement as a whole will not.
Maybe you are looking for
-
Just yesterday I upgraded my OS to tiger 10.4.8 from 10.2.8 I did the erase and install option so as to remove OS9 from my hard drive since I have no OS9 software. Prior to the upgrade I saved all my important files to CD RW. (this took 3 CDs, so the
-
Mac Mini5,3 Display port conectivity SAMSUNG U28D590D
Hi New mac user here, I have a Mac Mini MC936B/A OS X Server Lion 10.7.5 Im using a Samsung U28D59D monitor, this works ok via HDMI at 50hz but i get no picture using the display port output from the mac. I just get a blank screen, the monitor picks
-
I am having problems with HND's activity reports. First off, I use both HND & Network Magic. I have a problem with both viewing and customizing my activity reports. 1. When I click on the Customize Settings, my browser comes up and fails to produc
-
Is LENOVO G50-80 80L0006CIN supports Intel Vertualization Technology ?
Hi All, I want to purchage ENOVO G50-80 80L0006CIN. I want to run Virtual PC through Oracle Vertual Mechine or VMWare Player to run 64 bit OS (Linux CentOS) on Windows 7 64 bit host. Is this laptop supports Intel Vertulaization (is there option to en
-
Need HELP...Flash Trial didn't finish downloading-now can't find it
I just downloaded the trial version of Flash from the Adobe website, but for some reason the download didn't finish or the installation of the download was interrupted/causing it not to finish. Now I can't seem to find Macromedia Flash on my computer