Create Directory in Procedure

Hi Guys,
Any one please help i am getting an error during creating directory in procedure. Below is the code and error
I am using windows XP, oracle 10g, sql developer and sql plus.
code: -
create or replace
procedure checking as
filing UTL_File.File_Type;
create or replace directory dir as 'c:\temp';
begin
filing := UTL_File.Fopen(dir,'check.txt','w');
UTL_File.put_line(filing, 'Test');
UTL_File.FClose(filing);
End;
error
Error(5,1): PLS-00103: Encountered the symbol "CREATE" when expecting one of the following: begin function package pragma procedure subtype type use <an identifier> <a double-quoted delimited-identifier> form current cursor
Thanks

SQL> create or replace procedure myproc1
  2  as
  3  begin
  4  execute immediate 'create or replace directory MYDIR as ' || '''' || '/oracle/arch' || '''';
  5  end;
  6  /
Warning: Procedure created with compilation errors.
SQL> show error
Errors for PROCEDURE MYPROC1:
LINE/COL ERROR
4/1      PLS-00103: Encountered the symbol "CREATE" when expecting one of
         the following:
         begin case declare exit for goto if loop mod null pragma
         raise return select update while with <an identifier>
         <a double-quoted delimited-identifier> <a bind variable> <<
         close current delete fetch lock insert open rollback
         savepoint set sql execute commit forall merge
         <a single-quoted SQL string> pipe
SQL> create or replace procedure myproc1
  2  as
  3  begin
  4  execute immediate 'create or replace directory MYDIR as ' || '''' || '/oracle/arch' || '''';
  5  end;
  6  /
Procedure created.
SQL> exec myproc1;
PL/SQL procedure successfully completed.
SQL>

Similar Messages

  • Create directory from procedure using IN parameter-Directory name with path

    Hi,
    I wrote a procedure which takes directory name(C:\temp) as IN parameter and create oracle directory using EXECUTE IMMEDIATE by the procedure. Proc compiled fine but when i try to execute it (exec prc_lx_e_m_fund_activty ('C:\interface','test1.txt','20040102') , i am getting the following error with the execute immediate statement mentioned below.
    create or replace
    PROCEDURE prc_lx_e_m_fund_activty
    i_output_dir IN VARCHAR2,
    i_output_file_name IN VARCHAR2,
    i_interface_date IN VARCHAR2
    AS
    EXECUTE IMMEDIATE 'CREATE OR REPLACE DIRECTORY OUTPUT_PATH AS ' || ''''||i_output_dir||'''' ||';'; -- Where i_output_dir=C:\temp (I am passing this parameter as IN)
    END
    ORA-01481: invalid number format model
    ORA-06512: at "DBO.PRC_LX_E_M_FUND_ACTIVTY", line 326
    ORA-00911: invalid character
    ORA-06512: at line 10
    Process exited.
    Regards,
    Nagarjun.

    You don't need to put it in a string first. Your actual problem was that you included a ";" on the end of your statement which you don't require with execute immediate.
    This would do the job...
    EXECUTE IMMEDIATE 'CREATE OR REPLACE DIRECTORY OUTPUT_PATH AS '''||i_output_dir||'''';or this (if you are on 10g upwards)
    EXECUTE IMMEDIATE q'[CREATE OR REPLACE DIRECTORY OUTPUT_PATH AS ''||i_output_dir||'']';However, I would seriously question why you are creating directories dynamically in code.
    The purpose of creating directories and granting permission to read and/or write to them is to maintain security over which users can access various places on the file system. If you give this flexibility of creating directories to users then effectively they can kill your database server and/or hack into information that they shouldn't.

  • Create directory issue in Store Procedure

    Hi Guys,
    can any one help?
    I am using XP, Oracle 10g, sql developer and Sql Plus.
    I am trying to create directory in storeprocedure, but it not let me to do that thing. below is the statement i am using
    create or replace directory public_access as '/tmp/public_access';
    please let me know hoe can i initialize my dir object in store procedure.
    Thanks

    user13012136 wrote:
    Hi Guys,
    can any one help?
    I am using XP, Oracle 10g, sql developer and Sql Plus.
    I am trying to create directory in storeprocedure, but it not let me to do that thing. below is the statement i am using
    create or replace directory public_access as '/tmp/public_access';
    please let me know hoe can i initialize my dir object in store procedure.
    ThanksTypically best NOT to do something like this in a procedure, but there are cases where it's needed.
    In those cases, you need to use Native Dynamic SQL.
    execute immediate 'create or replace directory public_access as ''/tmp/public_access''';  Assuming your syntax was correct before (i just copied and pasted what you had, adding quotes where needed).

  • Need help to create export table procedure

    Hi,
    I have created a procedure, which may use to do following things:
    1. first create a duplicate table of sys.aud$ records
    2. export that duplicate table
    here I am enclosing my code:
    1. create or replace procedure crt_tab
    2. is
    3. sqlstring varchar2(100);
    4. tablename varchar2(100);
    5. sys_date varchar2(100);
    6. h1 number;
    7. begin
    8. select to_char(sysdate,'DDMMYYYY_HH12MISSAM') into sys_date from dual;
    9. tablename :='AUDIT_RECORD_'||sys_date;
    10. sqlstring := 'create table ' || tablename|| ' as select * from sys.aud$';
    11. execute immediate sqlstring;
    12. h1 := dbms_datapump.open(operation=>'EXPORT',job_mode=>'TABLE',job_name=>NULL,version=>'COMPATIBLE');
    13. dbms_datapump.add_file(handle =>h1, filename =>tablename||'.dmp',directory =>'AUDIT_RECORD', filetype =>1);
    14. dbms_datapump.add_file(handle =>h1,filename =>tablename||'.log',directory =>'AUDIT_RECORD',filetype =>3);
    15. dbms_datapump.metadata_filter(h1,'NAME_LIST','(''tablename'')');
    16. dbms_datapump.start_job(h1);
    17. dbms_output.put_line('Data Pump job started successfully');
    18. end;
    Well, in line number 15. I am passing a variable tablename as a parameter to dbms_datapump.metadata_filter but it exporting an empty dump. Could you please let me know how to pass a variable value in this.
    looking forward to your early response.
    Regards,
    M.A.Bamboat
    [email protected]

    SQL> ed
    Wrote file afiedt.buf
      1  DECLARE
      2    l_dp_handle     NUMBER;
      3    l_last_job_state VARCHAR2(30) := 'UNDEFINED';
      4    l_job_state     VARCHAR2(30) := 'UNDEFINED';
      5    l_logfilename     VARCHAR2(20) := to_char(sysdate, 'DDMMRRRR') || '.log';
      6    l_expfilename     VARCHAR2(20) := to_char(sysdate, 'DDMMRRRR') || '.dmp';
      7    l_tbl_name     VARCHAR2(30) :='EMP';
      8  BEGIN
      9    l_dp_handle := DBMS_DATAPUMP.OPEN(operation   => 'EXPORT',
    10                          job_mode    => 'TABLE',
    11                          remote_link => NULL,
    12                          job_name    => 'SAUBHIK_EXPORT',
    13                          version     => 'COMPATIBLE');
    14    DBMS_DATAPUMP.ADD_FILE(handle     => l_dp_handle,
    15                     filename     => l_expfilename,
    16                     directory => 'SAUBHIK',
    17                     filetype     => DBMS_DATAPUMP.KU$_FILE_TYPE_DUMP_FILE);
    18    DBMS_DATAPUMP.ADD_FILE(handle     => l_dp_handle,
    19                     filename     => l_logfilename,
    20                     directory => 'SAUBHIK',
    21                     filetype     => DBMS_DATAPUMP.KU$_FILE_TYPE_LOG_FILE);
    22    dbms_datapump.metadata_filter(handle => l_dp_handle,
    23                         name   => 'NAME_EXPR',
    24                         value  =>'= '||''''||l_tbl_name||'''');
    25    dbms_datapump.start_job(l_dp_handle);
    26    dbms_datapump.detach(l_dp_handle);
    27  EXCEPTION
    28    WHEN OTHERS THEN
    29      dbms_datapump.stop_job(l_dp_handle);
    30      RAISE;
    31* END;
    SQL> /
    PL/SQL procedure successfully completed.
    SQL> SELECT * FROM user_datapump_jobs;
    JOB_NAME                 OPERATION                JOB_MODE                    STATE                    DEGREE ATTACHED_SESSIONS DATAPUMP_SESSIONS
    SAUBHIK_EXPORT                 EXPORT                     TABLE                    EXECUTING                         1       0           2
    SQL> /
    JOB_NAME                 OPERATION                JOB_MODE                    STATE                    DEGREE ATTACHED_SESSIONS DATAPUMP_SESSIONS
    SAUBHIK_EXPORT                 EXPORT                     TABLE                    NOT RUNNING                    0       0           0
    SQL> /
    no rows selected
    SQL>
    oracle@ubuntu-desktop:~/Documents$ pwd
    /home/oracle/Documents
    oracle@ubuntu-desktop:~/Documents$ ls -l 05092011*
    -rw-r----- 1 oracle oinstall 98304 2011-09-05 15:07 05092011.dmp
    -rw-r--r-- 1 oracle oinstall   928 2011-09-05 15:07 05092011.log
    oracle@ubuntu-desktop:~/Documents$

  • VMS, create directory and the chamber of secrets

    Ok, here I am bumbling around in the dark. Here is the scenario I am developing an application using PL/SQL under the constraints of the SCT Banner web form system. The Banner function calls create the web page on the fly from data obtained with PL/SQL. What I would like to do is incorporate a java function into the web page. The only method available to me is via Banners function call twbkfrmt.p_printmessage (my_string); Here is the 'Plan' (caution: may be seriously flawed). I thought I could store my java code in a the CLOB field of a table, access it with a cursor and insert the code into the generated web page like so: twbkfrmt.p_printmessage (my_java_from_the_CLOB); I am having troubles loading the .js into my table. Here is how I attempted to accomplish this and the result (and to add insult to injury, it is on a VMS system!):
    CREATE TABLE js_holder (
    js_name varchar(30),
    js_body CLOB );
    CREATE DIRECTORY foos as 'USR$DISK:[CLEMENSD.SQL_EDIT]';
    CREATE OR REPLACE PROCEDURE Load_CLOB IS
    dest_clob CLOB;
    in_file BFILE := BFILENAME('foos', 'supernote.js');
    dst_offset number := 1 ;
    src_offset number := 1 ;
    lang_ctx number := DBMS_LOB.DEFAULT_LANG_CTX;
    warning number;
    BEGIN
    DBMS_OUTPUT.ENABLE(100000);
    INSERT INTO js_holder(js_name, js_body)
    VALUES('supernote', empty_clob())
    RETURNING js_body INTO dest_clob;
    DBMS_LOB.OPEN(in_file, DBMS_LOB.LOB_READONLY);
    DBMS_LOB.LoadCLOBFromFile(
    DEST_LOB => dest_clob
    , SRC_BFILE => in_file
    , AMOUNT => DBMS_LOB.GETLENGTH(in_file)
    , DEST_OFFSET => dst_offset
    , SRC_OFFSET => src_offset
    , BFILE_CSID => DBMS_LOB.DEFAULT_CSID
    , LANG_CONTEXT => lang_ctx
    , WARNING => warning
    DBMS_LOB.CLOSE(in_file);
    COMMIT;
    DBMS_OUTPUT.PUT_LINE('Loaded File using DBMS_LOB.LoadCLOBFromFile.');
    END;
    then the following:
    EOUTST> set serveroutput on
    EOUTST> exec Load_CLOB
    EOUTST> exec load_clob
    BEGIN load_clob; END;
    ERROR at line 1:
    ORA-22285: non-existent directory or file for FILEOPEN operation
    ORA-06512: at "SYS.DBMS_LOB", line 672
    ORA-06512: at "BANINST1.LOAD_CLOB", line 13
    ORA-06512: at line 1
    EOUTST>

    Is the directory owned by the same schema that owns the procedure?
    If not did you GRANT READ and WRITE to the proc's schema?
    If so then you might want to create a simple external table to confirm that your directory and permissions are valid.

  • Create directory error on a VMS system

    Ok, I am trying to load some date into a CLOB field within a small table I have created. Here is how I attempted to accomplish this and the result (and to add insult to injury, it is on a VMS system!):
    CREATE TABLE js_holder (
    js_name varchar(30),
    js_body CLOB );
    CREATE DIRECTORY foos as 'USR$DISK:[CLEMENSD.SQL_EDIT]';
    CREATE OR REPLACE PROCEDURE Load_CLOB IS
    dest_clob CLOB;
    in_file BFILE := BFILENAME('foos', 'supernote.js');
    dst_offset number := 1 ;
    src_offset number := 1 ;
    lang_ctx number := DBMS_LOB.DEFAULT_LANG_CTX;
    warning number;
    BEGIN
    DBMS_OUTPUT.ENABLE(100000);
    INSERT INTO js_holder(js_name, js_body)
    VALUES('supernote', empty_clob())
    RETURNING js_body INTO dest_clob;
    DBMS_LOB.OPEN(in_file, DBMS_LOB.LOB_READONLY);
    DBMS_LOB.LoadCLOBFromFile(
    DEST_LOB => dest_clob,
    SRC_BFILE => in_file,
    AMOUNT => DBMS_LOB.GETLENGTH(in_file),
    DEST_OFFSET => dst_offset ,
    SRC_OFFSET => src_offset,
    BFILE_CSID => DBMS_LOB.DEFAULT_CSID,
    LANG_CONTEXT => lang_ctx,
    WARNING => warning );
    DBMS_LOB.CLOSE(in_file);
    COMMIT;
    DBMS_OUTPUT.PUT_LINE('Loaded File using DBMS_LOB.LoadCLOBFromFile.');
    END;
    then the following:
    SQL> set serveroutput on
    SQL> exec Load_CLOB
    SQL> exec load_clob
    BEGIN load_clob; END;
    ERROR at line 1:
    ORA-22285: non-existent directory or file for FILEOPEN operation
    ORA-06512: at "SYS.DBMS_LOB", line 672
    ORA-06512: at "BANINST1.LOAD_CLOB", line 13
    ORA-06512: at line 1
    SQL>

    Wow you've sure got a lot of threads going on this one (Ok Waz zup? and VMS, create directory and the chamber of secrets
    My first question is have you checked to ensure that the file and directory permissions will allow oracle to read the file you want? Have you tried dumping your supernote.js file in the jobsub directory, or chaning it's (and/or the directories) protections?
    From the documentation for create directory: "Oracle Database does not verify that the directory you specify actually exists. Therefore, take care that you specify a valid directory in your operating system. In addition, if your operating system uses case-sensitive path names, be sure you specify the directory in the correct format."

  • Create directory utl_file errors

    I thought that I would be able to answer my problem with all the help I've seen online. I don't seem to be able to.
    I have the following code (snippet) below from my procedure:
    v_file varchar2(100);
    v_direc constant varchar2(30) := 'c:\output\';
    v_testfile UTL_FILE.FILE_TYPE;
    BEGIN
    v_testfile := utl_file.fopen('C:\output', 'JohnsUIICounts.txt', 'w');
    open csr_uii;
    loop
    fetch csr_uii into csr_uii_a, csr_uii_b, csr_uii_c, csr_uii_d;
    exit when csr_uii%NOTFOUND;
    utl_file.put_line(v_testfile, csr_uii_a || ' ' || csr_uii_b || ' '|| csr_uii_c || ' '|| csr_uii_d);
    end loop;
    I logged on to SQL Developer and did:
    CREATE DIRECTORY V_DIREC AS 'C:\output\';
    GRANT WRITE ON DIRECTORY V_DIREC TO PUBLIC;
    I got the message back that the directory was created. When I go to the c:\ drive, I don't see the directory.
    Any ideas? I've gone through all sorts of iterations like changing the drive from c to e, different folder names, upper and lower case, nothing works.
    Victoria

    Thanks. Now that I understand that, I created the directory on the server. I reran the code. I'm still getting:
    ORA-29280: invalid directory path
    ORA-06512: at "SYS.UTL_FILE", line 33
    ORA-06512: at "SYS.UTL_FILE", line 436
    I notice that on the Windows Server, when I create the directory (as an admin user), I check on the properties, and it keeps staying read only. I can modify it, but the change doesn't save. I heard something about group permissions. Is it possible that the problem is because of permissions on the server? I would think that might be the real problem at this point.
    Thanks,
    Victoria
    Edited by: user3804901 on May 20, 2009 4:31 AM

  • Creating directory

    How can I create directory(folder) in the file system with pl/sql. I know you can create file or write in to a file, in any folder in file system with utl_file. but what about creating a folder then a file in to it.

    depending on your os/oracle version, you can use dbms_scheduler to do that.
    ex in AIX5L/10.2.0.2
    $ cat /tmp/x            
    #!/bin/ksh
    mkdir /tmp/xxx
    SQL> exec dbms_scheduler.create_job(job_name=>'createdir',job_type=>'EXECUTABLE',job_action=>'/tmp/x',start_date=>sysdate,enabled=>true)                                       
    PL/SQL procedure successfully completed.or you can use java

  • How can i create a native procedure??

    Hi all,
    How can i create a native procedure in Oracle 8.1.7???
    P.S.: Without using OCI.
    thanx.

    Log into shared services, expand User Directories > Native Directory > Right click users and select "New"
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Create directory on OpenVms

    Hi all i create a directory on ovms server
    CREATE OR REPLACE DIRECTORY MY_FILES AS '$DISK2:[ADG.DATI_SPOOL_1]';
    How i can veriify if exists or if the directory is right?
    I create a procedure that read a file from this directory and i get an error on the file reading so i suspect that the directory is not visible or the path format is wrong for oracle.
    help?

    Hi i have grant for read and write and i get this error
    ORA-00600: internal error code, arguments: [9999], [], [], [], [], [], [], []
    ORA-06512: at "SYS.DBMS_LOB", line 607
    ORA-06512: at "CONTAB_AZ001.INSERT_TEST", line 9
    ORA-06512: at line 1
    00600. 00000 - "internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s]"
    *Cause:    This is the generic internal error number for Oracle program
    exceptions.     This indicates that a process has encountered an
    exceptional condition.
    *Action:   Report as a bug - the first argument is the internal error number
    this is the procedure
    create or replace procedure insert_test(test_id in integer, filename in varchar) IS
    l_blob blob;
    l_bfile bfile;
    begin
    insert into demo values ( 1, empty_blob() )
    returning theBlob into l_blob;
    l_bfile := bfilename( 'MY_FILES', filename );
    dbms_lob.fileopen( l_bfile );
    dbms_lob.loadfromfile( l_blob, l_bfile,
    dbms_lob.getlength( l_bfile ) );
    dbms_lob.fileclose( l_bfile );
    end;

  • 'CREATE DIRECTORY' performs COMITT

    Hi,
    We are trying to update an image in a table contains BLOB data type column.
    the steps are:
    1. delete (without commit)
    2. create or replace directory
    3. insert a new image
    In case that INSERT fails, we want to keep the privious image.
    The CREATE DIRECTORY step performs a commit, which cause a loose of the image.
    Is there a way to avoid the commit, or any work around?
    Thanks in advance!
    Maya
    null

    Hi.
    You can do it. Try something like this:
    CREATE OR REPLACE
    PROCEDURE Do_DDl (p_ddl VARCHAR2) IS
    PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
    EXECUTE IMMEDIATE p_ddl;
    END;
    And use this to do your DDL:
    DELETE record
    Do_DDL('CREATE OR REPLACE DIRECTORY ....');
    INSERT record
    COMMIT;
    The PRAGMA AUTONOMOUS_TRANSACTION; means the procedure runs in its own transaction, so it doesn't screw up your other stuff.
    Hope this helps.
    Tim....

  • Create directory object question ?

    I have been given right to create directory object by my DBA.
    The DBA has also created the folder specified in the create directory command.Now my Unix operating system user id is A and my Oracle user Id is B.The DBA is telling me that he has created the folder and has given all right to my unix user id.But my doubt is that it will not work because I am accessing that folder via Oralce PL-SQL procedure and not manually accessing that unix folder using unix id.
    Please help.
    Thanks
    ,m

    Files you create will be owned by the database owner (oracle). The folder needs to have group rwx privs for the same group a oracle (usually DBA).

  • Pointbase : How can I create a stored procedure with Pointbase database?

    Hello,
    Excuse me for my english, I'm not anglophone. I try to create a stored procedure.
    This is my file SampleExternalMethods.java :
      import java.sql.*;    //import com.pointbase.jdbc.jdbcInOutDoubleWrapper;          public class SampleExternalMethods    {      // A connection object to allow database callback      static Connection conn = null;      static Statement l_stmt;      static Statement m_stmt;      static CallableStatement m_callStmt = null;      static ResultSet l_rs = null;          public static void main(String[] args)      {        try        {          String url = "jdbc:pointbase:server://localhost/pointbaseDB";          String username = "PBPUBLIC";          String password = "PBPUBLIC";          conn = DriverManager.getConnection(url, username, password);          doCreateProcedure();          doInvokeProcedure();        } catch (SQLException e) {          e.printStackTrace();        } finally {          if (m_stmt != null) {            try {              m_stmt.close();            } catch (Exception e) {              e.printStackTrace();            }          }          if (m_callStmt != null) {            try {              m_callStmt.close();            } catch (Exception e) {              e.printStackTrace();            }          }          if (conn != null) {            try {              conn.close();            } catch (Exception e) {              e.printStackTrace();            }          }        }      }                  public static void getCountry(String Iso_Code)      {        try        {          // Query the database for the country iso code          l_stmt = conn.createStatement();          l_rs = l_stmt.executeQuery( "SELECT * FROM countries"          + " WHERE country_iso_code ='" + Iso_Code + "'");          //Affichage du résultat de la requête          l_rs.next();          System.out.print(l_rs.getString(1) + " - ");          System.out.print(l_rs.getString(2) + " - ");          System.out.println(l_rs.getString(3));          // Close the result set          l_rs.close();        } catch (SQLException e) {          e.printStackTrace();        } finally {          if (l_rs != null) {            try {              l_rs.close();            } catch (Exception e) {              e.printStackTrace();            }          }          if (l_stmt != null) {            try {              l_stmt.close();            } catch (Exception e) {              e.printStackTrace();            }          }        }      }            public static void doCreateProcedure() throws SQLException {        // SQL statement to create a stored procedure        String SQL_CREATE_PROC = "CREATE PROCEDURE getCountry(IN P1 VARCHAR(30))"        + " LANGUAGE JAVA"        + " SPECIFIC getCountry"        + " NO SQL"        + " EXTERNAL NAME \"SampleExternalMethods::getCountry\""        + " PARAMETER STYLE SQL";        // Create a SQL statement        m_stmt = conn.createStatement();        // Execute the SQL        m_stmt.executeUpdate(SQL_CREATE_PROC);        // Close the statement        //m_stmt.close();      }          public static void doInvokeProcedure() throws SQLException {        // Create SQL to invoke stored procedures        String SQL_USE_PROC = "{ call getCountry(?) }";        // Create a callable statement with three binding parameters        m_callStmt = conn.prepareCall(SQL_USE_PROC);        m_callStmt.setString(1, "CA");        m_callStmt.executeQuery();        // Close the callable statement        //m_callStmt.close();      }    } 
    Afterwards, I have read this note in a Pointbase document:
    To invoke the dateConvert external Java method from a stored function, you must use the
    CREATE FUNCTION statement. The dateConvert external Java method is called from the
    class, SampleExternalMethods.
    In order for the database to access this external Java method, the class SampleExternalMethods
    must be included in the database CLASSPATH. For PointBase Embedded - Server Option, it
    must be in the Server CLASSPATH, but not in the Client CLASSPATH.
    If PointBase Server is run with the Java Security Manager, in the java policy file grant
    ’com.pointbase.sp.spPermission’ to the class that implements the external Java method.
    An "spPermission" consists of a class name with no action. The class name is a name of a class
    that could be used in creating a Stored Procedure in PointBase. The naming convention follows
    the hierarchical property naming convention and that is supported by
    "java.security.BasicPermission". An asterisk may appear by itself, or if immediately preceded
    by ".", may appear at the end of the name, to signify a wildcard match. The name cannot
    contain any white spaces.
    I'm not sure, but I suppose that I must include the class SampleExternalMethods in a .jar file.
    The database CLASSPATH could be : C:\Sun\AppServer\pointbase\lib\
    These my files in this database CLASSPATH:
    pbclient.jar
    pbembedded.jar
    pbtools.jar
    pbupgrade.jar
    I have tryed to include the class SampleExternalMethods in pbclient.jar and pbembedded.jar with this command:
    jar -uf pbembedded.jar SampleExternalMethods
    Afterwards I do that,
    1) Start Pointbase
    2) Configuration of classpath
    set classpath=C:\Sun\AppServer\pointbase\lib\pbclient.jar
    set classpath=%classpath%;D:\J2EE\Ch07Code\Ch07_06
    I precise that my file SampleExternalMethods is into D:\J2EE\Ch07Code\Ch07_06\Ch07.
    Then, I run the program:
    D:\J2EE\Ch07Code\Ch07_06>java -Djdbc.drivers=com.pointbase.jdbc.jdbcUniversalDriver Ch07.SampleExternalMethods
    But I have an error message:
    Exception in thread "main" java.lang.NoClassDefFoundError: Ch07.SampleExternalMethods (wrong name: SampleExternalMethods)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.DefineClass(ClassLoader.java:539)
    The problem, I suppose, comes from that the class SampleExternalMethods
    must be included in the database CLASSPATH, but there is a pbserver.jar with pointbase normally, but I didn't find it. That's why I use pbembedded.jar or pbclient.jar in order to include the class SampleExternalMethods. May be I must start from C:\Sun\AppServer\pointbase\lib\ instead of D:\J2EE\Ch07Code\Ch07_06\Ch07?
    Please, can somebody helps me?
    Thank you in advance.
    cagou!

    jschell wrote:
    And I doubt you can recurse like that for embedded java. You must have a class that does the functionality and another class that creates the proc.
    >And I doubt you can recurse like that for embedded java. You must have a class that does the functionality and another class that creates the proc.
    >
    And I doubt you can recurse like that for embedded java. You must have a class that does the functionality and another class that creates the proc.
    Thank you for your response, I have done two classes:
    SampleExternalMethods.java:
    package Ch07;
    import java.sql.*;*
    *public class SampleExternalMethods*
    *public static void getCountry(String Iso_Code)*
    *// A connection object to allow database callback*
    *Connection l_conn = null;*
    *Statement l_stmt = null;*
    *ResultSet l_rs = null;*
    *try*
    *String url = "jdbc:pointbase:server://localhost/pointbaseDB";*
    *String username = "PBPUBLIC";*
    *String password = "PBPUBLIC";*
    *l_conn = DriverManager.getConnection(url, username, password);*
    *// Query the database for the country iso code*
    *l_stmt = l_conn.createStatement();*
    *l_rs = l_stmt.executeQuery( "SELECT* FROM PBPUBLIC.COUNTRIES"
    +" WHERE country_iso_code ='"+ Iso_Code +"'");+
    +//Affichage du r&eacute;sultat de la requ&ecirc;te+
    +l_rs.next();+
    +System.out.print(l_rs.getString(1)+ " - ");
    System.out.print(l_rs.getString(2) +" - ");+
    +System.out.println(l_rs.getString(3));+
    +// Close the result set+
    +l_rs.close();+
    +} catch (SQLException e) {+
    +e.printStackTrace();+
    +} finally {+
    +if (l_rs != null) {+
    +try {+
    +l_rs.close();+
    +} catch (Exception e) {+
    +e.printStackTrace();+
    +}+
    +}+
    +if (l_stmt != null) {+
    +try {+
    +l_stmt.close();+
    +} catch (Exception e) {+
    +e.printStackTrace();+
    +}+
    +}+
    +if (l_conn != null) {+
    +try {+
    +l_conn.close();+
    +} catch (Exception e) {+
    +e.printStackTrace();+
    +}+
    +}+
    +}+
    +}+
    +}+
    CreateMethods.java:
    +package Ch07;+
    +import java.sql.*;+
    +public class CreateMethods+
    +{+
    +// A connection object to allow database callback+
    +static Connection m_conn = null;+
    +static Statement m_stmt;+
    +static CallableStatement m_callStmt = null;+
    +public static void main(String[] args)+
    +{+
    +try+
    +{+
    +String url = "jdbc:pointbase:server://localhost/pointbaseDB";+
    +String username = "PBPUBLIC";+
    +String password = "PBPUBLIC";+
    +m_conn = DriverManager.getConnection(url, username, password);+
    +doCreateProcedure();+
    +doInvokeProcedure();+
    +} catch (SQLException e) {+
    +e.printStackTrace();+
    +} finally {+
    +if (m_stmt != null) {+
    +try {+
    +m_stmt.close();+
    +} catch (Exception e) {+
    +e.printStackTrace();+
    +}+
    +}+
    +if (m_callStmt != null) {+
    +try {+
    +m_callStmt.close();+
    +} catch (Exception e) {+
    +e.printStackTrace();+
    +}+
    +}+
    +if (m_conn != null) {+
    +try {+
    +m_conn.close();+
    +} catch (Exception e) {+
    +e.printStackTrace();+
    +}+
    +}+
    +}+
    +}+
    +public static void doCreateProcedure() throws SQLException {+
    +// SQL statement to create a stored procedure+
    +String SQL_CREATE_PROC = "CREATE PROCEDURE PBPUBLIC.getCountry(IN P1 VARCHAR(30))"+
    " LANGUAGE JAVA"
    +" SPECIFIC getCountry"+
    " NO SQL"
    +" EXTERNAL NAME \"SampleExternalMethods::getCountry\""+
    " PARAMETER STYLE SQL";
    // Create a SQL statement
    m_stmt = m_conn.createStatement();
    // Execute the SQL
    m_stmt.executeUpdate(SQL_CREATE_PROC);
    // Close the statement
    //m_stmt.close();
    public static void doInvokeProcedure() throws SQLException {
    // Create SQL to invoke stored procedures
    String SQL_USE_PROC = "{ call getCountry(?) }";
    // Create a callable statement with three binding parameters
    m_callStmt = m_conn.prepareCall(SQL_USE_PROC);
    m_callStmt.setString(2, "CA");
    m_callStmt.executeQuery();
    // Close the callable statement
    //m_callStmt.close();
    }But I have the same error message that previously.
    I have read this note and I suppose that the problem is linked:
    If PointBase Server is run with the Java Security Manager, in the java policy file grant
    *’com.pointbase.sp.spPermission’ to the class that implements the external Java method.*
    An "spPermission" consists of a class name with no action. The class name is a name of a class
    that could be used in creating a Stored Procedure in PointBase. The naming convention follows
    the hierarchical property naming convention and that is supported by
    *"java.security.BasicPermission". An asterisk may appear by itself, or if immediately preceded*
    by ".", may appear at the end of the name, to signify a wildcard match. The name cannot
    contain any white spaces.
    Can you explain me what I must to do in order to solve this problem of spPermission.
    Thanks.

  • Creating pl/sql procedure problems

    Dear all,
    I have problems with creating a procedure which select returns more then one row.
    CREATE OR REPLACE PROCEDURE ECM_DATA.check_padrones_datos
    IS
      v_padron_check   VARCHAR2(50);
      v_padron_number   VARCHAR2(50);
    BEGIN
       SELECT count(pd.estado)
       INTO v_padron_check
       FROM par6.padrones_datos pd, par6.padrones p, par6.FECHAS f
         where pd.estado not in ('2000','8000')
         AND PD.ARCHIVO = P.ARCHIVO
         AND P.FECHA = F.datum_s;
        DBMS_OUTPUT.PUT_LINE('Št. neuspešnih zapisov :  ' || v_padron_check);
        SELECT distinct pd.archivo
       INTO v_padron_number
       FROM par6.padrones_datos pd, par6.padrones p, par6.FECHAS f
         where pd.estado not in ('2000','8000')
         AND PD.ARCHIVO = P.ARCHIVO
         AND P.FECHA = F.datum_s;
        DBMS_OUTPUT.PUT_LINE('Padron št. :  ' || v_padron_number);
      EXCEPTION
        WHEN NO_DATA_FOUND THEN
         v_padron_number := 'Vsi padroni so OK';
         DBMS_OUTPUT.PUT_LINE('Padron št. :  ' || v_padron_number);
    END;
    Error ->  -01422: exact fetch returns more than requested number of rows
    Select returns 2 or more rows.
    SELECT distinct pd.archivo
        FROM par6.padrones_datos pd, par6.padrones p, par6.FECHAS f
         where pd.estado not in ('2000','8000')
         AND PD.ARCHIVO = P.ARCHIVO
         AND P.FECHA = F.datum_s;
    How to write correct syntax in pl/sql. I apologize in advance for rookie questions. Any help would be appreciated.
    Regards,
    Robert

    The exact implementation depends on the use case.
    You can loop through the results
    FOR r IN (
        SELECT  DISTINCT pd.archivo
        FROM    par6.padrones_datos pd
               ,par6.padrones p
               ,par6.fechas f
        WHERE   pd.estado not in ('2000','8000')
        AND     pd.archivo = p.archivo
        AND     p.fecha = F.datum_s
    LOOP
        dbms_output.put_line('Padron št. :  ' || r.archivo);
    END LOOP;
    Or maybe you can process all results in one step, e.g. if you want to update a table based on the select.
    Regards
    Marcus

  • Error 7 occurred at Create Folder in Create Directory Recursive.vi-

    Recieved following message when attemoting to create source distribution
    Error 7 occurred at Create Folder in Create Directory Recursive.vi->ABAPI Dist Create Directory Recursive.vi->ABAPI Dist Chk for Destinations.vi->ABAPI Copy Files and Apply Settings.vi->SDBEP_Invoke_Build_Engine.vi->SDBUIP_Build_Invoke.vi->SDBUIP_Build_Rule_Editor.vi->SDBUIP_Item_OnDoProperties.vi->SDBUIP_Item_OnDoProperties.vi.ProxyCaller
    Possible reason(s):
    LabVIEW:  File not found. The file might have been moved or deleted, or the file path might be incorrectly formatted for the operating system. For example, use \ as path separators on Windows, : on Mac OS, and / on Linux.

    Hello,
    Could you please list which options you are selecting when building a
    source distribution (I am assuming you are using LabVIEW 8.0?).
    Do you get this error when clicking on "Generate Preview" button when configuring source distribution properties?
    Under "Distribution Settings" category, could you try checking the
    "Disconnect type definitions and remove unuses polymorphic VI
    instances" option and see if that helps with the build process?
    Also I suggest Mass Compiling your VIs (Tools -> Advanced -> Mass Compile) before creating a source distribution.
    If these do not help, could you attach your project with all the VIs it contains here?
    Thank you and best regards,
    Shakhina P.
    Applications Engineer
    National Instruments

Maybe you are looking for