Simple Dir Listing save to Oracle Temp Table

Hello All, any help appreciated...
I'm trying to perform the following:
import java.io.*;
import java.sql.*;
public class DirList
// public static void getList(String directory)
public static String getList(String directory)
throws SQLException
File path = new File( directory );
String[] list = path.list();
String element;
String element2;
element2 = "";
for(int i = 0; i < list.length; i++)
element = list;
element2 = element2 + ":" + list[i];
// #sql {INSERT INTO DIR_LIST (FILENAME)
// VALUES (:element)};
return element2;
Issues:
I found the above code snippet from AskTom on Oracle's web site... exactly what I want to do, but cant get it to work/compile...
1) Cannot get the #sql statement to compile... Thus I created the variable String element2, which works, except for large directories... It would be nice if I could insert each element into the temporary table and then use sql... Am I missing something with the #sql statement? Is it not within java.sql? on my system? How to verify this/ workarounds?
2) the only way I could load this (with #sql commented out) was via loadjava... I tried loading within the database via sqlplus but get the following error...
ORA-29536: badly formed source: Encountered "<EOF>" at line 1, column 24.
example:
CREATE or replace and compile java source
named "MyTimestampx"
as
import java.lang.String;
import java.sql.Timestamp;
public class MyTimestampx
public static String getTimestamp()
return (new
Timestamp(System.currentTimeMillis())).toString();
produces the above error...
any ideas why it fails to load via the above method?
thanks for any help.

I solved this issue and perhaps this may help others...
I coded the insert statement a better way and
as for the error with sqlplus, EOF, the answer is:
You have to use 8i or above sqlplus
the 8.0 plus doesn't understand the "create or replace and compile ..." syntax and is prematurely submitting the CREATE statement to the database.
Viola... my client sqlplus version is 8.0.6....
Installing 8i...
null

Similar Messages

  • Problem w/ Oracle temp tables and WL61SP3

    I have an odd problem that arises when I use Weblogic 6.1, Oracle, callable statements,
    and a stored procedure that uses temporary tables. Specifically I don't get the
    result set pack I expect.
    Specifically, I have a stored procedure which first populates a temporary table,
    then joins the temporary table with the additional tables to build the final result
    set--i.e. which it returns as a cursor.
    I've tested this procedure and it works fine when called from PLSQL and from Jboss
    (using Oracle's driver). When I switch to Weblogic 6.1, *using the same database
    and the same Oracle driver*, the returned result set (cursor) has no records.
    I've added additional debugging to the stored procedure and find that it indeed
    is populating the temporary table, but for some reason, the select/join acts like
    the temporary table has no records. Similar 'exists' or 'in' clauses likewise
    do not work.
    In playing with the stored procedure I found that removing the join with the
    temporary table brings back results. This isn't functionally correct--i.e. the
    final result set has too many rows--but it confirmed that the problem lies in
    the temporary tables.
    Again, we've developed to run on multiple app servers so can switch from jboss
    to Weblogic simply by running an ant task. The same callable statement executed
    using the same driver, but from different app servers lead to different results.
    The next step is to try to mess with the 'on commit preserve rows' clause in the
    'create global temporary table' section and see if this has any effect. This procedure
    doesn't perform any commits, however, so this shouldn't produce any changes.
    Any suggestions? Thanks in advance.
    bill milbratz

    william milbratz wrote:
    I have an odd problem that arises when I use Weblogic 6.1, Oracle, callable statements,
    and a stored procedure that uses temporary tables. Specifically I don't get the
    result set pack I expect.
    Specifically, I have a stored procedure which first populates a temporary table,
    then joins the temporary table with the additional tables to build the final result
    set--i.e. which it returns as a cursor.
    I've tested this procedure and it works fine when called from PLSQL and from Jboss
    (using Oracle's driver). When I switch to Weblogic 6.1, *using the same database
    and the same Oracle driver*, the returned result set (cursor) has no records.First, make sure you are using the same driver, by ensuring the driver you want
    is in front of all weblogic stuff in the classpath the server startup script creates for the
    server. We ship a version of oracle's thin driver, so it could be picked up instead
    of yours if the classpath is weblogic-first.
    Second, and this is a long shot, are you using our connection pools? I guess not,
    but let me know...
    Joe
    >
    >
    I've added additional debugging to the stored procedure and find that it indeed
    is populating the temporary table, but for some reason, the select/join acts like
    the temporary table has no records. Similar 'exists' or 'in' clauses likewise
    do not work.
    In playing with the stored procedure I found that removing the join with the
    temporary table brings back results. This isn't functionally correct--i.e. the
    final result set has too many rows--but it confirmed that the problem lies in
    the temporary tables.
    Again, we've developed to run on multiple app servers so can switch from jboss
    to Weblogic simply by running an ant task. The same callable statement executed
    using the same driver, but from different app servers lead to different results.
    The next step is to try to mess with the 'on commit preserve rows' clause in the
    'create global temporary table' section and see if this has any effect. This procedure
    doesn't perform any commits, however, so this shouldn't produce any changes.
    Any suggestions? Thanks in advance.
    bill milbratz

  • How to work on temp table in oracle 10g

    Hi Guys,
    I have one simple procedure and it is returning some records through dbms_output.put_line.
    cursor c1 is select object_name from t_Turbo;
    type c1_type is table of c1%rowtype;
    rec1 c1_type;
    begin
    open c1;
    loop
    fetch c1 bulk collect into rec1 limit 200;
    for i in 1..rec1.count loop
    dbms_output.put_line(rec1.i);
    end loop;
    exit when c1%notfound;
    end loop;
    end;
    Now i am plaing to use temp table at dmbs_output.put_line in place and from there I want to select the records.
    Can any one help me on this.
    Thanks in advance!
    Regards,
    KLR

    This is what you need.
    create or replace procedure test ( pRet out sys_refcursor )
    as
    begin
      open pRet for select object_name from t_Turbo;
    end;SYS_REFCURSOR is a cursor type defined by oracle. You can define your owner.

  • Global temp table trigger error on Oracle AS

    we have a set of triggers that load a temp table in the before delete,update and process the table in an after statement trigger. the data that's loaded is a complaintid and when the complaintid is selected into a variable in the after statement, a No data found error is fired. This only happens on Oracle AS both 9i and 10g, it does not happen on jboss. All the app servers use connection pooling and they are 9i Enterprise Edition Dedicated database servers.
    Is it possible that there is a bug in Oracle AS that allows multiple sessions to affect the same global variables ?
    Sorry it's a long one, but I wanted to include everything I could
    table creation script.
    CREATE GLOBAL TEMPORARY TABLE TEMPEVENTS
    (     COMPLAINTID VARCHAR2(20) NOT NULL ENABLE,
         COMPLAINTEVENTID NUMBER NOT NULL ENABLE,
         STARTDATE DATE,
         EVENTTYPE NUMBER,
         EVENTSUBTYPE NUMBER,
         DELETED NUMBER
    ) ON COMMIT DELETE ROWS
    Before update trigger-- as a test I saved the data in a permanent table and all columns have usable values.
    create or replace trigger BeforeUpdateReportDataROW
    BEFORE Delete or Update of deleted, startdate on complaintevents
    FOR EACH ROW
    BEGIN
    IF (DELETING AND :old.deleted = 0) OR (UPDATING AND :new.deleted=1 AND :old.startDate = :new.startDate) THEN
         TEMPDATA.v_triggerType := 'D';
    ELSIF UPDATING AND :old.deleted=1 AND :old.startDate = :new.startDate THEN /*undeleting*/
         TEMPDATA.v_triggerType := 'U';
    ELSIF UPDATING AND :old.startDate != :new.startDate THEN /*new date*/
         TEMPDATA.v_triggerType := 'S';
    ELSE
         TEMPDATA.v_triggerType := 'N';
    END IF;
    TEMPDATA.v_NumEntries := TEMPDATA.v_NumEntries + 1;
    TEMPDATA.v_complaintids(TEMPDATA.v_NumEntries) := :old.complaintid;
    TEMPDATA.v_complainteventids(TEMPDATA.v_NumEntries) := :old.complainteventid;
    END;
    After statement trigger -- the error happens on the
    SELECT complaintid
    INTO complaintid
    FROM complaintevents
    WHERE complaintid = tempdata.v_complaintids (loop_index)
    AND complainteventid = tempdata.v_complainteventids (loop_index);
    statement. this is all one transaction the complaintid is loaded from the complaintevent table, and is not a primary key, nor is there only one record in the complaintevent table for each complaintid.
    create or replace trigger complaintevents_del_upd_trig
    AFTER DELETE OR UPDATE OF deleted, startdate
    ON complaintevents
    DECLARE
    complaintid VARCHAR2 (20);
    loop_index NUMBER;
    hold_complaintid VARCHAR2 (20);
    BEGIN
    IF tempdata.v_triggertype = 'D'
    THEN /*deleting event*/
    hold_complaintid := ' ';
    FOR loop_index IN 1 .. tempdata.v_numentries
    LOOP
    SELECT complaintid
    INTO complaintid
    FROM complaintevents
    WHERE complaintid = tempdata.v_complaintids (loop_index)
    AND complainteventid = tempdata.v_complainteventids (loop_index);
    IF hold_complaintid != complaintid
    THEN
    INSERT INTO tempevents
    (complaintid, complainteventid, startdate, eventtype,
    eventsubtype, deleted)
    SELECT complaintid, complainteventid, startdate, eventtype,
    eventsubtype, deleted
    FROM complaintevents
    WHERE complaintid = tempdata.v_complaintids (loop_index);
    END IF;
    DELETE tempevents
    WHERE complainteventid =
    tempdata.v_complainteventids (loop_index)
    OR deleted = 1;
    hold_complaintid := complaintid;
    END LOOP;
    ELSIF tempdata.v_triggertype = 'U'
    THEN /*undeleting*/
    hold_complaintid := ' ';
    FOR loop_index IN 1 .. tempdata.v_numentries
    LOOP
    SELECT complaintid
    INTO complaintid
    FROM complaintevents
    WHERE complaintid = tempdata.v_complaintids (loop_index)
    AND complainteventid = tempdata.v_complainteventids (loop_index);
    IF hold_complaintid != complaintid
    THEN
    INSERT INTO tempevents
    (complaintid, complainteventid, startdate, eventtype,
    eventsubtype, deleted)
    SELECT complaintid, complainteventid, startdate, eventtype,
    eventsubtype, deleted
    FROM complaintevents
    WHERE complaintid = tempdata.v_complaintids (loop_index);
    END IF;
    DELETE tempevents
    WHERE deleted = 1;
    INSERT INTO tempevents
    (complaintid, complainteventid, startdate, eventtype,
    eventsubtype, deleted)
    SELECT complaintid, complainteventid, startdate, eventtype,
    eventsubtype, 0
    FROM complaintevents
    WHERE complainteventid =
    tempdata.v_complainteventids (loop_index);
    hold_complaintid := complaintid;
    END LOOP;
    ELSIF tempdata.v_triggertype = 'S'
    THEN /*date change*/
    hold_complaintid := ' ';
    FOR loop_index IN 1 .. tempdata.v_numentries
    LOOP
    SELECT complaintid
    INTO complaintid
    FROM complaintevents
    WHERE complaintid = tempdata.v_complaintids (loop_index)
    AND complainteventid = tempdata.v_complainteventids (loop_index);
    IF hold_complaintid != complaintid
    THEN
    INSERT INTO tempevents
    (complaintid, complainteventid, startdate, eventtype,
    eventsubtype, deleted)
    SELECT complaintid, complainteventid, startdate, eventtype,
    eventsubtype, deleted
    FROM complaintevents
    WHERE complaintid = tempdata.v_complaintids (loop_index);
    END IF;
    DELETE tempevents
    WHERE deleted = 1;
    hold_complaintid := complaintid;
    END LOOP;
    ELSE
    RETURN;
    END IF;
    END;

    CREATE GLOBAL TEMPORARY TABLE test_glb ON COMMIT DELETE ROWS
    AS SELECT * FROM test1;btw I'm assuming you are just using the SELECT statement to copy the definition of test1. Since DDL statements commit, there will be no rows in test_glb after creating it.
    Edited by: William Robertson on Feb 23, 2009 7:31 AM

  • Global temp table in Oracle EBS

    hi gurus,
    i have a GTT with "ON COMMIT PRESERVE ROWS".
    i am populating this table through an OAF page and displaying the data.
    as per the documentation it should delete the data from the table once user logs out from the Oracle EBS but it's not happening.
    the user still sees the records from the previous session.
    please throw some light here.
    thanks,

    i was wondering if there is any sysadmin level setup/profile setup which can end the session (JDBC) once user logs out?No such profile option exists.
    Behavior of Global Temp Table in JDBC
    Behavior of Global Temp Table in JDBC
    Global temp tables with connection pooling
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:4444273995237
    Make global temporary tables transaction specific
    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:868691300346807468
    Thanks,
    Hussein

  • How to use "Auto increment" in temp table Oracle

    Pleas tell me yaar,
    In MS Sql for Auto increment i am using like this "seqid int identity" for temp table
    t_seq_tbl table(seqid int identity,EVENT_SEQ_NO varchar(30))
    In oracle how to use....

    As far as I know there is not any auto increment data type in Oracle. Instead of this you should create a sequence and get the next value of the sequence while creating a row in your table.
    CREATE SEQUENCE Test_Sequence ;
    CREATE TABLE Test_Table ( Id NUMBER , Foo VARCHAR2(4) ) ;
    ALTER TABLE Test_Table ADD CONSTRAINT Test_Table_PK_Id PRIMARY KEY ( Id ) ;
    INSERT INTO Test_Table ( Id , Information ) VALUES ( Test_Sequence.NEXTVAL , 'FOO' ) ;

  • Update Global Temp Table in Oracle 11g

    Hi Experts,
    Scenario: I have stored  procedure A which calls procedure B. Procedure B uses Global temp Tables(With On Commit Preserve Rows)  to work with the data.
    I am trying to update one of the GTT in Proc B but unable to do it .. via SQL or via PL/SQL Cursor/Collection. There is no syntax nor logical error and the PL/SQL proc completes execution successfully but the rows are not getting updated. My Db version is Oralce 11g 11203.
    Update statement is something like this.
    Update <GTT>
    SET amount1 = amount1 *-1, amount2 = amount2 *-1
    where field1 = <value>
    and field2 in ( Select filed2 from <table1> );
    Any idea why would this update not work? Has anyone faced this issue in Oracle 11g??
    Appreciate your suggestions & thanks in Advance for your inputs.
    Cheers,
    MS

    Update statement is something like this.
    Update <GTT>
    SET amount1 = amount1 *-1, amount2 = amount2 *-1
    where field1 = <value>
    and field2 in ( Select filed2 from <table1> );
    Any idea why would this update not work?
    You already told us that it DOES work - no errors or exceptions.
    It is trivial to determine if that update will do anything - just turn it into a SELECT and see if any rows are ntselected:
    v_cnt INTEGER;
    SELECT COUNT(*) INTO v_cnt FROM  myGTT
    WHERE field1 = <value>
    AND field2 in (Select field2 from <tablee1>);
    Then take a look at the 'count' that you get.

  • Temp Tables in Oracle?

    Hi.
    Where can i find information abount using temp tables in Oracle?
    I usually work with SQL Server and use temp tables. I don't have any idea about temp tables in Oracle. Could you give me any information?
    Thanks.
    I'm sorry for may english, I'm spanish.

    There are two completely different things being discussed here temporary segments used by Oracle's internal processes and Oracle global temporary tables.
    Or did I misunderstand?
    We have used Oracle's global temporary tables as quick staging array while data is being integrated into finance apps. Testing showed the process performed faster with this design.
    Both temporary segments and Oracle's global temporary tables are stored in the TEMP tablespace.

  • Is it possible to load and read from an Oracle global temp table?

    Is there a way to call an Oracle database package to pre-load global temp tables in BIP? I am an Oracle Reports user but a newbie to BIP. In Oracle Reports, I use the before-reports trigger to execute a database package that will populate a temp table with data. Then, in Oracle Reports, I read the temp table as the report data source. In BIP, I cannot find the ‘before-reports trigger’ equalivant. Since all the complicated business logic is contained in package it would be helpful to bring in the loaded temp table into BIP. Any thoughts?
    Example:
    Step 1. In the Oracle Reports before report trigger : exec db_package.load_temp_table_procedure (:var1, :var2, :var3);
    Step 2: Select * from temp_table.

    Look at Datatemplates,
    It has pre and post report trigger,
    You can do all these stuff over there,
    Calling a package  in Data template

  • Individual Checkboxes save in multiple rows in an oracle Database table

    I'm using C# .NET and an oracle db table tab1
    create table tab1(col1 number primary key);
    insert into tab1 values (1);
    commit;
    In Web forms tab use CheckBox to create three individual CheckBoxes (don't use CheckBoxList):
    <asp:CheckBox id="CheckBox1" style="Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 24px" runat="server"
    Text="aaa"></asp:CheckBox>
    <asp:CheckBox id="CheckBox2" style="Z-INDEX: 102; LEFT: 40px; POSITION: absolute; TOP: 56px" runat="server"
    Text="bbb"></asp:CheckBox>
    <asp:CheckBox id="CheckBox3" style="Z-INDEX: 104; LEFT: 40px; POSITION: absolute; TOP: 88px" runat="server"
    Text="ccc"></asp:CheckBox>
    And one Button and a Label:
    <asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 40px; POSITION: absolute; TOP: 128px" runat="server"
    Text="Button"></asp:Button>
    <asp:Label id="Label1" style="Z-INDEX: 105; LEFT: 328px; POSITION: absolute; TOP: 56px" runat="server"></asp:Label><INPUT style="Z-INDEX: 106; LEFT: 24px; POSITION: absolute; TOP: 184px" type="text" id="Text1" name="Text1" runat="server">
    Using
    oracleDataAdapter1.Fill(dataSet11);
    oracleDataAdapter1.Update(dataSet11);
    When a user selects a checkbox and presses Button1
    a new row is created in the table TAB1 under COL1
    and when the user reopens the web app the selected checkbox is still displayed because of the number value stored under COL1.
    Can anyone help me on how to save the selected checkbox into COL1 so that when user closes and opens the web app the same selected checkbox is displayed.
    I also am wondering if the user unchecks a checkbox and selects a different checkbox, submits the new change
    to the COL1
    Is there a way to delete the old rows of TAB1 prior to inserting the new row of the new selected checkbox?
    any suggestions would be appreciated.
    Thanks.
    bebop

    I tried looking for a forum to post this Individual Checkboxes question.
    Which forum should I go to for this?
    Any suggestions?
    bebop

  • Use of Oracle global temp table in BI Publisher

    Hi All,
    I have witten a function which populates a Gobal temp table.I call the function and do a select on the global temp table.This fails to give me any result.
    We are calling the function within the package in the 'beforeReport' trigger in our Data Template in BI Publisher.
    I tried to check the session id and found that the sessions are different when we execute the functiona and when we do a select query.
    How can I avoid this situation of changing session?
    I have tried by removing commit from the function but even thta didnt help.
    Please let me know if anyone has suugestion on this.
    Thanks in advance!

    Hi,
    To check if the function is working fine , we inserted the output from temp table into a normal physical table .We queried the physical table and found the values there.
    So , the function is working fine.
    We dont have any statement like 'PRAGMA AUTONOMOUS_TRANSACTION ' in our function.
    Do we need to add it?
    Just to clarify the issue , We have populated the temp table by calling a function and after that we are trying to query the temp table.However, it appears that the session changes between teh function call and issuing of select query .This is resultin into no data being fetched as the values in Gloabal temp table persist only for a session.
    Thanks!

  • Global temp tables difference in oracle 10g and 11g

    Hi All,
    we are planning to upgrade metasolv applications from 6.0.15 (currently suing 10g) to 6.2.1(currently using 11g).We are using the Global temp tables in 10g .i just want to know is there any impact if we upgrade the Global temp tables from 10g to 11g.if so can u please explain me clearly ?
    Please and thanks.

    FAQ on new features: Re: 14. What's the difference between different versions of the database?
    This can be used as a reference for all your queries..

  • Disk space transaction  and temp table lock  in oracle

    Hi,
    Today many sessions used to get disk space transaction lock and temp table lock and i am seeing these locks first time in my Production database,
    is there any workaround to avoid this contension.
    Thanks
    Prakash GR

    Post your version (all 3 decimal places).
    Post the SELECT statement and results that have led you to this conclusion.
    Other than the fact that you have seen a number what, precisely, is the issue.

  • How to create Nested table in oracle stored procedure(Temp Table)

    Hi
    I am creating Nested table in stored procedure(Temp Table)
    type t_v_tbl_rec is record(cumid number,col1 varchar(50),col2 varchar(50),col3 varchar(50),col4 varchar(50),col5 varchar(50),col6 varchar(50));
    type t_v_tbl is table of t_v_tbl_rec index by binary_integer;
    V_V_TBL t_v_tbl;
    But i can't insert value in to this temp table
    Plz help me

    What is problem?
    SQL>declare
      2      type t_v_tbl_rec is record( cumid number,
      3                                  col1 varchar(50),
      4                                  col2 varchar(50),
      5                                  col3 varchar(50),
      6                                  col4 varchar(50),
      7                                  col5 varchar(50),
      8                                  col6 varchar(50) );
      9      type t_v_tbl is table of t_v_tbl_rec index by binary_integer;
    10      v_v_tbl t_v_tbl;
    11  begin
    12      v_v_tbl(1).cumid := 1;
    13      dbms_output.put_line(v_v_tbl(1).cumid);
    14  end;
    15  /
    1
    PL/SQL procedure successfully completed.

  • Create temp table using EXECUTE IMMEDIATE

    Is there any performance issue in creating globally temp table
    using EXECUTE IMMEDIATE or creating globally temp table from
    SQL PLUS.
    Any response will be greatly appreciated.
    null

    Anish,
    Creating tables is likely to be an expensive operation.
    Performance issues can only be considered in comparison to
    alternatives.
    Alternatives include: PLSQL tables, cursors and/or recoding so
    that tmp tables are not required. (One of our consultants reckons
    that sqlserver temp tables are usually used to get around
    limitations in sqlserver, ie slightly more complicated sql
    statements could be used instead of simpler sql and temporary
    tables).
    I would think creating the temp table once during sqlplus would
    be cheaper than creating and deleting it repeatedly at run time.
    Note that EXECUTE IMMEDIATE may do an implicit commit (dbms_sql
    certainly does). This may be got over my using the PRAGMA
    AUTONOMOUS_TRANSACTION; direction which places a
    procedure/function in a seperate transaction.
    Turloch
    P.S. We have some difficulty in getting information back from the
    field/customer sites. If you have questions and answers that are
    likely to be useful to other Oracle Migration Workbench
    users, and migrators in general, please send them in for possible
    inclusion in our Frequently Asked Question list.
    Oracle Migration Workbench Team
    Anish (guest) wrote:
    : Is there any performance issue in creating globally temp table
    : using EXECUTE IMMEDIATE or creating globally temp table from
    : SQL PLUS.
    : Any response will be greatly appreciated.
    Oracle Technology Network
    http://technet.oracle.com
    null

Maybe you are looking for

  • Safari 2.0.4 Crashes on Powerbook G4

    Safari just seems to love to crash on me - it always happens after a period of time of using the program, and the crashes happen on a daily basis. My my initial research of the crash report (seem below) this may have something to do with memory - but

  • How to register/configure a Data Provider with Crystal Report Designer

    Hi, Iu2019m in the process of developing an ADO .Net XML Data Provider which works with Data Sets. I want to use this custom Data Provider through Crystal Report Designer 2008 so that I can access it from the u201CStandard Report Creation Wizard\Avai

  • Records lost and not transferable/playable

    Now I am quite angry Have just come back from 2 days with interviews and found that none of the recordings were possible to transfer either by using Itunes or by using iPod as a harddisk. In the iPod in the memolist, all memos were there and every me

  • Which iPad 2 is best for me?  What uses the space up the most?

    Hi, I'm considering an iPad 2 purchase, but just wondering if I go for the 64GB model would it be space wasted? I don't plan on doing any video editing, and I won't store my main iPhoto library on it (but will likely keep a few photos on there for sh

  • Problem with Nokia N97

    Hi, My N97 went off all the sudden out of the blue so i tried switching it back on but it just froze on the welcome message (the blank screen saying "NOKIA") ...i've tried taking the battery out and putting it back in, connecting it to the charger, c