Case with where clause - ORA-00920: invalid relational operator

Hi all, when I try to run the following query, I get the following error...

ORA-00920: invalid relational operator

00920 00000 - "invalid relational operator.

* Cause:

* Action:

Error on line: column 16: 5

Anyone know what the problem with my request? Thanks in advance.

SELECT concat (year, period)

OF DD_ACTUALS_FACT

CASE WHERE period

WHEN 'JAN' THEN '01'

WHEN 'FEB' THEN '02'

WHEN 'MAR' THEN ' 03 "

WHEN "APR" THEN ' 04 "

WHEN 'CAN' THEN ' 05 "

WHEN "JUN" THEN '06'

WHEN 'JUL' THEN '07'

WHEN 'AUG' THEN '08'

WHEN 'MS' THEN '09'

WHEN 'OCT' THEN '10'

WHEN 'NOV' THEN '11'

WHEN 'DEC' THEN '12'

END as number 'months '.

ORDER OF CONCAT (year, number 'months') / / DESC

The problem is the number 'month' - you cannot give an "ACE" alias for an expression in a where clause clause.

You have not really given any condition, that a set of translations of period in a number.

Also, you didn't say what you're trying to do.

Maybe you want to:

SELECT concat (year, period)

OF DD_ACTUALS_FACT

WHERE something

ORDER OF CONCAT (year, period of the CASE

WHEN 'JAN' THEN '01'

WHEN 'FEB' THEN '02'

WHEN 'MAR' THEN ' 03 "

WHEN "APR" THEN ' 04 "

WHEN 'CAN' THEN ' 05 "

WHEN "JUN" THEN '06'

WHEN 'JUL' THEN '07'

WHEN 'AUG' THEN '08'

WHEN 'MS' THEN '09'

WHEN 'OCT' THEN '10'

WHEN 'NOV' THEN '11'

WHEN 'DEC' THEN '12'

END DESC)

/

Tags: Database

Similar Questions

  • ERROR at line 1: ORA-00920: invalid relational operator

    Hello;

    I get this error with this code:
    EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' || in_table_name || ' WHERE '     
         || in_column1 || ' like (''%'|| in_value1 ||'%'') AND '|| in_column2 || 'like (''%'|| in_value2 ||'%'') AND '
         || in_column3 || ' like (''%' || in_value3 ||'%'') AND ROWNUM = 1' INTO ln_test;
    Help me please, cordially

    you are missing a space in this part:

    in_column2 || 'like (''%'||
    

    should be

    in_column2 || ' like (''%'||
    
  • ORA-00920: invalid relational operator

    SELECT PATIENT_FILE_NO,PATIENT_NAME,START_DATE,END_DATE,AGE,GENDER,ATTENDANCE_TYPE,PATIENT_CATEGORY,EPISODE_NO,VISIT_ID,ORGANIZATION_NO FROM (SELECT PM.PATIENT_FILE_NO,
                                   PE.EPISODE_NO,
                                   DECODE(CURRENT_LANG_P_S,'P', PATIENT_NAME_P  ||' '||PATIENT_NAME_2_P||' '||
                                                                                     PATIENT_NAME_3_P||' '||PATIENT_NAME_F_P,
                                                                                     PATIENT_NAME_S  ||' '||PATIENT_NAME_2_S||' '||
                                                                                     PATIENT_NAME_3_S||' '||PATIENT_NAME_F_S ) PATIENT_NAME ,                                                              
                                   EXSYS.GET_AGE(PM.DATE_OF_BIRTH,SYSDATE) AGE ,
                                   CODES_PKG.GET_DESCRIPTION(PM.GENDER,103) GENDER,
                                   CODES_PKG.GET_DESCRIPTION(PM.PATIENT_CATEGORY,110) PATIENT_CATEGORY,                               
                                   PE.ATTENDANCE_TYPE  ,
                                   PE.START_DATE       ,
                                   NVL(PE.END_DATE,PA.CLINICAL_DISCHARGE_DATE)END_DATE , 
                                   PE.ORGANIZATION_NO,
                                   MR.VISIT_ID 
                            FROM   RC_PATIENTS             PM,
                                   RC_PATIENT_EPISODES     PE,
                                   AD_PATIENT_ADMISSIONS   PA    ,
                                   MR_PATIENT_VISITS             MR                    
                            WHERE  PM.PATIENT_FILE_NO              =PE.PATIENT_FILE_NO                        
                            AND    PE.ADMISSION_NO                 =PA.ADMISSION_NO
                            AND      PM.PATIENT_FILE_NO                          =MR.PATIENT_FILE_NO
                            AND    PE.STATUS                      != 'C'
                            AND    PM.PATIENT_FILE_NO              =NVL('',PM.PATIENT_FILE_NO)              
                            AND    PA.CLINICAL_DISCHARGE_DATE IS NOT NULL
                            AND    TRUNC(PA.CLINICAL_DISCHARGE_DATE)     BETWEEN '25-05-14' AND '25-05-14'                        
                            AND    PE.PRIMARY_ELIGIBILITY          ='Y'
                            AND    PE.ATTENDANCE_TYPE         M    in ('I','D')                        
                            and    '12226' IN  (SELECT RCST1.STAFF_ID
                                                                    FROM   RC_CLINICAL_TEAMS            RCTE,                              
                                                                           RC_CLINICAL_TEAM_STAFF       RCST,
                                                                           RC_CLINICAL_TEAM_STAFF       RCST1 
                                                                   WHERE   RCTE.CLINICAL_TEAM_ID =RCST.CLINICAL_TEAM_ID
                                                                     AND   RCTE.CLINICAL_TEAM_ID =RCST1.CLINICAL_TEAM_ID                                                                 
                                                                     AND   RCTE.WARD_ALLOCATION  ='Y'
                                                                     AND   RCST.STAFF_ID         =PE.DOCTOR_ID                                         
                                                                     AND   trunc(PE.start_date)   BETWEEN RCTE.APPLIES_START AND nvl(RCTE.APPLIES_END,trunc(PE.start_date))
                                                                     AND   trunc(PE.start_date)   BETWEEN RCST.APPLIES_START AND nvl(RCST.APPLIES_END,trunc(PE.start_date))))
                                                                     AND      PE.DOCTOR_ID IN ('1' ,'11906' ,'13074' ,'12767' ,'11903' ,'11904' ,'12495' ,'11905' ,'11939'))  order by PATIENT_NAME
    

    When I run this code, I am facing this error?

    where the operator that he speaks?

    Thank you, I had.

    There is the letter "M" next to the "attendance_type column.

    Thank you

  • Invalid relational operator error.

    Hello

    What is the problem with this query? I'm getting ORA-00920: invalid relational operator error.

    SELECT *.

    TEMP

    WHERE FLAG_Y = 1 AND (FLAG_N IS NOT NULL

    OR FLAG_K NOT NULL)

    Thank you

    you just forgot the IS before the second NOT NULL...

    HTH

  • Export (expdp) with where clause

    Hello gurus,

    I'm trying to export with where clause. I am getting error below.


    Here is my order of export.
    expdp "'/ as sysdba'" tables = USER1.TABLE1 directory=DATA_PUMP dumpfile=TABLE1.dmp logfile=TABLE1.log query= “USER1.TABLE1:where auditdate>'01-JAN-10'”
    Here is the error
    [keeth]DB1 /oracle/data_15/db1> DATA_PUMP dumpfile=TABLE1.dmp logfile=TABLE1.log query= USER1.TABLE1:where auditdate>'01-JAN-10'                    <
    
    Export: Release 11.2.0.3.0 - Production on Tue Mar 26 03:03:26 2013
    
    Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
    
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    Starting "SYS"."SYS_EXPORT_TABLE_03":  "/******** AS SYSDBA" tables=USER1.TABLE1 directory=DATA_PUMP dumpfile=TABLE1.dmp logfile=TABLE1.log query= USER1.TABLE1:where auditdate
    Estimate in progress using BLOCKS method...
    Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
    Total estimation using BLOCKS method: 386 MB
    Processing object type TABLE_EXPORT/TABLE/TABLE
    Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
    Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
    Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
    Processing object type TABLE_EXPORT/TABLE/TRIGGER
    Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
    ORA-31693: Table data object "USER1"."TABLE1" failed to load/unload and is being skipped due to error:
    ORA-00933: SQL command not properly ended
    Master table "SYS"."SYS_EXPORT_TABLE_03" successfully loaded/unloaded
    ******************************************************************************
    Dump file set for SYS.SYS_EXPORT_TABLE_03 is:
      /oracle/data_15/db1/TABLE1.dmp
    Job "SYS"."SYS_EXPORT_TABLE_03" completed with 1 error(s) at 03:03:58
    Version
    SQL> select * from v$version;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production

    Hello

    You must use the settings file. Another question, I see you are using 11g. Why don't you use a data pump.?
    Data pump is faster and has more features and that regular improvement imp and exp.

    You can do the following:

    sqlplus / as sysdba
    
    Create directory DPUMP_DIR3  for 'Type here your os path that you want to export to';
    

    then tap on a file:
    Touch par.txt

    In this file, type the following line the following:

    tables=schema.table_name
    dumpfile=yourdump.dmp
    DIRECTORY=DPUMP_DIR3
    logfile=Your_logfile.log
    QUERY =abs.texp:"where hiredate>'01-JAN-13' "
    

    then proceed as follows
    expdp username/password name parfile = 'par.txt'

    You will import to Oracle 11 g to 10g version should add 'version = 10' parameter in the above setting file

    BR
    Mohamed enry
    http://mohamedelazab.blogspot.com/

  • SYS. Question UTL_FILE survey ORA-29283: invalid file operation

    We have a cron to demand that gives the State of the database in our emails. Recently we have cloned the instance, and all by doing this, we bounced back the entire server.

    After that we stopped getting emails of this instance. When I checked the crontab file and run the scripts manually. It showed the following error.

    SQL > alter session SET smtp_out_server = "xxxx1:100";
    declare
    v_utl_filehandler UTL_FILE. TYPE_DE_FICHIER;
    v_rawfile RAW (32767).
    v_size NUMBER;
    5 v_block NUMBER;
    6 v_boolean BOOLEAN;
    v_file_dir varchar2 (100);
    7 8 v_transfer_location varchar2 (100): = "[email protected], [email protected], [email protected];
    9 v_file_name varchar2 (100): = "mailattachment.doc";
    10 starts
    11 v_file_dir: = "MAIL_DIR";
    12 v_utl_filehandler: = UTL_FILE. FOPEN (v_file_dir, v_file_name, "r");
    13 UTL_FILE.fgetattr (v_file_dir, v_file_name, v_boolean, v_size, v_block);
    14 UTL_FILE.get_raw (v_utl_filehandler, v_rawfile, v_size);
    15 UTL_FILE. FCLOSE (v_utl_filehandler);
    16
    17 sys.utl_mail.send_attach_raw (sender = > '[email protected]')
    18, recipients = > v_transfer_location
    19, subject = > 'database of status of EBS UAT.
    20, message = > "Dear Sir". CHR (13) | CHR (13) |
    21 ' Please find attached file database state of EBS UAT. "| CHR (13) | CHR (13) |
    22 'thank you ' | CHR (13) |
    23 ' oracle@UATDB1'|| CHR (13) | CHR (13)
    24, attachment = > v_rawfile
    25, att_inline = > FALSE
    26, att_filename = > v_file_name
    (27);
    28 end;
    29.
    declare
    *
    ERROR on line 1:
    ORA-29283: invalid file operation
    ORA-06512: at "SYS." UTL_FILE", line 536
    ORA-29283: invalid file operation
    ORA-06512: at the level of line 12

    It was working fine before the cloning.

    Published by: Gerard may 24, 2012 11:52

    I guess that the problem is caused by

    v_utl_filehandler := UTL_FILE.FOPEN(v_file_dir, v_file_name, 'r');
    

    Is the path to the directory "MAIL_DIR" exists in your database server?
    The file 'mailattachment.doc' exists in this path?
    You have read access to this path?

    You can check the path of the directory with:

    select * from all_directories where directory_name='MAIL_DIR';
    

    When the directory does not exist in this table, you need to create (such as s/n):

    CREATE DIRECTORY MAIL_DIR AS 'yourdirectory';
    

    To grant read access to the DBA, you need:

    GRANT READ ON DIRECTORY MAIL_DIR TO ; 
    

    (Overall precondition is that the oracle user (operating system - the user running your oracle instance) can access the given directory).

    Published by: hm on 23.05.2012 22:52

  • ORA-29283: invalid file operation

    Hi friends,
    I m getting ORA-29283: invalid file operation. I tried to use create directory option as well. I have to wriite the file to a specific location determined by the system setting
    even I tried to write by specifying the path setting and direct read/write permision he throw the error.any even input will be highly appreciated.
    Thank you
    Create or replace procedure (table_csv)
    in_succ_fail IN kcc_case_trans_fin_audit.success_or_fail%type by default NULL
    in_team_id IN kcc_case_trans_fin_audit.ounit_identifier_kt%type by default NULL,
    in_run_reference IN kcc_case_trans_fin_audit.run_reference%type by default NULL,
    )
    IS

    v_file_path varchar2 (100) default Null;-to contain the path
    v_file_name varchar2 (100) default Null; - to hold the name of the file
    v_file_name_component varchar2 (20) default Null; - to contain the part of file name
    v_string varchar2 (4000) default Null;
    v_actual_start_date PROVISIONS.actual_start_date%type;
    v_actual_end_date PROVISIONS.actual_end_date%type;
    v_provid_identifier PROVISIONS.provid_identifier%type;
    v_citem_identifier PROVISIONS.citem_identifier%type;
    v_start_date COST_COMMITMENTS.start_date%type;
    v_end_date COST_COMMITMENTS.end_date%type;
    v_ccentr_identifier COST_COMMITMENTS.ccentr_identifier%type;
    v_ccreas_identifier COST_COMMITMENTS.ccreas_identifier%type;
    v_meaning coded_cost_reasons.meaning%type;
    v_cost_centre_code cost_centres.cost_centre_code%type;
    v_sch_start_date schedules.start_date%type;
    v_sch_end_date schedules.end_date%type;
    v_schedule_type schedules.schedule_type%type;
    v_she_ccentr_identifier schedules.ccentr_identifier%type;
    v_she_cost_centre_code cost_centres.cost_centre_code%type;
    v_success_or_fail kcc_case_trans_fin_audit.success_or_fail%type;
    v_file_audit UTL_FILE. TYPE_DE_FICHIER; -File pointer variable
    File_Exception Exception; -User-defined exceptions

    Cursor cur_kctfaudit is
    Select ID, krestr_identifier, person_identifier,.
    ounit_identifier_kt, new_ccentr_identifier
    provis_identifier, ccommi_identifier, schedu_identifier
    success_or_fail, error_message, run_reference
    of kcc_case_trans_fin_audit
    where success_or_fail = in_succ_fail
    or ounit_identifier_kt = in_team_id
    or run_reference = in_run_reference;
    Begin
    -To get the location of the directory, and then to make the name of the file.
    v_file_path: = Adf_Getparam ('END', 'RFDR');
    Select to_char (sysdate, 'ddmmyyhhmi') in the double v_file_name_component;
    v_file_name: = 'kcc_restr_fin_audit_ ' | v_file_name_component |'. CSV';
    If v_file_path is null then
    Raise FILE_Exception;
    End if;
    -If the system "END/RFDR" parameter is not set then do not pass further and get out
    If v_file_path is not null then
    v_file_path: = v_file_path | » \';
    v_file_audit: = UTL_FILE. FOPEN (v_file_path, v_file_name, 'W');
    -v_file_audit: = UTL_FILE. FOPEN ("C: \ KCCTEST', v_file_name, 'W'");
    -If the file to write has been opened successfully
    IF utl_file.is_open (v_file_audit) THEN
    -loops through each line of the file
    I'm IN cur_kctfaudit LOOP
    -The value null if the provis_identifier on the case_tran_fin_audit is null.

    -a code here...

    -to build the string with all the information to write to the file

    v_string: = i.identifier | ','
    || baf_name_list (i.person_identifier, 'P'). ','
    || baf_name_list (i.ounit_identifier_kt, 'P'). ','
    || i.new_ccentr_identifier | ','
    || v_sch_start_date | ','
    || v_sch_end_date | ','
    || v_schedule_type | ','
    || v_she_cost_centre_code | ','
    ||     v_success_or_fail | ','
    || i.ERROR_MESSAGE | ','
    || i.krestr_identifier;
    UTL_FILE. Put_line (v_file_audit, v_string, autoflush = > true);
    END LOOP;

    DBMS_OUTPUT. Put_line (' file Created: ' | v_file_name);
    UTL_FILE. FCLOSE (v_file_audit);
    END IF;

    END IF;
    EXCEPTION
    WHEN utl_file.invalid_mode THEN
    RAISE_APPLICATION_ERROR (-20051, 'invalid parameter Mode');
    WHEN utl_file.invalid_path THEN
    RAISE_APPLICATION_ERROR (-20052, 'Invalid File Location');
    WHEN utl_file.invalid_filehandle THEN
    RAISE_APPLICATION_ERROR (-20053, 'no valid Filehandle');
    -WHEN utl_file.invalid_operation CAN
    -RAISE_APPLICATION_ERROR (-20054, "Invalid File opération");
    WHEN utl_file.internal_error THEN
    RAISE_APPLICATION_ERROR (-20057, 'internal error');
    WHEN utl_file.charsetmismatch THEN
    RAISE_APPLICATION_ERROR (-20058, 'Open with FOPEN_NCHAR but later IO inconsistent');
    WHEN utl_file.file_open THEN
    RAISE_APPLICATION_ERROR (-20059, "file already open");
    WHEN utl_file.invalid_maxlinesize THEN
    RAISE_APPLICATION_ERROR (-20060, 'Row size exceeds 32 K');
    WHEN utl_file.invalid_filename THEN
    RAISE_APPLICATION_ERROR (-20061, "Invalid File Name");
    WHEN utl_file.access_denied THEN
    RAISE_APPLICATION_ERROR (-20062, "file access denied by ');
    When FILE_Exception then
    RAISE_APPLICATION_ERROR (-20002,' system END/RFDR parameter is not defined.) Set the system and try again! ');
    dbms_output.put_line (' system END/RFDR parameter is not defined.) Set the system and try again! ');
    WHILE others THEN
    -dbms_output.put_line (sqlerrm);
    RAISE_APPLICATION_ERROR (-20099, "UTL_FILE Unknown Error");

    END table_csv;
    29283, 00000, "invalid file operation"
    // *Cause:  An attempt was made to read from a file or directory that does
    //          not exist, or file or directory access was denied by the
    //          operating system.
    // *Action: Verify file and directory access privileges on the file system,
    //          and if reading, verify that the file exists.
    

    I have confidence in Oracle reports reality of the more acurrately, you.
    View simplified code that produces the error and after CUT PASTE & showing evidence why Oracle is bad.

  • ORA-29283: invalid file operation, SP2-0103: nothing in the SQL buffer to run.

    Hi gurus of the Oracle,.

    Our version of oracle's 11 g RAC 2.

    We write records into a file using utl_file.

    According to the request, data should write to 160 files.

    After writing to 50 records, his mistake to launch. as

    BEGIN PROC_WRITE_TO_FILE; END;

    *

    ERROR on line 1:

    ORA-29283: invalid file operation

    ORA-06512: at "SYS." UTL_FILE", line 536

    ORA-29283: invalid file operation

    ORA-06512: at "TEST. PROC_WRITE_TO_FILE', line 130 '.

    ORA-06512: at line 1

    SQL > SP2-0103: nothing in the SQL buffer to run.

    My procedure is

    -DECLERATION

    BEGIN

    OPEN C2;

    LOOP

    EXTRACT THE C2 IN P_WRITE;

    WHEN THE EXIT C2% NOTFOUND;

    L_NAME: = "WRITE" | P_WRITE | » _. TXT';

    L_FILE: = UTL_FILE. FOPEN (L_DIR, L_NAME, 'W');

    OPEN C1 (P_WRITE);

    LOOP

    FETCH C1 INTO P_OD_PLACE, P_OD_USER, P_ED_PERF, P_GM_LST, P_GM_FIRST, P_GM_MOD, P_GM_SUFF, P_BD_NUM, P_BD_FRET, P_BD_UNIT, P_BD_GOLE, P_BD_GEP, P_DAT_BOD, P_DAT_EFF, P_ED_RACE, P_ED_GENDER, P_LAND_DIST, P_LAND_LOT, P_ED_STAT_REASON ,P_OD_PRECINCT,P_OD_JANI_PREC,P_NB_PIST_CNG,P_NB_PIST_SEN,P_NB_PIST_VASER,P_NB_PIST_JUD,P_NB_PIST_COMMI,P_NB_PIST_SCHOL,P_NB_PIST_WD,P_NB_PIST_JANIB,P_NB_PIST_JANIC,P_NB_PIST_FIRE,P_NB_PIST_SCHOB,P_NB_PIST_SUPCM,P_NB_PIST_WATBD,P_NB_PIST_GOLEL P_GM_NAME, P_ED_JANI_CODE, P_DAT_ACCEPT, P_DAT_CHANGED, P_OD_COMBO, P_TX_DESC, P_DAT_LST_CTT, P_BD_NUM2, P_BD_FRET1, P_BD_UNIT2, P_BD_GOLE2, P_BD_ST, P_BD_GEP5, P_BD_GEP4, P_BD_FRET2, P_BD_FRET3, P_BD_COUNTRY;

    WHEN EXIT C1% NOTFOUND;

    UTL_FILE. PUT_LINE (L_FILE, P_OD_PLACE: ' |) ' || P_OD_USER |' | ' || P_ED_PERF |' | ' || P_GM_LST |' | ' || P_GM_FIRST |' | ' || P_GM_MOD |' | ' || P_GM_SUFF |' | ' || P_BD_NUM |' | ' || P_BD_FRET |' | ' || P_BD_UNIT |' | ' || P_BD_GOLE |' | ' || P_BD_GEP |' | ' || P_DAT_BOD |' | ' || P_DAT_EFF |' | ' || P_ED_RACE |' | ' || P_ED_GENDER |' | ' || P_LAND_DIST |' | ' || P_LAND_LOT |' | ' || P_ED_STAT_REASON |' | ' || P_OD_PRECINCT |' | ' || P_OD_JANI_PREC |' | ' || P_NB_PIST_CNG |' | ' || P_NB_PIST_SEN |' | ' || P_NB_PIST_VASER |' | ' || P_NB_PIST_JUD |' | ' || P_NB_PIST_COMMI |' | ' || P_NB_PIST_SCHOL |' | ' || P_NB_PIST_WD |' | ' || P_NB_PIST_JANIB |' | ' || P_NB_PIST_JANIC |' | ' || P_NB_PIST_FIRE |' | ' || P_NB_PIST_SCHOB |' | ' || P_NB_PIST_SUPCM |' | ' || P_NB_PIST_WATBD |' | ' || P_NB_PIST_GOLEL |' | ' || P_GM_NAME |' | ' || P_ED_JANI_CODE |' | ' || P_DAT_ACCEPT |' | ' || P_DAT_CHANGED |' | ' || P_OD_COMBO |' | ' || P_TX_DESC |' | ' || P_DAT_LST_CTT |' | ' || P_BD_NUM2 |' | ' || P_BD_FRET1 |' | ' || P_BD_UNIT2 |' | ' || P_BD_GOLE2 |' | ' || P_BD_ST |' | ' || P_BD_GEP5 |' | ' || P_BD_GEP4 |' | ' || P_BD_FRET2 |' | ' || P_BD_FRET3 |' | ' || P_BD_COUNTRY);

    UTL_FILE. FFLUSH (L_FILE);

    END LOOP;

    CLOSE C1;

    END LOOP;

    CLOSE C2;

    UTL_FILE. FCLOSE (L_FILE);

    END;

    /

    Appreciate your suggestions.

    Thank you and best regards,

    REDA

    You understand, but you can't do it?  What?  Move a single line in the right place?

    * sigh * I wish I was your code monkey...

    -DECLERATION

    BEGIN

    OPEN C2;

    LOOP

    EXTRACT THE C2 IN P_WRITE;

    WHEN THE EXIT C2% NOTFOUND;

    L_NAME: = "WRITE" | P_WRITE | » _. TXT';

    L_FILE: = UTL_FILE. FOPEN (L_DIR, L_NAME, 'W');

    OPEN C1 (P_WRITE);

    LOOP

    FETCH C1 INTO P_OD_PLACE, P_OD_USER, P_ED_PERF, P_GM_LST, P_GM_FIRST, P_GM_MOD, P_GM_SUFF, P_BD_NUM, P_BD_FRET, P_BD_UNIT, P_BD_GOLE, P_BD_GEP, P_DAT_BOD, P_DAT_EFF, P_ED_RACE, P_ED_GENDER, P_LAND_DIST, P_LAND_LOT, P_ED_STAT_REASON ,P_OD_PRECINCT,P_OD_JANI_PREC,P_NB_PIST_CNG,P_NB_PIST_SEN,P_NB_PIST_VASER,P_NB_PIST_JUD,P_NB_PIST_COMMI,P_NB_PIST_SCHOL,P_NB_PIST_WD,P_NB_PIST_JANIB,P_NB_PIST_JANIC,P_NB_PIST_FIRE,P_NB_PIST_SCHOB,P_NB_PIST_SUPCM,P_NB_PIST_WATBD,P_NB_PIST_GOLEL P_GM_NAME, P_ED_JANI_CODE, P_DAT_ACCEPT, P_DAT_CHANGED, P_OD_COMBO, P_TX_DESC, P_DAT_LST_CTT, P_BD_NUM2, P_BD_FRET1, P_BD_UNIT2, P_BD_GOLE2, P_BD_ST, P_BD_GEP5, P_BD_GEP4, P_BD_FRET2, P_BD_FRET3, P_BD_COUNTRY;

    WHEN EXIT C1% NOTFOUND;

    UTL_FILE. PUT_LINE (L_FILE, P_OD_PLACE: ' |) ' || P_OD_USER |' | ' || P_ED_PERF |' | ' || P_GM_LST |' | ' || P_GM_FIRST |' | ' || P_GM_MOD |' | ' || P_GM_SUFF |' | ' || P_BD_NUM |' | ' || P_BD_FRET |' | ' || P_BD_UNIT |' | ' || P_BD_GOLE |' | ' || P_BD_GEP |' | ' || P_DAT_BOD |' | ' || P_DAT_EFF |' | ' || P_ED_RACE |' | ' || P_ED_GENDER |' | ' || P_LAND_DIST |' | ' || P_LAND_LOT |' | ' || P_ED_STAT_REASON |' | ' || P_OD_PRECINCT |' | ' || P_OD_JANI_PREC |' | ' || P_NB_PIST_CNG |' | ' || P_NB_PIST_SEN |' | ' || P_NB_PIST_VASER |' | ' || P_NB_PIST_JUD |' | ' || P_NB_PIST_COMMI |' | ' || P_NB_PIST_SCHOL |' | ' || P_NB_PIST_WD |' | ' || P_NB_PIST_JANIB |' | ' || P_NB_PIST_JANIC |' | ' || P_NB_PIST_FIRE |' | ' || P_NB_PIST_SCHOB |' | ' || P_NB_PIST_SUPCM |' | ' || P_NB_PIST_WATBD |' | ' || P_NB_PIST_GOLEL |' | ' || P_GM_NAME |' | ' || P_ED_JANI_CODE |' | ' || P_DAT_ACCEPT |' | ' || P_DAT_CHANGED |' | ' || P_OD_COMBO |' | ' || P_TX_DESC |' | ' || P_DAT_LST_CTT |' | ' || P_BD_NUM2 |' | ' || P_BD_FRET1 |' | ' || P_BD_UNIT2 |' | ' || P_BD_GOLE2 |' | ' || P_BD_ST |' | ' || P_BD_GEP5 |' | ' || P_BD_GEP4 |' | ' || P_BD_FRET2 |' | ' || P_BD_FRET3 |' | ' || P_BD_COUNTRY);

    UTL_FILE. FFLUSH (L_FILE);

    END LOOP;

    CLOSE C1;

    UTL_FILE. FCLOSE (L_FILE);

    END LOOP;

    CLOSE C2;

    END;

    /

  • CASE in a WHERE clause: ORA-00905

    Hello world
    I try to use a BOX in a WHERE clause clause and I got the error ORA-00905: lack of keyword. Here is my code:

    SELECT id_reserv,
    Concat (name, Concat ('_', index)) as name,
    Libelle,
    num_lot,
    resa_keyword1,
    resa_keyword2,
    resa_keyword3,
    resa_keyword4,
    date_creation,
    comm_creation,
    id_util,
    assets,
    id_env_act,
    (SELECT connection of user u where u.id_util = r.id_util) AS nom_util,
    (SELECT name e environment where e.id_env = r.id_env_act) AS nom_env,
    (SELECT count (*) of rc reserv_comp where rc.id_reserv = r.id_reserv) AS nbComp,
    (SELECT count (*) MC reserv_modif where mc.id_reserv = r.id_reserv) AS nbModif
    BOOKING r
    WHERE the r.nom NOT LIKE 'RESERV_LOT_ % '.
    AND id_util = '1'
    AND active = '1'
    AND id_env_act > = '-1'.
    AND the MATTER sansdemande
    WHEN true THEN id_reserv not in some id_reserv from demande_livraison where id_env_dep > = '-1'.
    ELSE id_reserv = id_reserv
    END
    AND name LIKE '% '.
    ORDER BY date_creation;

    I already looked at the CASE statement and it seems that the syntax is correct, so I don't know I can use in a WHERE clause.
    Any help would be nice!

    Andalusians

    Hello

    It should be something like this:

    AND CASE
      WHEN 'false'='true' THEN (select id_reserv from demande_livraison where id_env_dep>='-1')
      ELSE id_reserv
         END = id_reserv 
    

    The subquery must return a line

    But I think that it is better to write your query in the form:

    SELECT id_reserv,
         concat(nom,concat('_',indice)) as nom,
         libelle,
         num_lot,
         resa_keyword1,
         resa_keyword2,
         resa_keyword3,
         resa_keyword4,
         date_creation,
         comm_creation,
         id_util,
         actif,
         id_env_act,
         (SELECT login from utilisateur u where u.id_util=r.id_util) AS nom_util,
         (SELECT nom from environnement e where e.id_env=r.id_env_act) AS nom_env,
         (SELECT count(*) from reserv_comp rc where rc.id_reserv=r.id_reserv) AS nbComp,
         (SELECT count(*) from reserv_modif mc where mc.id_reserv=r.id_reserv) AS nbModif
    FROM reservation r
         WHERE r.nom NOT LIKE 'RESERV_LOT_%'
         AND id_util='1'
         AND actif='1'
         AND id_env_act>='-1'
         AND
                       (
                          (  'false'='true' and id_reserv not in (select id_reserv from demande_livraison where id_env_dep>='-1')
                          )
                          or
                          ( 'true'= 'true' and id_reserv=id_reserv
                          )
                       )
         AND nom LIKE '%'
    ORDER BY date_creation;
    

    This coding in SQL something as if a = b, then c, d also in the simplest form.

    Herald tiomela
    http://htendam.WordPress.com

  • Merger with subquery causes ORA-38101 invalid column to INSERT the VALUES C

    What follows is a slightly shortened version of a SQL statement that causes the error.
              MERGE INTO applicant_matches m_table USING
              (
                   SELECT DISTINCT
                               s.student_id,
                               a.term_scope_id,
                               a.first_name,
                             a.last_name,
                             a.ssn_visa,
                             a.birth_date,
                             ...     
                         
              ) m_list ON
              (m_list.student_id =     m_table.student_id AND
                   m_list.first_name     =     m_table.first_name AND
                   m_list.last_name =     m_table.last_name AND
                   m_list.birth_date     =     m_table.birth_date AND
                   m_list.ssn_visa =     m_table.ssn_visa AND
                   m_list.term_scope_id =     m_table.term_scope_id)
    
              WHEN NOT MATCHED THEN
                     INSERT (m_table.student_id, m_table.term_scope_id, m_table.ssn_visa, m_table.first_name, m_table.last_name,
                           m_table.birth_date, m_table.ssn_match, m_table.dob_match, m_table.soundex_match, m_table.name_match, m_table.past_present)
                     VALUES
                        (m_list.student_id, m_list.term_scope_id, m_list.ssn_visa, m_list.first_name, 
                             m_list.last_name, m_list.birth_date, m_list.ssn_match, m_list.dob_match, m_list.soundex_match, 
                             m_list.name_match, 
    
    
                             (SELECT                    
                   'A'
                        FROM  term_scope ts
                             JOIN campus_term ct ON ts.campus_term_id=ct.campus_term_id
                             WHERE
                             ts.term_scope_id = 5  )
               
               )
               
    I've simplified the request a bit to see what combination of things are the cause of the problem, that is why she always inserts 'A' in m_list.past_present (a CHAR (1)) and always use 5 for the term_scope_id.

    On the SELECT subquery I get one
    ORA-38101 invalid column in the INSERT VALUES Clause: string "ts". "" term_scope_id ".

    However, if I leave the
    JOIN the ct campus_term ON ts.campus_term_id = ct.campus_term_id
    Then, the query works fine.

    Anyway, it must be insert 'A', so I can't imagine what that JOIN has to do with anything anyone. The term_scope_id is valid. It won't let you do a join in a subquery for a merge insert?

    BTW: I'm using Oracle Database 11 g Enterprise Edition Release 11.1.0.6.0 - Production

    Try using the old join syntax

    Select 'x '.
    from t1, t2
    where t1.col = t2.col
    and t2.other_col = using_set.other_col

  • Help with Where clause

    Hello world

    I have an argument to function entry, lets call this file number. This argument can be 0 (zero) or any number like 9800. No negative number.

    My where clause, I would like to say, if the number is 0 (zero), then extract all the cases, otherwise just retrieve the lines/records that belong to the passed in file number.

    select * 
    from table1
    where case_num = (if case num is 0 then retrieve all cases, 
                    otherwise retrieve only the records that belong to the number passed in)
    

    Thanks in advance.

    Select *.

    FROM table1

    where case_num = num

    or num = 0;

    SY.

  • 8287 error: manual/refresh operations with Where clause

    Hello

    I defined a group of read-only cache

    CREATE CACHE READONLY ABC GROUP

    AUTOREFRESH INTERVAL 60 seconds

    OF ORACLE_TABLE

    I want to only load the 3 months of the underlying table for Oracle data so I don't


    ABC LOADING CACHE GROUP

    WHEN TRUNC (date_column) > TRUNC (add_months (sysdate,-3))

    COMMIT ALL 256 ROWS

    4 PARALLEL;

    However, I get the error message

    8287: manual LOADING/REFRESH with clauses WITHID or WHERE operations are not be allowed on ABC Group cache because it is specified as AUTOREFRESH

    The command failed.

    What should I do to load the data of 3 months only if possible? Can I use autorefresh?

    Thanks in advance

    Cache AUTOREFRESH groups to include the WHERE clause in the definition of Group of cache. For example, if drop you in Oracle's:

    CREATE TABLE MYDATE

    (

    C1 VARCHAR2 (10) NOT NULL PRIMARY KEY,

    C2 DATE NOT NULL

    );

    Then your cache group definition would look like this:

    CREATE CACHE READONLY ABC GROUP

    AUTOREFRESH INTERVAL OF 60 SECONDS

    OF MYDATE

    (

    C1 VARCHAR2 (10) NOT NULL PRIMARY KEY,

    C2 DATE NOT NULL

    )

    WHEN TRUNC (c2) > TRUNC (add_months (sysdate,-3));

    And then you would load by using

    ABC LOADING CACHE GROUP

    COMMIT ALL 256 ROWS

    4 PARALLEL;

    As auto refreshes occur time passes, all the data that falls outside the range will be removed from the cache and new data that now lying in the range will be added to the cache.

    Chris

  • Need help with where clause

    Hi all

    Could someone please help me on this one where clause.
    The structure of the table like this:

    < code >
    create table (test)
    primary key ID number,
    TYPE_ID number not null,
    name varchar2 (10));

    insert into test values (1, 10, 'name 1');
    insert into test values (2, 10, 'name 2');
    insert into test values (3, 20, 'name 3');
    insert into test values (4, 20, 'name 4');
    insert into test values (5, 20, 'name 5');
    insert into test values (6, 10, 'name 6');
    insert into test values (7, 10, 'name 7');
    commit;

    SQL * more > select * from test;

    TYPE_ID ID NAMES
    ---------- ---------- ----------
    1 10 name 1
    2 10 2 name
    3 20 name 3
    4 20 4 name
    5 20 5 name
    6 10 6 name
    7 10 7 name

    7 selected lines.
    < code >

    Here are the values of the drop-down list box which the user will be able to select
    0 all the project
    Type of project 10 10
    20 of the Type 20

    Based on the selection of the user, we need a SELECT to get all records or certain types of records.

    Thanks in advance!

    Hello

    If: selected_type_ID is the value in the drop-down list (0, 10, or 20), then:

    WHERE   :selected_type_id IN (test.type_id, 0)
    

    This assumes that test.type_id is never NULL.

  • ORA-01427 with WHERE clause and CASE statement

    Hi guys,.
    I get the error ORA-01427 when you try to select * from my dimension table
    When the parameter: P_HZA is 4. I used the keyword IN but the error still appears.
    no idea why?

    Select * from testtab
    where mycar = 4
    and "coretable". "" HZA ' IN
    CASE
    When: P_HZA = "4" then (button SELECTION OF DIM_HZA)
    other: P_HZA
    END

    Thank you

    you missed table_name and also this can cause several error so lines (ORA-01427: einreihig subquery returns more than one line)

    SELECT *
      FROM tableA
     WHERE mycar = 4
           AND "coretable"."HZA" IN
                  CASE
                     WHEN :P_HZA = '4' THEN (SELECT key FROM DIM_HZA)   ---- may be you need to have max  to get only one value
                     ELSE :P_HZA
                  END
    

    See you soon,.
    Manik.

  • SQL case in where clause

    I have the following table.

    I need to create a query that returns:

    (a) if the table contains 1 and 0 on pass that only values with 1

    (b) otherwise, if the table contains only 1 on collar that only values 1

    (c) otherwise, if the table contains only 0 on pass that only values to 0.

    I tried with the following query, but if the table contains only 0 returns nothing

    {code}

    create table test

    (col1 number);

    Insert in the test

    values (1);

    Insert in the test

    values (1);

    Insert in the test

    values (1);

    Insert in the test

    values (0);

    Insert in the test

    values (0);

    Insert in the test

    values (0);

    commit;

    Select *.

    of the test

    where

    col1 case

    When 1 then 1

    0 otherwise

    end = nvl2 (col1, 1, 0);

    {code}

    Thank you

    Hello

    If you want to find which is the highest value of col1 in the table and view only the lines where col1 has this value.

    Here's a way to do it:

    WITH got_max_col1 AS

    (

    SELECT col1

    MAX (col1) ON (AS max_col1)

    OF the test

    WHERE col1 IN (0, 1) - if necessary

    )

    SELECT col1

    OF got_max_col1

    WHERE col1 = max_col1

    ;

    With the sample data you posted, you do not have the condition: WHERE col1 IN (0, 1)

    If you add lines where col1 can be anything other than 0 or 1, then this condition will ignore them.

Maybe you are looking for

  • Export of images published in Pages ' 09?

    I'm currently editing images in Pages (especially just add text to photos) but has a little trouble exporting. Using the procedure described here, I have all the selected items in the Pages copied and paste into a new file by using the "New from Clip

  • Satellite P300D 10V - problem with TV OUT

    Hello! I have a card ATI HD3650 in my Toshiba Satellite P300D 10V model and I can't use my TV out!It does not work! How to start! I use a newer driver of origin! With the previous driver output TV not too worked! Kind regards!

  • Driver Windows 8 for the satellite Pro L650 - 17 p

    Hello I would like to know if there will be Windows 8 drivers in the foreseeable future. GreetingsZwulf

  • Airport express base station at will without connect to airport extreme

    I tried to get my airPort Express to connect to the extreme via my iphone using the application configuration of the airport. He finds the express and he knows I have the extreme. I said I want to extend my current network and finds it units, but I r

  • Question about updating BIOS for Satellite M70-337

    I just bought an M70-337 and the Toshiba site I noticed that there is an update of the BIOS - my current v1.3 to v1.4. Several things occurred to me - mainly centering around me after spending 3 days Exchange my sytems to a new computer: -. I've neve