Need help with a PL/SQL code

Hello

I am trying to execute the following PL/SQL code, which translates errors, obviously I'm not doing things, but it gives you an idea what I'm trying to do:

DECLARE

INT var_count;

SELECT COUNT (*) IN var_count

FROM sys.all_tables WHERE OWNER = 'SAKILA' AND table_name = "ACTOR";

If var_count > 0 then

BEGIN

DROP TABLE "ACTOR";

END;

/

Erros:

SELECT COUNT (*) IN var_count

*

ERROR at line 3:

ORA-06550: line 3, column 1:

PLS-00103: encountered the symbol "SELECT" at the expected in the following way:

Start function < an ID > pragma procedure subtype type

< between double quote delimited identifiers > delete the current cursor

There is before

The symbol 'start' has been substituted for "SELECT" to continue.

ORA-06550: line 7, column 1:

PLS-00103: encountered the symbol "DROP" when expecting one of the following conditions:

(begin case declare exit for goto if loop mod null pragma

raise return select update while < ID >

< between double quote delimited identifiers of > < a variable binding > < <

continue the narrow current delete fetch locking insert open rollback

savepoint sql set run commit forall fusion pipe purge

Your help to create it in a right way will be appreciated.

Thank you very much.

Tonya.

Try the following:

My = $ora $csr-> prepare (q {}

DECLARE

INT var_count;

BEGIN

SELECT COUNT (*) IN var_count

FROM sys.all_tables WHERE OWNER = 'SAKILA' AND table_name =: ts;

If var_count > 0 then

RUN IMMEDIATELY 'DROP TABLE' |: ts | "CASCADE CONSTRAINTS;

end if;

END;

});

Tags: Database

Similar Questions

  • Need help with this pl/sql code

    Hello
    It is showing an error sql command not properly ended... where FLX_TEXTTRAN802003. SPTEXTINSERT
    is a package... help me please
    BEGIN
       DECLARE
          v_TextID   NUMBER :=0;
          I_LanguageID NUMBER := 1033;
          v_count number;
          e_error EXCEPTION;
    
    BEGIN 
     
    
    
    
            
    --INsert into text
                FLX_TEXTTRAN802003.SPTEXTINSERT
                                               (io_id                => v_TextID,
                                                i_type               => N'',
                                                i_lastupdateon       => cob_f_getutc,
                                                i_lastupdatedby      => 'NGMESSystem',
                                                i_createdon          => cob_f_getutc,
                                                i_createdby          => 'NGMESSystem'
                                               );
            
    
            
            
         
    --    Insert into TEXT_TRANSLATION
                FLX_TEXTTRAN802003.SPTEXTTRANINSERT
                                               (i_TextID             => v_TextID,
                                                I_LanguageID         => I_LanguageID,
                                                i_short              => 'CUSTOMER',
                                                i_medium             => 'CUSTOMER',
                                                i_extended           => 'CUSTOMER',
                                                i_lastupdateon       => cob_f_getutc,
                                                i_lastupdatedby      => 'NGMESSystem',
                                                i_createdon          => cob_f_getutc,
                                                i_createdby          => 'NGMESSystem'
                                               );
                        
                
        select count(*) into v_count from characteristic_class where name='CUSTOMER' 
    if v_count = 0 then
         
    
           
      
            Insert into FLXUSER.characteristic_class
       (ID, NAME, TEXTID, REFERENCEID, LASTUPDATEON, LASTUPDATEDBY, CREATEDON, CREATEDBY, ACTIVE, LASTDELETEON, LASTDELETEDBY, LASTREACTIVATEON, LASTREACTIVATEDBY, ARCHIVEID, LASTARCHIVEON, LASTARCHIVEDBY, LASTRESTOREON, LASTRESTOREDBY, ROWVERSIONSTAMP)
     Values
       (SEQ_CHARACTERISTIC_CLASS.nextval, 'CUSTOMER', v_TextID, NULL, 
        NULL, NULL, TO_DATE('11/05/2012 16:49:05', 'MM/DD/YYYY HH24:MI:SS'), 'SYSTEM', 1, 
        NULL, NULL, NULL, NULL, NULL, 
        NULL, NULL, NULL, NULL, 1);
    commit;
      
    
    ELSE
    Raise e_error;
    END IF;
    EXCEPTION
    when e_error then
    dbms_output.put_line('data already exist');
    end;

    Hello

    next to what Frank says, the following line:

       select count(*) into v_count from characteristic_class where name='CUSTOMER' 
    

    missing semicolon at the end:

       select count(*) into v_count from characteristic_class where name='CUSTOMER' ;
    

    Also the BEGIN initial until the DECLARE is unmatched (no corresponding END).
    You can remove it.

    Kind regards.
    Al

    Published by: Alberto Faenza on November 6, 2012 16:24

  • Hi there I need help with my laptop my code is 55385917 please help

    • Hi there, I need help wit my computer hp pavilion laptop it starts just to show enter them administration or turn on password after 3 times the disable password are 55385917 Please HELP ME because THAT ALL MY WORK IS IT ON please

    Groove

    Try: 40083339

    Concerning

    Visruth

  • Need help with ics. SQL return null

    Hi experts WCS.

    I have this ics. SQL statement that returns an IList as null and nothing in the errStr in debugging print.

    IList rsATypes is ics. SQL (, sqlATypes, listName, limit, bCache errStr);

    The code is in one of my jsp. He ran very well in my local JSK (HyperSQL Db), but returns NULL in the case of Test (Oracle DB, if this is another).

    I got the sql statement println during execution and run it directly in Oracle DB (same instance) it returns the expected result set.

    The code snippet:

      System.out.println("## ics.GetSSVar(\"pubid\")          : " + ics.GetSSVar("pubid"));
    
        // Get Attribute Types
        String sqlATypes = "SELECT DISTINCT assetpublication.assettype "
                         + "FROM assetpublication "
                         + "LEFT JOIN approvedassets "
                         + "    ON assetpublication.assetid = approvedassets.assetid "
                         + "WHERE pubid = '" + ics.GetSSVar("pubid") + "' "
                         + "AND (tstate is null OR tstate <> 'A') "
                         + "AND (voided is null OR voided <> 'T') "
                         + "ORDER BY assettype; ";
        System.out.println("##0126 sqlATypes : " + sqlATypes);
        String from = "AssetPublication, ApprovedAssets";
        // String listName = null;
        String listName = "ATypesList";
        int limit = -1;
        // boolean bCache = true;
        boolean bCache = false;
        StringBuffer errStr = new StringBuffer("");
        ics.ClearErrno();
        IList rsATypes = ics.SQL(from, sqlATypes, listName, limit, bCache, errStr);
    
        System.out.println("## rsATypes : " + rsATypes);
        if (rsATypes == null) {
            System.out.println("## NO DATA in rsATypes! errStr : " + errStr.toString());
    

    }

    The journal:

    ## ics.GetSSVar("pubid")          : 1374097570685
    ## sqlATypes : SELECT DISTINCT assetpublication.assettype FROM assetpublication LEFT JOIN approvedassets     ON assetpublication.assetid = approvedassets.assetid WHERE pubid = '1374097570685' AND (tstate is null OR tstate <> 'A') AND (voided is null OR voided <> 'T') ORDER BY assettype;
    ## rsATypes : null
    ## NO DATA in rsATypes! errStr :
    


    I got enclosing try catch block, who did not take any exception.


    The funny thing is, in the same piece of code, an ics. Casea used already worked (which I noticed outside because there was not enough for what I want to do):

            StringBuffer errSB = new StringBuffer("");
            ics.SetVar("assetid", id);
            IList approvedAsset = ics.SelectTo("ApprovedAssets", "state,voided,tstate,locked,reason,treason", "assetid", null, -1, null, true, errSB);
    

    Any help/ideas from anyone would be really appreciated.

    Thanks Guddu1223, I discovered why.

    The SQL statement cannot end with a semicolon (see line 11 of my original above codes). Delete who had back all the records provided for in my resultset in the IList.

    The reason why it works in my local, but not stable instance that I guess is my local JSK + HyperSQL, in WCS + Oracle DB instance trying...

  • I need help with the following sql.

    I'm lost. I'm collecting information for the days of the month.  For days I have not, I would like to query to get these days also.
    The days of return I have with data and all other days where I'm not.

    How can I get the rest of the days of the month of June.  If I execute sql against the following.

    Select * from
    (Select '02' as the double Study_Date
    Union Select '03' as the double Study_Date
    Union Select '04' as the double Study_Date
    Union Select '04' as the double Study_Date
    Union Select '05' as the double Study_Date
    Union Select '06' as the double Study_Date
    Union Select '09' as the double Study_Date
    Union Select '10' as the double Study_Date
    Union Select '11' as the double Study_Date
    Union Select '12' as the double Study_Date
    Union Select '13' as the double Study_Date
    Union Select '16' as the double Study_Date
    Union Select '19' as double Study_Date)

    Thank you

    Howard

    Hello, Howard.

    Thanks for posting the sample data!  Don't forget to post the exact results you want from these data.

    Looks like you want something involving everyday of the month, they have a day corresponding to your table or not.  This looks like a job for an outer join.

    This should give you some ideas:

    WITH days_wanted AS

    (

    SELECT TO_CHAR (LEVEL, 'fm00') n

    OF the double

    CONNECT BY LEVEL<=>

    )

    SELECT d.n

    t.study_date

    NVL2 (t.study_date

    'Yes '.

    'No '.

    ) AS in_table_x

    OF days_wanted d

    LEFT OUTER JOIN table_x t ON t.study_date = d.n

    ORDER BY d.n

    ;

    Output:

    STUDY_DATE N IN_TABLE_X

    --- ---------- ----------

    01 NO.

    02 02 Yes

    03 03 Yes

    04 04 Yes

    05 05 Yes

    Yes 06 06

    07 NO.

    08 NO.

    09 09 Yes

    10 10 Yes

    11 11 Yes

    12 12 Yes

    13 13 Yes

    14 NO.

    15 NO.

    16 16 Yes

    17 NO.

    18 NO.

    19 19 Yes

    20 NO.

    21 NO.

    22 NO.

    23 NO.

    24 NO.

    25 NO.

    26 NO.

    27 NO.

    28 NO.

    29 NO.

    30 NO.

    You must use a DATE for study_date, not a VARCHAR2 column.  What will you do if you have days of different months in the table?

  • HP 630: Need help with the system off code 54257826

    Try to install the OS on HP 630.  54257826 disabled BIOS password locking system. Any help please.

    Hello

    Enter 41135208

    Kind regards

    DP - K

  • Need help with the launching track pack for forza code 4

    Bought new Forza 4 and the lancer Track Pack code does not work, how do I get a code that is generated in the form I've already paid for it. Rank of loads of numbers and sent 10 s of emails but cant seem to get help.

    This is the help I get when the cat to an Ambassador xbox on xbox.com

    Terry wrote:
    Need help with the launching track pack for forza code 4
    The Xbox Ambassador says:
    Location of Ambassador of the community...
    The Xbox Ambassador says:
    Location of Ambassador of the community...
    The Xbox Ambassador says:
    Your question will be answered by an Ambassador of the Xbox. You have been connected to the Ambassador as a user Xbox [3]
    The Xbox Ambassador says:
    Hello
    Terry wrote:
    Hello
    The Xbox Ambassador says:
    Hey
    Terry wrote:
    just to be on the phone to xbox live support and was told to come here
    The Xbox Ambassador says:
    ok\
    The Xbox Ambassador says:
    What is your problem?
    Terry wrote:
    I bought the 4 for forza ansd 360 new sealed Christmas...
    Terry wrote:
    has got 2 codes that accompanies the game but the pack track code does not work
    The Xbox Ambassador says:
    Wow good
    Terry wrote:
    whenever I put in the code it says code redeemed
    The Xbox Ambassador says:
    I think the code is used. You must return to the retailer
    Terry wrote:
    I tried to, but since I already opened the case they will not accept
    The Xbox Ambassador says:
    Oh. No,
    Terry wrote:
    the code had been used or defective as I am the only person who has touched the game once opened, tried to enter the code when it is open
    The Xbox Ambassador says:
    Maybe it was auto bought?
    Terry wrote:
    so, how do I get another code generated track Pack if defective?
    The Xbox Ambassador says:
    I do not know.
    Terry wrote:
    bought the game new, so I get the track pack
    The Xbox Ambassador says:
    Oh. It's bad.
    The Xbox Ambassador says:
    I think that if you Exchange 1 code it will buy it
    Terry wrote:
    car pack code worked, starter pack did not work
    The Xbox Ambassador says:
    Oh.
    The Xbox Ambassador says:
    It's a bad
    The Xbox Ambassador says:
    BTW you have an evolution of the tests?
    Terry wrote:
    Yes, I want to? but more anxious to get a code object generated for this pack
    The Xbox Ambassador says:
    Hey if I help can u give me this game too?
    Terry wrote:
    ?????????????????
    Terry wrote:
    So is it possible to get a code for that time?
    The Xbox Ambassador says:
    Hey
    The Xbox Ambassador says:
    Yes.
    The Xbox Ambassador says:
    you need to contact them
    The Xbox Ambassador says:
    and tell them that the code is used.
    Terry wrote:
    I was told to come here? where can I go to get the code?

    Hi Terryg76,

    ·         What version of the operating system is installed on the computer?

    I suggest you to contact the game manufacturer for more help and information.

  • need help with windows update C8000F1A error code

    I need help with an error code that is given to my PC when I try to put up-to-date

    Hello

    1. don't you make recent changes?

    2. This does happen with any special updates or all updates?

    I suggest you to follow these steps and check if that helps:

    Method 1:

    If you have installed a security software on the computer, then I suggest you try to disable temporary and check to see if the same problem happens. Make sure that you enable security software back once the diagnosis is made to prevent the computer from virus attacks.
    http://Windows.Microsoft.com/en-us/Windows-Vista/disable-antivirus-software

    Method 2:
    I suggest you follow the steps in the link below and check if it helps:
    http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-problems-with-installing-updates

    It will be useful.

  • Need help with slui message with the Validation Code: 50

    OT: need help with the message 'victim' slui...

    Diagnostic report (1.9.0027.0):
    -----------------------------------------
    Validation of Windows data-->

    Validation code: 50
    Code of Validation caching online: 0xc004c4a2
    Windows product key: *-* - YMK9F - 7Q3XK-X7D3P
    Windows product key hash: 9WDJkbD1PdUJ + GCdK63bG2yus5g =
    Windows product ID: 00371-702-8613485-06367
    Windows product ID type: 5
    Windows license type: retail
    The Windows OS version: 6.1.7601.2.00010100.1.0.048
    ID: {60986DD4-5ADA-464C-A590-469385BD5D3A} (1)
    Admin: Yes
    TestCab: 0x0
    LegitcheckControl ActiveX: N/a, hr = 0 x 80070002
    Signed by: n/a, hr = 0 x 80070002
    Product name: Windows 7 Professional
    Architecture: 0 x 00000009
    Build lab: 7601.win7sp1_gdr.150928 - 1507
    TTS error:
    Validation of diagnosis:
    Resolution state: n/a

    Given Vista WgaER-->
    ThreatID (s): n/a, hr = 0 x 80070002
    Version: N/a, hr = 0 x 80070002

    Windows XP Notifications data-->
    Cached result: n/a, hr = 0 x 80070002
    File: No.
    Version: N/a, hr = 0 x 80070002
    WgaTray.exe signed by: n/a, hr = 0 x 80070002
    WgaLogon.dll signed by: n/a, hr = 0 x 80070002

    OGA Notifications data-->
    Cached result: n/a, hr = 0 x 80070002
    Version: N/a, hr = 0 x 80070002
    OGAExec.exe signed by: n/a, hr = 0 x 80070002
    OGAAddin.dll signed by: n/a, hr = 0 x 80070002

    OGA data-->
    Office status: 109 n/a
    OGA Version: N/a, 0 x 80070002
    Signed by: n/a, hr = 0 x 80070002
    Office Diagnostics: 025D1FF3-364-80041010_025D1FF3-229-80041010_025D1FF3-230-1_025D1FF3-517-80040154_025D1FF3-237-80040154_025D1FF3-238-2_025D1FF3-244-80070002_025D1FF3-258-3

    Data browser-->
    Proxy settings: N/A
    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Win32)
    Default browser: C:\Program Files (x 86) \Mozilla Firefox\firefox.exe
    Download signed ActiveX controls: fast
    Download unsigned ActiveX controls: disabled
    Run ActiveX controls and plug-ins: allowed
    Initialize and script ActiveX controls not marked as safe: disabled
    Allow the Internet Explorer Webbrowser control scripts: disabled
    Active scripting: allowed
    Recognized ActiveX controls safe for scripting: allowed

    Analysis of file data-->

    Other data-->
    Office details: {60986DD4-5ADA-464C-A590-469385BD5D3A}1.9.0027.06.1.7601.2.00010100.1.0.048x 64*-*-*-*-X7D3P5S-1-5-21-4040712825-3780279311-4191590923the system manufacturer,System Product NameAmerican Megatrends Inc. 00371-702-8613485-06367 0802 20110601000000.000000 + 000F3A53C07018400FE04090409Central Standard Time(GMT-06:00)03109

    Content Spsys.log: 0 x 80070002

    License data-->
    The software licensing service version: 6.1.7601.17514

    Name: Windows 7 Professional edition
    Description: operating system Windows - Windows (r) 7, retail channel
    Activation ID: c1e88de3-96c4-4563-ad7d-775f65b1e670
    ID of the application: 55c92734-d682-4d71-983e-d6ec3f16059f
    Extended PID: 00371-00212-702-861348-00-1033-7601.0000-1142014
    Installation ID: 022214046070387640229264400212325972472065330163335456
    Processor certificate URL: http://go.microsoft.com/fwlink/?LinkID=88338
    Machine certificate URL: http://go.microsoft.com/fwlink/?LinkID=88339
    Use license URL: http://go.microsoft.com/fwlink/?LinkID=88341
    Product key certificate URL: http://go.microsoft.com/fwlink/?LinkID=88340
    Partial product key: X7D3P
    License status: Notification
    Reason for the notification: 0xC004F200 (non-genuine).
    Remaining Windows rearm count: 4
    Trust time: 12/01/2016 11:28:57

    Windows Activation Technologies-->
    HrOffline: 0x00000000
    HrOnline: 0xC004C4A2
    Beyond: 0 x 0000000000000000
    Event timestamp: 1:11:2016 12:55
    ActiveX: Registered, Version: 7.1.7600.16395
    The admin service: recorded, Version: 7.1.7600.16395
    Output beyond bitmask:

    --> HWID data
    Current HWID of Hash: QAAAAAEAAwABAAEAAQADAAAABwABAAEAln3OI0bUDFRsO24dgCKo58SW2JyUY/1mMckmPrb67HxoDsAKMMl2Vg ==

    Activation 1.0 data OEM-->
    N/A

    Activation 2.0 data OEM-->
    BIOS valid for OA 2.0: Yes, but no SLIC table
    Windows marker version: N/A
    OEMID and OEMTableID consistent: n/a
    BIOS information:
    ACPI Table name OEMID value OEMTableID value
    APIC1425 APIC 060111
    FACP 060111 FACP1425
    HPET 060111 OEMHPET
    MCFG 060111 OEMMCFG
    LASRYVITRAGE OEMB1425 060111
    ASPT 060111 PerfTune
    OEMOSFR OSFR 060111
    SSDT DpgPmm CpuPm

    Hello

    Thanks to everyone who responded to my question.

    Turns out it would not activate the system properties page.

    He did, however, turn on the tool online browser without a

    hitch. Yes, problem solved.

    Jon

  • Need help with SQL/PL/SQL for Dates

    Hi Experts - need help with a SQL query.

    I need to insert some date fields in a table called CALENDAR_PERIOD.

    Current data in CALENDAR_PERIOD table with their data types:

    STARTPERIOD (DATE) YEAR (NUMBER) PERIOD_LABEL (Varchar2 255)

    02/11/2014 2014 2014/02/11 SUN

    03/11/2014 2014 14/03/11 MON

    04/11/2014 2014 11/04/14 MAR

    I have to increment above values up to the year 2025. I don't know how to write SQL and increment of these values.

    Ex: My next value should insert: 05/11/2015 2014 11/05/14 WED like that I need to insert data until 12 31, 2025.

    Can you please help me with PL/SQL block?

    Really appreciate your help!

    DB version:

    Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    PL/SQL Release 11.2.0.3.0 - Production

    CORE Production 11.2.0.3.0

    AMT for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production

    NLSRTL Version 11.2.0.3.0 - Production

    Thank you
    Sandy

    Hello Sandy,

    Maybe something like

    INSERT INTO calendar_period (startperiod, year, period_label)

    SELECT DATE '' 2014-11-04 + LEVEL

    , TO_NUMBER (TO_CHAR (DATE '' 2014-11-04 + LEVEL, "YYYY"))

    , TO_CHAR (DATE '' 2014-11-04 + LEVEL, "MM/DD/YY DY")

    OF the double

    CONNECT BY LEVEL<= date="" '2025-12-314="" -="" date="">

    ;

    ((mais je ne comprends pas pourquoi nous créons une telle table "année" et "period_label" peuvent être calculé à partir de startperiod))

    Best regards

    Bruno Vroman.

  • Need help with a SQL query

    Hello

    I have a data in table (raj_table) with columns (char11) raj_id, raj_number (varchar2 (15)), raj_format (NUMBER), Primary_ID (identity with the values of the primary key column)

    Primary_ID raj_id Raj_number Raj_format

    1                            raj                 rajvend                      1

    2                            raj                 rajvend                      1

    3                            raj                 rajvendor1                 2

    4                            raj                 rajvendor1                 2

    5                            raj                 rajvendor1                 2

    6                            raj                 rajvendor2                 3

    I used under SQL to get query output as below, but has not achieved the required result:

    Select client_id vendor_number, vendor_format, primary_id, row_number() on sl_no (client_id partition, primary_id, vendor_format order of client_id primary_id, vendor_format, vendor_number, vendor_number)

    from raj_table by sl_no asc

    SL_NO raj_id raj_number raj_format primary_id

    1                   1                   raj              rajvendor                 1

    1                   2                  raj              rajvendor                 1

    2                   3                   raj              rajvendor1                2

    2                   4                   raj              rajvendor1                2

    2                   5                  raj               rajvendor1                2

    3                   6                    raj              rajvendor2                3

    I need help with a SQL query to get the result as above without using the group by clause. I want to bring together the combination of separate line of the three columns (raj_id, raj_number, raj_format) and add a unique serial number for each online game (SL_NO column below). So, above there are 3 unique set of (raj_id, raj_number, raj_format) I can get in a group by clause, but I can not add prmiary_id, SL_NO values if I group by clause. I used the analytical functions like row_number() but no luck. Need solution for this.

    with t as)

    Select 'raj' raj_id, 'rajvend' raj_number, 1 raj_format, 1 primary_id Union double all the

    Select option 2, 'raj', 'rajvend', 1 double Union all

    Select 3, 'raj', 'rajvendor1', 2 double Union all

    Select 4, 'raj', 'rajvendor1', 2 double Union all

    Select 5, 'raj', 'rajvendor1', 2 double Union all

    Select 6, 'raj', 'rajvendor2', 3 double

    )

    Select dense_rank() over (order of raj_id, raj_number, raj_format) sl_no,

    t.*

    t

    order by primary_id

    /

    PRIMARY_ID RAJ RAJ_NUMBER RAJ_FORMAT SL_NO
    ---------- ---------- --- ---------- ----------
    1 1 raj rajvend 1
    1 2 raj rajvend 1
    2 3 raj rajvendor1 2
    2 4 raj rajvendor1 2
    2 5 raj rajvendor1 2
    3 6 raj rajvendor2 3

    6 selected lines.

    SQL >

    SY.

  • Need help: loop of pl/sql with UTL_FILE reading and analysis of file text 2

    Hello, I am working on a new project using the UTL_FILE utility in oracle 11 g. and I was wondering if someone could help me with a pl/sql code, I can't understand.
    My goal is to open and then read a Type_de_fichier file1.txt
    copy a specific paragraph of the file1.txt where
    the first word in a specific line in the file1.txt starts with "foo" then when the last word in fichier1.txt ends in 'ZEN'
    write to file2.txt only the analysis section in my where statement.
    I don't know if it's possible, but any guidance will greatly appreciate!

    My code example:

    CREATE OR REPLACE PROCEDURE my_app2 IS
    Utl_file.file_type inFile;
    OutFile utl_file.file_type;
    buffer VARCHAR2 (30000);
    BEGIN
    -Open a file to read
    InFile: = utl_file.fopen ('TEST_DIR', 'mytst.txt', 'r');
    -Opens a file for writing
    OutFile: = utl_file.fopen ('TEST_DIR', "Out.txt", "w");

    -Check the file is open
    IF utl_file.is_open (InFile) THEN
    -lines in the file in loop
    LOOP
    BEGIN
    UTL_FILE.get_line (InFile, buffer);
    -Write to out.txt
    UTL_FILE.put_line (OutFile, buffer, FALSE);
    UTL_FILE.fflush (outfile);

    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    EXIT;
    END;
    END LOOP;
    END IF;
    UTL_FILE.fclose (INFILE);
    UTL_FILE.fclose (outfile);
    EXCEPTION
    WHILE OTHERS THEN
    RAISE_APPLICATION_ERROR (-20099, "UTL_FILE Unknown Error");
    END my_app2l;
    /

    Hello

    According to the code should work-

    CREATE OR REPLACE PROCEDURE my_app2 IS
       infile              utl_file.file_type;
       outfile             utl_file.file_type;
       buffer              VARCHAR2(30000);
       b_paragraph_started BOOLEAN := FALSE; -- flag to indicate that required paragraph is started
    BEGIN
       -- open a file to read
       infile := utl_file.fopen('TEST_DIR', 'mytst.txt', 'r');
       -- open a file to write
       outfile := utl_file.fopen('TEST_DIR', 'out.txt', 'w');
    
       -- check file is opened
       IF utl_file.is_open(infile)
       THEN
          -- loop lines in the file
          LOOP
             BEGIN
                utl_file.get_line(infile, buffer);
    
                IF buffer LIKE 'foo%' OR b_paragraph_started
                THEN
                   --write to out.txt
                   utl_file.put_line(outfile, buffer, FALSE);
                   b_paragraph_started := TRUE;
                END IF;
    
                IF buffer LIKE '%ZEN'
                THEN
                   b_paragraph_started := FALSE;
                END IF;
                utl_file.fflush(outfile);
    
             EXCEPTION
                WHEN no_data_found THEN
                   EXIT;
             END;
          END LOOP;
       END IF;
       utl_file.fclose(infile);
       utl_file.fclose(outfile);
    EXCEPTION
       WHEN OTHERS THEN
          raise_application_error(-20099, 'Unknown UTL_FILE Error');
    END my_app2l;
    /
    

    What I've done here is added a new Boolean variable. Loop in each iteration after reading one line, we check if the line starts with "foo". If yes then set the Boolean variable and writing out the startup file until we get a line that ends with "ZEN." That way even if there are several paragraphs in an input file starting with foo and ending with ZEN, then those should get copied to the output file.

    Hope this helps,

    -Gregory

  • Need help with PL/SQL query complex

    I need help with a query that need access to data from 3 tables. That's what I did

    I created 3 tables

    CREATE TABLE post_table
    (
    post_id varchar (20),
    datepost DATE,
    KEY (post_id) elementary SCHOOL
    ) ;

    CREATE TABLE topic
    (
    TOPIC_ID varchar (20),
    name varchar (20),
    PRIMARY KEY (topic_id)
    );

    CREATE TABLE blogpost_table
    (
    TOPIC_ID varchar (20),
    post_id varchar (20),
    PRIMARY KEY (topic_id, post_id);
    FOREIGN KEY (topic_id) REFERENCES topic (topic_id) ON DELETE CASCADE,
    FOREIGN KEY (post_id) REFERENCES post_table (post_id) ON DELETE CASCADE
    );


    Now, I inserted a few values in these tables as

    INSERT INTO post_table VALUES ('p1', to_date ('2009-09-14 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p2', to_date ('2009-07-18 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p3', to_date ('2009-07-11 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p4', to_date ('2009-03-11 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p5', to_date ('2009-07-13 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p6', to_date ('2009-06-12 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p7', to_date ('2009-07-11 18:00 "," MM/DD/YYYY mi:ss'));))

    INSERT INTO VALUES subject ("t1", "baseball");
    INSERT INTO category VALUES ('t2', 'football');

    INSERT INTO blogpost_table VALUES ("t1", "p1");
    INSERT INTO blogpost_table VALUES ('t1', 'p3');
    INSERT INTO blogpost_table VALUES ("t1", "p4");
    INSERT INTO blogpost_table VALUES ('t1', 'p5');
    INSERT INTO blogpost_table VALUES ('t2', 'p2');
    INSERT INTO blogpost_table VALUES ('t2', 'p6');
    INSERT INTO blogpost_table VALUES ("t2", "p7");


    I'm launching SQL queries on the table in this topic.

    I want to write a SQL query that returns me the name of a topic (s) and the number of blog_post (s) associated with the topic in descending order of the number of blog posts created in July.

    Can someone please help me to write this query?

    Thank you

    Published by: user11994430 on October 9, 2009 07:24

    Thanks for the test of the configuration!

    SQL>SELECT   t.NAME, COUNT(*)
      2      FROM topic t, blogpost_table b, post_table p
      3     WHERE b.topic_id = t.topic_id
      4       AND p.post_id = b.post_id
      5       AND p.datepost >= DATE '2009-07-01'
      6       AND p.datepost < DATE '2009-08-01'
      7  GROUP BY t.NAME
      8  ORDER BY COUNT(*) desc;
    
    NAME                   COUNT(*)
    -------------------- ----------
    baseball                      2
    soccer                        2
    

    HTH, Urs

  • Need help with query SQL Inline views + Group

    Hello gurus,

    I would really appreciate your time and effort on this application. I have the following data set.

    Reference_No---Check_Number---Check_Date---description---Invoice_Number---Invoice_Type---Paid_Amount---Vendor_Number
    1234567 11223 - 05/07/2008 -paid for cleaning- 44345563-I-* 20.00 *---19
    1234567 11223 - 05/07/2008 - 44345563 -a--10,00---19 ofbad quality adjustment
    7654321 11223 - 05/07/2008 - setting the last billing cycle - 23543556 - A - 50.00 - 19
    4653456 11223 - 05/07/2008 - paid for cleaning - 35654765 - I - 30, 00-19

    Please ignore '-' added for clarity

    I'm writing a paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, aggregate query Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Type, Invoice_Number, Vendor_Number. When there are no more records I want to display the respective Description.

    The query should return the following data set

    Reference_No---Check_Number---Check_Date---description---Invoice_Number---Invoice_Type---Paid_Amount---Vendor_Number
    1234567 11223 - 05/07/2008 -paid for cleaning- 44345563-I-* 10.00 *---19
    7654321 11223 - 05/07/2008 - setting the last billing cycle - 23543556 - A - 50.00 - 19
    4653456 11223 - 05/07/2008 - paid for cleaning - 35654765 - I - 30, 00-19
    Here's my query. I'm a little lost.

    Select b., A.sequence_id, A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
    de)
    Select sequence_id, check_number, check_date, invoice_number, sum (paid_amount) sum, vendor_number
    of the INVOICE
    Sequence_id group check_date, check_number, invoice_number, vendor_number
    ) A, B OF INVOICE
    where A.sequence_id = B.sequence_id


    Thank you
    Nick

    It seems that this is a duplicate thread - correct me if I am wrong in this case->

    Need help with query SQL Inline views + Group

    Kind regards.

    LOULOU.

  • I need help with an installation failure to interpret and troubleshoot a Setup log.

    Background: A few years ago, many editors of cinema used Final Cut Pro 6 (also contained in Final Cut Studio 2) for their editing projects.  Shared Apple Final Cut X uses a different format that is not compatible with FCP6.  Sometimes, these editors are called to work on a few historical projects that have been published in FCP6 and need this version to run now.

    Starting with OS X Lion, FCP6 would install not in Lion and thereafter.

    According research by Jeremy Johnston as noted on his blog, he discovered that Apple has inserted a file in the folder CoreServices in the Library folder of the system folder that causes versions the version Final Cut Pro X (and other older Apple programs in the same situation) do not settle.  He suggested changes to this file that would seek to prevent interfering with the installation of FCP6 in Lion, many users of final cut PRO 6 were successful in their efforts to install in Lion and work with it.

    Later in a discussion update on installing FCP6 in Mavericks, HawaiianHippie determined that the simplest way to perform the installation of FCP6 was simply copy this file and remove it from the system folder, install FCP6 and then restore the copied file:

    https://discussions.Apple.com/message/26309669#26309669

    I used this method with success to install FCS2 in Yosemite:

    [click on images to enlarge]

    However, in my attempts to install FCS2 in El Capitan, it fails in the last 5% to install the first DVD:

    First of all, I need advice on how to display an extremely large Setup log in this thread (on MacRumors, it is a method to insert a 'code' in a small box that can be the object of a scrollbar if necessary to read all along).  I am unable to find such a method to post here.

    Then once approved, I need help to determine which component is causing the installation to fail and perhaps this element can be omitted from the installation:

    If this element is not required, then maybe FCP6 can be installed successfully without it.  And if that omitted element is necessary, perhaps a manual method to install it can be determined by pacifists.

    It is my goal to help those who need to install and use FCP6 on their new Macs running El Capitan.

    Here is the post on MacRumors with pre-installed Setup log:

    http://forums.MacRumors.com/threads/i-need-help-with-an-installation-failure-to-interpret-and-troubleshoot-an-Installer-log.1954786/#post-22541389

Maybe you are looking for