Why does this select statement fail.....

declare
t_name varchar2(100):='america';
begin
execute immediate '
select * from'|| t_name;
end;

Because it looks like you need to add a space after 'from' and add an INTO CLAUSE?
introduction to bulk pl/sql enhancements in 9i

Similar Messages

  • Why would this select statement give an error?

    *LOOKUP Z_HELPER
    *DIM TGT1 : ACCOUNT="AA_1070100"
    *DIM CATEGORY="ACTUAL"
    *DIM TIME="2011.JAN"
    *ENDLOOKUP
    *SELECT(%TGTDEST2%, "[ID]", TARGETDESTINATION, "[UNIQUEIDENTIFIER]"=LOOKUP(TGT))
    UniqueIdentifier is a property of Targetdestination dimension. Here is the error its giving:
    Validation status of executable file: Failed
    - Unclosed quotation mark after the character string '=LOOKUP(TGT'. in:select [ID] from mbrTARGETDESTINATION where [UNIQUEIDENTIFIER]"=LOOKUP(TGT
    Validation status of syntax: Failed
    - Invalid syntax found; see statements in red

    Nilanjan, I changed TGT to TGT1, still same thing.  Here is the big picture outcome I am trying to achieve.
    Reporting App
    Entity   Costcenter    Shipto   Time          Category  Account    Signed data
    ABC        CO1             USA    2011.jan      Actual     ACT123       200
    So data is coming in like this, the business wants to set up rules such as.....when Costcenter is CO1 AND Shipto is USA AND Entity is ABC....Change the shipto from USA to INDIA. These rules have to be able to be updated by a business user, So I cant hardcode these rules. My manager doesnt want to use Stored procedures, so here is what I did....
    Z_Helper App(Non reporting App)
    Entity Costcenter Shipto   signeddata (other required dimensions are just dummy values)
    ABC     CO1            USA       9
    Now how does 9 get linked to INDIA? I created a new dimension called TARGETDESTINATION. it has ID(which is nothing but shipto country values), and a property called UNIQUEIDENTIFIER. Unique Identifier basically just assigned a unique value to that shiptocountry member row.
    So now I need to write a script logic in reporting app that will look up signed data of 9 in this example, and I was thinking use a select statement to pull INDIA from TARGETDESTINATION dimension.
    Let me know if you have any suggestions. thanks.

  • Why does this numeric compare fail in MDX?

    Given the MDX query below you can see that under certain circumstances MDX fails to see the .22 is not less than .22; what's going on here?
    WITH
    MEMBER Measures.X1
    as
     1.0 + ((22.0 - 100.0)/100.0),
    FORMAT_STRING = '.00'
    MEMBER Measures.Y1
    as
     IIF(Measures.X1 < .22,
    'Fail', 'Pass')
    MEMBER Measures.X2
    as
     (22.0/100.0),
    FORMAT_STRING = '.00'
    MEMBER Measures.Y2
    as
     IIF(Measures.X2 < .22,
    'Fail', 'Pass')
    MEMBER Measures.X3
    as
      StrToValue(1.0 + ((22.0 - 100.0)/100.0)),
    FORMAT_STRING = '.00'
    MEMBER Measures.Y3
    as
     IIF(Measures.X3 < .22,
    'Fail', 'Pass')
    MEMBER Measures.Z
    as
     IIF(.22 < .22,
    'Fail', 'Pass')
    SELECT{[Measures].[X1],
    [Measures].[Y1],
    [Measures].[X2],
    [Measures].[Y2],
    [Measures].[X3],
    [Measures].[Y3],
    [Measures].[Z]} ON 0
      FROM [APM]
    Thanks,
    David Skelton

    I'm sure you are correct... thanks for the quick response...
    Given what you've said I think this results for Y1 in this query are misrepresented:
    WITH
    MEMBER Measures.Y1 as
     1 + ((22 - 100)/100), FORMAT_STRING = '.0000000000000000000000000000'
    MEMBER Measures.Z2 as
      Y1 - .22, FORMAT_STRING = '.0000000000000000000000000000'
    SELECT{[Measures].[Y1],
           [Measures].[Z2]} ON 0
      FROM [APM]

  • Why does this select binding throw a NullPointerException?

    This should be pretty simple.  The javadoc for Bindings#selectString says:
    Creates a binding used to get a member, such as a.b.c. The value of the binding will be c, or "" if c could not be reached (due to b not having a c property, b being null, or c not being a String etc.).
    Running this example:
    import javafx.beans.binding.Bindings;
    import javafx.beans.binding.StringBinding;
    import javafx.beans.property.*;
    public class SelectBindingExample {
        public static void main(String[] args) {
            ParentModel parentModel = new ParentModel();
            StringBinding bindingA = createBinding(parentModel);
            String nameA = bindingA.get(); // NPE while evaluating
            System.out.println("Bound value is " + (nameA != null ? nameA : "null") + ".");
            parentModel.setChildModel(new ChildModel());
            StringBinding bindingB = createBinding(parentModel);
            String nameB = bindingB.get();
            System.out.println("Bound value is " + (nameB != null ? nameB : "null") + ".");
        private static StringBinding createBinding(ParentModel parentModel) {
            return Bindings.selectString(parentModel.childModelProperty(), "name");
        public static class ParentModel {
            private final ObjectProperty<ChildModel> childModel = new SimpleObjectProperty<>();
            public final ReadOnlyObjectProperty<ChildModel> childModelProperty() {return childModel;}
            public final ChildModel getChildModel() {return childModel.get();}
            public final void setChildModel(ChildModel childModel) {this.childModel.set(childModel);}
        public static class ChildModel {
            private final StringProperty name = new SimpleStringProperty("Child Model Name");
            public final ReadOnlyStringProperty nameProperty() {return name;}
            public final String getName() {return name.get();}
            protected final void setName(String name) {this.name.set(name);}
    ..causes a NPE while evaluating the binding:
    WARNING: Exception while evaluating select-binding [name]
    Jan 24, 2014 7:10:57 AM com.sun.javafx.binding.SelectBinding$SelectBindingHelper getObservableValue
    INFO: Property 'name' in ReadOnlyObjectProperty [bean: SelectBindingExample$ParentModel@4437c4, name: childModel, value: null] is null
    java.lang.NullPointerException
      at com.sun.javafx.binding.SelectBinding$SelectBindingHelper.getObservableValue(SelectBinding.java:481)
      at com.sun.javafx.binding.SelectBinding$AsString.computeValue(SelectBinding.java:394)
      at javafx.beans.binding.StringBinding.get(StringBinding.java:152)
      at SelectBindingExample.main(SelectBindingExample.java:9)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:483)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
    What's going wrong here?  I've updated the example to work with the Bindings#selectString method from Java 7 and things work as expected.  Is this a bug?
    Slight modification to the example so it works with Java 7.

    An additional thought, though.
    This suggests (implies, I think) that Bindings.selectString(...) is using try-catch structures to process the logic of stepping through the properties and evaluating the result. In pseudocode, something like
    public static StringBinding selectString(ObservableValue<?> root, String... steps) {
       try {
        ObservableValue<?> ov = root ;
        for (String step : steps) {
           ov = findObservableValue(ov, step);
        return (String) ov.getValue();
      } catch (NullPointerException | ClassCastException exc) {
       // display horrible warning
       return "" ;
    Apart from the unnecessary warning (because the state that's being warned about is supported, according to the spec), this is a very inefficient implementation, and it wouldn't be too hard, for example, to come up with scenarios where this made table sorting of the order of 100 times slower than it should be. (See this for a similar example, which is now fixed.) It is probably worth verifying this, and filing a JIRA if true.

  • Why this select statement is failing

    Hi to all experts.
    Im not able to understand why this select statement is not fetching the record with this parameters. When i give the same parameters in se11 table t512w.. It has one record, but here the sy-subrc Value is 4.
    select  * from t512w where molga EQ '15'
             and lgart in g_lgart01
           and endda gt pn-endda
       and begda lt pn-endda.

    Dear Mohamed,
    This Select Statement is bound to Fail. When you are doing a select * from T512W, you intend to get a single record from T512W into the work area T512W which you have declared using TABLES statement. So, here you need to use Select single instead of Select *
    If you want more data, then you declare an internal table, say gt_t512w type standard table of t512w and use "
    Select from T512W
    Into TABLE GT_T512W
    WHERE ........
    Hope this solves your problem.
    Regards,
    Amit Sharma

  • After Effects CC 2014 will not upgrade?  Gets to 100% and then says application failed.  Why does this not upgrade?

    After Effects CC 2014 will not upgrade?  Gets to 100% and then says application failed.  Why does this not upgrade?

    We can't know anything. You have not provided any useful details like system information or the install logs.
    Mylenium

  • HT5007 Why does this app stop at about 10 seconds into a selected trailer then resume on it's own?

    Why does this app stop and resume?

    I believe the OP is asking about the Apple iTunes Movies Trailer app, so it is an Apple app.
    I think maybe the video playback catches up with the download and until the download resumes, the video is stopping. Just a guess at this point.

  • Re: Select statement fails under Express, but works underForte when usi

    Hi there,
    I have logged this with Forte and it as been recognized as a bug ( #46554 ).
    The Express methods you need to look at if you want to modify this behavior
    are :
    1 - BusinessQuery.BuildQuery() starting at line 217
    2 - SqlQuery.GetWhereText() starting at line 60
    We have gotten around the problem by modifying what Express generates by
    changing it from ( col1, col2 ) in ( select col1, col2 ... ) to ( col1 +
    col2 ) in ( select col1 + col2 ... )
    Just one thing i'm not sure that the '+' is standard on every DBMS for
    concatenation.
    We are using SQL Server 6.5
    Hope this helps.
    Christian Boult ([email protected])
    Programmeur - Analyste
    Influatec inc.
    -----Original Message-----
    From: Metcalf, Roger <[email protected]>
    To: '[email protected]' <[email protected]>
    Date: Thursday, May 06, 1999 1:55 PM
    Subject: Select statement fails under Express, but works under Forte when
    using DB2
    Express sometimes (e.g. with nested windows) generates SQL with a select
    subquery, e.g.
    select x1, x2 from t1 where (x1,x2) in (select x1,x2 from t2.....)
    This fails on DB2 with a message that the comma in the where clause (x1,x2)
    is not allowed.
    This works on Oracle.
    Does anyone have a workaround or other suggestion?
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    joe.meszaros wrote:
    (SELECT ? AS Id, ? AS UserBytes FROM dual)I suggest that you test to see if that statement and ONLY that statement works at all.
    There are rules for bind variables and that statement certainly looks suspicious.
    If you can't get that to work then the rest of the attempt is pointless.

  • Re: Select statement fails under Express, but works underForte whenusin

    Roger,
    This was a bug with Express and was fixed in Express E.2.0.L.0.
    You might be able to get more details on Forte's website.
    Ajith Kallambella M
    From: "Metcalf, Roger" <[email protected]>
    Reply-To: "Metcalf, Roger" <[email protected]>
    To: "'[email protected]'" <[email protected]>
    Subject: Select statement fails under Express, but works under Forte
    whenusing DB2
    Date: Thu, 6 May 1999 11:55:19 -0400
    Express sometimes (e.g. with nested windows) generates SQL with a select
    subquery, e.g.
    select x1, x2 from t1 where (x1,x2) in (select x1,x2 from t2.....)
    This fails on DB2 with a message that the comma in the where clause (x1,x2)
    is not allowed.
    This works on Oracle.
    Does anyone have a workaround or other suggestion?
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>_______________________________________________________________
    Get Free Email and Do More On The Web. Visit http://www.msn.com
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    joe.meszaros wrote:
    (SELECT ? AS Id, ? AS UserBytes FROM dual)I suggest that you test to see if that statement and ONLY that statement works at all.
    There are rules for bind variables and that statement certainly looks suspicious.
    If you can't get that to work then the rest of the attempt is pointless.

  • Please explain on what does these select statements get from these tables..

    Hello Experts,
    What does these select statements get?and what are these tables CDHDR and CDPOS used for?
    The program that I am currently modifying lets users post documents and the ones that are not posted
    are saved in a custom table. Now, we had a scenario in PROD server wherein certain items are not being
    fetched as bypassed but we saved it in the bypassed table. Anyway, below is the select statements:
    get all change document header within the selected dates
      SELECT * INTO CORRESPONDING FIELDS OF TABLE it_cdhdr
        FROM cdhdr
       WHERE udate IN s_udate
         AND objectclas EQ 'CHARGE'
         AND tcode IN (lc_tcode_msc1,
                       lc_tcode_msc2,
                       lc_tcode_msc1n,
                       lc_tcode_msc2n,
                       lv_tcode_vl33n,
                       'SE38',
                       'ZGENE').
    IF NOT it_cdhdr[] IS INITIAL.
    SELECT objectid changenr value_new
          FROM cdpos
          INTO TABLE it_cdpos
          FOR ALL ENTRIES IN it_cdhdr
         WHERE objectclas EQ it_cdhdr-objectclas
           AND objectid   = it_cdhdr-objectid
           AND changenr   = it_cdhdr-changenr
           AND tabname    = lc_tabname_mcha
           AND fname     IN (lc_fname_zustd,'LWEDT').
    DELETE it_cdpos WHERE value_new+00(01) = 'X'.
      LOOP AT it_cdpos ASSIGNING <fs_cdpos>.
        l_matnr = <fs_cdpos>-objectid+00(18).
        l_charg = <fs_cdpos>-objectid+22(10).
        l_zustd = <fs_cdpos>-value_new+00(01).
        READ TABLE it_batch INTO wa_batch
             WITH KEY matnr = l_matnr
                      charg = l_charg.
        IF sy-subrc EQ 0.
          l_tabix = sy-tabix.
          wa_batch-zustd = l_zustd.
          MODIFY it_batch FROM wa_batch INDEX l_tabix
                 TRANSPORTING zustd.
        ELSE.
          wa_batch-matnr = l_matnr.
          wa_batch-charg = l_charg.
          wa_batch-zustd = l_zustd.
          wa_batch-code  = 'A'.              "selected within period
          APPEND wa_batch TO it_batch.
        ENDIF.
      ENDLOOP.
      ENDIF.

    Hi,
                            The first select statement is for Change document header.CDHDR table contains this object class in your case if you change any batch number for any material number  from the transaction for example (MB01) you can trace this .
    From CDPOS you can trace which tables affected (EX : MCHA) and the new value(l_zustd ).
    Regds,
    Vinsa.R

  • HP Photosmart C8180 Printer! WHY does this keep happening every day??

    I have only had this for 3 months and it already has problems.
    It keeps telling me its out of paper when it is not.
    i always have at least 20 sheets in there!
    You can hear the rollers going but it can't pick up the paper and I only use high quality A4 paper in there.
    i then have to pull the tray out and push it back in, and yes i have the paper inserted in there correctly
    also, sometimes when i get this "out of paper" message, i ignore it and just press OK and it works fine 
    why does this keep happening?
    this is disgusting coming from a Quality brand like HP
    think its time to go to BBC Watchdog! 
    A printer is an item meant to print. 
    It is generally helpful if a printer recognizes such out-of-the-ordinary, eccentric, unheard-of media such as...oh, I dunno, 8.5 x 11-inch PAPER?????
    It claims repeatedly to have run out of paper. No paper. No paper. Insert paper into paper tray. Now, granted, the minimalist quality of the paper tray--it holds 20 pages, roughly--might convince you that I had indeed used up all my paper; this is not the case. 18 of the 20 sheets are still there. So I readjust that paper, close the tray. It starts to pull in a piece of paper, and then there is the giant crunchy noise of a paper jam in progress. And forget about “easy access” for removing them, either.
    In the months I have had this printer, I don’t believe it has EVER allowed me to print five pages consecutively without some sort of problem.  To me, this is known as an EPIC FAIL. 
    Message Edited by Waynester on 04-16-2009 04:09 PM

    So how is the printer set up?  Is it wireless or USB?  If USB you will need a cable, purchased seperately.  It is a standard A/B USB cable widely available inexpensively.  (The $1 cables form the dollar store work fine....
    Running the diagnostics at http://www.hp.com/go/tools may help resolve the issue.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • Why does this cause error (ORA 01008: Not all variables bound)

    When I assign values to parameters for a command object, I used the following code with the .NET provider:
    If oReq.CritSpec = Nothing Or oReq.CritSpec = "" Then
    cmdReq.Parameters.Add(":po5", DBNull.Value)
    Else
    cmdReq.Parameters.Add(":po5", oReq.CritSpec)
    End If
    This works fine, but when I switch to using ODP it generates the 'not all variables bound' error. I checked the parameter's status and it was Success. However, if I change the second line of the statement to
    If oReq.CritSpec = Nothing Or oReq.CritSpec = "" Then
    cmdReq.Parameters.Add(":po5", OracleDbType.Varchar2, DBNull.Value, ParameterDirection.Input)
    Else
    cmdReq.Parameters.Add(":po5", nReq.CritSpec)
    End If
    It seems to be OK. So my question is - why does the first statement generate the error? Am I misinterpreting the overloaded constructor or it it a bug in my code? Thanks.
    ck

    No need to answer, I solved it.
    For anyone else who might run into this, there were two issues:
    1. Assigning DBNull.Value to a parameter without specifying the parameter's type causes the Value property for that parameter to not be initialized. If you reference it, it will come back as a runtime error (check it first by testing for IsNot Nothing).
    2. In my update code, I have a lot of where clauses like "WHERE (COL1 = :1 OR COL1 IS NULL AND :1 IS NULL)". The default binding for parameters treats these two references to :1 as two different parameters. Setting BindByName to true solves the problem.
    ck
    Edited by: user536671 on Feb 15, 2009 7:04 PM

  • While trying to instal Mountain Lion OS on my macbook pro, I got the error message that my HD was damaged and it reverted to my Lion OS. Why does this happen? I bought the OS online through the app store

    While trying to instal Mountain Lion OS on my macbook pro, I got the error message that my HD was damaged and it reverted to my Lion OS. Why does this happen? I bought the OS online through the app store.

    The Mountain Lion installer looks at your internal drive to make certain that it's error-free before continuing installation. You should have an application named "Install OS X Mountain Lion.app" in your Applications folder now so you shouldn't have to download it again. Do this...
    Boot to your Lion recovery partition by holding down both the Command and the R keys while booting. Open Disk Utility from the Recovery partition and select your hard drive (usually named "Macintosh HD" unless you've renamed it) and click on Verify Disk. If you come up with any errors, click on Repair Disk. At the end of the cycle you will get a message that the disk was successfully repaired or a message that the hard drive could not be repaired.
    If you're able to repair the disk, just reboot as normal and open the "Install OS X Mountain Lion.app" and the installation will proceed. If Disk Utility was unable to repair the disk, you need to get to your local Apple Store as soon as possible so that they can see if the disk is salvageable or beyond repair.
    Good luck,
    Clinton

  • Why did this mini-video fail to go viral?

    Why did this mini-video fail to go viral?
    I created this short motion graphics project in AE and PR Pro for my hearing protection client in Switzerland for their "Sleep Plugs" product. She asked for a European look and feel, where tasteful nudity is common in advertising. Our target demographic is males, aged 18-35. The client posted it at her Zurich-based company’s website and hoped it would spread virally. We believed there was actually a good chance of that happening since we have three main elements of a viral video: sexiness, surprise, and humor. However, the number of views was much lower than we had hoped.
    Please watch the video (it's just 30 seconds) before reading my comments and questions below so that I don't influence your first impression. 
    https://vimeo.com/63794871
    Password: GUNN
    Please give me your thoughts on these questions: 
    1. It was my intention to set the viewer up to expect that the couple was going to have sex, then to provide some unexpected humor when she goes to sleep and snores instead. Did you think that was funny?
    2. In an ideal world, this would have been live video, but, for budget constraints, and since there would've been very little movement in a video anyway, we went for a graphic approach, basically a pan across a wide, horizontal photo, with music bed and voiceovers, and logo/tagline at the end. Do you think this was an acceptable compromise?
    3. With the outtake-style photos at the end, It was my intention to add a touch of silliness and show that we are not taking ourselves too seriously. Do you think that worked?
    4. What do you think of the voiceovers?
    5. What do you think of the choice of music? (I wish we could have had Marvin Gaye's "Let's Get It On"! altho, not sure how big that is with 18-35 year old males in Switzerland.)
    6. These next two may be the most important questions: the context the video was presented in. My intention was to have the viewer sucked in by the sexy partial image and want to know more, thinking "What is this? . . . a  joke? . . . porn?!?" (remember, they are 18-35 yr old males!) and watch it long enough to get to the joke and the appearance of the product. (I know I have watched several videos that turned out to be ads, but they were so entertaining and well done, I did not mind. In fact, I admired how they sucked me in!)
    My client posted the link to the video on her company Facebook page, with the comment "Check out our new video." The link led to her company's official website and the video appeared on a page surrounded by other text, photos, and the company's name. It is my opinion that this took away some of the incentive to watch the video, since now the viewer already knows it is going to be an advertisement. Would you agree?
    7. I feel the video should've been presented "in a vacuum", so the viewer would have no fore-knowledge of what it was or why their buddy forwarded it to them. I think links to most viral videos lead to YouTube or Vimeo (not to a company website.)  What do you think would be the best method of distribution for this little video?
    And, if you have any other thoughts, please let me know.
    Thank you for your time and consideration,
    --Carol Carol Gunn
    Gunn Graphics
    Austin, TX
    www.gunngraphics.biz
    www.linkedin.com/in/carolgunn 

    Hi Carol,
    I have to agree with Jim.  A still image screams 'cheap'.  If I didn't watch the video with the intention of providing feedback, I would have tuned out after about 5 seconds, before even getting to the 'punch line'.  With so many bad videos on YouTube, people's attention span have been reduced to mere seconds.  If we don't like what we see in the first few seconds, we tune out and click on another link.  I imagine many people who watch this video never get to the end since the moment they see it's a still image that probably won't change to live action, they think 'cheap' and tune out.
    For a video to go viral, people have to want to pass it on to all of their contacts.  For this to happen, they have to imagine that others will thank them for sharing the video, not roll their eyes and ask 'Why are you wasting my time with this?'  "sexiness, surprise, and humor" are not enough for a video to go viral.  You also need great execution.
    3. Didn't work for me.  It makes it look like the commercial and product are a joke, especially hearing the guy's laughter in the background.  First the commercial would have to sell us on why the product is worthwhile/needed, which is doesn't.
    4. The girl's voice is sexy, but it does not match the visuals, thus it ends up sounding fake and unnatural.
    The guy's tatoo is a huge distraction.  Is it a human heart?  Why is it there?
    Low budget doesn't have to mean a cheap look.  Unfortunately the titles and the transitions (push, ripple dissolve) at the end also scream cheap.  Nobody uses these kinds of effects on TV, so it's best to leave these for home videos and out of any professional work.  Push transitions can work, but usually only if it's a quick transition, around 3-8 frames long.  Slow push transitions scream 'Power Point', which in turn screams 'cheap'.
    Hope this helps!
    Cheers

  • Lately when I sync certain albums to my iPhone, the tracks are duplicated one behind the other so that I have to listen to each song twice. Why does this happen and how can it be fixed?

    Lately when I sync certain albums to my iPhone, the tracks are duplicated one behind the other so that I have to listen to each song twice. Why does this happen and how can it be fixed?

    Very strange behavior.  Don't entirely give up on the "Manually Added Items" category ... I have seen things magically appear there even after I've checked and seen nothing there.  I think things got real quirky when Apple released iCloud ... I don't remember extra copies of purchases lingering on my iPhone once transferred to my library before that.  Sure, if I bought an album directly to my iPhone it would stay on there even after I sync to my library, but if I deleted the album from the iPhone it stayed deleted.  Now it seems that there are some phantom copies that come and go with no explanation.
    jcburbank wrote:
    I've tried deleting the album from both the phone and from iTunes and then redownloading them to both and the same problem occurs.
    If you're re-downloading an album to iTunes and your iPhone, that may perpetuate the problem.  What happens if you completely delete every copy of the album, then just download to your iTunes library and then sync the album to your iPhone from your library?  That should put only one copy on your iPhone.
    A few other things to try:
    1- Completely sign out of your Apple account on your iPhone, then re-sync to iTunes, then sign into your account on your iPhone again.  Maybe throw in a Reset or at least a power OFF/ON somewhere in the middle.
    2- Go to Settings/ General/ Usage, then select Music and when you see All Music, swipe your finger across it and tap the Delete button.  Before doing anything else, Reset your iPhone.  This does not actually delete your music, but seems to clear up some cobwebs left behind (people use this technique to reduce "Other" that swells up over time).

Maybe you are looking for