What is the correct syntax for using a variable in an ad hoc query?

Hi all
I am an occasional DB user and at the moment need to update about 1000+ records so that a certain column gets a unique value.
So I thought that I would use a variable for this.
I then built this kind of SQL statement for just a small subset of the records:
variable recNumber number;
exec :recNumber := 1;
UPDATE TABLE_TO_BE_UPD
SET COL_TO_BE_UPD = COL_TO_BE_UPD + recNumber
WHERE COL_TO_BE_UPD IN ('VAL_A','VAL_B');
I get the invalid SQL statement error when attempting to execute above (besides the prompt that asks for a value which I would like to omit).
Anyway I also tried this one:
CREATE SEQUENCE seqCounter;
UPDATE TABLE_TO_BE_UPD
SET COL_TO_BE_UPD = COL_TO_BE_UPD + seqCounter.NEXTVAL
WHERE COL_TO_BE_UPD IN ('VAL_A','VAL_B');
From this one I got the error ORA-01722: invalid number...I am guessing this comes because seqCounter is of type number and the COL_TO_BE_UPD is of type character...(?)
So what I would like to ask is what is the correct way to define and use a counter type of variable to append a number at the end of a character string?
Also another question that I would like to ask is that are variables that are used in ad hoc queries also called 'bind variables'?
Thanks muchly

If you want to append a unique number to a column then this would do it:
UPDATE TABLE_TO_BE_UPD
SET COL_TO_BE_UPD = COL_TO_BE_UPD ||to_char(rownum)
WHERE COL_TO_BE_UPD IN ('VAL_A','VAL_B');

Similar Messages

  • What's the correct syntax for this?

    Hey guys
    If...
    trace(rowsHolder.getChildByName("mc"+newStr).y);  
    ...correctly outputs the y coordinate of (in this case) mc001, how do I output the y coordinate of a movieClip called item_base_mc that's within the timeline of mc001?
    trace(rowsHolder.getChildByName("mc"+newStr).item_base_mc.y);
    ...gives me a display object error.
    I've tried permutations of the above with [] brackets in various places, but haven't cracked the code.
    What would be the correct way to write it?
    Thanks for taking a look.
    Shaun

    I don't know how to really explain this, but from documentation you will notice  -   getChildByName()  -  is actually a function from  -  DisplayObject  - not MovieClip.
    Link here provides a better explanation!
    http://curtismorley.com/2007/06/13/flash-cs3-flex-2-as3-error-1119
    GOOD LUCK

  • What's the correct syntax for animate scale

    I have tried to animate the scale transformation of an object from code.
    I had a little success with the code from here:
    http://stackoverflow.com/questions/5029035/how-do-we-add-css-animation-in-jquery
    But animating the scale looks jerky on the iPad with this hack.
    There must be an option of doing it from within Edge since a timeline animation which does the same (just transform scale of an object over time) runs smooth.
    I know there are jQuery extensions for things like that but I don't want to interfere with anything Edge does itself.
    Can someone give me a hint what syntax I need for animating the scale of an object within Edge?

    Hi Bittamer,
    There is no built-in code to animate objects. If you don't want to use the CSS scale code, you can use jQuery animate to animate the width and height props of your object, like so:
    sym.yourHeight = 500;
    sym.yourWidth = 500;
    sym.$("your_symbol").animate({height:sym.yourHeight, width:sym.yourWidth}, 500, 'swing');

  • What is the correct syntax for Sumif when condition is for a text string?

    B2 and b3 both contain the text "Grc".
    C2 contains 1 and C3 contains 2.
    F2 contains a Sumif that reads as: =SUMIF(B2:B10, "=Grc", C2:C10)
    The result is "0" when it should yield 3
    I can't figure out what happened.

    Hi ishii,
    Your screen shots make no sense to me. I am using Numbers'09 on a MacBook Pro running OS X. Please tell us what device, operating system and app you are using. You still have not told us.
    This forum is for Numbers on a Mac running OS X. Is your screen shot from an iOS device?
    I don't know anything about Numbers for iOS.
    Or are you using Excel?
    I can not help you. If you are using an iPad, you will get a better answer in this forum:
    https://discussions.apple.com/community/app_store/iwork_for_ios?view=discussions
    Regards,
    Ian.

  • Can't figure out the correct syntax for this select statement

    Hello,
    The following statement works great and gives the desired results:
    prompt
    prompt Using WITH t
    prompt
    with t as
       select a.proj_id,
              a.proj_start,
              a.proj_end,
              case when (
                         select min(a.proj_start)
                           from v b
                          where (a.proj_start  = b.proj_end)
                            and (a.proj_id    != b.proj_id)
                        is not null then 0 else 1
              end as flag
         from v a
        order by a.proj_start
    select proj_id,
           proj_start,
           proj_end,
           flag,
           -- the following select statement is what I am having a hard time
           -- "duplicating" without using the WITH clause
            select sum(t2.flag)
              from t t2
             where t2.proj_end <= t.proj_end
           ) s
      from t;As an academic exercise I wanted to rewrite the above statement without using the WITH clause, I tried this (among dozens of other tries - I've hit a mental block and can't figure it out):
    prompt
    prompt without with
    prompt
    select c.proj_id,
           c.proj_start,
           c.proj_end,
           c.flag,
           -- This is what I've tried as the equivalent statement but, it is
           -- syntactically incorrect.  What's the correct syntax for what this
           -- statement is intended ?
            select sum(t2.flag)
              from c t2
             where t2.proj_end <= c.proj_end
           ) as proj_grp
      from (
            select a.proj_id,
                   a.proj_start,
                   a.proj_end,
                   case when (
                              select min(a.proj_start)
                                from v b
                               where (a.proj_start  = b.proj_end)
                                 and (a.proj_id    != b.proj_id)
                             is not null then 0 else 1
                   end as flag
              from v a
             order by a.proj_start
           ) c;Thank you for helping, much appreciated.
    John.
    PS: The DDL for the table v used by the above statements is:
    drop table v;
    create table v (
    proj_id         number,
    proj_start      date,
    proj_end        date
    insert into v values
           ( 1, to_date('01-JAN-2005', 'dd-mon-yyyy'),
                to_date('02-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 2, to_date('02-JAN-2005', 'dd-mon-yyyy'),
                to_date('03-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 3, to_date('03-JAN-2005', 'dd-mon-yyyy'),
                to_date('04-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 4, to_date('04-JAN-2005', 'dd-mon-yyyy'),
                to_date('05-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 5, to_date('06-JAN-2005', 'dd-mon-yyyy'),
                to_date('07-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 6, to_date('16-JAN-2005', 'dd-mon-yyyy'),
                to_date('17-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 7, to_date('17-JAN-2005', 'dd-mon-yyyy'),
                to_date('18-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 8, to_date('18-JAN-2005', 'dd-mon-yyyy'),
                to_date('19-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           ( 9, to_date('19-JAN-2005', 'dd-mon-yyyy'),
                to_date('20-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           (10, to_date('21-JAN-2005', 'dd-mon-yyyy'),
                to_date('22-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           (11, to_date('26-JAN-2005', 'dd-mon-yyyy'),
                to_date('27-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           (12, to_date('27-JAN-2005', 'dd-mon-yyyy'),
                to_date('28-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           (13, to_date('28-JAN-2005', 'dd-mon-yyyy'),
                to_date('29-JAN-2005', 'dd-mon-yyyy'));
    insert into v values
           (14, to_date('29-JAN-2005', 'dd-mon-yyyy'),
                to_date('30-JAN-2005', 'dd-mon-yyyy'));

    Hi, John,
    Not that you asked, but as you proabably know, analytic functions are much better at doing this kind of thing.
    You may be amazed (as I continually am) by how simple and efficient these queries can be.
    For example:
    WITH     got_grp          AS
         SELECT     proj_id, proj_start, proj_end
         ,     proj_end - SUM (proj_end - proj_start) OVER (ORDER BY  proj_start)     AS grp
         FROM     v
    SELECT       ROW_NUMBER () OVER (ORDER BY grp)     AS proj_grp
    ,       MIN (proj_start)                         AS proj_start
    ,       MAX (proj_end)               AS proj_end
    FROM       got_grp
    GROUP BY  grp
    ORDER BY  proj_start
    ;Produces the results you want:
      PROJ_GRP PROJ_START  PROJ_END
             1 01-Jan-2005 05-Jan-2005
             2 06-Jan-2005 07-Jan-2005
             3 16-Jan-2005 20-Jan-2005
             4 21-Jan-2005 22-Jan-2005
             5 26-Jan-2005 30-Jan-2005This is problem is an example of Neighbor-Defined Groups . You want to GROUP BY something that has 5 distinct values, to get the 5 rows above, but there's nothing in the table itself that tells you to which group each row belongs. The groups are not defined by any column in hte table, but by relationships between rows. In this case, a row is in the same group as its neighbor (the row immediatly before or after it when sorted by proj_start or proj_end) if proj_end of the earlier row is the same as proj_start of the later row. That is, there is nothing about 03-Jan-2005 that says the row with proj_id=2 is in the first group, or even that it is in the same group with its neighbor, the row with proj_id=3. Only the relation between those rows, the fact that the earlier row has end_date=03-Jan-2005 and the later row has start_date=03-Jan-2003, that says these neighbors belong to the same group.
    You're figuring out when a new group starts, and then counting how many groups have already started to see to which group each row belongs. That's a prefectly natural procedural way of approaching the problem. But SQL is not a procedural language, and sometimes another approach is much more efficient. In this case, as in many others, a Constant Difference defines the groups. The difference between proj_end (or proj_start, it doesn't matter in this case) and the total duratiojn of the rows up to that date determines a group. The actual value of that difference means nothing to you or anybody else, so I used ROW_NUMBER in the query above to map those distinct values into consecutive integers 1, 2, 3, ... which are a much simpler way to identify the groups.
    Note that the query above only requires one pass through the table, and only requires one sub-query. It does not need a WITH clause; you could easily make got_grp an in-line view.
    If you used analytic functions (LEAD or LAG) to compute flag, and then to compute proj_grp (COUNT or SUM), you would need two sub-queries, one for each analytic function, but you would still only need one pass through the table. Also, those sub-queries could be in-line views; yiou would not need to use a WITH clause.

  • What is the setVariable syntax for AS3

    Hi,
    I am having issues with setting a variable in AS3 SWF playing inside a Dir12
    spriteObjRef.setVariable(variableName, newValue)
    In the context of ActionScript 3, this method is only supported on a Flash object, not on a
    spriteObjectRef.
    What would the Flash Object syntax be??
    Thanks,
    Jim

    Jusclark-Oracle wrote:
    What is the correct syntax for referencing a page item (P23_ID, for example) in a PL/SQL page process, after submit?
    See "About Referencing Session State" in the documentation.
    Within an anonymous block in an APEX page process, use the standard bind variable syntax:
    :P23_ID
    In general, use bind variable syntax when referencing session state values in SQL or DML:
    select
        ename
    into
        :p23_name
    from
        emp
    where
        empno = to_number(:p23_id);
    and obviously when assigning values to the item:
    :P23_ID := foo.nextval;
    PL/SQL function references v('p23_id') and nv('p23_id') [for number values] must be used to access values in stored program units called from APEX, although it's usually better to pass the values as parameters: foo(:p23_id).

  • Syntax for using a variable in an equation.

    Hi all,
    Simple question here.  What is tha appropriate syntax for using a variable in a calculation equation.  Specifically, I am taking an established curve fitting equation from my channels and trying to calculate it over a lineargenerated data set to extend the curve  beyond the original data sample.  Here is the small portion of script I have that will not work.  Thanks for any help.
    dim a,b,c
    a = Data.Root.ChannelGroups(5).Channels("air consumption formula").Properties("ResultApprAnsatzCoef1").Value
    b = Data.Root.ChannelGroups(5).Channels("air consumption formula").Properties("ResultApprAnsatzCoef2").Value
    c = Data.Root.ChannelGroups(5).Channels("air consumption formula").Properties("ResultApprAnsatzCoef3").Value
    Call Calculate("Ch(""[5]/Air Consumption LG"")= ""a"" + Ch(""[5]/LinearGenerated"")*""b""+""c""*ch(""[5]/LinearGenerated"")^2")

    Hi Gloorious,
    I am using diadem script.  In my example above, for the equation, if I substitue a,b,and c with numerical values, the script runs just fine and the formula executes as desired.  Is there a way to place the variables there instead as I have tried to do (I was hoping it was just a syntax issue) or do I have to approach it a completely different way?
    This script will execute just fine:
    Call Calculate("Ch(""[5]/Air Consumption LG"")= 4 + Ch(""[5]/LinearGenerated"")*5+6*ch(""[5]/LinearGenerated"")^2")
    but this will not:
    dim a,b,c
    a = Data.Root.ChannelGroups(5).Channels("air consumption formula").Properties("ResultApprAnsatzCoef1").Value
    b = Data.Root.ChannelGroups(5).Channels("air consumption formula").Properties("ResultApprAnsatzCoef2").Value
    c = Data.Root.ChannelGroups(5).Channels("air consumption formula").Properties("ResultApprAnsatzCoef3").Value
    Call Calculate("Ch(""[5]/Air Consumption LG"")= ""a"" + Ch(""[5]/LinearGenerated"")*""b""+""c""*ch(""[5]/LinearGenerated"")^2")

  • What are the correct settings for my WRT54GS for using remote access on a Windows Home Server?

    I can not remotely access my Windows Home Server from outside.  What are the correct settings for my WRT54GS?

    I have opened ports 80, 443,and 4125 to PCP.  The  router address is http://192.168.1.1, my address is 221.40.138.170.
    Thank you.

  • Update my app. What is the correct procedure for updating an app/folio?

    I designed a folio in Indesign CS6 and created an app of the folio in adobe dps and succesfully uploaded it to the app store. Now I want to update my app. What is the correct procedure for updating an app/folio?

    no, just update your content and recreate the Single Edition App. Your certificate should still be valid so there is not need to recreate these.
    ... your App ID absolutely need to be the exact same one you used for the first version if you want to make sure this is an update.

  • The correct syntax for a recursive chmod command in Terminal

    I need to set recursive permissions on an external HDD to '777' or 'all read&write'.
    I have tried all of the following commands in Terminal:
    sudo chmod 777 -r /Volumes/...
    sudo chmod -r 777 /Volumes/...
    sudo chmod a+rw -r /Volumes/...
    sudo chmod -r a+rw /Volumes/...
    ...all of which being back a 'no such file or directory' error, e.g.
    sudo chmod 777 -r /Volumes/232Gb
    chmod: -r: No such file or directory
    Can anyone confirm the correct syntax for this command?
    Thanks in advance...
    Message was edited by: ChippyDeluxe

    If there were a solution that didn't involve using Terminal, I would prefer that.
    The reason I ask is, since my old iMac died and I connected my iMac's external HDD to my MacBook, thousands of folders on my external HDD have 'stop signs' on them and require me to go to
    Get Info -> Sharing & Permissions
    ...and add my MacBook username and set the privilege as "read and write". A bigger problem is, no backup software I've tried will back up this external HDD onto another external HDD any more, so I no longer have an up-to-date backup, which is very worrying.
    I am looking for a way of fixing this, and the chmod command appears to be the answer.
    Ideally, I don't want any permission restrictions on my external HDD at all, so I can connect it to any machine without problems.

  • What is the correct cable for iMac 11,2 Intel core i3, mini dvi to vga or mini display port to vga?

    What is the correct cable for iMac 11,2 Intel core i3, mini DVI to VGA or mini display port to VGA to hook up to projector? Thanks!

    mini-DisplayPort.
    Regards.

  • What is the best practice for using the Calendar control with the Dispatcher?

    It seems as if the Dispatcher is restricting access to the Query Builder (/bin/querybuilder.json) as a best practice regarding security.  However, the Calendar relies on this endpoint to build the events for the calendar.  On Author / Publish this works fine but once we place the Dispatcher in front, the Calendar no longer works.  We've noticed the same behavior on the Geometrixx site.
    What is the best practice for using the Calendar control with Dispatcher?
    Thanks in advance.
    Scott

    Not sure what exactly you are asking but Muse handles the different orientations nicely without having to do anything.
    Example: http://www.cariboowoodshop.com/wood-shop.html

  • What is the best  way for using a  C++ in the EJB?

    What is the best way for using C++ in the EJB ie
    either 1. Socket programming
    2. JNI

    To what purpose?
    To use C++ in the client you could generate IDL from your remote interfaces and run that through your vendor's IDL-to-C++ processor.

  • What is the exact syntax for calling remote function module.

    Hi to all
    1.....what is the exact syntax for calling remote function module.?
    Thanks and regards,
    k.swaminath reddy

    hi
    good
    Lets do simple example where you will first create a RFC in one server (say A) and create normal program in othere server (say B). Finally you will call the RFC in A from B.
    Do the following steps for creating RFC in server A.
    1. log on to server A
    2. go to se37
    3. Edit -> function groups-> create function group and give the function group name (say ZGRP).
    4. create a FM ( say Z_TEST_RFC) in se37 providing the function group which is created just now.
    5. go to attribute tab -> choose remote-enabled module from processing type.
    so that your FM will become RFC.
    6. provide the import parameter in import tab.
    we will provide only two import parameters.
    - parameter name : P_NUM1, typing: TYPE, associated type : I & check the pass value (all the parameters of RFC must pass by value).
    - parameter name : P_NUM2, typing: TYPE, associated type : I & check the pass value
    7. provide the export parameter in export tab.
    parameter name : P_SUM, typing: TYPE, associated type : I & check the pass value
    8. write the given simple code in source code tab.
    FUNCTION Z_TEST_RFC.
    P_TOT = P_NUM1 + P_NUM2.
    ENDFUNCTION.
    Do the following steps for creating ABAP program which will call the RFC in server B.
    1. se38 - > creat a program.
    2. write the given simple code.
    data tot type i.
    call function 'Z_TEST_RFC' destination 'XXXXXX'
    exporting
    p_num1 = 10
    p_num2 = 15
    importing
    p_tot = tot.
    write tot.
    please note that XXXXXX is RFC connection which is avialable in sm59 transaction in server A.
    -go to sm59 - > abap connection (list of RFC connection configurations are avialable). choose server B connection and replace it of XXXXXX in the code.
    finally you can execute the normal abap program that will call the RFC and display the result.
    reward point if helpful.
    thanks
    mrutyun^

  • HT1229 what is the best method for using a iphoto with an external hard drive for greater capacity?

    what is the best method for using a iphoto with an external hard drive for greater capacity?

    Moving the iPhoto library is safe and simple - quit iPhoto and drag the iPhoto library intact as a single entity to the external drive - depress the option key and launch iPhoto using the "select library" option to point to the new location on the external drive - fully test it and then trash the old library on the internal drive (test one more time prior to emptying the trash)
    And be sure that the External drive is formatted Mac OS extended (journaled) (iPhoto does not work with drives with other formats) and that it is always available prior to launching iPhoto
    And backup soon and often - having your iPhoto library on an external drive is not a backup and if you are using Time Machine you need to check and be sure that TM is backing up your external drive
    LN

Maybe you are looking for

  • Output could not be issued

    Hi, We are in process of upgrade.now we are in testing face.When we testing vy printing sales order doucments from VF03 trasaction we are getting error message 'Output Could not be issue',but when we are trying to see print preview it appears correct

  • Installing Business Objects XI R2 on the same server (LPAR) multiple times

    Greetings! My goal is to create "multiple" Business Objects XI R2 instances on a single AIX LPAR, so that I might have up to 8 Business Objects environments.  Each environment would be be used to promote reports through test and eventually production

  • Explorer folder update issues Server 2008 R2 Terminal Server

    Hi Folks,  We are having a few issues here. We have a cluster of 5 Server 2008 X64 R2 SP1 Terminal Servers running Citrix Xenapp 6. Our file server is a Server 2008 R2 SP1 server also. All servers are virtualised on ESX vSphere 4.0 and are connected

  • Quotation List Report

    Hi Gurus, I need a report for quotations not only for a combination of material/ship to party like in VA25 but to be able to run for a given ship-to-party or even for the sales organization. In SDO1 I tried to run any report (on an IDES base), but wi

  • Fireworks has unexpectedly quit

    That's the message I get when i try to start Fireworks CS4. It pops up immediately and I can not even get to the splash screen. I had used Fireworks a few times when I installed it, but haven't needed it in several weeks. I have reinstalled with no l