Error-29280 ORA-29280: invalid directory in UTL_FILE path

Hi all

When I execute the code below, I get the error

ERROR-29280ORA-29280: invalid directory path
declare
  v_MyFileHandle UTL_FILE.FILE_TYPE;
BEGIN
  v_MyFileHandle := UTL_FILE.FOPEN('$XXX_OUT', 'HELLO.TXT', 'a');
  
  UTL_FILE.PUT_LINE(v_MyFileHandle,
                    'Hello Again for the Second Time! ' ||
                    TO_CHAR(SYSDATE, 'MM-DD-YY HH:MI:SS AM'));
                    
  UTL_FILE.FCLOSE(v_MyFileHandle);
  
  null;
  
EXCEPTION
  WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('ERROR ' || TO_CHAR(SQLCODE) || SQLERRM);
    NULL;
END;
Please let me know if anyone has an idea about this error.

Kind regards

Check if the directory $XXX_OUT is in dba_directories.
I think that there is no directory of that name and thus the error.
Apparently $XXX_OUT resembles an UNIX environment variable. If it's a level UNIX environment variable, then it is false... you can't use it here.

Use in queries

CREATE OR REPLACE DIRECTORY  as ;
GRANT READ,WRITE ON  to ;

Tags: Database

Similar Questions

  • ORA-29280: invalid directory path

    do face a problem,

    My requirement is I have to brought from a schema for a remote database my current schema some procedure, packages, functions scripts and compile them here in my current schema.
    Basically, straight word what I have to do is, all functions, procedures, are there packages in the remote schema (that I can access by a datbase link) must be created in my current schema.
    so I got what I was trying to make is just source codes to access all_sources and creating files in a code here directory.giving.

    First, what I've done is created an Oracle Directory.

    First I created a directory called "PROC_PKG_FUNC" in drive D, then I ran the following command.

    SQL > create directory 'PROC_PKG_FUNC' as 'D:\'PROC_PKG_FUNC ';
    Created directory.

    CREATE or REPLACE PROCEDURE Get_Db_Ddl_Scripts as
    v_file Utl_File.FILE_TYPE;
    v_file_dir VARCHAR2 (50);
    i_first_line NUMBER: = 1;
    BEGIN

    v_file_dir: = 'PROC_PKG_FUNC ';

    FOR REC_OBJ IN
    (SELECT a DISTINCT NAME, TYPE, DECODE (TYPE, 'FUNCTION', 'FUNCTIONS', 'PACKAGE', "PACKAGES", "PACKAGE BODY ', 'PACKAGES_BODY'," PROCEDURE", 'PROCEDURES', 'TYPE', 'TYPE', 'TYPE BODY', 'TYPES_BODY') v_file_dir)
    FROM ALL_SOURCE@FRISKDEVI41B_ORCL WHERE OWNER = 'FRISKDEVI41B. '
    AND TYPE IN ('FUNCTION, PROCEDURE, 'PACKAGE', 'PACKAGE BODY', 'TYPE'))
    LOOP
    v_file: = Utl_File.FOPEN (card = > REC_OBJ.v_file_dir,)
    filename = > REC_OBJ.NAME | ".sql",.
    OPEN_MODE = > 'w ',.
    max_linesize = > 32767);
    i_first_line: = 1;
    FOR REC IN (SELECT TEXT FROM ALL_SOURCE@FRISKDEVI41B_ORCL WHERE NAME = REC_OBJ.NAME AND TYPE = REC_OBJ. TYPE AND OWNER = 'FRISKDEVI41B' ORDER BY LINE)
    LOOP
    IF i_first_line = 1 THEN
    Utl_File.put_line (v_file, "CREATE or REPLACE" |) REPLACE (REC. TEXT, CHR (10), NULL));
    ELSE Utl_File.PUT_LINE (v_file, REPLACE (REC. TEXT, CHR (10), NULL));
    END IF;
    i_first_line: = i_first_line + 1;
    END LOOP;
    Utl_File.FCLOSE (v_file);

    END LOOP;

    END;
    /


    but when I try to run this am getting error,
    ORA-29280: invalid directory path
    ORA-06512: at "SYS." UTL_FILE", line 33
    ORA-06512: at "SYS." UTL_FILE", line 436
    ORA-06512: at "SYS." GET_DB_DDL_SCRIPTS', line 15
    ORA-06512: at line 2

    I know probbaly get this error because I am trying to create different directories, just like functions packages etc. under the external using this loop recording repertoire, but how would it be possible, please help.

    Kind regards
    Manuella

    In oracle when you say that CREATE or REPLACE the DIRECTORY you do not create a directory in the operating system, you simply create a reference to the directory in the operating system.

    So I don't know what you're asking.

  • Invalid directory with UTL_FILE question

    Hi all

    I am facing problem of invalid directory with UTL_FILE package. Someone could review my mwntioned code below and correct me if something wrong here.

    SQL > DECLARE
    2 directory VARCHAR2 (300): = "$XXEQ_TOP/data/ar/invoices";
    3 name VARCHAR2 (300): = 'GEM5289_04102011 - 03.dat';
    4 l_file UTL_FILE.file_type;
    5 l_text VARCHAR2 (32767).
    6 l_text_not_null VARCHAR2 (32767).
    7. START
    8 l_file: =.
    9 UTL_FILE.fopen (directory,
    10 file name,
    11 'r ',.
    12 32767);
    13 UTL_FILE.get_line (l_file, l_text, 32767);
    14 DBMS_OUTPUT. Put_line ('first save' | l_text);
    15 UTL_FILE.fclose (l_file);
    16 EXCEPTION
    17 THEN THAN OTHERS THEN
    18 DBMS_OUTPUT. Put_line ("Exception" |) SQLERRM);
    END 19;
    20.
    ExceptionORA-29280: invalid directory path

    PL/SQL procedure successfully completed.

    Concerning
    Ramanantsoa nara

    UTL_FILE_DIR parameter has been deprecated by oracle for direcory objects because of its security problems.

    The right thing to do is to create a directory for instance object:

    CREATE OR REPLACE DIRECTORY mydir AS 'c:\myfiles';
    

    Note: This does not create the directory on the file system. Must you do and make sure that oracle has permission to write to this directory of the file system.

    Then, grant permission to users who need to access for example...

    GRANT READ,WRITE ON DIRECTORY mydir TO myuser;
    

    Then use this object directory inside your FOPEN statement example

    fh := UTL_FILE.FOPEN('MYDIR', 'myfile.txt', 'r');
    

    Note: You MUST specify the object name of directory in quotes and uppercase for this works because it is a string that references a database object name that is stored in uppercase by default.

  • Number of error SQL ORA-00904: invalid column name has occurred.

    Hello
    on P8.18 on a Win 2003 server when we launch SWPAUDIT, it failed with:
    Number of error SQL ORA-00904: invalid column name has occurred. Query process failed.
    I searched this error on metalink3. Nothing in connection with.

    Any idea?

    Thank you.

    Please give a clear picture of what you are doing... .and what paintings... There is the possibility of the audit refers to certain tables... with deleted. names of columns just look in the structure of what you audit?

    Please, find the name of column...

    ORA-00904: string: invalid identifier
    Cause: The column name entered is invalid or missing.
    Action: Enter a valid column name. A valid column name must start with a letter, must be less than or equal to 30 characters and include only alphanumeric characters and the special characters $, _, and #. If it contains other characters, then it must be enclosed in quotation marks. It cannot be a reserved word.

  • IKM Partition Oracle Exchange Error loading - ORA-14006: invalid partition name

    Hello

    I use ODI Standalone Edition Version 11.1.1

    I've created an interface, the target table's partition.

    DDL script

    CREATE TABLE big_table2)

    ID NUMBER (10),

    CREATED_DATE DATE,

    lookup_id NUMBER (10),

    given VARCHAR2 (50)

    )

    PARTITION OF RANGE (created_date)

    (PARTITION big_table_2007 VALUES LESS THAN (MAXVALUE));

    the performance of the interface error: -.

    InternalCZ_SC_CONSULTINGjar:file:/D:/Oracle/middleware/Oracle_ODI1/oracledi/client/jdev/extensions/Oracle.ODI.Navigator.jar!/com/Sunopsis/graphical/gif/State/f_error.gif2015-01-28 10:58:38.02015-01-28 10:59:08.03014006ODI-1226: step INT_EXCH_PART fails after 1 attempt.

    ODI-1240: Flow INT_EXCH_PART fails during an operation of integration. This flow of charge table BIG_TABLE2 target.

    ODI-1228: failed INT_EXCH_PART (integration) task on the target of ORACLE ODI_STAGE connection.

    Caused by: java.sql.SQLException: ORA-14006: invalid partition name

    ORA-06512: at line 2

    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:462)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:405)
    at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:931)
    at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:481)
    at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:205)
    at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:548)
    at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:217)
    at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1115)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1488)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3769)
    at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3954)
    at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1539)
    at oracle.odi.runtime.agent.execution.sql.SQLCommand.execute(SQLCommand.java:163)
    at oracle.odi.runtime.agent.execution.sql.SQLExecutor.execute(SQLExecutor.java:102)
    at oracle.odi.runtime.agent.execution.sql.SQLExecutor.execute(SQLExecutor.java:1)
    at oracle.odi.runtime.agent.execution.TaskExecutionHandler.handleTask(TaskExecutionHandler.java:50)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2913)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2625)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:577)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:468)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:2128)
    to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$ 2.doAction(StartSessRequestProcessor.java:366)
    at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:216)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:300)
    to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$ 0 (StartSessRequestProcessor.java:292)
    to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$ StartSessTask.doExecute (StartSessRequestProcessor.java:855)
    at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:126)
    to oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$ 2.run(DefaultAgentTaskExecutor.java:82)
    at java.lang.Thread.run(Thread.java:662)
    10000000000invalid partition error.JPG

    Please can I know what is the problem.

    Put your name of the partition in upper case and double coate as:

    'BIG_TABLE_2007 '.

    The capital should not be a problem, but it is better to be like that because it will store like this in the table USER or ALL_TAB_PARTITIONS.

    This makes it easier to compare if you need to check if a partition already exists or not.

    Hope this can help you.

  • error SQL ORA-00900: invalid SQL statement

    Hi all

    I'm new to sql and I'm trying to solve this problem, I have here.

    When I run this query (1) I get this message: ORA-00900: invalid SQL statement

    Query: 1


    WITH t1
    AS (SELECT CID,
    TYPE,
    TO_CHAR)
    TO_DATE (' 00:00:00 ', 'HH24:MI:SS')
    + (lg_end_time - lg_start_time).
    Call_time 'HH24:MI:SS'),
    ROW_NUMBER)
    COURSES (SORTING CID CID NULLS FIRST PARTITION)
    AS call_id1
    OF test_1
    )
    SELECT SUM (call_time)
    FROM t1;
    output:
    I get the error: ORA-01722: invalid number




    table structure:

    Select * form test_1;

    CID TYPE LG_END_TIME LG_START_TIME
    1508643 expedition 2012/12/03 14:05 2012/12/03 14:02
    1508643 treatment 2012/12/03 14:00 03/12/2012 14:00
    1508643 initiation 2012/12/03 14:00 03/12/2012 14:00
    1508662 expedition 2012/12/03 14:18 2012/12/03 14:16
    1508662 initiation 2012/12/03 14:01 03/12/2012 14:01
    1508662 treatment 2012/12/03 14:02 03/12/2012 14:01
    1508643 expedition 2012/12/03 14:02 03/12/2012 14:00
    1508662 expedition 2012/12/03 14:16 2012/12/03 14:02

    Thanks for your help

    I think this example might help.

    SQL> select decode(call_id1,99,null,cid)        cid,
      2         decode(call_id1,99,null,type)       type,
      3         decode(call_id1,99,null,to_char(call_time,'hh24:mi:ss'))  call_time,
      4         decode(call_id1,99,null,substr(call_id1,1,5))   call_id1,
      5         total_time
      6    from (select cid,
      7                 type,
      8                 call_time,
      9                 call_id1,
     10                 total_time
     11            from (select cid,
     12                         type,
     13                         call_time,
     14                         call_id1,
     15                         null total_time
     16                    from (SELECT CID ,
     17                                 TYPE,
     18                                 to_date(TO_CHAR (TO_DATE ('00:00:00', 'HH24:MI:SS') +
     19                                        (lg_end_time - lg_start_time),'HH24:MI:SS'),'HH24:MI:SS') call_time,
     20                                 ROW_NUMBER () OVER (PARTITION BY CID ORDER BY CID NULLS FIRST) AS call_id1
     21                            FROM test_1 ) t1
     22                  union all
     23                  select cid,
     24                         null type,
     25                         null call_time,
     26                         99   call_id1,
     27                         lpad(hours,2,'0')||':'||lpad(minutes,2,'0')||':'||lpad(seconds,2,'0') total_time
     28                    from (select cid,
     29                                 sum(to_number(to_char(call_time,'hh24'))) +
     30                                     trunc((sum(to_number(to_char(call_time,'mi'))) +
     31                                     (trunc(sum(to_number(to_char(call_time,'ss')))/60)))/24) hours,
     32                                 sum(to_number(to_char(call_time,'mi'))) +
     33                                    (trunc(sum(to_number(to_char(call_time,'ss')))/60)) minutes,
     34                                 (sum(to_number(to_char(call_time,'ss'))) -
     35                                     ((trunc(sum(to_number(to_char(call_time,'ss')))/60)) * 60)) seconds
     36                            from (SELECT CID ,
     37                                         TYPE,
     38                                         to_date(TO_CHAR (TO_DATE ('00:00:00', 'HH24:MI:SS') +
     39                                                (lg_end_time - lg_start_time),'HH24:MI:SS'),'HH24:MI:SS') call_time,
     40                                         ROW_NUMBER () OVER (PARTITION BY CID ORDER BY CID NULLS FIRST) AS call_id1
     41                                    FROM test_1 ) t1
     42                          group by cid) )
     43          order by cid, call_id1 );
    
    CID                                      TYPE                 CALL_TIME CALL_ID1 TOTAL_TIME
    ---------------------------------------- -------------------- --------- -------- ----------
    1508643                                  Dispatching          00:02:06  1
    1508643                                  Initiation           00:00:00  2
    1508643                                  Treatment            00:00:39  3
    1508643                                  Dispatching          00:02:50  4
                                                                                     00:05:35
    1508662                                  Treatment            00:01:03  1
    1508662                                  Initiation           00:00:00  2
    1508662                                  Dispatching          00:13:17  3
    1508662                                  Dispatching          00:02:43  4
                                                                                     00:17:03
    
    10 rows selected
    
    SQL> 
    
  • ORA-29280: invalid directory path error

    I use the code below in the Unix system to generate the data in XML format. But get the error ORA-29280.
    I tried to use create order directory in vain because I don't have DBA privileges to create directories.

    *******************************
    SET SERVEROUTPUT ON
    DECLARE
    v_ctx DBMS_XMLGen.ctxHandle;
    v_file Utl_File.File_Type;
    v_xml CLOB.
    v_more BOOLEAN: = TRUE;
    BEGIN
    -Create the XML context.
    v_ctx: = DBMS_XMLGen.newContext ("SELECT table_name, nom_tablespace FROM user_tables WHERE rownum < 6'");

    -Set the settings to change the names of default tag lines and line and case-sensitive by default.
    DBMS_XMLGen.setRowsetTag (v_ctx, 'USER_TABLES');
    DBMS_XMLGen.setRowTag (v_ctx, 'TABLE');
    -DBMS_XMLGen.setTagCase (v_ctx, DBMS_XMLGen.LOWER_CASE);

    -Add stylesheet XSL IE specfic reference so browser can transform the file.
    -DBMS_XMLGen.setStylesheetHeader (v_ctx, 'C:\Development\XML\IEStyle.xsl', ' text/xsl');

    -Create the XML document.
    v_xml: = DBMS_XMLGen.GetXML (v_ctx);
    DBMS_XMLGen.closeContext (v_ctx);

    -Document XML output to the file.
    v_file: = Utl_File.FOpen ("/ xxx/yyy/zzz ', 'test1.xml', 'w'");
    While v_more LOOP
    Utl_File.put (v_file, Substr (v_xml, 1, 32767));
    IF Length (v_xml) > 32767 THEN
    v_xml: = Substr (v_xml, 32768).
    ON THE OTHER
    v_more: = FALSE;
    END IF;
    END LOOP;
    Utl_File.FClose (v_file);

    EXCEPTION
    WHILE OTHERS THEN
    DBMS_OUTPUT. Put_line (substr (SQLERRM, 1, 255));
    Utl_File.FClose (v_file);
    END;
    /
    ***********************************************

    Please help me solve this problem.

    Or, please let me know other the best way to generate XML from Oracle 9i DB.

    Appreciate your help.

    Thank you
    Vikram

    Use an account with DBA privileges to CREATE a DIRECTORY, or have a DBA on the DB create for you.

    You can also generate XML via XMLElement, XMLForest, XMLAgg, etc. in a SQL statement, or via the xmldom package and at least another option in 9i that does not come to mind right now.

  • ORA-29280 Invqalid directory path

    Hi guru,.

    connected through sys as sysdba
    I created using the directory create or replace directory
    Grant read, write on...
    Grant execute utl_file made

    using the function created utl_file compiled and successful
    When running ORA-29280 invalid directory path error comes
    checked through select * from all_directories
    some place of creation is in order
    Then
    What has gone wrong?
    your
    Dr.s.r.bhattachar

    PS I use oracleXE with apex 3.2

    The directory name is case-sensitive.

    Please give it a try.

  • ORA-01722: invalid number calculation error during the treatment.

    My version of the APEX is Application Express 4.2.6.00.03

    I imported apex application 4.0.2 and his object of decision-making support in my apex.

    Its installed successfully.

    But when I try to run this application it show me this error:

    ORA-01722: invalid number calculation error during the treatment.

    Thank you guys for your help.

    I found the solution.

    There was a problem in the authentication scheme.

    I called function as return function_name in 4.0.2

    but in the Apex 4.2.6 to call a function word return is not necessary.

    He was throwing the error caused that Word back.

  • The AUDIT command in, oracle apex (version 4.2.5.00.08), error "ORA-00911: invalid character '.

    I am trying to run

    "AUDIT INSERT, UPDATE, DELETE on emp BY ACCESS WHENEVER SUCCESSFUL;"

    in "SQL commands" on oracle-apex (version 4.2.5.00.08).

    I get the error message ' ORA-00911: invalid character '.

    Can someone tell me the solution for this?

    Apex environment we need to set the database AUDIT_TRAIL to TRUE for the control

    "AUDIT INSERT, UPDATE, DELETE on emp BY ACCESS WHENEVER SUCCESSFUL;"  to work.

    By their Summit, to be able to change the setting of database AUDIT_TRAIL we have to log-in as a DBA from the link "SQL workshop--> utilities--> on the database.

  • An another ORA-01722: invalid number error

    Hi all
    I have 2 Validations on, 1 not Null and Not Exists, very standard.
    select fk_session_name_id
    from hrt_session
    where fk_session_name_id = :p9_fk_session_name_id
      and fk_class_id = :p9_fk_class_id;
    My question must be a Select list that returns the ID of the FK_SESSION_NAME_ID.
    select distinct SESSION_NAME display_value, PK_SESSION_NAME_ID return_value
    from HRT_SESSION_NAME
    order by 1
    My form Page up the error number ORA-01722 invalid only when I do a Select list item. If the item is a
    Value of text field and entry ID and you click on create data are saved, but not when it's a list of Select. I have read many things
    threads that talk about this point conversion to_number but I have not been successful in doing so. Once the element is
    There is a list of select validation not working, but not Validation Null fills the Error Message. Can anyone
    help me with this please? Thank you
    My FK_SESSION_NAME_ID and sessionname INTEGER data Type is VARCHAR2.
    SESSIONNAME data...
    SESSION 1
    SESSION 2
    EGR 1
    EGR 2
    BASIC WORD 2003...

    Published by: Charles on January 11, 2010 13:42

    Hello

    I changed validation FK.

    Now, it seems to work. Please check and let me know

    BR, Jari

  • ORA-39002: invalid operation

    I am using expdp, replacing the scripts of the exp.
    I get these error lines:
    ORA-39002: invalid operation
    ORA-39070: unable to open the log file.
    ORA-29283: invalid file operation

    My expdp order:
    Directory of dumpfile = test.dmp for = export_meta content = metadata_only expdp system

    Yes.CREATE DIRECTORY does not create the directory export_meta to you on disk.

  • ORA-22907: invalid CAST to a type that is not a nested table or VARRAY. Typed collection function

    Hello

    I tried to create a function that might return the type that is created on the outside.

    So I wrote script below. until the function created it compiled successfully, but after that, when the data querying, we encountered error,

    "ORA-22907: invalid CAST to a type that is not a nested table or VARRAY.

    SQL> create table emp
      2  (
      3    ename        varchar2(200 byte),
      4    mgr          number,
      5    employee_id  number
      6  );
    
    
    Table created.
    
    
    SQL> insert into emp (ename, mgr, employee_id)
      2       values ('king', 12, 1);
    
    
    1 row created.
    
    
    SQL> insert into emp (ename, mgr, employee_id)
      2       values ('clark', 12, 2);
    
    
    1 row created.
    
    
    SQL> commit;
    
    
    Commit complete.
    
    
    SQL> create or replace type t_emp as object (ename varchar2 (200), mgr number, employee_id number);
      2  /
    
    
    Type created.
    
    
    SQL> create or replace function f_emp return  t_emp
      2   is
      3  type rc_emp is ref cursor;
      4  r_emp rc_emp;
      5  v_emp t_emp;
      6  begin
      7   open r_emp for select * from emp where rownum=1;
      8   fetch r_emp into v_emp;
      9  close r_emp;
     10  return v_emp;
     11  exception
     12      when others then
     13      dbms_output.put_line(dbms_utility.format_error_stack);
     14      dbms_output.put_line(dbms_utility.format_call_stack);
     15      dbms_output.put_line(dbms_utility.format_error_backtrace);
     16      raise_application_error(-20001,sqlerrm);
     17  end;
     18  /
    
    
    Function created.
    
    
    SQL> show errors;
    No errors.
    SQL> select * from f_emp;
    select * from f_emp
                  *
    ERROR at line 1:
    ORA-04044: procedure, function, package, or type is not allowed here
    
    
    
    
    SQL> select * from table(cast (f_emp as t_emp));
    select * from table(cast (f_emp as t_emp))
                              *
    ERROR at line 1:
    ORA-22907: invalid CAST to a type that is not a nested table or VARRAY
    
    
    
    
    SQL>
    

    Like this:

    ...

    CREATE or REPLACE TYPE t_emp_array IS TABLE OF THE t_emp;

    /

    FUNCTION to CREATE or REPLACE f_emp RETURN t_emp_array

    is

    type rc_emp is ref cursor;

    r_emp rc_emp;

    v_emp_array t_emp_array: = t_emp_array();

    BEGIN

    R_emp OPEN for SELECT t_emp(ename,mgr,employee_id) FROM emp WHERE ROWNUM = 1;

    collect the fetch r_emp in bulk in v_emp_array;

    CLOSE R_emp;

    Return v_emp_array;

    exception

    while others then

    dbms_output.put_line (dbms_utility.format_error_stack);

    dbms_output.put_line (dbms_utility.format_call_stack);

    dbms_output.put_line (dbms_utility.format_error_backtrace);

    raise_application_error (-20001, SQLERRM);

    end;

    /

    SELECT *.

    table (f_emp ());

    a table function works with a table (nested table or varray)

    HTH

  • ORA 00904: invalid identifier "JAN".

    Hello

    I have the rest of the table.

    ===========================================

    create table ATT_ATTENDANCESHEET as

    (

    Select 1 empid, to_date('21/01/2014','dd/mm/yyyy') prdate, 240 reg, 0 unpaid all double union

    Select 2, to_date (January 21, 2014 ', ' dd/mm/yyyy'), 200 reg, 0 unpaid all double union

    Select 3, to_date (January 21, 2014 ', ' dd/mm/yyyy'), 240 reg, 0 unpaid all double union

    Select option 4, to_date (January 21, 2014 ', ' dd/mm/yyyy'), 480 reg, 0 unpaid all double union

    Select 5, to_date (January 21, 2014 ', ' dd/mm/yyyy'), 240 reg, unpaid double 0

    );

    =================================================

    I want to remove rows from table ATT_ATTENDANCESHEET.

    If the parameter passed empids, lines for employees would be eliminated.

    If empids is null, all records between the given period will be deleted.

    I created after the procedure to that effect.

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

    CREATE or replace FUNCTION deleteAttendanceDetails (startdate DATE, enddate DATE, empids varchar2) RETURN NUMBER as


    n number;

    condition varchar2 (200);

    vsql varchar2 (2000);

    BEGIN

    IF empids is not null

    THEN

    condition: condition = |' and empid in ('| empids |') ' ;

    END IF;

    vsql: =' delete from ATT_ATTENDANCESHEET where prdate between ' | StartDate | 'and' | EndDate | condition;

    EXECUTE IMMEDIATE (vsql);

    return n;

    END;

    /

    The empids parameter contains the employee IDS separated by commas.

    for example

    "1,2,3,4"

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

    But when I call this function using

    Select deleteAttendanceDetails (to_date('25/01/2014','dd/mm/yyyy'), to_date (' 01/31/2014 ',' dd/mm/yyyy'), ") double;

    I get the following error

    ORA 00904: invalid identifier "JAN".

    ORA-06512: at.. .line 21

    I use oracle 10g.

    Help, please

    Do not use dynamic sql. It's more trouble that it's worth.

    Your error comes from the fact that you convert a date to a string, implicitly and then come back.

    In addition, your example doesn't have a field of prddate... so I added that, in my test table so that it works.

    Try something like that, entirely avoid dynamic sql:

    CREATE or replace FUNCTION deleteAttendanceDetails (
                                  startdate DATE,
                                  enddate DATE,
                                  empids varchar2
                               )
       RETURN NUMBER
    as
       n number;
    BEGIN
       delete from ATT_ATTENDANCESHEET
          where ( empid IS NULL
                OR empid in ( select regexp_substr ( empids, '[^,]+', 1, level) empid
                             from dual connect by level <= (LENGTH(empids) - LENGTH(REPLACE(empids, ',')) + 1)
                          )
                )
            and prdate between nvl(startdate, to_date('01-jan-1900','dd-mon-yyyy'))
                           and nvl(enddate  , to_date('01-jan-5000','dd-mon-yyyy'));
    
      return n;  -- what is "n" ?
    END;
    /
    

    Not really sure what you want to do with "n"... you have nothing in your code... so I did the same

  • ORA-04076: invalid specification NEW or OLD

    Dear all,

    I am creating a trigger with option AFTER UPDATE but its raise the error:

    ORA-04076: invalid specification NEW or OLD

    Here's the syntax I'm using to create a trigger that sends an email, if there is no update table tab1 column NLN001. If I use not WHEN the clause then the trigger is created without any problem. But the requirement here is that the changed value of the NLN001 column trigger for the combination of the time clause ( NLKCO = "00001" NLDCT AND = 'I' AND NLCTRY = AND NLFY = 14 20) only.

    CREATE OR REPLACE TRIGGER SCHM1. UPDATE_tab1_TRG

    AFTER UPDATE

    ON SCHM1. TAB1 FOR EACH LINE

    WHERE (NLKCO = "00001" AND "EI" AND NLCTRY = 20 = NLDCT AND NLFY = 14)

    Start

    If (: NEW.) NLN001 <>: OLD. NLN001) THEN

    MAIL_FILES ('FROM_MAIL_ADD', 'TO_MAIL_ADD', 'value changed tab1', ' the value of I-TAB1 is passed to ' |: OLD.) NLN001 | « à » || : NEW. NLN001, 9999999999, null, null);

    END IF;

    End;

    /

    I hope that I have clarified my requirement. Please help me out in this matter.

    Oracle DB Version: 11.2.3.0

    Version of the OS: RHEL 5.11

    Kind regards

    Imran Khan

    Hello

    WHEN (OLD. NLKCO = "00001" AND OLD. NLDCT = "EI" AND OLD. NLCTRY = 20 AND OLD. NLFY = 14)

    This means that when the existing function of values NLKCO = "00001" oly, you must update this table right?

    So we use OLD to existing values.

Maybe you are looking for