Problem with passing filename for extract proc

24 views
Skip to first unread message

Sharon Zzz

unread,
Aug 20, 2015, 2:25:26 PM8/20/15
to iq...@googlegroups.com
Hi,

I have an issue with the passing the filename to the proc that extract data.  Here is my proc
*****************************************************************************************************************

alter proc extractFOData 
(@startdate integer,
@endDate integer,
@archiveFileName varchar(255))

begin
select getDate();

set temporary option TEMP_EXTRACT_NULL_AS_EMPTY='ON';
set temporary option TEMP_EXTRACT_COLUMN_DELIMITER=':|:';
set temporary option TEMP_EXTRACT_NAME1=@archiveFileName;


select * from FOrder2012 where tradedateid between @startdate and @enddate;




select getDate();

end

******************************************************************************

However, if I pass '/dump/abc'  I cannot find the output file under /dump

If I hard code in the proc with the file name '/dump/abc',  I will see the file out without any problem.
I wonder if anyone knows how to fix the issue.  Maybe some escape character needed?  I tried some escape character, but still failed.  

Thanks.

Sharon

cjd

unread,
Sep 22, 2015, 4:01:38 AM9/22/15
to iqgoogle

temp_extract_directory

regards
cjd

--
You received this message because you are subscribed to the Google Groups "iqug" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iqug+uns...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark Mumy

unread,
Sep 22, 2015, 5:40:32 AM9/22/15
to iq...@googlegroups.com
I would add, too, that most options cannot include an variable as it is written.  Typically, we would use a string to store the entire command then execute the string/command.

set @str = ‘set temporary option TEMP_EXTRACT_NAME1=‘ || @archiveFileName || ‘;’   ;
execute @str;

Mark

cjd

unread,
Sep 24, 2015, 5:14:25 AM9/24/15
to iqgoogle

You might need to add char (39) at both side of  @archiveFileName.

set @str = ‘set temporary option TEMP_EXTRACT_NAME1=‘ ||char (39)|| @archiveFileName || char(39)||‘;’   ;

regards
cjd

Mark Mumy

unread,
Sep 24, 2015, 7:42:30 AM9/24/15
to iq...@googlegroups.com
Correct. I forgot that little, yet very important, piece!  Good catch. 

Mark
 
========================

Sent from my mobile device

Sharon Zzz

unread,
Sep 24, 2015, 12:57:15 PM9/24/15
to iq...@googlegroups.com
I have tried, however, I got the following error: (using interactive SQL)

Could not execute statement.
Syntax error near '@str' on line 9
SQLCODE=-131, ODBC 3 State="42000"
Line 1, column 1

create procedure extractFCOData (
  @tid integer, @endDate integer, @fname varchar(252))
begin
  declare @str varchar(254);
  select getDate();
  set temporary option TEMP_EXTRACT_NULL_AS_EMPTY = 'ON';
  set temporary option TEMP_EXTRACT_COLUMN_DELIMITER = ':|:';
  set @str = 'set temporary option TEMP_EXTRACT_NAME1=' ||char (39)|| @fname || char(39)||';'   ;
  execute @str;
  select * from FcombinedOrder where tradedateid=@tid;
  select getDate()
end

Mark Mumy

unread,
Sep 24, 2015, 12:59:06 PM9/24/15
to iq...@googlegroups.com
I was going from memory. It may be execute immediate. 


Mark
 
========================

Sent from my mobile device

Sharon Zzz

unread,
Sep 24, 2015, 1:34:21 PM9/24/15
to iq...@googlegroups.com
Hi Mark,

Thanks, yes, execute immediate works.  And finally the passing of the fileName worked!!!

Thanks again
Reply all
Reply to author
Forward
0 new messages