Home » SQL & PL/SQL » SQL & PL/SQL » Query Issue and Help in Query merged
Query Issue and Help in Query merged [message #537022] Mon, 26 December 2011 02:13 Go to next message
aallan
Messages: 150
Registered: October 2011
Senior Member
/forum/fa/9666/0/Dear All;
My issue is:

i used sql loader to import data from csv file to my db.

but every time the columns places are changed.

so i need dynamic way to insert data into correct column in the table.

in csv file contains column name and i insert this data to temp table, after that i want to read data over column name.

also i read the column names from (All_Tab_Columns) to make combination of column name between temp table and All_Tab_Columns table to insert data to right place...

i think its will be looks like a tree...first row in the query will be in level = 1 and the rest will be in level = 2

any idea ??

  • Attachment: 1.PNG
    (Size: 54.71KB, Downloaded 1555 times)

[Updated on: Mon, 26 December 2011 02:21]

Report message to a moderator

Re: Query Issue [message #537052 is a reply to message #537022] Mon, 26 December 2011 06:26 Go to previous messageGo to next message
muralikri
Messages: 638
Registered: August 2011
Location: chennai
Senior Member

How many records in CSV file? Can you attach the sample file.
Re: Query Issue [message #537101 is a reply to message #537052] Mon, 26 December 2011 13:16 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Pardon me, Aallan, but ... why the heck did you choose such a model?!?
Quote:
but every time the columns places are changed
Why did you agree with that? DEMAND that CSV file is ALWAYS created the same way, following YOUR instructions. ID first, NAME follows, DATE_FROM on the third place, etc. etc. What "dynamic" model, why?
Re: Query Issue [message #537104 is a reply to message #537101] Mon, 26 December 2011 15:00 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9088
Registered: November 2002
Location: California, USA
Senior Member
You can load it into a staging table using a sequence so that the heading line with the column names is the row with sequence 1. Then you can load that from the staging table to the correct columns in the target table, based on the headings in the row with sequence 1. In the demonstration below, I have assumed that the data is tab-delimited. It uses two data files with the columns and corresponding headings in different orders. I have used a procedure to do the loading from staging table to target table.

-- test1.dat:
    DEPTNO	DNAME         	LOC
        10	ACCOUNTING    	NEW YORK
        20	RESEARCH      	DALLAS


-- test2.dat:
DNAME         	LOC          	    DEPTNO
SALES         	CHICAGO      	        30
OPERATIONS    	BOSTON       	        40


-- test.ctl:
load data
replace
into table staging
fields terminated by x'09'
trailing nullcols
(seq sequence, col1, col2, col3)


-- staging table:
SCOTT@orcl_11gR2> create table staging
  2    (seq   number,
  3  	col1  varchar2 (4000),
  4  	col2  varchar2 (4000),
  5  	col3  varchar2 (4000))
  6  /

Table created.


-- target table:
SCOTT@orcl_11gR2> create table target
  2    (deptno	number,
  3  	dname	varchar2 (15),
  4  	loc	varchar2 (15))
  5  /

Table created.


-- procedure to load data from staging table to target table:
SCOTT@orcl_11gR2> create or replace procedure staging_to_target
  2  as
  3    v_sql  varchar2 (32767);
  4  begin
  5    select 'insert into target ('
  6  	      || col1 || ',' || col2 || ',' || col3 || ')
  7  	      select col1, col2, col3
  8  	      from   staging
  9  	      where  seq > 1'
 10    into   v_sql
 11    from   staging
 12    where  seq = 1;
 13    execute immediate v_sql;
 14  end staging_to_target;
 15  /

Procedure created.


-- loads:
SCOTT@orcl_11gR2> host sqlldr scott/tiger control=test.ctl data=test1.dat log=test1.log

SCOTT@orcl_11gR2> exec staging_to_target

PL/SQL procedure successfully completed.

SCOTT@orcl_11gR2> host sqlldr scott/tiger control=test.ctl data=test2.dat log=test2.log

SCOTT@orcl_11gR2> exec staging_to_target

PL/SQL procedure successfully completed.


-- results:
SCOTT@orcl_11gR2> select * from target
  2  /

    DEPTNO	DNAME          	LOC
----------	---------------	---------------
        10	ACCOUNTING     	NEW YORK
        20	RESEARCH       	DALLAS
        30	SALES          	CHICAGO
        40	OPERATIONS     	BOSTON

4 rows selected.

Re: Query Issue [message #537110 is a reply to message #537104] Mon, 26 December 2011 18:58 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9088
Registered: November 2002
Location: California, USA
Senior Member
This thread got me thinking about the possibilities of creating a generic method for creating a table from a delimited file with column headings without knowing anything but the location of the file, name of the file, and the delimiter. I came up with the following method that should work for most typical delimited files with column headings and rows <= 4000 characters that can be placed into a directory on the server. Once you have done a one-time creation of the Oracle directory object, the external table, and the procedure, all you have to do to create the table from the file is execute the procedure, passing the file name, delimiter, and table name. I have demonstrated it below.

-- create oracle directory object that points to operating system path
-- on server where files to be loaded into tables will be:
SCOTT@orcl_11gR2> create or replace directory my_dir as 'c:\my_oracle_files'
  2  /

Directory created.


-- create staging table:
SCOTT@orcl_11gR2> create table staging
  2    (col1  varchar2(4000))
  3  ORGANIZATION external
  4  (
  5    TYPE oracle_loader
  6    DEFAULT DIRECTORY MY_DIR
  7    ACCESS PARAMETERS
  8    (
  9  	 RECORDS DELIMITED BY NEWLINE
 10  	 LOGFILE 'staging.log'
 11  	 FIELDS LDRTRIM
 12  	 MISSING FIELD VALUES ARE NULL
 13  	 REJECT ROWS WITH ALL NULL FIELDS
 14  	 ("COL1" CHAR(4000))
 15    )
 16    location ('staging.dat')
 17  )REJECT LIMIT UNLIMITED
 18  /

Table created.


-- create procedure to accept file name, delimiter, and table name as parameters
-- and create table of specified table name from file name:
SCOTT@orcl_11gR2> create or replace procedure create_source_tab
  2    (p_filename  in varchar2,
  3  	p_delim     in varchar2,
  4  	p_tablename in varchar2)
  5  as
  6    v_sql	varchar2 (32767);
  7    v_count	number;
  8  begin
  9    execute immediate 'alter table staging location (''' || p_filename || ''')';
 10    select 'create table ' || p_tablename || '(rn,'
 11  	      || replace (col1, p_delim, ',')
 12  	      || ') as select * from (select rownum rn'
 13    into   v_sql
 14    from   staging
 15    where  rownum = 1;
 16    --
 17    select regexp_count (col1, p_delim) + 1
 18    into   v_count
 19    from   staging where rownum = 1;
 20    --
 21    for i in 1 .. v_count
 22    loop
 23  	 v_sql := v_sql ||
 24  	   ',substr
 25  	      (''' || p_delim || ''' || col1 || ''' || p_delim || ''',
 26  	       instr (''' || p_delim || ''' || col1 || ''' || p_delim || ''', '''
 27  		 || p_delim || ''', 1, ' || i || ') + ' || length (p_delim) || ',
 28  	       instr (''' || p_delim || ''' || col1 || ''' || p_delim
 29  		 || ''', ''' || p_delim || ''', 1, ' || to_char (i + 1) || ')
 30  	       - instr (''' || p_delim || ''' || col1 || ''' || p_delim || ''', '''
 31  		 || p_delim || ''', 1, ' || i || ')
 32  	       - ' || length (p_delim) || ')';
 33    end loop;
 34    v_sql := v_sql || ' from staging) where rn > 1';
 35    execute immediate v_sql;
 36  end create_source_tab;
 37  /

Procedure created.

SCOTT@orcl_11gR2> show errors
No errors.


-- test1.dat:
DEPTNO	DNAME          	LOC
    10	ACCOUNTING     	NEW YORK
    20	RESEARCH       	DALLAS


-- test2.dat:
DNAME          	LOC            	DEPTNO
SALES          	CHICAGO        	    30
OPERATIONS     	BOSTON         	    40


-- create source_tab1 from test1.dat:
SCOTT@orcl_11gR2> exec create_source_tab ('test1.dat', chr(9), 'source_tab1')

PL/SQL procedure successfully completed.

SCOTT@orcl_11gR2> column deptno format a15
SCOTT@orcl_11gR2> column dname	format a15
SCOTT@orcl_11gR2> column loc	format a15
SCOTT@orcl_11gR2> select * from source_tab1
  2  /

        RN DEPTNO          DNAME           LOC
---------- --------------- --------------- ---------------
         2     10          ACCOUNTING      NEW YORK
         3     20          RESEARCH        DALLAS

2 rows selected.


-- create soruce_tab2 from test2.dat:
SCOTT@orcl_11gR2> exec create_source_tab ('test2.dat', chr(9), 'source_tab2')

PL/SQL procedure successfully completed.

SCOTT@orcl_11gR2> select * from source_tab2
  2  /

        RN DNAME           LOC             DEPTNO
---------- --------------- --------------- ---------------
         2 SALES           CHICAGO             30
         3 OPERATIONS      BOSTON              40

2 rows selected.


-- create target table:
SCOTT@orcl_11gR2> create table target
  2    (deptno	number,
  3  	dname	varchar2 (15),
  4  	loc	varchar2 (15))
  5  /

Table created.


-- insert into target table from source_tab1 and source_tab2:
SCOTT@orcl_11gR2> insert into target
  2  select deptno, dname, loc from source_tab1
  3  union all
  4  select deptno, dname, loc from source_tab2
  5  /

4 rows created.


-- results:
SCOTT@orcl_11gR2> column deptno format 9999
SCOTT@orcl_11gR2> select * from target
  2  /

DEPTNO DNAME           LOC
------ --------------- ---------------
    10 ACCOUNTING      NEW YORK
    20 RESEARCH        DALLAS
    30 SALES           CHICAGO
    40 OPERATIONS      BOSTON

4 rows selected.

[Updated on: Mon, 26 December 2011 19:01]

Report message to a moderator

Help in Query [message #537254 is a reply to message #537022] Tue, 27 December 2011 07:01 Go to previous messageGo to next message
aallan
Messages: 150
Registered: October 2011
Senior Member
Dears;

I read columns names from table as:

Select Column_Id, Column_Name
  From All_Tab_Columns
 Where Table_Name = 'IMPORT_STC_DAILY_REPORTS_DTL'
   And Column_Id  > 2;


I have another table i insert the column name in it by using SQLLDR (Import_Stc_Daily_Reports_Dtl_Tbl)..

What I need ?

if columns position in (Import_Stc_Daily_Reports_Dtl_Tbl) that i imported them, are different

If the order of the columns in (Import_Stc_Daily_Reports_Dtl_Tbl) that i imported them are different from the order of columns in All_Tab_Columns >>> I need it to raise for example ??

Any Idea ?


Re: Help in Query [message #537258 is a reply to message #537254] Tue, 27 December 2011 07:05 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Generate a control file that is in the order of your data file and not of all_tab_columns order.

Regards
Michel
Re: Help in Query [message #537261 is a reply to message #537258] Tue, 27 December 2011 07:26 Go to previous messageGo to next message
aallan
Messages: 150
Registered: October 2011
Senior Member
thanks Barbara Boehmer;
i tried to do your solution but its gave an error of regexp_count invalid identifier
Re: Help in Query [message #537263 is a reply to message #537261] Tue, 27 December 2011 07:33 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
That would be because you didn't specify database you use. Barbara's example is created on 11g (which supports REGEXP_COUNT).
Re: Help in Query [message #537265 is a reply to message #537263] Tue, 27 December 2011 07:41 Go to previous messageGo to next message
aallan
Messages: 150
Registered: October 2011
Senior Member
thanks littlefoot
so i cant use it in 10 g or there is another word ?
Re: Help in Query [message #537268 is a reply to message #537265] Tue, 27 December 2011 07:52 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Yes; something like this:
SQL> with test as
  2    (select 'abc,123,xyz' col from dual)
  3  select length(col) - length(replace(col, ',', ''))  + 1 v_count
  4  from test;

   V_COUNT
----------
         3


P.S. Barbara's code, rewritten:
select length(col1) - length(replace(col1, p_delim, '')) + 1
into v_count
from staging where rownum = 1;

[Updated on: Tue, 27 December 2011 07:56]

Report message to a moderator

Re: Help in Query [message #537275 is a reply to message #537268] Tue, 27 December 2011 08:21 Go to previous messageGo to next message
aallan
Messages: 150
Registered: October 2011
Senior Member
thx Littlefoot
but when i tried to execute the procedute, its gave me

ORA-01031: insufficient privileges
ORA-06512: at "SALE.CREATE_SOURCE_TAB", line 36
ORA-06512: at line 11


on this Execute Immediate V_Sql;
Re: Help in Query [message #537277 is a reply to message #537275] Tue, 27 December 2011 08:24 Go to previous messageGo to next message
aallan
Messages: 150
Registered: October 2011
Senior Member
i solved it

Grant Create Table To Sale;
Re: Help in Query [message #537278 is a reply to message #537275] Tue, 27 December 2011 08:24 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Unless I'm wrong, it is supposed to execute CREATE TABLE statement. Do you have that privilege?

P.S. Forgot to mention: even if you do, was it granted to you via role or directly to your user? Because, privileges acquired via roles won't work in PL/SQL - you'll need to be granted directly.

[Updated on: Tue, 27 December 2011 08:25]

Report message to a moderator

Re: Help in Query [message #537301 is a reply to message #537278] Tue, 27 December 2011 11:38 Go to previous messageGo to next message
aallan
Messages: 150
Registered: October 2011
Senior Member
Thanks littlefoot;
i execute the procedure from toad and it works well, but i tried to execute it from form doesn't work !!

Create_Source_Tab(:Blk_1.File_Name, ';', 'Import_Stc_Daily_Reports_Tbl');
Re: Help in Query [message #537302 is a reply to message #537301] Tue, 27 December 2011 11:46 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9088
Registered: November 2002
Location: California, USA
Senior Member
Can you be more specific than doesn't work? Do you get an error message? Or does it run without error, but doesn't create the table? Or what? What version of forms are you using?
Re: Query Issue and Help in Query merged [message #537303 is a reply to message #537022] Tue, 27 December 2011 12:01 Go to previous messageGo to next message
aallan
Messages: 150
Registered: October 2011
Senior Member
first, i wanna tell u that your a genius man, its very great idea.
no errors and the table doesn't create...
and when i put messages to trace the code it came into 1 and didnt show message # 2

  message(1);pause;
  Create_Source_Tab(:Blk_1.File_Name, ';', 'Import_Stc_Daily_Reports_Tbl');
  message(2);pause;


Please help

[Updated on: Tue, 27 December 2011 12:05]

Report message to a moderator

Re: Query Issue and Help in Query merged [message #537304 is a reply to message #537303] Tue, 27 December 2011 12:06 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9088
Registered: November 2002
Location: California, USA
Senior Member
It sounds like the remaining portion of the problem is more of a Forms problem than anything else. Forms is not my area of expertise. I will move this thread to the Forms sub-forum where, hopefully, people who are more familiar with Forms can suggest how to debug it. I am sure they will want to know your Forms version.

Re: Query Issue and Help in Query merged [message #537305 is a reply to message #537303] Tue, 27 December 2011 12:08 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Did you connect to Forms as the same user as the one you tested the procedure from TOAD?
Did you, by any chance, include WHEN OTHERS exception handler anywhere in your form or a procedure?
Re: Query Issue and Help in Query merged [message #537306 is a reply to message #537304] Tue, 27 December 2011 12:08 Go to previous messageGo to next message
aallan
Messages: 150
Registered: October 2011
Senior Member
thanks again,
im using Forms [32 Bit] Version 10.1.2.0.2 (Production)
Re: Query Issue and Help in Query merged [message #537307 is a reply to message #537306] Tue, 27 December 2011 12:11 Go to previous messageGo to next message
aallan
Messages: 150
Registered: October 2011
Senior Member
ya same user...
No exception..
please help..
Re: Query Issue and Help in Query merged [message #537308 is a reply to message #537307] Tue, 27 December 2011 12:17 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
So, you created a stored procedure. It works fine from TOAD.
Then you run Forms, connect as the same user as previously. You create a form and ... what then? How do you call that procedure? From a trigger? Which one? Could you post the whole trigger code?
Re: Query Issue and Help in Query merged [message #537309 is a reply to message #537022] Tue, 27 December 2011 12:22 Go to previous messageGo to next message
aallan
Messages: 150
Registered: October 2011
Senior Member
Thanks again,

I Create a program Unit as:

Procedure Pu_Uploade_Data_File_Prc Is
    
	LC$Fichier            Varchar2(128) ;
	vb_client_to_as       Boolean;
	vn_msg                Number;
	vn_counter            Number := 1;
Begin

  LC$Fichier := PKG_FICHIERS.Selection ;
  If LC$Fichier is not null Then
    :Blk_1.File_Name := LC$Fichier;
  End if;
  
  message(1);pause;
  Create_Source_Tab(:Blk_1.File_Name, ';', 'Import_Stc_Daily_Reports_Tbl');
  message(2);pause;
End;



i create a push button and when-button-pressed i wrote:

Pu_Uploade_Data_File_Prc;


Regards.
Re: Query Issue and Help in Query merged [message #537311 is a reply to message #537309] Tue, 27 December 2011 12:26 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Seems to be OK (at least, to me).

Do you see MESSAGES while executing that code?

Another idea: create a simple table:
create table orafaq (datum date);
and put
insert into orafaq (datum) values (sysdate);
at the very beginning of a stored procedure. Run the form. Don't forget to COMMIT.

Then go to SQL*Plus and
select * from orafaq;
Anything in there?

Actually - did you COMMIT in the form at all?!?
Re: Query Issue and Help in Query merged [message #537312 is a reply to message #537311] Tue, 27 December 2011 12:31 Go to previous messageGo to next message
aallan
Messages: 150
Registered: October 2011
Senior Member
/forum/fa/9669/0/thanks again,
i did what you said and its work..look to the picture..
and i COMMIT in the form at all!!!
  • Attachment: 1.PNG
    (Size: 45.37KB, Downloaded 1165 times)

[Updated on: Tue, 27 December 2011 12:32]

Report message to a moderator

Re: Query Issue and Help in Query merged [message #537313 is a reply to message #537312] Tue, 27 December 2011 12:46 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9088
Registered: November 2002
Location: California, USA
Senior Member
Try adding another such insert statement at the end of the procedure. If both rows are inserted, then you will know it is getting all the way through the procedure. If not, then add some more insert statements inbetween, so that you can narrow down at what point it fails.

My best guess is that there is some required privilege that is not granted explicitly, rather than through a role.
Re: Query Issue and Help in Query merged [message #537316 is a reply to message #537313] Tue, 27 December 2011 12:59 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I hope not; we discussed privileges via roles earlier today.
Re: Query Issue and Help in Query merged [message #537319 is a reply to message #537313] Tue, 27 December 2011 13:02 Go to previous messageGo to next message
aallan
Messages: 150
Registered: October 2011
Senior Member
I added a lot of insert statement as:

CREATE OR REPLACE Procedure SALE.Create_Source_Tab (P_Filename  In Varchar2,
                                                    P_Delim     In Varchar2,
                                                    P_Tablename In Varchar2)
    As
      V_Sql    Varchar2 (32767);
      V_Count    Number;
    Begin
    insert into orafaq (datum) values (1);
      Execute Immediate 'alter table staging location (''' || P_Filename || ''')';
      insert into orafaq (datum) values (2);
     Select 'create table ' || P_Tablename || '(rn,'
             || Replace (Col1, P_Delim, ',')
             || ') as select * from (select rownum rn'
     Into   V_Sql
     From   Staging
     Where  Rownum = 1;
     insert into orafaq (datum) values (3);
     Select Length(Col1) - Length(Replace(Col1, P_Delim, '')) + 1
     Into   V_Count
     From   Staging 
    Where Rownum = 1;
    insert into orafaq (datum) values (4);
     For I In 1 .. V_Count     
     Loop
     insert into orafaq (datum) values (5);
        V_Sql := V_Sql ||
          ',substr
             (''' || P_Delim || ''' || col1 || ''' || P_Delim || ''',
              instr (''' || P_Delim || ''' || col1 || ''' || P_Delim || ''', '''
            || P_Delim || ''', 1, ' || I || ') + ' || Length (P_Delim) || ',
              instr (''' || P_Delim || ''' || col1 || ''' || P_Delim
            || ''', ''' || P_Delim || ''', 1, ' || To_Char (I + 1) || ')
              - instr (''' || P_Delim || ''' || col1 || ''' || P_Delim || ''', '''
            || P_Delim || ''', 1, ' || I || ')
              - ' || Length (P_Delim) || ')';
     End Loop;
     insert into orafaq (datum) values (6);
     V_Sql := V_Sql || ' from staging) where rn > 1';
     insert into orafaq (datum) values (7);
     Execute Immediate V_Sql;
     Execute Immediate 'Alter Table '||P_Tablename ||' Add '||'Import_Id'||' '|| 'Number';
     Execute Immediate 'Alter Table '||P_Tablename ||' Add '||'Import_Date'||' '|| 'Date';
     
   End Create_Source_Tab;
/


just value 1 inserted!!

Privileges like what ?
Re: Query Issue and Help in Query merged [message #537322 is a reply to message #537319] Tue, 27 December 2011 13:05 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9088
Registered: November 2002
Location: California, USA
Senior Member
Privileges like CREATE TABLE and ALTER TABLE. These privileges must be granted directly, not through a role. After running the procedure, try:

select * from staging;

If you do not get any rows, then it is likely the ALTER TABLE privilege.
Re: Query Issue and Help in Query merged [message #537325 is a reply to message #537322] Tue, 27 December 2011 13:12 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9088
Registered: November 2002
Location: California, USA
Senior Member
Another possiblity is READ privileges on the Oracle directory object.
Re: Query Issue and Help in Query merged [message #537329 is a reply to message #537322] Tue, 27 December 2011 13:18 Go to previous messageGo to next message
aallan
Messages: 150
Registered: October 2011
Senior Member
Thank,

i gave the user these privileges:

Grant Create Session To Sale;

Grant Create Table To Sale;

grant execute on Sale.Create_Source_Tab to Sale;


and in the procedute i added:

Execute Immediate 'Grant Alter On' ||P_Tablename || 'To Sale';


Still not working... Plzzz help
Re: Query Issue and Help in Query merged [message #537330 is a reply to message #537329] Tue, 27 December 2011 13:22 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Well, no - you don't grant privileges to yourself.

Connected as SALE to SQL*Plus, does this work (for me, it does - ALTER TABLE finished successfully):
SQL> create table orafaq (col number(1));

Table created.

SQL> alter table orafaq modify col number(2);

Table altered.

SQL>


[EDIT] Uh, oh ... now I'm being stupid. Owner has full control over his objects, so CREATE TABLE covers ALTER TABLE as well, no additional privilege is required.

It means that READ on a directory is all that remains, eh?

[Updated on: Tue, 27 December 2011 13:26]

Report message to a moderator

Re: Query Issue and Help in Query merged [message #537331 is a reply to message #537330] Tue, 27 December 2011 13:27 Go to previous messageGo to next message
aallan
Messages: 150
Registered: October 2011
Senior Member
dear littlefoot;

/forum/fa/9671/0/

  • Attachment: 1.PNG
    (Size: 13.34KB, Downloaded 1115 times)

[Updated on: Tue, 27 December 2011 13:28]

Report message to a moderator

Re: Query Issue and Help in Query merged [message #537332 is a reply to message #537331] Tue, 27 December 2011 13:30 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9088
Registered: November 2002
Location: California, USA
Senior Member
GRANT READ ON DIRECTORY your_Oracle_dir_object TO sale;

Re: Query Issue and Help in Query merged [message #537333 is a reply to message #537332] Tue, 27 December 2011 13:34 Go to previous messageGo to next message
aallan
Messages: 150
Registered: October 2011
Senior Member
i did it but does't work Sad
Re: Query Issue and Help in Query merged [message #537334 is a reply to message #537332] Tue, 27 December 2011 13:35 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9088
Registered: November 2002
Location: California, USA
Senior Member
What is the value of PKG_FICHIERS.Selection that is being passed to p_filename? It should be just a file name, not a path. Does it have an extension? Perhaps it is case sensitive on your system. Is it upper or lower or mixed case? Does it match what is on your operating system? Is it the same file, with the same delimiter, that you used in your previous test from Toad?
Re: Query Issue and Help in Query merged [message #537335 is a reply to message #537333] Tue, 27 December 2011 13:36 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9088
Registered: November 2002
Location: California, USA
Senior Member
When you say it doesn't work, what doesn't work? Does the grant not work? Or does the grant work, but the procedure still doesn't work?
Re: Query Issue and Help in Query merged [message #537336 is a reply to message #537334] Tue, 27 December 2011 13:45 Go to previous messageGo to next message
aallan
Messages: 150
Registered: October 2011
Senior Member
Barbara Boehmer wrote on Tue, 27 December 2011 13:35
What is the value of PKG_FICHIERS.Selection that is being passed to p_filename? It should be just a file name, not a path. Does it have an extension? Perhaps it is case sensitive on your system. Is it upper or lower or mixed case? Does it match what is on your operating system? Is it the same file, with the same delimiter, that you used in your previous test from Toad?


That's right...
when i changed:

Sale.Create_Source_Tab(Substr(:Blk_1.File_Name, 4), ';', 'Import_Stc_Daily_Reports_Tbl');


because the file name value was passed like:
C:\Stc_File.Scv 

I cut and pass just a file name>>>>> wok well....

Thank you littlefoot...
Thank you Genius man Barbara Boehmer...

so, if i want to repeate the process, i mean if i want to upload file for second tile i should drop the table ?

[Updated on: Tue, 27 December 2011 13:47]

Report message to a moderator

Re: Query Issue and Help in Query merged [message #537337 is a reply to message #537336] Tue, 27 December 2011 13:51 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9088
Registered: November 2002
Location: California, USA
Senior Member
If you are creating the Import_Stc_Daily_Reports_Tbl, then using that table to insert selected rows into another table, then yes, you would need to drop that table before running the procedure again with the same table name. Or, you could use another table name.
Re: Query Issue and Help in Query merged [message #537338 is a reply to message #537337] Tue, 27 December 2011 13:58 Go to previous messageGo to previous message
aallan
Messages: 150
Registered: October 2011
Senior Member
Thanks brother...
really thank you.
Previous Topic: Distribution of data on table
Next Topic: how to get hours minute and secod from a date datatype field
Goto Forum:
  


Current Time: Wed Apr 17 23:49:58 CDT 2024