IF (SELECT...) END IF; questions of syntax

Here I have this quite straight forward piece of sql:

------------------------------------------------------------
IF
(SELECT COUNT (DISTINCT FLOOR (CAST (x 1 as float))) FROM SOURCEArchive) > 20 THEN
DELETE SOURCEArchive
)
END IF
------------------------------------------------------------

now, the error is:
PLS-00103: encountered the symbol ")" when expecting one of the following values: , @ ; for a < ID > < a double quote delimited identifier > Group having less cross order partition boot subpartition union where connect SAMPLE_

What I'm doing wrong here. It is not valid to have a select statement after the if...?



When I do
IF
222 > 20 THEN
SELECT SOURCEEArchive AData
END IF;

I get PL/SQL: ORA-00933: SQL not correctly completed command

Published by: metalray on May 8, 2009 07:25

Hello

Try something like this:

DECLARE
   v_count NUMBER; -- assing proper size
BEGIN
   -- more code

   -- assigning v_count
   SELECT COUNT(DISTINCT FLOOR(CAST(x1 AS FLOAT))) INTO v_count FROM SOURCEArchive;

   IF v_count > 20 THEN
      DELETE SOURCEArchive;
      COMMIT,
   END IF;

   -- Maybe more code...
END;
/

Kind regards

Tags: Database

Similar Questions

  • (Newbie question) Interval syntax question / explanation of the error

    Ok. So I reach into a big ticketing system based on Oracle (64 bit 11g 11.2.0.1.0) where they store 'ticket-open-time', 'ticket-fixed-time' and the interval of 'time-to-repair. Initially I wanted to calculate the number of minutes of the time of repair. 6 hours and countless Google searches later, I'm not about to the appropriate syntax. I was able to work around the problem through a simple calculation based on the values open and resolved. What I can't understand, is why I can't apply the same syntax extract just the interval field.

    Here's a simplified query that works:

    SELECT
    To_char (OpenTimeGMT, ' ' the HH24: MI: SS DD/MM/YYYY) "OT".
    , TO_CHAR (ResolvedTimeGMT, ' ' the HH24: MI: SS DD/MM/YYYY) "RT".
    , TO_CHAR (TimeToRepairGMT, ' ' the HH24: MI: SS DD/MM/YYYY) "TTR".
    excerpt (days of day (ResolvedTimeGMT - OpenTimeGMT) the second) "days".
    excerpt (time of day (ResolvedTimeGMT - OpenTimeGMT) the second) "hours."
    excerpt ((ResolvedTimeGMT - OpenTimeGMT) minute second day) "Minutes."
    , (extract (day of (ResolvedTimeGMT - OpenTimeGMT) day to second)) * 24 * 60 +.
    (extract (hour of the day (ResolvedTimeGMT - OpenTimeGMT) the second)) * 60 +.
    extract (minute since (ResolvedTimeGMT - OpenTimeGMT) second day) "TotalMinutes".
    FROM there where

    Which produces:
    [OT] 24/09/2012 20:06:29
    [RT] 26/09/2012 13:56:13
    [TTR] 4000/02/01 17:49:44 - Note the year.
    [Days] 1
    [Hours] 17
    [Minutes] 49
    [TotalMinutes] 2509

    The question:
    When I write [extract (minute of day (ResolvedTimeGMT - OpenTimeGMT) the second) "Minutes"], I get 49 minutes I expect

    When I write [extract (minute since (TimeToRepairGMT) second day) "Minutes"], I get an error "syntax error was found in the interval value expression.

    The three fields are declared as 'date' DESC command (even if TimeToRepairGMT is clearly an interval, based on the value of "4000/02/01 17:49:44" ""). While I can plough with my work-around, I really want to know how to deal with intervals that are stored in Oracle tables as dates. Any help is appreciated!

    Hello

    Welcome to the forum!

    966091 wrote:
    Ok. If I am living in a large (64 bit 11g 11.2.0.1.0) Oracle-based ticketing system

    Thanks, that's very useful. Always give your version (11.2.0.1.0) whenever you post a question.

    where they store 'ticket-open-time' and "ticket-fixed-time" interval "time-to-repair. Initially I wanted to calculate the number of minutes of the time of repair. 6 hours and countless Google searches later, I'm not about to the appropriate syntax. I was able to work around the problem through a simple calculation based on the values open and resolved. What I can't understand, is why I can't apply the same syntax extract just the interval field.

    Here's a simplified query that works:

    SELECT
    To_char (OpenTimeGMT, ' ' the HH24: MI: SS DD/MM/YYYY) "OT".
    , TO_CHAR (ResolvedTimeGMT, ' ' the HH24: MI: SS DD/MM/YYYY) "RT".
    , TO_CHAR (TimeToRepairGMT, ' ' the HH24: MI: SS DD/MM/YYYY) "TTR".
    excerpt (days of day (ResolvedTimeGMT - OpenTimeGMT) the second) "days".
    excerpt (time of day (ResolvedTimeGMT - OpenTimeGMT) the second) "hours."
    excerpt ((ResolvedTimeGMT - OpenTimeGMT) minute second day) "Minutes."
    , (extract (day of (ResolvedTimeGMT - OpenTimeGMT) day to second)) * 24 * 60 +.
    (extract (hour of the day (ResolvedTimeGMT - OpenTimeGMT) the second)) * 60 +.
    extract (minute since (ResolvedTimeGMT - OpenTimeGMT) second day) "TotalMinutes".
    FROM there where

    Which produces:
    [OT] 24/09/2012 20:06:29
    [RT] 26/09/2012 13:56:13
    [TTR] 4000/02/01 17:49:44 - Note the year.
    [Days] 1
    [Hours] 17
    [Minutes] 49
    [TotalMinutes] 2509

    The question:
    When I write [extract (minute of day (ResolvedTimeGMT - OpenTimeGMT) the second) "Minutes"], I get 49 minutes I expect

    When I write [extract (minute since (TimeToRepairGMT) second day) "Minutes"], I get an error "syntax error was found in the interval value expression.

    The three fields are declared as 'date' DESC command (even if TimeToRepairGMT is clearly an interval, based on the value of "4000/02/01 17:49:44" "").

    In fact, it is more likely that it is just a DATE, who got the year wrong somehow. Show how you have assigned values to these columns.

    While I can plough with my work-around, I really want to know how to deal with intervals that are stored in Oracle tables as dates. Any help is appreciated!

    The intervals are difficult to work. I suggest that you use very little, or not at all. Keep the storage points in time as DATEs, but store the length of the time as a NUMBER; either the number of minutes, hours, or days, depending on what is appropriate for your data and your business needs best.

    Let's say you decide to keep TimeToRepair as the number of minutes, the length of time of OpenTImeGMT to ResolvedTimeGMT. When you subtract one DATE from another in Oracle, the result is a NUMBER, the number of days between these two DATEs. To get the number of minutes, which multiplied by the number of minutes per day. So the forumla for TimeToRepair is

    (ResolvedTimeGMT - OpenTimeGMT) * 24 * 60
    

    If you store the length of time as a NUMBER, it is very easy to get totals and averages.

    If you want to display this number of minutes like days hours: minutes: seconds, then you can use an INTERVAL, but just for display. Use the NUMTODSINTERVAL function to convert the NUMBER to an INTERVAL DAY TO SECOND:

    NUMTODSINTERVAL (TimeToRepair, 'MINUTE')
    

    I hope this helps you.
    Whenever you have a question, it is useful to show an example of what you have tried and what results you want to get. Post CREATE TABLE and instructions INSERT for examples of data and the results you would get from these data. You will get answers sooner if your question is specific. "How work intervals?" is a very difficult question. Many people who can help you to not trying to answer a question as broad. But if you can formulate your question as: "I need help understanding intervals. Beginning with this data... I tried thinking it would follow... but instead, I got... Why is this? The manual SQL language, to... says..., why is... happening? ", and then it will be easier to help you.

  • Audio loop at the end in question Media Encoder

    Turned into a problem when rendering After Effects on Media Encoder since update to 2015.3. When you send an AE project to the SOUL, it will make a part of the audio at the end of the video even if there is no audio data. I tested the rendering in AAC, Dolby and MPEG audio codecs in the SOUL and the problem persists. Then I used first to import the AE project and saw on the waveform in import, dealing of EI, the audio is repeated. When rendering AE for an intermediate format, there is no audio loop. It seems that this issue is only to come in trying to go the AE and return in any other Adobe software.

    I also found that people have had this issue and other similar for over a year at this point. Adobe has even closed open a forum that had this problem and it as answered, which was not clearly marked.

    Original thread: Audio Glitch rendering repeat

    Reddit Thread (similar question): https://www.reddit.com/r/premiere/comments/4l76tz/has_adobe_really_not_fixed_the_audio_loo ping_at /

    First Screencap:Screen Shot 2016-07-22 at 11.13.42 PM.png

    Video excerpt:

    Video rendering through SOUL with preselection of Youtube HD 1080 p

    This problem is fixed in update fixes after effects CC 2015.3 (13.8.1). This update, available now, can be installed by using the creative Office Cloud app, or by choosing Help > updates within any Adobe application.

  • First cursor and selection of the questions

    I'm on a Macbook Pro OS X El Capitan v. 10.11.3, Intel i7, 16 GB ram, Geforce GTX 750 m, using Premiere Pro build v.9.2.0 (41) and run into questions weird cursor.

    Whenever I try to drag the parts to select my sequence, the timeline begins to scroll. The cursor icon will not change or highlight to indicate functions or selections.

    After playing, I noticed that all my menus option open on the adjacent monitor instead of insite Premiere Pro windows. I have to restart the program, restarted my computer, and nothing worked. Did not have a question like this until that earlier.

    Recommendations on how to solve this problem?

    Disable the second monitor and see how it goes.

  • Question of syntax for the Desktop - generator model for Word - BI Publisher

    Hello

    Anyone have experience to add reports using the Publsiher BI for Word template generator?

    Practical question I have: how to implement logic such as: If < field_name > is not null, then, write "Hello" end if

    If anyone gave me some useful links, I'd be very happy.

    Thank you

    PL check the "Oracle XML Publisher Report Designer Guide" at http://docs.oracle.com/cd/B40089_10/current/html/docset.html

    HTH
    Srini

  • questions of syntax

    I'm studying just a script and I wanted to understand some of the syntax:

    First sound with the regular expressions and variable has the value get-content a text file like $w = get-content c:\text.txt

    Then, if a statement reads $w - match "\w+. '   "My question is what does'\w+" means and what it is trying to match.

    Secondly, and I see a lot of variables like this foreach or instructions foreach-object like this:

    (& $variable) or (! $variable).  That means & and! mean before the variables.

    Can someone please advise.

    In an expression the string RegEx "^ \w+ ' means:

    -start at the beginning of the chain (the ^ symbol)

    -Search for a word character (letters, numbers...) (the symbol \w) which appears between 1 and unlimited time (sign +)

    See The Regular Expressions in excellent (and free) e-book of Tobias.

    PS manages the text between quotation marks as a string.

    For PS to run cmdlets in the chain to put an ampersand in front of her.

    Ex:

    $t = "Get-Service"
    & $t
    

    PS, the exclamation point is a logical operator, which means "not."

    You can also use the - no operator.

    Ex:

    $u = $true
    !$u             # Will show $false
    -not $u      # The same as the previous line
    
  • Questions of syntax for message ORA-01555

    My DBA has delivered the following message. I understand the cause of the message ORA-01555. My questions are about the additional content in the message.

    Imply the request of 8907 seconds time the failing query worked for so long?

    The 'GATHER_STATS_JOB met mistakes' States that the gather_stats_job was running when the error occurred?

    Has been the cause of the error message GATHER_STATS_JOB (not the root cause of the problem, but rather the ongoing process of execution when the error occurred)?


    ORA-01555 caused by the following SQL statement (SQL ID: fn1ccz80nx7g4, duration of application s = 8907, SNA: 0x0000.18f89957):
    /* SQL Analyze(124,1) */ select /*+ full(t) no_parallel(t) no_parallel_index(t) dbms_stats cursor_sharing_exact use_weak_name_resl dynamic_sampling(0) no_monitoring */to_char(count("MUNI_STAGING_DATE")),to_char(substrb(dump(min("MUNI_STAGING_DATE"),16,0,32),1,120)),to_char(substrb(dump(max("MUNI_STAGING_DATE"),16,0,32),1,120)),to_char(count("PRICING_REC_ID")),to_char(substrb(dump(min("PRICING_REC_ID") ,16,0,32),1,120)),to_char(substrb(dump(max("PRICING_REC_ID"),16,0,32),1,120)),to_char(count("DATE_OF_INSERT")),to_char(substrb(dump(min("DATE_OF_INSERT"),16,0,32),1,120)),to_char(substrb(dump(max("DATE_OF_INSERT"),16,0,32),1,120)),to_char(count("DATE_OF_UPDATE")),to_char(substrb(dump(min("DATE_OF_UPDATE"),16,0,32),1,120)),to_char(substrb(dump(max("DATE_OF_UPDATE") ,16,0,32),1,120)),to_char(count("INTERNAL_ISSUE_ID")),to_char(substrb(dump(min("INTERNAL_ISSUE_ID"),16,0,32),1,120)),to_char(substrb(dump(max("INTERNAL_ISSUE_ID"),16,0,32),1,120)),to_char(count("PRICING_DATE")),to_char(
    substrb (dump (min ("PRICING_DATE"), 16
    Met GATHER_STATS_JOB of errors. Check the trace file.
    Errors in the /u02/oracle/diag/FIAPPE/diag/rdbms/fiappe/FIAPPE1/trace/FIAPPE1_j000_16866.trc file:
    ORA-20011: approximate NDV failed: ORA-01555: snapshot too old: rollback segment number 12 with the name ' _SYSSMU12_1268237196$ ' too small

    Published by: 846797 on March 23, 2011 11:40

    Details of the message from the database pl and OS versions.

    846797 wrote:
    My DBA has delivered the following message. I understand the cause of the message ORA-01555. My questions are about the additional content in the message.

    Imply the request of 8907 seconds time the failing query worked for so long?

    Fix. About 2 hours and a half.

    The 'GATHER_STATS_JOB met mistakes' States that the gather_stats_job was running when the error occurred?

    Fix.

    Has been the cause of the error message GATHER_STATS_JOB (not the root cause of the problem, but rather the ongoing process of execution when the error occurred)?

    Fix.

    >

    ORA-01555 caused by the following SQL statement (SQL ID: fn1ccz80nx7g4, duration of application s = 8907, SNA: 0x0000.18f89957):
    /* SQL Analyze(124,1) */ select /*+ full(t) no_parallel(t) no_parallel_index(t) dbms_stats cursor_sharing_exact use_weak_name_resl dynamic_sampling(0) no_monitoring */to_char(count("MUNI_STAGING_DATE")),to_char(substrb(dump(min("MUNI_STAGING_DATE"),16,0,32),1,120)),to_char(substrb(dump(max("MUNI_STAGING_DATE"),16,0,32),1,120)),to_char(count("PRICING_REC_ID")),to_char(substrb(dump(min("PRICING_REC_ID") ,16,0,32),1,120)),to_char(substrb(dump(max("PRICING_REC_ID"),16,0,32),1,120)),to_char(count("DATE_OF_INSERT")),to_char(substrb(dump(min("DATE_OF_INSERT"),16,0,32),1,120)),to_char(substrb(dump(max("DATE_OF_INSERT"),16,0,32),1,120)),to_char(count("DATE_OF_UPDATE")),to_char(substrb(dump(min("DATE_OF_UPDATE"),16,0,32),1,120)),to_char(substrb(dump(max("DATE_OF_UPDATE") ,16,0,32),1,120)),to_char(count("INTERNAL_ISSUE_ID")),to_char(substrb(dump(min("INTERNAL_ISSUE_ID"),16,0,32),1,120)),to_char(substrb(dump(max("INTERNAL_ISSUE_ID"),16,0,32),1,120)),to_char(count("PRICING_DATE")),to_char(
    substrb (dump (min ("PRICING_DATE"), 16
    Met GATHER_STATS_JOB of errors. Check the trace file.
    Errors in the /u02/oracle/diag/FIAPPE/diag/rdbms/fiappe/FIAPPE1/trace/FIAPPE1_j000_16866.trc file:
    ORA-20011: approximate NDV failed: ORA-01555: snapshot too old: rollback segment number 12 with the name ' _SYSSMU12_1268237196$ ' too small

    Published by: 846797 on March 23, 2011 11:40

    HTH
    Srini

  • Is it possible to score report for a selected set of questions in a quiz?

    Hi I am new to Captivate and SCORM. I have read the threads on the forum and the blog Lilybirl and learned a lot in the last days. I wish someone could help me with this too:

    We hope to develop a course in a single captivate project that allows the following functions:

    • There are several pre-test and post-test. The scores of each of the preliminary tests will be used to effect branching. See, if we take 1 pre-test and passes, then it will go to the conference 2. otherwise returns to give lectures 1;  If one takes 2 pre-test and past then, then she will go to statement No. 3; otherwise, go back to the 2 conference; same thing for the pretest 3, 4, 5...  Now, I know I can use a custom variable to carry out this part. I can create a varaible user as pretest_score and set it as the 0 at the beginning of each test; Let him do the math all what the learner answers a question slide. Then at the end of each test, jump at the base on the value of the pretest_score. So for the post-test, the pretest_score will be set as 0 once again, and the culculation will start from 0. It will also generate a report page personalized report on each pre-test and post-test scores.
    • However, we want to be able to pass only the final score on the post-test of the LMS. Since I read that most of the quiz variables is read-only. Is there a way I can get around this? Is there something in the package SCORM that I can change the variable I created for that I can pass the value of the variable from the LMS?

    Any suggestions would be very helpful.

    Thank you very much.

    Hello

    I do not describe it in blog posts, but you could also set the scores from the pre-test to 0 question slides and follow these scores with a user variables and advanced actions. In this way the total score will be only the scores of the final test, where you attach notes to those question slides. Only one bad thing: the total number of questions will have questions included, same with the number used in the progress indicator. You will need to avoid showing those numbers to the user, but if you can live with that, might be easier to create custom question slides.

    Lilybiri

  • Newbie on selection and weight question

    Hi all

    I'm new here and for Illustrator.

    I was not using Illustrator for a long time and especially as a go between SketchUp, fom where I export files EPS and Photoshop, where I can easily paste their pie until my heart as dynamic objects and then.

    In Illustrator, clean the drawing before Pshop, removal of unnecessary lines that clutter the plan or section, no correction of errors I task etc.

    One thing I want to do is to select individual lines (paths?) and change line thickness; for the moment, when I select one and change its weight, it also changes a lot of random others in the drawing that obviously the program considers somehow related, but that shouldn't really be. I ended up deleting the line and he redrawing in the correct weight, which wastes a lot of time.

    Is there a way to "blow up" (for lack of a better term) the drawing so that the lines are not connected more?

    Thank you

    ALWAYS indicate what version of the AI that you use.

    Whenever making selections, always pay attention to this kind of object is selected. According to the version, which will help you understand what is happening in this little intuitive interface.

    Maintain the visible appearance palette. Select one of the paths to change. Recent versions can present 'A composite path' object type. If you understand what is a composite track, which alone will tell you why to change the weight of the race of the chosen path also changes others.

    Whenever it comes to vector graphics imported from other programs (including other programs owned by Adobe), you may encouter these constructions: groups, composed of railways, the clipping mask. Groups and the clipping mask can even be nested. Application (often repeated application) disassociate, object > CompoundPath > Release and object > ClippingMask > commnands communicated frequently need to 'split' these buildings down to individual objects of cowards.

    You should probably spend some time in the documentation.

    JET

  • question of syntax dropdown.addItem

    Anyone can suggest the following function does not work why? addItem does not seem to accept the 'i' as an argument.

    function

    dropdownRange (dropdown,Start end increment)

    {

    for (var i = start; i < end; i+=increment) {

    dropdown.addItem (i);

    }

    }

    I'm calling the function of a group of radio change event that toggles the range drop-down menu:

    functions.dropdownRange (mydropdown

    , 200 , 1500 , 100);

    Thanks in advance

    Everything seems fine except the addItem syntax.

    It should be written as:

    dropdown.addItem(i+'');     don't forget to convert the variable whole i of the string here...

    It is to go...

    Nith

  • End of question creating a table and change the format of date on the creation

    Hi all

    I'm Googling the hell out of this but either it cannot be done or im just not finiding it.

    I know how to interview and select to_char allows you to change the date format.

    My question is when you create a table as follows:

    CREATE TABLE myTable2
    2 (NAME VARCHAR2 (15),)
    3 CHAR (2) STATE,
    4 SALARY NUMBER (5.2).
    5 YEARSEMP NUMBER (2),
    6 DATE STARTDATE);

    How can I set the DATE format will be a four-digit year? It is even possible to make when you create or you do it only when inserting?

    Thank you!

    Hello

    791443 wrote:
    Okay, so I guess that you can't change the default value for more than one session? So that whenever I have connect the date MM/DD/YYYY came? I know how ALTER, I was wondering if I can schedule the date WHEN I'll get the value by default whenever I connect JJ/MM/AAAA

    Exactly.

    The DBA can change the default format, which will then apply to all the columns DATE for all users.
    If you are the ADMINISTRATOR of you own private database, which is an option.

    If you are using SQL * Plus, you can put the ALTER SESSION SET NLS_DATE_FORMAT command in a file, login.sql, so it will run automatically every time that you start a session.
    Other frontends probably have similar functionality.

    You can also create a view, which had a column VARCHAR2 with formatted data. If you do this, the view also have the actual DATE column — VARCHAR2 column won't be good for sorting or making comparisons of inequality.
    From Oracle 11, you can have a virtual column in the table itself.

  • Question about syntax of Format specifier

    Dear community,

    I try to write data in an Excel file, it does not work properly. My problem is that I'm not able to get the correct number of decimal points in my data. I would have three decimals after the comma (and not a period) and am currently using "% 3d" as a specifier to format syntax but it seems to round the data to numbers with no decimal point. I enclose below two screenshots, one of VI and the output of said file.

    Any suggestion would be great!

    Thanks in advance,

    Use .3f. Le.3 is for the number of digits after the decimal point and the f for a floating point number.

  • SELECT and mask question

    Hey everyone, in the Select again and the mask is possible to rotate the screen?

    Feels probably more natural to make some choices at an angle. (Just a guess, if.)

    @Michael photoart: try to submit an idea (if it has not already been suggested) to: Photoshop community customer family

  • Select tool Indesign question

    Hello

    In a page, I first inserted a block of text with a column, and then inside it, I inserted an another fram of text I used two columns on.

    The problem is that I am not able to adjust the block of text inside the main text frame. How can I do it please?

    Would be glad for any help received here and he really likes.

    With regard to Camille

    Create the text block with two columns, and then select the text in a single column and apply span to 2.

  • All the colors I select end grayscale. How can I fix it?

    I am trying to color in a photo in levels of gray that was sent to me, but whenever I take a color like yellow it ends around the top white or blue becomes dark gray, etc. Photoshop is simply this automatically, I don't know how to disable or enable this.

    I use a PC and a Wacom tablet, if it helps.

    Most likely, you will need to move the image in grayscale mode to RGB color

    Image > Mode

Maybe you are looking for

  • The fan works like a crazy and super fast drain battery after installation of Sierra

    I installed Sierra on my MacBook Pro, the fan works like crazy and the battery is empty after about 1.5 hours. Which never happened before. I'm only using Safari and Mail in the moment. I talked to Apple Support and they suggested to reset the SMC, b

  • JavaScript advanced options (subject: config)

    I know that the JavaScript options are unavailable on the options (in spite of finding a bad decision).I agree to go to the topic: config and try to solve things here. My problem is that the "advanced features" are not so clear that the activation of

  • Tecra M7: Where can I get Win XP Edition?

    Hello I recently bought a Tecra M7 off a friend who had neglected it. He lay around more than a year with a broken power jack. As a result, he lost all disks and pen! I have upgraded the ram and have a 120 gig HARD drive that I want to put into it, b

  • Upgrade the amount of RAM on Satellite A50

    Hello worldI need advice on upgrading the RAM,I have on my system, 256 MB of ram (DDR pc2700) on a site and I have a free slot out, so my question is: what is the best combination to upgrade? and if I can add for example, a module of 512 (pc2700) so

  • Where can I find specifications for Acer laptops to upgrade? I have an Acer Aspire one

    Hello Where can I find specifications for Acer laptops to upgrade? I have an Acer Aspire One, which is still under Windows XP. I looked on the website and check the manual with no techinical inside info.   I'm not find respect for this netbook. Can s