Help with using variable for name of table in PLSQL block...

I am trying to use a variable for the name of a table but getting errors ...i am sure I am close to the correct form here but something is wrong. I sure would appreciate some help!
DECLARE
ln_month Number;
ln_day Number;
ln_year Number;
ls_year VarChar2(4);
ls_prev_table VarChar2(30);
ls_cur_table VarChar2(30);
ln_prev_year Number;
ls_prev_year VarChar2(4);
ln_prev_month Number;
BEGIN
Select To_Number(To_Char(sysdate, 'MM')) into ln_month from dual;
Select To_Number(To_Char(sysdate, 'DD')) into ln_day from dual;
Select To_Number(To_Char(sysdate, 'YYYY')) into ln_year from dual;
If ln_month = 01 Then
ls_cur_table := "T_CPRS_FDW_CUR_JAN_ACTUALS";
ls_prev_table := "T_CPRS_FDW_PREV_DEC_ACTUALS";
ln_prev_year := ln_year - 1;
/***above is where I am trying to use variables for assignement to years and months tables***//// ln_prev_month := 12;
End If;
/*------MORE IF STATEMENTS FOR EACH MONTH ---OF --THE YEAR ...AND its the following 2 variable statements that the compiler doesnt like! */
If ln_day < 20 Then
Delete from :ls_prev_table;
INSERT INTO :ls_prev_table /*(STUFF TO BE INSERTED GOES HERE)*/
HELP PLEASE!
null

Hi,
The parser does not under variables directly in dml statements.u need to form a statement and the parse and execute the same...
so the soln is
Declare
lv_stmt varchar2(250);
Begin
lv_stmt := 'Delete from '&#0124; &#0124;ls_prev_table;
execute immediate lv_stmt;
-- Same is the case with the insert stmt--
End;
This should solve ur problem.
u could also give a direct call like
execute immediate 'Delete from '&#0124; &#0124;ls_prev_table ;
Note: This statement "execute immediate" holds good for oracle versions 8.x and above which makes the stmt very simple. For lower version u need to use the dbms_sql package to parse and execute the statement which has a series of statements for the same.
Kiran

Similar Messages

  • Need help with using variable

    Using Automator I want to launch a URL where part of the URL is the Automator variable User name.
    Since Automator now has these variables I want to use that.
    Something like this:
    smb://domain/server/folder/User name
    I cannot see how to get the URL to include the placeholder for the variable

    When I use the AppleScript in Automator I get this:
    The action "Run AppleScript" encountered an error.
    Check the actionʼs properties and try running the workflow again.
    The line in question that I copied and pasted is:
    mount volume "smb://domain/server/folder/"&quoted form of input
    Does anyone see the problem?
    If I remove the whole section trying to use the variable (like this:
    mount volume "smb://domain/server/folder/name) the script runs fine.
    Any more ideas?

  • Help with using photos for web

    I would like to use some photos I have stored in iphoto library, but I need to reduce them. Reading the help guide, it is indicate to export to web page. But in that case it opens automatically a new web page. How can I export to a page that I have already created?
    Moreover what I do not understand is how can I reduce the dimension of the photo without changing the quality? This can be done in iphoto with export?
    I am a little bit confused...
    thanks for help

    Yep you have answered your own question.
    Choose export, file export and click the scale images option, and original options (assuming they are already jpegs).
    (As you say exporting as webpage creates the page for you but can create images in two sizes (thumnails and main) which can be helpful. The downside the that the filenames for the images as numeric. 1.jpg, 2.jpg etc.)
    While a longer process and with no direct control over file size and quality I prefer the file export option as above. It preserves filenames and quality is fine.
    and do choose 'original' as you should avoid re-saving a jpeg as a jpeg (that causes a quality reduction)
    You will need to manually bring the images into your web pages (save the exported images into your site folder and bring each one into your page individually) unless you are very clever with filenaming!
    Hope this helps.
    M.

  • Help with using MACROS for mac

         I have a serious issue and not sure if Im in the right place. i just started school. I am try to using the riverpoint writer on my mac, but for some reason it keeps saying that it cant load visual basic for application. Has anyone had this problem and if so can you tell me how you resolved it. that you for your help in advance.

    I must say sir I went thru it trying to get something that worked with riverpoint writer. And guess what I had to do in order for it to work on my macbook. REINSTALL OFFICE FOR MACS, thats all. Now its up and running and I am please, after searchin and spending unneccesary money on products that I did not need after all. Thank you for steering me wrong, to where I almost gave up.

  • Help with using frames for animation

    I am using frames to animate webpage using fireworks 4 (I
    know, hopelessly outdated). I seem to have two different
    collections of frames that interact- one for the main image, and
    one for the slice I'm trying to animate as a GIF. I can't seem to
    change the time delay for each frame when I'm editing the slice.
    What can I do to make this work?

    Yep you have answered your own question.
    Choose export, file export and click the scale images option, and original options (assuming they are already jpegs).
    (As you say exporting as webpage creates the page for you but can create images in two sizes (thumnails and main) which can be helpful. The downside the that the filenames for the images as numeric. 1.jpg, 2.jpg etc.)
    While a longer process and with no direct control over file size and quality I prefer the file export option as above. It preserves filenames and quality is fine.
    and do choose 'original' as you should avoid re-saving a jpeg as a jpeg (that causes a quality reduction)
    You will need to manually bring the images into your web pages (save the exported images into your site folder and bring each one into your page individually) unless you are very clever with filenaming!
    Hope this helps.
    M.

  • Can you please help me with validation logic for Events in Table maintenance generator

    Can you please help me with validation logic for Events in Table maintenance generator,i.e if i enter record in 1st internal table then automatically 2nd internal table should be updated.

    Hi Glen Anthony,
        Thanks for replay,
         I used foreign key relationship between those 2 internal tables....
    I used event 05: When creating a new entry. I want to know the custom logic by which my 2nd Internal table gets automatically updated when i update my 1st Internal table
    Thanks Glen.

  • What is the benefit in using OID for names resolution?

    I have been wondering about this for awhile. I have been working on getting this to work in Iplanet along with Pat Lehane ([email protected]), and it works now.
    What are the benefits in using OID for names resolution when you can just use the static tnsnames.ora. Database and database names are not created dynamically and they don't change that often. Would creates a new database every day and has to worry about changing the static tnsnames.ora file. In my environment, we run Oracle applications from a server, so there is only one tnsnames.ora file, on the file server.
    It would appear that using OID would cause extra traffic (LDAP lookups) on your network.
    I would like some opinions from both Oracle and Oracle users. Thanks

    hi,
    A benefit of using OID for names resolution is that it allows you to centralize net8 naming (i.e., tnsnames) information in the same place (OID) where other types of administrative information (about users, enterprise groups, enterprise roles, etc) gets stored. If you are more comfortable using tnsnames.ora files for net8 naming, that is perfectly fine!
    An important reason that Oracle had for providing Net8 naming functionality in OID is that the legacy 'Oracle Names' functionality of Oracle 7 will eventually be desupported. This is discussed in metalink Note #135696.1 on http://metalink.oracle.com .
    Hope this helps.

  • Using variable coulmn name in sql function

    Hi there,
    I am not an expert with PL/SQL and I can not figure out how to use variable column names in my function.
    My function is:
    CREATE OR REPLACE FUNCTION RESET_TRIGGERS(aTrigger VARCHAR2) RETURN NUMBER IS
    TEMP_ID NUMBER;
    TEMP_USER_ID NUMBER;
    BEGIN
    SELECT 'LIMS.'||'$aTrigger'||'.NEXTVAL' INTO TEMP_ID FROM DUAL;
    SELECT 'LIMS.'||'$aTrigger'||'_USER.NEXTVAL' INTO TEMP_USER_ID FROM DUAL;
    IF TEMP_ID > TEMP_USER_ID THEN
    LOOP
    SELECT LIMS.SQ_U_FINALRESULT_USER.NEXTVAL INTO TEMP_USER_ID FROM DUAL;
    EXIT WHEN TEMP_USER_ID = TEMP_ID;
    END LOOP;
    ELSE
    WHILE TEMP_ID < TEMP_USER_ID LOOP
    SELECT LIMS.SQ_U_FINALRESULT.NEXTVAL INTO TEMP_ID FROM DUAL;
    END LOOP;
    END IF;
    COMMIT;
    RETURN (TEMP_ID);
    END;
    What I want is that I pass a seqencename with aTrigger and that two triggers will be equal if not.
    eg ifaTrigger = 'SQ_U_FINALRESULT'
    than I want the triggers LIMS.SQ_U_FINALRESULT and LIMS.SQ_U_FINALRESULT_USER to be set equal.
    The above function will not work, but what will?????
    I hope you can help me out!
    Cheers

    A very strange function indeed.
    But here is what I think he meant to do:
    SQL> create procedure reset_sequences
      2  ( p_sequence_name in  varchar2
      3  , p_nextval          out number
      4  )
      5  is
      6    l_nextval1 number;
      7    l_nextval2 number
      8    ;
      9    procedure reset_sequence_value
    10    ( p_sequence_name in varchar2
    11    , p_current_value in number
    12    , p_new_value     in number
    13    )
    14    is
    15      l_dummy number;
    16    begin
    17      execute immediate 'alter sequence ' || p_sequence_name || ' increment by ' || to_char(p_new_value-p_current_value);
    18      execute immediate 'select ' || p_sequence_name || '.nextval from dual' into l_dummy;
    19      execute immediate 'alter sequence ' || p_sequence_name || ' increment by 1';
    20    end reset_sequence_value
    21    ;
    22  begin
    23    execute immediate
    24      'select ' || p_sequence_name || '.nextval,' || p_sequence_name || '_user.nextval from dual'
    25    into l_nextval1, l_nextval2
    26    ;
    27    if l_nextval1 < l_nextval2
    28    then
    29      reset_sequence_value(p_sequence_name,l_nextval1,l_nextval2);
    30    end if
    31    ;
    32    if l_nextval1 > l_nextval2
    33    then
    34      reset_sequence_value(p_sequence_name || '_user',l_nextval2,l_nextval1);
    35    end if
    36    ;
    37    p_nextval := greatest(l_nextval1,l_nextval2)
    38    ;
    39  end reset_sequences;
    40  /
    Procedure is aangemaakt.
    SQL> show err
    Er zijn geen fouten.
    SQL> create sequence testseq start with 5 increment by 1
      2  /
    Reeks is aangemaakt.
    SQL> create sequence testseq_user start with 2 increment by 1
      2  /
    Reeks is aangemaakt.
    SQL> declare
      2    l_new_value number;
      3  begin
      4    reset_sequences('testseq',l_new_value);
      5    dbms_output.put_line(l_new_value);
      6  end;
      7  /
    5
    PL/SQL-procedure is geslaagd.
    SQL> select testseq.currval from dual
      2  /
                                   CURRVAL
                                         5
    1 rij is geselecteerd.
    SQL> select testseq_user.currval from dual
      2  /
                                   CURRVAL
                                         5
    1 rij is geselecteerd.Regards,
    Rob.

  • Using variables for answers to fill-in-the-blank questions

    Hello,
    For fill-in-the-blank questions, one has to provide answers. I want to provide these in the form of (user-created) variables, rather than in the form of fixed strings of characters (so then, as $$var1$$ rather than as 'rabbit'). I haven't been able to get this to work. The enter variable function is indeed available (in the properties panel), but it doesn't actually work (i.e. even if you select a variable to be entered, it doesn't actually get entered).
    Is there a way around the problem?
    1. NB that this same issue holds for text entry boxes (rather than fill-in-the-blank questions). If I could get this to work for text entry boxes, I would use them rather than fill-in-the-blank questions.
    2. One can use variables for answers to multiple choice questions. So I'm hoping I can get it to work for fill-in-the-blank questions as well.
    Thank you in advance. Marvin DuBois

    That would have been my suggestion. I don't have a dedicated blog post, but use TEB's for that kind of questions myself as well. And contrary to the widget/interaction I mentioned before, a TEB is an interactive object, which means it can be validated and there can be a score attached to it. But, it will not help you, since you have to add the correct answers in the same way as for a dropdown list in the FIB question (they are sort of TEB's there). And it is that list that doesn't allow to enter a variable instead of a fixed sequence of characters.
    Which means that you are back to the advanced actions, same as in my blog posts with the widget/interaction.
    Have a workaround (after all I am the workaround Queen) to have reporting, if you need to check only one TEB, described here:
    http://blog.lilybiri.com/report-custom-questions-part-2
    The idea is to use another interactive object that can have a score. In reality I use two instances of that same object: one with score 0 and one with score X and show the right one depending on the conditional action.
    However if you want to have multiple TEB's on the same slide, that have to be checked all with the same advanced action, than you'll need either the Mastery widget by InfoSemantics (only for SWF output) or Javascript.
    Lilybiri

  • Help with Simple Applescript for Midipipe

    Hey all, I'm in desperate need of help with some Applescript for use in a program called Midipipe:
    http://web.mac.com/nicowald/SubtleSoft/MidiPipe.html
    I simply require an Applescript for Midipipe that filters out all OFF notes except for the most recently pressed key, or most recently pressed ON note. So for example, when multiple keys have been pressed, only the most recently pressed key will send an OFF note. I hope that is clear enough, i've had some major issues trying to get this work and my last hope is to hit the forums and find some help .. I've posted on some of the audio forums and i'm hoping someone here knows how to code this.
    Thanks so much!! .. Its for an upcomming show next week so i'm hoping someone can get me in the right direction to solving this.
    -Jes

    I try to help, but you'll need to apply your brain cells to get it working with what I've already explained (three times with what I offer below).  Try something like the following (I am renaming your buttons to ch1,ch2,ch3,ch4,ch5,ch6 so that the same functions can be shared by all buttons...
    // this assigns listeners to all 6 buttons
    for(var i:uint=1; i<7; i++){
              this["ch"+String(i)].addEventListener(MouseEvent.CLICK, fl_ClickToSeekToCuePoint);
    // this processes any one of the 6 btns when they are clicked
    function fl_ClickToSeekToCuePoint_1(event:MouseEvent):void
        var btn = event.currentTarget;
        var cuePointInstance:Object = vid.findCuePoint(btn.name);
        vid.seek(cuePointInstance.time);
       resetButtons();    // this makes all buttons go back to normal
        btn.upState = btn.overState; // this makes the clicked button change states
    function resetButtons():void {
         for(var i:uint=1; i<7; i++){
              this["ch"+String(i)].upState =  this["ch"+String(i)].hitTestState;
    For this to work, your buttons need to have the same artwork in the hit frame as they do in the up frame.

  • Last Used status for Reports, Transactions, Tables ??

    Dear all,
    Kindly let me know how to find the last used status for
    Reports, Transactions, Tables ??
    This is very urgent, Please do the needful.
    Waiting for the responses..
    Cheers,
    Virendra.

    Here the issue is same.
    STAT transaction is asking for the time which is the main hurdle.
    I am hanging around with STAT transaction but not finding
    how to getover the time specification.
    if i dont specify the time i takes by default the 2 or minutes back from the current time.
    which is not useful for me at all.
    My main requirement is that my seniors want to know what are all reports or transaction or tables which are not used at what last time ?
    so if i have to specify the time wont be so useful for me.
    And writing a report 'll not gain anything coz internal SAP report is take time as main parameter.
    Regards,
    Virendra.

  • Help with Report Variables

    I have been doing battle with the SBO Customer Receivables Aging Report. I am trying to add the fields "Customer Reference" and "Creation Date" to the Repetitive area of the report with no success. All of the existing fields are variables, and the on-line help says to contact SAP support (which would be me) for help with changing variables. Does anyne have a list of these variables, or know how to define them?
    Many thanks,
    Mike.

    Hi Mike Stroud, i'm actualy also working on the customer ageing report. You also responded to my post. It was the reports one. Well, im not sure about the variables but i simply wrote a query that brings all that info and more up. But i'm having problems diplsying it. In the normal SAP report/print layout, if i  make the report based on the query it doesn't let me move the info from the repetitive area to the header....why.....can you get around this??? I then did it in the advanced layout but the first page is always wrong. What do you want to do with the variables?? what are you trying to achieve with the report because me and my coleagues have had a BIG problem with the ageing.

  • What are Parameters? How are they differenet from Variables? Why can't we use variables for passing data from one sequnece to another? What is the advantage of using Parameters instead of Variables?

    Hi All,
    I am new to TestStand. Still in the process of learning it.
    What are Parameters? How are they differenet from Variables? Why can't we use variables for passing data from one sequnece to another? What is the advantage of using Parameters instead of Variables?
    Thanks in advance,
    LaVIEWan
    Solved!
    Go to Solution.

    Hi,
    Using the Parameters is the correct method to pass data into and out of a sub sequence. You assign your data to be passed into or out of a Sequence when you are in the Edit Sequence Call dialog and in the Sequence Parameter list.
    Regards
    Ray Farmer

  • HELP HELP HELP with adminstrator password for pavilion dv7 beats audio

    Hi. I need help with  adminstrator password for pavilion dv7 with window 7. I don't remember with is the  adminstrator password for pavilion dv7 beats audio. Is there anyway you can help me with this? once i enter 3 times is gives me this system disabled code: 52464663.  

    Hi
    Try this Key : 43542265 That should fix your issue 
    Hope this helps.
    ***** Click the KUDOS Thumbs UP (Like) on the left to say 'Thanks'*****
    ****Make it easier for other people to find solutions, by marking my answer “Accept as Solution”&"Kudos"if it solves your problem.****
    -VJ
    Although I am an HP Employee, I am speaking for myself and not for HP.

  • I still need help with the Dictionary for my Nokia...

    I still need help with the Dictionary for my Nokia 6680...
    Here's the error message I get when trying to open dictionary...
    "Dictionary word information missing. Install word database."
    Can someone please provide me a link the where I could download this dictionary for free?
    Thanks!
    DON'T HIT KIDS... THEY HAVE GUNS NOW.

    oops, im sorry, i didnt realised i've already submitted it
    DON'T HIT KIDS... THEY HAVE GUNS NOW.

Maybe you are looking for

  • ITunes Downloads Same Episode Simulataneously?

    iTunes 6.0.1, 12" PowerBook G4 867 MHz, 256 MB RAM, Mac OS X 10.4.3 iTunes 6.0.1, 15" eMac 1.0 GHz, 256 MB RAM, Mac OS X 10.3.9 I am downloading 5 episodes of "Monk" and we thought that I I used Advanced>Check for Purchases on our eMac that maybe we

  • I Pod Wont Sync

    I restored my I pod recently and now when it syncs it will get to song 544 out of 606 and then say "The Ipod cannot be synced. The required disc cannot be found." and the sync stops. I then tried to eject the Ipod through both Itunes and Windows and

  • Adressbook got stuck in an other desktop.

    In my MBP(Lion) ,used by my wife, the adressbook got stuck on an other desktop. Some time ago she tried to update a page in adressbook but did not succeed. Yesterday I found out about it.When tapping ,via the trackpad, the adressbook-icoon in the doc

  • Best option for data replication

    Hello: II am trying to understand the pros of cons of using snapshots, materialized views or replication to maintain data concurrency between a primary table and its copy in another database. In addition, there are tables dependent on this copy in th

  • Do apple stores clean out the headphone jack?

    My headphones arent going all the way into the jack.  This is because my friend talked me in mud and im pretty sure there is a small buidl up of mud in there.  We tried with compressed air and paper clips to get it out but still no luck.  If I bring