Can I create a file using pl/sql code in application server ?

Hi
I wanted to create a file(any kind of file .txt .csv .exe etc..) using pl/sql code in application server?
Please help me with an example...in this regard
Regards
Sa

864334 wrote:
I wanted to create a file(any kind of file .txt .csv .exe etc..) using pl/sql code in application server?And how is this "file" to be delivered?
Files can be created by PL/SQL code and stored in the Oracle database as CLOBs. This a fairly easy and robust process. It runs entirely in the database. It conforms to transaction processing. The "file" (as a CLOB) resides in the database and can thus be secured via database security, is part of database backups and so on.
The basic issue is how to deliver the contents of the CLOB to the user. If via FTP, then the database can directly FTP the contents of the CLOB to the FTP server as a file. If via HTTP, the database can deliver the CLOB as a HTTP download directly to the web browser.
If the client is Java or .Net, then the CLOB contents can be delivered via SQL or DBMS_LOB or a custom PL/SQL interface.
In such cases, there is no need to step outside the secure and flexible database environment and create a physical o/s file in the wild (outside the controls of database security, data integrity and transaction processing). This is thus recommended and is the preference.

Similar Messages

  • Can't create a file using fm 'File_Get_Name'

    hi gurus,
    Can you please help me with this issue. There's a program that have to create a file using the said fm. It was working before when it was set in OS NT. But when the settings and codes have been changed to UNIX, the program was able to generate the program. But the file doesn't exist. It seems it  doesn't create a file in that server.
    What else do I need to check?
    Points will be rewarded. Thanks
    Here's the code for your reference:
    CALL FUNCTION 'FILE_GET_NAME'
           EXPORTING
    *         CLIENT                  = SY-MANDT
                logical_filename        = 'Z_SYSBRIDGE' 
             OPERATING_SYSTEM        = SY-OPSYS
    *         PARAMETER_1             = ' '
    *         PARAMETER_2             = ' '
    *         USE_PRESENTATION_SERVER = ' '
    *         WITH_FILE_EXTENSION     = ' '
    *         USE_BUFFER              = ' '
           IMPORTING
    *         emergency_flag          =
    *         file_format             =
                file_name               = ltfile-out_path
           EXCEPTIONS
                file_not_found          = 1
                OTHERS                  = 2.

    Hi Maui,
    Did you check SM69, where the code that ties to this FM creates a file after it execute your FM...
    SM69 are os commands that does UNIX execution or other OS commands...
    or maybe you have missed another FM like FM 'SXPG_OS_COMMAND' or of some sort.
    Thanks
    William Wilstroth

  • How can i create  Jar file using Eclipse IDE.

    Hi Guys
    Am new to java. I want convert my project into executable jar file.
    In my project am using itext.jar.And some other folder.
    already i create jar file.But its not working.only its working 4 modules after that its say file cannot found exception.but the file path is correct.i dont know why its happen.
    This is my project folder strutre also
    Log:->
    src(folder)
    logs(folder)
    comments(folder)
    lib-->itext.jar.
    images-->1,gif
    properties-->catconfig.properties (file)
    now can i create jar file
    this code also show error when i run the jar file
    And this is my catconfig. properties file
    fileName=total_system_log.log
    DDSingle=DD_bysingleIP_comment.txt
    DDRange=DD_byrange_comment.txt
    NDPing=ping_comments.txt
    NDFPing=fping_comments.txt
    reportFileName=report.txt
    moduleFileName=Modules.txt
    propFileName=nameDetails.properties
    Choice=DDSingle
    logFileName=DDSingleIP_10.32.0.2.log
    finalReport=FinalReport.txt
    logFilePath=\logs\
    commentFilePath=\\Comments\\
    its very urgent for me . could u pls send my error  and u r ideas.
    thanks for u r Ansewering.
    import java.io.BufferedReader;
    import java.io.DataOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.InputStream;
    import java.io.RandomAccessFile;
    import java.util.Properties;
    import java.util.ResourceBundle;
    import java.util.ArrayList;
    public class LogReader {  
        public void getValuesFromFilesOnly(String Choice,String logFileName)
              try {
                   ArrayList commentsList = new ArrayList();
                   ArrayList tempList = new ArrayList();
                   String userdir = System.getProperty("user.dir");
                   String logFilePath=ResourceBundle.getBundle("catconfig").getString("logFilePath");
                   String commentDir =ResourceBundle.getBundle("catconfig").getString(Choice);
                   String commentFilePath=ResourceBundle.getBundle("catconfig").getString("commentFilePath");
                   String currentdir1 =userdir+logFilePath+logFileName;
                   StringBuffer strBuff=new StringBuffer();
                   RandomAccessFile randomFile = null;
                   RandomAccessFile commentsFile = null;
                   String tempLine = null;
                   String commentLine = null;
                   String catVersion = null;
                   String finalReport=null;
                   int colon = 0;                    
                   int counter = 0;
                   boolean startFlag = false;
                   boolean endFlag = false;                    
                   boolean endOfFileFlag = false;          
                   System.out.println("Log file checked----->"+currentdir1);
                   System.out.println("comments file used--->"+commentDir);
                   try {
                        randomFile = new RandomAccessFile(currentdir1, "r");
                   } catch (Exception e) {
                        System.out.println("exception@getValuesFromFilesOnly@begin : "+e);
                   System.out.println("hi test1");
                   String commentDir1=userdir+commentFilePath+commentDir;
                   try{
                   System.out.println("Comment Dir:"+commentDir1);
                   commentsFile = new RandomAccessFile(commentDir1, "r");
                   catch (Exception e) {
                        System.out.println("exception@getValuesFromCommentDirOnly@begin : "+e);
                   while ((commentLine = commentsFile.readLine()) != null) {                         
                        String checkLine = commentLine.substring(commentLine.indexOf("=")+1, commentLine.length());
                        String message = commentLine.substring(0,commentLine.indexOf("="));
                        commentsList.add(checkLine);
                   commentsFile.close();
                   String startComment = (String)commentsList.get(0);
                   String endComment = (String)commentsList.get(commentsList.size()-1);
                   strBuff.append("                          CAT LOG REPORT                           \n\n");
                   while ((tempLine = randomFile.readLine()) != null) {               
                        if(tempLine.contains("CAT version is :"))
                             colon = tempLine.indexOf("is :");
                             catVersion = tempLine.substring(colon+4,tempLine.length());
                             String version=tempLine;
                             strBuff.append("Version : "+catVersion+"\n");
                             System.out.println("catVersion is :"+catVersion);
                        commentsFile = new RandomAccessFile(commentDir1, "r");
                        while ((commentLine = commentsFile.readLine()) != null) {
                             String checkLine = commentLine.substring(commentLine.indexOf("=")+1, commentLine.length());
                             String message = commentLine.substring(0,commentLine.indexOf("="));
                             checkLine=checkLine.toLowerCase();
                             tempLine=tempLine.toLowerCase();
                             if(tempLine.contains(checkLine))
                                  colon = tempLine.indexOf("info -");
                                  catVersion = tempLine.substring(colon+7,tempLine.length());
                                  strBuff.append(message+" ==> "+catVersion+"\n");
                                  System.out.println(message+" ==> "+catVersion);
                                  tempList.add(message+" ==> "+catVersion);
                                  if (catVersion.contains(startComment)){
                                       startFlag = true;
                                       counter++;
                                       System.out.println("*******startFlag**********"+startFlag);
                                  if (catVersion.contains(endComment)){
                                       endFlag = true;
                                       System.out.println("*******endFlag**********"+endFlag);
                                  if (startFlag == true && endFlag == true){
                                       System.out.println("******************************************");
                                       System.out.println("-------------Successfull completion-------");
                                       System.out.println("******************************************");
                                       startFlag = false;
                                       endFlag = false;
                                       counter = 0;
                                       tempList.clear();
                                  if (startFlag == true && endFlag == false && counter > 1){
                                       System.out.println("******************************************");
                                       System.out.println("---------------Failure after-----:"+tempList.get(tempList.size()-1));
                                       System.out.println("******************************************");
                                       //startFlag = false;
                                       //endFlag = false;
                                       counter = 0;
                                       tempList.clear();
                        commentsFile.close();
                   endOfFileFlag = true;
                   if (startFlag == true && endFlag == false && endOfFileFlag == true){
                        System.out.println("******************************************");
                        System.out.println("---------------Failure after-----:"+tempList.get(tempList.size()-1));
                        System.out.println("******************************************");
                        startFlag = false;
                        endFlag = false;
                        counter = 0;
                        tempList.clear();
                   randomFile.close();
                 System.out.println("hi");
                   finalReport=ResourceBundle.getBundle("catconfig").getString("finalReport");
                   savereportFile(strBuff,finalReport);
                   System.out.println("Report Generated");
              } catch (Exception e){
                   System.out.println("Exception@getValuesFromFilesOnly : "+e);
        public void findDetails()
             String currentdir1 = ResourceBundle.getBundle("catconfig").getString("fileName");     
             String logFilePath=ResourceBundle.getBundle("catconfig").getString("logFilePath");
             String userdir = System.getProperty("user.dir");
             RandomAccessFile randomFile = null;
             StringBuffer strBuff=new StringBuffer();
             StringBuffer strBuff1=new StringBuffer();
             StringBuffer strBuff2=new StringBuffer();
             String tempLine = null;     
              String catVersion = null;
              String timeStr=null;
              String nameStr=null;
              String startIP="";
              String endIP="";
              String tempStart="";
              String tempEnd="";
              String reportFileName="";
              String moduleFileName="";
              String propFileName="";
              int startPos=0;
              int endPos=0;
              int fromIndex=0;
              boolean versionFlag=false;
              boolean ndFlag=false;
              boolean ddFlag=false;
              try {
                   randomFile = new RandomAccessFile(userdir+logFilePath+currentdir1, "r");
                   while ((tempLine = randomFile.readLine()) != null) {
                        if(tempLine.contains("CAT version is :") && !versionFlag)
                             startPos = tempLine.indexOf("is :");
                             catVersion = tempLine.substring(startPos+4,tempLine.length());
                             String version=tempLine;
                             strBuff.append("version : "+version+"\n");
                             versionFlag=true;
                             //System.out.println("version : "+version);
                        if(tempLine.contains("Inside NetworkDiscoverySlider.jsp"))
                             ndFlag=true;
                             strBuff.append("ND start : "+tempLine+"\n");                         
                        if(tempLine.contains("Inside NetworkDiscoveryDetails.jsp"))
                             strBuff.append("ND end : "+tempLine+"\n");
                             //System.out.println(" ND end : "+tempLine);
                        if(tempLine.contains("Given IPRange from"))
                             startPos = tempLine.indexOf("from");
                             catVersion = tempLine.substring(startPos+5,tempLine.length());
                             strBuff.append("NDRange : "+catVersion+"\n");     
                             //strBuff.append("NDRange : "+tempLine+"\n");                                             
                             //System.out.println("NDRange :"+catVersion);     
                             startPos=0;
                             fromIndex=tempLine.indexOf(":");
                             endPos= tempLine.indexOf(':', fromIndex+2);
                             //System.out.println("fromIndex : "+fromIndex+" endPos : "+endPos);
                             timeStr=tempLine.substring(startPos, endPos);
                             nameStr=catVersion.replaceAll(" ", "_");                         
                             strBuff2.append("ND_"+timeStr+" "+catVersion+" = "+"NDRange_"+nameStr+".log\n");
                        if(tempLine.contains("inside ByIpAddress.jsp"))
                             ddFlag=true;
                             strBuff.append("DD Start : "+tempLine+"\n");                                                  
                        if(tempLine.contains("start_IpAddress:"))
                             startPos = tempLine.indexOf("start_IpAddress:");
                             catVersion = tempLine.substring(startPos+16,tempLine.length());
                             startIP=catVersion;                         
                        if(tempLine.contains("end_IpAddress"))
                             startPos = tempLine.indexOf("end_IpAddress");
                             catVersion = tempLine.substring(startPos+13,tempLine.length());
                             endIP=catVersion;                         
                             if(endIP.length()==0)
                                  System.out.println("hi5");
                                  strBuff.append("DDSingleIP : "+startIP+"\n");
                                  //strBuff.append("DDSingleIP : "+tempLine+"\n");                              
                                  //System.out.println("DDSingleIP : "+startIP);
                                  //startPos = tempLine.indexOf(" ");
                                  startPos=0;
                                  fromIndex=tempLine.indexOf(":");
                                  endPos= tempLine.indexOf(':', fromIndex+2);
                                  timeStr=tempLine.substring(startPos, endPos);     
                                  strBuff2.append("DD_"+timeStr+" "+startIP+" = "+"DDSingleIP_"+startIP+".log\n");
                             else
                                  strBuff.append("DDRangeIP : "+startIP + " to "+ endIP+"\n");
                                  //strBuff.append("DDRangeIP : "+tempLine+"\n");                              
                                  //System.out.println("DDRangeIP : "+startIP + " to "+ endIP);
                                  //startPos = tempLine.indexOf(" ");
                                  startPos=0;
                                  fromIndex=tempLine.indexOf(":");
                                  endPos= tempLine.indexOf(':', fromIndex+2);
                                  timeStr=tempLine.substring(startPos, endPos);                         
                                  strBuff2.append("DD_"+timeStr+" "+startIP+" to "+endIP+" = "+"DDRangeIP_"+startIP +"_to_"+ endIP+".log\n");
                        if(tempLine.contains("set percentage completedCount: 100"))
                             System.out.println("hi...1");
                             strBuff.append("DD End : "+tempLine+"\n");
                             //System.out.println("DD End : "+tempLine);          
                   reportFileName=ResourceBundle.getBundle("catconfig").getString("reportFileName");
                   savereportFile(strBuff,reportFileName);
                   if(ndFlag)
                        strBuff1.append("Network Discovery\n");                    
                   if(ddFlag)
                        strBuff1.append("Device Discovery\n");
                   moduleFileName=ResourceBundle.getBundle("catconfig").getString("moduleFileName");
                   savereportFile(strBuff1,moduleFileName);
                   propFileName=ResourceBundle.getBundle("catconfig").getString("propFileName");
                   savereportFile(strBuff2,propFileName);
              } catch (Exception e)
                   System.out.println("error hi1");
                   System.out.println("Exception@findDetails : "+e);
        public void savereportFile(StringBuffer strBuff,String targetFileName)
              try{
                   String userdir = System.getProperty("user.dir");
                   String logFilePath=ResourceBundle.getBundle("catconfig").getString("logFilePath");
                   String reportFile=userdir+logFilePath+targetFileName;     
                   String fileContent="";
                   fileContent=strBuff.toString();
                      //System.out.println("file content : "+fileContent);
                      FileWriter fileWriter = new FileWriter(reportFile);
                      if(fileContent!=null)
                           fileWriter.write(fileContent);
                      fileWriter.close();
              catch(Exception e)
                   System.out.println("error hi1");
                   System.out.println("Exception@savereportFile : "+e);
        public ArrayList<String> getFileNames()
             String reportFile=ResourceBundle.getBundle("catconfig").getString("reportFileName");
             String logFilePath=ResourceBundle.getBundle("catconfig").getString("logFilePath");
             String userdir = System.getProperty("user.dir");
              RandomAccessFile repFile=null;
              String reportLine = null;
              int colon=0;
              int fromIndex=0;     
              int startPos=0;
              int endPos=0;
              String timeStr="";
              String fileName=null;          
              ArrayList<String> nameList=new ArrayList<String>();          
             try
                  reportFile=userdir+logFilePath+reportFile;
                  repFile = new RandomAccessFile(reportFile, "r");
                  while ((reportLine = repFile.readLine()) != null) {                    
                        if(reportLine.contains("NDRange"))
                             colon=reportLine.indexOf(" : ");
                             fileName=reportLine.substring(colon+3, reportLine.length());
                             fileName="NDRange_"+fileName.replaceAll(" ", "_");
                             nameList.add(fileName);
                             System.out.println("fileName : "+fileName);
                        if(reportLine.contains("DDSingleIP"))
                             colon=reportLine.indexOf(" : ");
                             fileName=reportLine.substring(colon+3, reportLine.length());
                             fileName="DDSingleIP_"+fileName.replaceAll(" ", "_");
                             nameList.add(fileName);
                             System.out.println("fileName : "+fileName);
                        if(reportLine.contains("DDRangeIP"))
                             colon=reportLine.indexOf(" : ");
                             fileName=reportLine.substring(colon+3, reportLine.length());
                             fileName="DDRangeIP_"+fileName.replaceAll(" ", "_");
                             nameList.add(fileName);
                             System.out.println("fileName : "+fileName);
                  repFile.close();
             catch(Exception e)
                   System.out.println("Error@getFileNames : "+e);
             return nameList;
        public void writeFile(String oldLogName,String newLogName)
             try
                   FileOutputStream writeFile=null;               
                   String line = null;
                   String userdir = System.getProperty("user.dir");
                   String reportFile=ResourceBundle.getBundle("catconfig").getString("reportFileName");     
                   String newLogPath=ResourceBundle.getBundle("catconfig").getString("logFilePath");
                   RandomAccessFile repFile=null;               
                   String reportLine = null;
                   String tempLine=null;
                   String prevLine=null;
                   String nextLine=null;
                   String target=null;
                   String tempStr=null;
                   String startStr=null;
                   String endStr=null;          
                   int pos=0;
                   boolean flag=false;
                   boolean writeFlag=false;
                   boolean versionFlag=false;               
                   //System.out.println("newLogName : "+newLogName);     
                   newLogPath=userdir+newLogPath;
                   System.out.println("newLogPath : "+newLogPath);     
                   BufferedReader buffRead = new BufferedReader(new FileReader(oldLogName));
                   writeFile = new FileOutputStream(newLogPath+newLogName+".log", false);//true-for append mode
                   DataOutputStream dout=new DataOutputStream(writeFile);               
                   tempStr=newLogName.replace("_", " ");
                   pos=tempStr.indexOf(" ");
                   startStr=tempStr.substring(0,pos);
                   endStr=tempStr.substring(pos+1, tempStr.length());
                   target=startStr+" : "+endStr;
                   System.out.println("target ===> "+target);               
                   reportFile=newLogPath+reportFile;
                   repFile = new RandomAccessFile(reportFile, "r");
                  while ((reportLine = repFile.readLine()) != null) {                   
                       if(reportLine.contains(target))
                            flag=true; 
                            prevLine=tempLine;
                            //System.out.println("prevLine *****: "+prevLine);
                       else
                            tempLine=reportLine;
                            if(flag==true)
                                 nextLine=reportLine;
                                 flag=false;
                                 //System.out.println("nextLine *******:"+nextLine);
                                 break;
                  repFile.close();     
                 if(prevLine!=null && prevLine.length()>0)
                       pos=prevLine.lastIndexOf(" : ");
                       prevLine=prevLine.substring(pos+3, prevLine.length());
                       //System.out.println("prevLine : "+prevLine);
                  else
                       System.out.println("Starting line not available for : "+target);
                  if(nextLine!=null && nextLine.length()>0)
                        pos=nextLine.lastIndexOf(" : ");
                        nextLine=nextLine.substring(pos+3, nextLine.length());
                        //System.out.println("nextLine : "+nextLine);
                  else
                       System.out.println("Ending line not available for : "+target);
                       nextLine=prevLine;
                   while ((line=buffRead.readLine()) != null) {     
                        if(line.contains("CAT version is :") && !versionFlag)
                             versionFlag=true;
                             dout.writeBytes(line+"\n");                         
                        if(line.contains(prevLine))
                             writeFlag=true;                         
                        if(line.contains(nextLine))
                             writeFlag=false;
                             break;
                        if(writeFlag)
                             dout.writeBytes(line+"\n");
                  dout.writeBytes(nextLine+"\n");
                   buffRead.close();     
                   System.out.println("done");
              catch(Exception e)
                   System.out.println("Exception@writeFile : "+e.getMessage());
        public String folderCheck(String foldName)
              File folder=null;
              File newFile=null;
              String[] folderContent=null;
              String tempFileName="";
              String newLogName="";
              int count=0;     
              String logFilePath="";     
              String fileName="";
              String feedBackMsg="";          
              String userdir = System.getProperty("user.dir");
              logFilePath=ResourceBundle.getBundle("catconfig").getString("logFilePath");
              fileName=ResourceBundle.getBundle("catconfig").getString("fileName");
              folder=new File(foldName);
              if(folder.isDirectory())
                   newLogName=userdir+logFilePath+fileName;
                   //System.out.println("newLogName : "+newLogName);
                   newFile=new File(newLogName);
                   if(newFile.exists())
                        newFile.delete();
                   folderContent= folder.list();
                   if (folderContent != null && folderContent.length>0)
                        System.out.println("folder has files : "+folderContent.length);                    
                        for(int iterate=0;iterate < folderContent.length;iterate++){                         
                             if (folderContent[iterate].toLowerCase().contains("system"))
                                  count++;                              
                                  tempFileName=foldName+"/"+folderContent[iterate];     
                                  try
                                       FileOutputStream appendedFile=null;
                                       BufferedReader buffRead = new BufferedReader(new FileReader(tempFileName));
                                       appendedFile = new FileOutputStream(newLogName, true);//true-for append mode
                                        DataOutputStream dout=new DataOutputStream(appendedFile);
                                        String line = null;
                                       System.out.println("writting : "+tempFileName);
                                       while ((line=buffRead.readLine()) != null) {                                        
                                            dout.writeBytes(line+"\n");
                                       buffRead.close();          
                                       //System.out.println("done");
                                  catch(Exception e)
                                       System.out.println("Exception@folderCheck : "+e);
                        if(count==0)
                             feedBackMsg="syslognotavail";
                             //System.out.println("System Log(s) not available");
                        else
                             feedBackMsg="syslogavail";
                             //System.out.println(count +" System log(s) avail");
                   else
                        feedBackMsg="filesnotavail";
                        //System.out.println("Files are not in the folder");
              else
                   feedBackMsg="Dirnotavil";
                   //System.out.println("Directory not exists in the given name");
              return feedBackMsg;
        public ArrayList<String> loadFileContent(String selectedStr)
             //System.out.println("inside loadFileContent()");
             String logFilePath="";
             String propFileName="";
             String line="";
             String choice="";
             String tempStr="";
             int startPos=0;
             int endPos=0;
             ArrayList<String> timeList=new ArrayList<String>();
             String userdir = System.getProperty("user.dir");
             try
                  logFilePath=ResourceBundle.getBundle("catconfig").getString("logFilePath");
                  propFileName=ResourceBundle.getBundle("catconfig").getString("propFileName");
                  propFileName=userdir+logFilePath+propFileName;
                  BufferedReader buffRead = new BufferedReader(new FileReader(propFileName));
                  if(selectedStr.equalsIgnoreCase("Device Discovery"))
                       choice="DD";
                  else if(selectedStr.equalsIgnoreCase("Network Discovery"))
                       choice="ND";
                  while ((line=buffRead.readLine()) != null) {                                        
                        if(line.contains(choice))
                             System.out.println(line);
                             startPos=line.indexOf("_");
                             endPos=line.indexOf(" =");
                             tempStr=line.substring(startPos+1, endPos);
                             System.out.println("tempStr : "+tempStr);
                             timeList.add(tempStr);
                   buffRead.close();          
             catch(Exception e)
                  System.out.println("Exception@loadFileContent : "+e);
             return timeList;
        public String getFileName(String timeStr)
             System.out.println("inside getFileName");
             String logFilePath="";
             String propFileName="";
             String line="";
             String tempStr="";
             int startPos=0;
             String userdir = System.getProperty("user.dir");
             try
                  logFilePath=ResourceBundle.getBundle("catconfig").getString("logFilePath");
                  propFileName=ResourceBundle.getBundle("catconfig").getString("propFileName");
                  propFileName=userdir+logFilePath+propFileName;              
                  BufferedReader buffRead = new BufferedReader(new FileReader(propFileName));              
                  while ((line=buffRead.readLine()) != null) {                                        
                        if(line.contains(timeStr))
                             System.out.println(line);
                             startPos=line.indexOf(" = ");                         
                             tempStr=line.substring(startPos+3, line.length());
                             System.out.println("tempStr : "+tempStr);                         
                   buffRead.close();          
             catch(Exception e)
                  System.out.println("Exception@loadFileContent : "+e);
             return tempStr;
        public ArrayList loadFile()
             String logFilePath="";
             String moduleFileName="";
             String line="";         
             ArrayList<String> moduleList=new ArrayList<String>();
             String userdir = System.getProperty("user.dir");
             try
                  logFilePath=ResourceBundle.getBundle("catconfig").getString("logFilePath");
                  moduleFileName=ResourceBundle.getBundle("catconfig").getString("moduleFileName");
                  moduleFileName=userdir+logFilePath+moduleFileName;
                  BufferedReader buffRead = new BufferedReader(new FileReader(moduleFileName));              
                  while ((line=buffRead.readLine()) != null) {     
                       moduleList.add(line);                    
                   buffRead.close();          
             catch(Exception e)
                  System.out.println("Exception@loadFile : "+e);
             return moduleList;
    public static void main(String[] args) {          
         System.out.println("Inside main");     
         //String userdir = System.getProperty("user.dir");
         //System.out.println("userdir : "+userdir);
         /*ArrayList<String> fileNameList=new ArrayList<String>();
         String Choice="";     
         String logFileName="";     
         String logFilePath="";     
         String totalLog="";     
         String newLog="";     
         String folderName="";
         Choice=ResourceBundle.getBundle("catconfig").getString("Choice");
         logFileName=ResourceBundle.getBundle("catconfig").getString("logFileName");     
         logFilePath=ResourceBundle.getBundle("catconfig").getString("logFilePath");
         folderName=ResourceBundle.getBundle("catconfig").getString("folderName");
         totalLog=ResourceBundle.getBundle("catconfig").getString("fileName");     */
         /*try
              //to write the total log
              //folderCheck(folderName);
              //to find the details in the given log
              //findDetails();
              //to split the logs accordingly
              totalLog=logFilePath+totalLog;          
              fileNameList=getFileNames();;
              System.out.println("FileNameList size = "+fileNameList.size());
              for(int i=0;i<fileNameList.size();i++)
                   newLog=fileNameList.get(i).toString();
                   writeFile(totalLog,newLog);
              //to analyse the logs & to produce reports          
              //getValuesFromFilesOnly(Choice,logFileName);          
         }catch (Exception e)
              System.out.println(e.getMessage());
    }[                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    JSP is used for server validation.
    So you need a an application server (like Tomcat or Jboss) to execute your jsp files.
    you can create the .war file of your simple jsp application and put it in the server.
    then you will have to access your page using a web browser.
    the URL will be
    http://<ComputerName or IP Address>:<PortNumber>/<WarFileName>/<MainJspPage>
    (eg: http://100.100.100.252:8080/SimpleApplication/mainPage.jsp)
    -Achyuth

  • Create PDF file using PL SQL

    Hello All:
    I have an requirement of generating a PDF file using Oracle PL SQL program. Can anyone please let me know the procedure/code of doing this?
    Thanks,
    k Ramesh Gupta

    I have steps to generate Excel sheet output, apply appropriate content-type for PDF in the PL/SQL written below, to get the same in PDF. i suppose it should be application/pdf
    1. Create a custom DAD if required using Enterprise Manager Console of MidTier for HTTP Server or use Portal DAD itself to implement the solution.
    2. Create a new procedure (a webdb solution) to stream the HTML for the excel sheet report which will be downloaded.
    a. Login to Portal schema through SQL*Plus or the respective DAD based schema if custom DAD is created. (below example is created in custom DAD - 'scott').
    SQL>CREATE OR REPLACE
    PROCEDURE generateCsv
    as
    cursor p_emp is select * from PORTAL_DEMO.EMP;
    begin
    owa_util.mime_header( 'application/vnd.ms-excel', False ); -- Here change the content-type to PDF Format accordingly
    htp.print('Content-Disposition: attachment;filename="pvasista.csv"');
    owa_Util.Http_Header_Close;
    for v_emp_cur in p_emp
    LOOP
    htp.p (v_emp_cur.ename || ',' || v_emp_cur.deptno || chr(13));
    END LOOP;
    end;
    SQL> grant execute on generateCsv to public;
    For education purpose getting the report of employee and deptno of al employees from PORTAL_DEMO.EMP table. Implement the necessary query/ Business Logic accordingly.
    b. Now access http://midtier_host:port/pls/dad_name/generateCsv, will download a .csv based excel file report as shown in the screenshot below,
    3. Open the Portal Page where the link is to be added, createa URL Item Link and add the above URL, select option "Open in new browser window"
    4. It can also be enhanced to have filtering enabled on the report by using Portal Form using Option, "Form based on stored procedure" and selecting the above stored procedure.

  • Can we create TDMS file using C# and retrieve the data using a diadem

    I want to write a tdms file from a dot net application and to use the diadem to retrieve the data and to create a user defined report

    Hello,
    If you want this kind of output, you can use Java Mapping e.g
    1. Create your data type like this:
    CHARSET 0..1
    LOADMODE 0..1
    CODEFORMAT 0..1
    CURRENCY 0..1
    SUPPLIERID_DOMAIN 0..1
    ITEMCOUNT 0..1
    TIMESTAMP 0..1
    UNUOM 0..1
    COMMENTS 0..1
    FIELDNAMES 0..1
    DATA 0..unbounded
    ENDOFDATA
    2.In your message mapping assign all the constants. You might want to concat all the values of the FIELDNAMES and output them to DATA
    3.In your Java Mapping, replace all the XML fields including ,, with ,''',
    4.In ID, do not use FCC.
    Hope this helps,
    Mark

  • Creating PDF file using PL/SQL

    I am writing a Web PL/SQL package. In this package I would like to create a pdf
    file with the data in a table and then display the file on the web. Is there a
    way to do this?
    Thanks
    Rohini Ananthakrishnan

    No we are using FOP in our applications, but I always refused to use it ;-)
    plpdf looks a lot simpler then FOP by the way (no usless XML code around...;-)
    Dim

  • Creating Files Using PL/SQL?

    Hi,
    Is there a way to create a file using PL/Sql? It seems that the
    utl_file package doesn't allow you to create a file. It only
    allows you to read, write to a file that already exists there.
    Thanks
    Vic

    Make sure the following is set in the init.ora:
    UTL_FILE_DIR = /path/to/your/file/directory (for unix)
    or
    UTL_FILE_DIR = <drive>:\path\to\your\file\directory (for windows)

  • Generating Excel file using PL/SQL

    Hi,
    I wanted to generate the excel file using the below pasted PL/SQL which I have downloaded from one of the tech sites. And as I have very limited knowledge about PL/SQL I really dont know how & where I should compile this below mentioned code and get the desired O/P?
    Please reply me ASAP if anybody can help me with this?
    Please see the below code and please help me to interpret the same.
    CREATE OR REPLACE PACKAGE gen_xl_xml IS
    -- Version 0.5
    -- Objective : The main objective OF this PACKAGE IS TO CREATE excel files from PL/SQL code
    -- Requirement : Excel version 2003 onwards support XML format.
    -- The procedures does have TO be called IN specific order at this moment.
    -- expected SEQUENCE AS OF now IS
    -- At first call create_file -> It creates a FILE WITH NAME that you pass AS parameter. This PROCEDURE writes the
    -- excel file header AND some basic requirments like default style.
    -- procedures 1. create_style , create_worksheet AND write_cell can be used IN ANY SEQUENCE AS many
    -- times AS you need.
    -- When done WITH writing TO FILE call the PROCEDURE close_file
    -- CLOSE FILE --> This will actually flush the data INTO the worksheet(s) one BY one and then close the file.
    -- What colors I can use ?
    -- red , blue , green, gray , YELLOW, BROWN , PINK . lightgray ,
    debug_flag BOOLEAN := TRUE ;
    PROCEDURE create_excel( p_directory IN VARCHAR2 DEFAULT NULL , p_file_name IN VARCHAR2 DEFAULT NULL ) ;
    PROCEDURE create_excel_apps ;
    PROCEDURE create_style( p_style_name IN VARCHAR2
    , p_fontname IN VARCHAR2 DEFAULT NULL
    , p_fontcolor IN VARCHAR2 DEFAULT 'Black'
    , p_fontsize IN NUMBER DEFAULT null
    , p_bold IN BOOLEAN DEFAULT FALSE
    , p_italic IN BOOLEAN DEFAULT FALSE
    , p_underline IN VARCHAR2 DEFAULT NULL
    , p_backcolor IN VARCHAR2 DEFAULT NULL );
    PROCEDURE close_file ;
    PROCEDURE create_worksheet( p_worksheet_name IN VARCHAR2 ) ;
    PROCEDURE write_cell_num(p_row NUMBER , p_column NUMBER, p_worksheet_name IN VARCHAR2, p_value IN NUMBER , p_style IN VARCHAR2 DEFAULT NULL );
    PROCEDURE write_cell_char(p_row NUMBER, p_column NUMBER, p_worksheet_name IN VARCHAR2, p_value IN VARCHAR2, p_style IN VARCHAR2 DEFAULT NULL );
    PROCEDURE write_cell_null(p_row NUMBER , p_column NUMBER , p_worksheet_name IN VARCHAR2, p_style IN VARCHAR2 );
    PROCEDURE set_row_height( p_row IN NUMBER , p_height IN NUMBER, p_worksheet IN VARCHAR2 ) ;
    PROCEDURE set_column_width( p_column IN NUMBER , p_width IN NUMBER , p_worksheet IN VARCHAR2 ) ;
    END ;
    -- Package : gen_xl_sml
    -- Version : 0.62
    CREATE OR REPLACE PACKAGE Body gen_xl_xml IS
    -- worksheets must be created before it could be passed AS parameter TO the write cell procedures
    l_file utl_FILE.file_type ;
    g_apps_env VARCHAR2(1) := 'U' ; -- unset at the start
    TYPE tbl_excel_data IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER ;
    g_excel_data tbl_excel_data ;
    g_null_data tbl_excel_data ;
    g_data_count NUMBER ;
    TYPE rec_styles IS record ( s VARCHAR2(30) , def VARCHAR2(2000) );
    TYPE tbl_style IS TABLE OF rec_styles INDEX BY BINARY_INTEGER ;
    g_styles tbl_style ;
    g_null_styles tbl_style ;
    g_style_count NUMBER := 0;
    TYPE rec_worksheets IS record ( w VARCHAR2(30) , whdr VARCHAR2(300), wftr VARCHAR2(2000) );
    TYPE tbl_worksheets IS TABLE OF rec_worksheets INDEX BY BINARY_INTEGER ;
    g_worksheets tbl_worksheets ;
    g_null_worksheets tbl_worksheets ;
    g_worksheets_count NUMBER := 0;
    TYPE rec_cell_data IS record ( r NUMBER , c NUMBER , v VARCHAR2(2000) ,s VARCHAR2(30) , w VARCHAR2(100), dt VARCHAR2(8) );
    TYPE tbl_cell_data IS TABLE OF rec_cell_data INDEX BY binary_INTEGER ;
    g_cells tbl_cell_data ;
    g_null_cells tbl_cell_data ;
    g_cell_count NUMBER := 0 ;
    TYPE rec_columns_data IS record( c NUMBER, wd NUMBER, w VARCHAR2(30) ) ;
    TYPE tbl_columns_data IS TABLE OF rec_columns_data Index BY BINARY_INTEGER ;
    g_columns tbl_columns_data ;
    g_null_columns tbl_columns_data ;
    g_column_count NUMBER ;
    TYPE rec_rows_data IS record( r NUMBER, ht NUMBER , w VARCHAR2(30) ) ;
    TYPE tbl_rows_data IS TABLE OF rec_rows_data Index BY BINARY_INTEGER ;
    g_rows tbl_ROWS_data ;
    g_null_rows tbl_rows_data ;
    g_ROW_count NUMBER ;
    PROCEDURE p ( p_string IN VARCHAR2) is
    begin
    IF debug_flag = TRUE THEN
    DBMS_OUTPUT.put_line( p_string) ;
    END IF;
    END ;
    FUNCTION style_defined ( p_style IN VARCHAR2 ) RETURN BOOLEAN IS
    BEGIN
    FOR i IN 1..g_style_count LOOP
    IF g_styles(i).s = p_style THEN
    RETURN TRUE ;
    END IF;
    END LOOP ;
    RETURN FALSE ;
    END ;
    -- Function : cell_used returns : BOOLEAN
    -- Description : Cell_used FUNCTION returns TRUE IF that cell IS already used
    -- Called BY : write_Cell_char, write_cell_num
    -- ??? right now it IS NOT called BY write_Cell_null , this needs TO be evaluated
    FUNCTION cell_used ( p_r IN NUMBER , p_c IN number , p_w IN VARCHAR2 ) RETURN BOOLEAN IS
    BEGIN
    FOR i IN 1..g_cell_count LOOP
    IF ( g_cells(i).r = p_r AND g_cells(i).c = p_c AND g_cells(i).w = p_w ) THEN
    RETURN TRUE ;
    END IF;
    END LOOP ;
    RETURN FALSE ;
    END ;
    PROCEDURE initialize_collections IS
    --- following lines resets the cell data and the cell count as it was
    -- observed that the data is retained across the two runs within same seseion.
    BEGIN
    g_cells := g_null_cells ;
    g_Cell_count := 0 ;
    g_styles := g_null_styles ;
    g_style_count := 0 ;
    g_rows := g_null_rows ;
    g_ROW_count := 0 ;
    g_columns := g_null_columns ;
    g_column_count := 0 ;
    g_excel_data := g_null_data ;
    g_data_count := 0 ;
    g_apps_env := 'U';
    g_worksheets := g_null_worksheets ;
    g_worksheets_count := 0;
    END ;
    PROCEDURE create_excel_apps is
    BEGIN
    -- CHECK the env value
    IF g_apps_env = 'N' THEN
    raise_application_error( -20001 , 'You have already called create_excel ( Non Apps ) procedure, Can not set env to create_excel_apps.');
    END IF ;
    initialize_collections ;
    g_apps_env := 'Y' ;
    END ;
    PROCEDURE create_excel( p_directory IN VARCHAR2 DEFAULT NULL , p_file_name IN VARCHAR2 DEFAULT NULL )
    IS
    BEGIN
    -- CHECK the env value
    IF g_apps_env = 'Y' THEN
    raise_application_error( -20001 , 'You have already called procedure create_excel_apps , Can not set env to Non-Apps create_excel.');
    END IF ;
    initialize_collections ;
    g_apps_env := 'N' ;
    IF ( p_directory IS NULL OR p_file_name IS NULL ) THEN
    raise_application_error( -20001 , 'p_directory and p_file_name must be not null');
    END IF ;
    BEGIN
    -- Open the FILE IN the specified directory
    l_file := utl_file.fopen( p_directory, p_file_name , 'w') ;
    EXCEPTION
    WHEN utl_file.write_error THEN
    raise_application_error( -20101 , 'UTL_FILE raised write error, check if file is already open or directory access');
    WHEN utl_file.INVALID_OPERATION THEN
    raise_application_error( -20101 , 'UTL_FILE could not open file or operate on it, check if file is already open.');
    WHEN utl_file.invalid_path THEN
    raise_application_error( -20101 , 'UTL_FILE raised invalid path, check the directory passed is correct and you have access to it.');
    WHEN others THEN
    raise_application_error( -20101 , 'UTL_FILE raised others exception ');
    END ;
    p( 'File '||p_file_name ||' created successfully');
    END ;
    PROCEDURE create_style( p_style_name IN VARCHAR2
    , p_fontname IN VARCHAR2 DEFAULT NULL
    , p_fontcolor IN VARCHAR2 DEFAULT 'Black'
    , p_fontsize IN NUMBER DEFAULT null
    , p_bold IN BOOLEAN DEFAULT FALSE
    , p_italic IN BOOLEAN DEFAULT FALSE
    , p_underline IN VARCHAR2 DEFAULT NULL
    , p_backcolor IN VARCHAR2 DEFAULT NULL ) is
    l_style VARCHAR2(2000) ;
    l_font VARCHAR2(1200);
    BEGIN
    --- CHECK IF this style IS already defined AND RAISE ERROR IF yes
    IF style_defined( p_style_name ) THEN
    RAISE_application_error( -20001 , 'Style "'||p_style_name ||'" is already defined.');
    END IF;
    g_style_count := g_style_count + 1;
    ---- ??? pass ANY value OF underline AND it will only use single underlines
    -- ??? pattern IS NOT handleed
    IF upper(p_style_name) = 'DEFAULT' THEN
    RAISE_application_error( -20001 , 'Style name DEFAULT is not allowed ');
    END IF ;
    IF upper(p_style_name) IS NULL THEN
    RAISE_application_error( -20001 , 'Style name can not be null ');
    END IF ;
    g_styles(g_style_count).s := p_style_name ;
    g_styles(g_style_count).def := ' <Style ss:ID="'|| p_style_name ||'"> ' ;
    l_font := ' <Font ' ;
    IF p_fontname IS NOT NULL THEN
    l_font :=l_font || 'ss:FontName="'|| p_fontname ||'" ';
    end if ;
    IF p_fontsize is not null then
    l_font := l_font ||' ss:Size="'|| p_fontsize ||'" ';
    end if ;
    IF p_fontcolor is not null then
    l_font := l_font ||' ss:Color="'|| p_fontcolor ||'" ';
    ELSE
    l_font := l_font ||' ss:Color="Black" ';
    end if ;
    IF p_bold = TRUE THEN
    l_font := l_font ||' ss:Bold="1" ' ;
    END IF;
    IF p_italic = TRUE THEN
    l_font := l_font ||' ss:Italic="1" ' ;
    END IF;
    IF p_underline IS NOT NULL THEN
    l_font := l_font ||' ss:Underline="Single" ' ;
    END IF ;
    -- p( l_font );
    g_styles(g_style_count).def := g_styles(g_style_count).def || l_font || '/>' ;
    IF p_backcolor IS NOT NULL THEN
    g_styles(g_style_count).def := g_styles(g_style_count).def || ' <Interior ss:Color="'||p_backcolor ||'" ss:Pattern="Solid"/>' ;
    ELSE
    g_styles(g_style_count).def := g_styles(g_style_count).def || ' <Interior/>';
    END IF ;
    g_styles(g_style_count).def := g_styles(g_style_count).def || ' </Style>' ;
    --- ??? IN font there IS SOME family which IS NOT considered
    END ;
    PROCEDURE close_file IS
    l_last_row NUMBER := 0 ;
    l_dt CHAR ; -- ??? Variable TO store the datatype ; this IS NOT used at this time but may be needed IF the memory
    -- issue IS there FOR example IF there IS big array
    l_style VARCHAR2(140) ;
    l_row_change VARCHAR2(100) ;
    l_file_header VARCHAR2(2000) := '<?xml version="1.0"?>
    <?mso-application progid="Excel.Sheet"?>
    <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:o="urn:schemas-microsoft-com:office:office"
    xmlns:x="urn:schemas-microsoft-com:office:excel"
    xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:html="http://www.w3.org/TR/REC-html40">
    <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
    <LastAuthor>a</LastAuthor>
    <Created>1996-10-14T23:33:28Z</Created>
    <LastSaved>2007-05-10T04:00:57Z</LastSaved>
    <Version>11.5606</Version>
    </DocumentProperties>
    <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
    <WindowHeight>9300</WindowHeight>
    <WindowWidth>15135</WindowWidth>
    <WindowTopX>120</WindowTopX>
    <WindowTopY>120</WindowTopY>
    <AcceptLabelsInFormulas/>
    <ProtectStructure>False</ProtectStructure>
    <ProtectWindows>False</ProtectWindows>
    </ExcelWorkbook>
    <Styles>
    <Style ss:ID="Default" ss:Name="Normal">
    <Alignment ss:Vertical="Bottom"/>
    <Borders/>
    <Font/>
    <Interior/>
    <NumberFormat/>
    <Protection/>
    </Style>'
    BEGIN
    IF gen_xl_xml.g_Cell_count = 0 THEN
    raise_application_error( -20007 , 'No cells have been written, this version of gen_xl_xml needs at least one cell to be written');
    END IF;
    IF gen_xl_xml.g_worksheets_count = 0 THEN
    raise_application_error( -20008 , 'No worksheets have been created, this version does not support automatic worksheet creation');
    END IF;
    p( gen_xl_xml.g_Cell_count) ;
    -- Write the header xml part IN the FILE.
    g_data_count := g_data_count + 1 ;
    g_excel_data( g_data_count ) := l_file_header ;
    p( 'Headers written');
    FOR i IN 1..g_style_count LOOP
    p( ' writing style number : '||i);
    g_data_count := g_data_count + 1 ;
    g_excel_data( g_data_count ) := g_styles(i).def ;
    END LOOP ;
    -- CLOSE the styles tag
    g_data_count := g_data_count + 1 ;
    g_excel_data( g_data_count ) := ' </Styles>' ;
    p( 'worksheet count '|| g_worksheets_count );
    FOR j IN 1..g_worksheets_count LOOP
    l_last_row := 0 ; --- FOR every worksheet we need TO CREATE START OF the row
    p( '()()------------------------------------------------------------ last row '||l_last_row );
    --- write the header first
    -- write the COLUMN widhts first
    -- write the cells
    -- write the worksheet footer
    l_row_change := NULL ;
    g_data_count := g_data_count + 1 ;
    g_excel_data( g_data_count ) := ' <Worksheet ss:Name="'|| g_worksheets( j).w ||'"> ' ;
    p( '-------------------------------------------------------------');
    p( '****************.Generated sheet '|| g_worksheets( j).w);
    p( '-------------------------------------------------------------');
    -- write the TABLE structure ??? change the LINE here TO include tha maxrow AND cell
    g_data_count := g_data_count + 1 ;
    g_excel_data( g_data_count ) := '<Table ss:ExpandedColumnCount="16" ss:ExpandedRowCount="44315" x:FullColumns="1" x:FullRows="1">' ;
    FOR i IN 1..g_column_count LOOP
    IF g_columns(i).w = g_worksheets( j).w THEN
    g_data_count := g_data_count + 1 ;
    g_excel_data( g_data_count ) := ' <Column ss:Index="'||g_columns(i).c||'" ss:AutoFitWidth="0" ss:Width="'||g_columns(i).wd ||'"/> ' ;
    END IF;
    END LOOP ;
    -- write the cells data
    FOR i IN 1..g_cell_count LOOP ------ LOOP OF g_cell_count
    p( '()()()()()()()()()()()() '|| i);
    --- we will write only IF the cells belongs TO the worksheet that we are writing.
    IF g_cells(i).w <> g_worksheets(j).w THEN
    p( '........................Cell : W :'|| g_worksheets( j).w ||'=> r='|| g_cells(i).r ||',c ='|| g_cells(i).c||',w='|| g_cells(i).w );
    p( '...Not in this worksheet ');
    -- l_last_row := l_last_row -1 ;
    ELSE
    p( '........................Cell : W :'|| g_worksheets( j).w ||'=> r='|| g_cells(i).r ||',c ='|| g_cells(i).c||',w='|| g_cells(i).w );
    IF g_cells(i).s IS NOT NULL AND NOT style_defined( g_cells(i).s ) THEN
    -- p(g_cells(i).s) ;
    raise_application_error( -20001 , 'Style "'||g_cells(i).s ||'" is not defined, Note : Styles are case sensative and check spaces used while passing style');
    END IF;
    p( '()()------------------------------------------------------------ last row '||l_last_row );
    IF l_last_row = 0 THEN
    FOR t IN 1..g_row_count LOOP
    p( '...Height check => Row =' ||g_rows(t).r ||', w='||g_rows(t).w);
    IF g_rows(t).r = g_cells(i).r AND g_rows(t).w = g_worksheets(j).w THEN
    p( '...Changing height') ;
    l_row_change := ' ss:AutoFitHeight="0" ss:Height="'|| g_rows(t).ht||'" ' ;
    g_data_count := g_data_count + 1 ;
    g_excel_data( g_data_count ) := ' <Row ss:Index="'||g_cells(i).r||'"'|| l_row_change ||'>' ;
    l_last_row := g_cells(i).r ;
    EXIT ;
    ELSE
    p( '...NO change height') ;
    l_row_change := NULL ;
    END IF ;
    END loop ;
    IF l_ROW_CHANGE IS NULL THEN
    g_data_count := g_data_count + 1 ;
    p( '...Creating new row ');
    g_excel_data( g_data_count ) := ' <Row ss:Index="'||g_cells(i).r||'"'|| l_row_change ||'>' ;
    l_last_row := g_cells(i).r ;
    END IF;
    END IF;
    IF g_cells(i).s IS NOT NULL THEN
    p( '...Adding style ');
    l_style := ' ss:StyleID="'||g_cells(i).s||'"' ;
    ELSE
    p( '...No style for this cell ');
    l_style := NULL ;
    END IF;
    p( '()()------------------------------------------------------------ last row '||l_last_row );
    IF g_cells(i).r <> l_last_row THEN
    p('...closing the row.'||g_cells(i).r);
    g_data_count := g_data_count + 1 ;
    g_excel_data( g_data_count ) := ' </Row>' ;
    p( 'ROWCOUNT : '||g_row_count );
    FOR t IN 1..g_ROW_count LOOP
    p( '.....Height check => Row =' ||g_rows(t).r ||', w='||g_rows(t).w);
    IF g_rows(t).r = g_cells(i).r AND g_rows(t).w = g_worksheets(j).w THEN
    p( '.....Changing height') ;
    l_row_change := ' ss:AutoFitHeight="0" ss:Height="'|| g_rows(t).ht||'" ' ;
    g_data_count := g_data_count + 1 ;
    g_excel_data( g_data_count ) := ' <Row ss:Index="'||g_cells(i).r||'"'|| l_row_change ||'>' ;
    EXIT ;
    ELSE
    p( '.....NO change height') ;
    l_row_change := NULL ;
    END IF ;
    END loop ;
    -- P( 'Row :'||g_cells(i).r ||'->'|| l_ROW_CHANGE);
    IF l_row_change IS NULL THEN
    g_data_count := g_data_count + 1 ;
    g_excel_data( g_data_count ) := ' <Row ss:Index="'||g_cells(i).r||'"'|| l_row_change ||'>' ;
    END IF;
    IF g_cells(i).v IS NULL THEN
    g_data_count := g_data_count + 1 ;
    g_excel_data( g_data_count ) := '<Cell ss:Index="'||g_cells(i).c||'"' || l_style ||' ></Cell>';
    ELSE
    g_data_count := g_data_count + 1 ;
    g_excel_data( g_data_count ) := '<Cell ss:Index="'||g_cells(i).c||'"' || l_style ||' ><Data ss:Type="'||g_cells(i).dt ||'">'||g_cells(i).v||'</Data></Cell>';
    END IF ;
    l_last_row :=g_cells(i).r ;
    ELSE
    IF g_cells(i).v IS NULL THEN
    g_data_count := g_data_count + 1 ;
    g_excel_data( g_data_count ) := '<Cell ss:Index="'||g_cells(i).c||'"' || l_style ||' > </Cell>';
    ELSE
    g_data_count := g_data_count + 1 ;
    g_excel_data( g_data_count ) := '<Cell ss:Index="'||g_cells(i).c||'"' || l_style ||' ><Data ss:Type="'||g_cells(i).dt ||'">'||g_cells(i).v||'</Data></Cell>';
    END IF ;
    END IF ;
    END IF ;
    NULL ;
    END LOOP ; -- LOOP OF g_cells_count
    p('...closing the row.');
    g_data_count := g_data_count + 1 ;
    g_excel_data( g_data_count ) := ' </Row>' ;
    -- ??? does following COMMENT will have sheet NAME FOR debugging
    p( '-------------------------------------------------------------');
    p( '....End of writing cell data, closing table tag');
    g_data_count := g_data_count + 1 ;
    g_excel_data( g_data_count ) := ' </Table>' ;
    g_data_count := g_data_count + 1 ;
    g_excel_data( g_data_count ) := g_worksheets(j).wftr ;
    p( '..Closed the worksheet '|| g_worksheets( j).w );
    END LOOP ;
    g_data_count := g_data_count + 1 ;
    g_excel_data( g_data_count ) := '</Workbook>' ;
    p( 'Closed the workbook tag');
    IF g_apps_env = 'N' THEN
    FOR i IN 1..g_data_count LOOP
    utl_FILE.put_line( l_file, g_excel_data(i ));
    END LOOP ;
    utl_file.fclose( l_file );
    p( 'File closed ');
    ELSIF g_apps_env = 'Y' THEN
    FOR i IN 1..g_data_count LOOP
    fnd_file.put_line( fnd_file.output , g_excel_data(i));
    fnd_file.put_line( fnd_file.log , g_excel_data(i));
    END LOOP ;
    ELSE
    raise_application_error( -20001 , 'Env not set, ( Apps or not Apps ) Contact Support.' );
    END IF;
    END ;
    PROCEDURE create_worksheet ( p_worksheet_name IN VARCHAR2 ) IS
    BEGIN
    g_worksheets_count := g_worksheets_count + 1 ;
    g_worksheets(g_worksheets_count).w := p_worksheet_name ;
    g_worksheets(g_worksheets_count).whdr := '<Worksheet ss:Name=" ' || p_worksheet_name ||' ">' ;
    g_worksheets(g_worksheets_count).wftr := '<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
    <ProtectObjects>False</ProtectObjects>
    <ProtectScenarios>False</ProtectScenarios>
    </WorksheetOptions>
    </Worksheet>' ;
    END ;
    PROCEDURE write_cell_char(p_row NUMBER, p_column NUMBER, p_worksheet_name IN VARCHAR2, p_value IN VARCHAR2, p_style IN VARCHAR2 DEFAULT NULL ) IS
    l_ws_exist BOOLEAN ;
    l_worksheet VARCHAR2(2000) ;
    BEGIN
    -- CHECK IF this cell has been used previously.
    IF cell_used( p_row , p_column , p_worksheet_name ) THEN
    RAISE_application_error( -20001 , 'The cell ( Row: '||p_row ||' Column:'||p_column ||' Worksheet:'||p_worksheet_name ||') is already used.Check if you have missed to increment row number in your code. ');
    END IF;
    -- IF worksheet NAME IS NOT passed THEN use first USER created sheet ELSE use DEFAULT sheet
    -- this PROCEDURE just adds the data INTO the g_cells TABLE
    g_cell_count := g_cell_count + 1 ;
    g_cells( g_cell_count ).r := p_row ;
    g_cells( g_cell_count ).c := p_column ;
    g_cells( g_cell_count ).v := p_value ;
    g_cells( g_cell_count ).w := p_worksheet_name ;
    g_cells( g_cell_count ).s := p_style ;
    g_cells( g_cell_count ).dt := 'String' ;
    END ;
    PROCEDURE write_cell_num(p_row NUMBER , p_column NUMBER, p_worksheet_name IN VARCHAR2, p_value IN NUMBER , p_style IN VARCHAR2 DEFAULT NULL ) IS
    l_ws_exist BOOLEAN ;
    l_worksheet VARCHAR2(2000) ;
    BEGIN
    -- ??? IF worksheet NAME IS NOT passed THEN use first USER created sheet ELSE use DEFAULT sheet
    -- this PROCEDURE just adds the data INTO the g_cells TABLE
    -- CHECK IF this cell has been used previously.
    IF cell_used( p_row , p_column , p_worksheet_name ) THEN
    RAISE_application_error( -20001 , 'The cell ( Row: '||p_row ||' Column:'||p_column ||' Worksheet:'||p_worksheet_name ||') is already used. Check if you have missed to increment row number in your code.');
    END IF;
    g_cell_count := g_cell_count + 1 ;
    g_cells( g_cell_count ).r := p_row ;
    g_cells( g_cell_count ).c := p_column ;
    g_cells( g_cell_count ).v := p_value ;
    g_cells( g_cell_count ).w := p_worksheet_name ;
    g_cells( g_cell_count ).s := p_style ;
    g_cells( g_cell_count ).dt := 'Number' ;
    END ;
    PROCEDURE write_cell_null(p_row NUMBER , p_column NUMBER , p_worksheet_name IN VARCHAR2, p_style IN VARCHAR2 ) IS
    BEGIN
    -- ???? NULL IS allowed here FOR time being. one OPTION IS TO warn USER that NULL IS passed but otherwise
    -- the excel generates without error
    g_cell_count := g_cell_count + 1 ;
    g_cells( g_cell_count ).r := p_row ;
    g_cells( g_cell_count ).c := p_column ;
    g_cells( g_cell_count ).v := null ;
    g_cells( g_cell_count ).w := p_worksheet_name ;
    g_cells( g_cell_count ).s := p_style ;
    g_cells( g_cell_count ).dt := NULL ;
    END ;
    PROCEDURE set_row_height( p_row IN NUMBER , p_height IN NUMBER, p_worksheet IN VARCHAR2 ) IS
    BEGIN
    g_ROW_count := g_ROW_count + 1 ;
    g_rows( g_row_count ).r := p_row ;
    g_rows( g_row_count ).ht := p_height ;
    g_rows( g_row_count ).w := p_worksheet ;
    END ;
    PROCEDURE set_column_width( p_column IN NUMBER , p_width IN NUMBER, p_worksheet IN VARCHAR2 ) IS
    BEGIN
    g_column_count := g_column_count + 1 ;
    g_columns( g_column_count ).c := p_column ;
    g_columns( g_column_count ).wd := p_width ;
    g_columns( g_column_count ).w := p_worksheet ;
    END ;
    END ;
    SHOW errors ;
    Thanks,
    Maddy B

    Hi,
    Peter Gjelstrup wrote:
    Next thing is how to use it:
    declare
    k_file constant varchar2(30) := 'YourFile.xls'
    begin
    create_file(k_file);
    -- Call other procedures
    close_file;
    end;
    Don't forget: these procedures are all part of the gen_xl_xml package.
    To call them from outside the package, you have to prefix each procedure name with the package name, like this:
    declare
    k_file constant varchar2(30) := 'YourFile.xls'
    begin
    gen_xl_xml.create_file(k_file);
    -- Call other procedures
    gen_xl_xml.close_file;
    end;

  • Can we create a file in temporary folders of the server?

    Hi all,
    can we create a file in the temporary folders of the server by getting the server temp path using System.getProperty("java.io.tmpdir") ?
    I dont have access to the server. I deployed my application in the server which should create a word file for me.
    I am trying to create a word file in the temporary folder of the server. Can my code create a file in the server to which I dont have access?
    Please come up with your help.
    Thanks,
    Phanindra.

    Hi:
    copy file to target folder
      CALL FUNCTION 'SCMS_FILE_COPY'                            "#EC *
        EXPORTING
          src_filename = t_source_file
          dst_filename = t_target_file
        EXCEPTIONS
          read_failed  = 1
          write_failed = 2
          OTHERS       = 3.
      IF sy-subrc <> 0.
        MESSAGE i208(00) WITH text-009.
        stop.
      ELSE.
    delete source file
        CALL FUNCTION 'SCMS_FILE_DELETE'                        "#EC *
          EXPORTING
            filename      = t_source_file
          EXCEPTIONS
            not_found     = 1
            name_too_long = 2
            OTHERS        = 3.
      ENDIF.

  • How can I create an csv/excel file using pl/sql and then sending that file

    How can I create an csv/excel file using pl/sql and then sending that file to a clients site using pl/sql?
    I know how to create the csv/excel file but I can't figure out how I would get it to the clients site.

    968776 wrote:
    How can I create an csv/excel file using pl/sql and then sending that file to a clients site using pl/sql?
    I know how to create the csv/excel file but I can't figure out how I would get it to the clients site.You are trying to do it at a wrong place..
    Whay do you want database (pl/sql) code to do these things?
    Anyhow, you may be interested in :
    {message:id=9360007}
    {message:id=9984244}

  • How can one  read a Excel File and Upload into Table using Pl/SQL Code.

    How can one read a Excel File and Upload into Table using Pl/SQL Code.
    1. Excel File is on My PC.
    2. And I want to write a Stored Procedure or Package to do that.
    3. DataBase is on Other Server. Client-Server Environment.
    4. I am Using Toad or PlSql developer tool.

    If you would like to create a package/procedure in order to solve this problem consider using the UTL_FILE in built package, here are a few steps to get you going:
    1. Get your DBA to create directory object in oracle using the following command:
    create directory TEST_DIR as ‘directory_path’;
    Note: This directory is on the server.
    2. Grant read,write on directory directory_object_name to username;
    You can find out the directory_object_name value from dba_directories view if you are using the system user account.
    3. Logon as the user as mentioned above.
    Sample code read plain text file code, you can modify this code to suit your need (i.e. read a csv file)
    function getData(p_filename in varchar2,
    p_filepath in varchar2
    ) RETURN VARCHAR2 is
    input_file utl_file.file_type;
    --declare a buffer to read text data
    input_buffer varchar2(4000);
    begin
    --using the UTL_FILE in built package
    input_file := utl_file.fopen(p_filepath, p_filename, 'R');
    utl_file.get_line(input_file, input_buffer);
    --debug
    --dbms_output.put_line(input_buffer);
    utl_file.fclose(input_file);
    --return data
    return input_buffer;
    end;
    Hope this helps.

  • Creating a text file using pl/sql

    how can one create a text file using pl/sql?
    Say for example abcd.txt in the d: drive
    (d:\abcd.txt)
    on a windows nt server

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by bhrigu nagal ([email protected]):
    thanks for your replies
    I had already set the utl_file_dir parameter
    I tried the utl package and wrote the following code but got some errors
    declare
    filehandler UTL_FILE.FILE_TYPE;
    begin
    filehandler:=UTL_FILE.fopen('d:/intel/','myfile.txt','w');
    utl_file.put_line(filehandler,'look masjdfgsd\n');
    utl_file.fclose(filehandler);
    exception when utl_file.invalid_path then
    raise_application_error(-20023,'bhrigu ,chk the path');
    end;
    the errors
    ERROR at line 1:
    ORA-06510: PL/SQL: unhandled user-defined exception
    ORA-06512: at "SYS.UTL_FILE", line 101
    ORA-06512: at "SYS.UTL_FILE", line 157
    ORA-06512: at line 4
    if u know what this is please tell me
    thanks bhrigu
    <HR></BLOCKQUOTE>
    U need :
    1) To have UTL_FILE_DIR param in the init file of the instance with the same directory (don't forget to stop and restart the base)
    2) Handled the exceptions listed in the utl_file package (Oracle_home\rdbms\admin\utlfile.sql) in your source.
    3) Turn set serveroutput on in SQL*Plus.
    Run your procedure and see the error message to debug.
    Good luck
    null

  • Downloading BLOB to a file using pl/sql toolkit

    Created an Oracle Reports RDF file using the reports builder (9.0.2.x).
    Uploaded the file into the database in a BLOB column using the following code:
    >>>>
    SET VERIFY OFF
    DECLARE
    p_bfile BFILE ;
    p_blob BLOB ;
    BEGIN
    p_bfile := BFILENAME('CDR_REPORTS', '&1') ;
    INSERT INTO RPTIDE (RPTID, RPTMODULE) VALUES ('&1', EMPTY_BLOB()) RETURNING
    RPTMODULE INTO p_blob ;
    DBMS_LOB.FILEOPEN(p_bfile, DBMS_LOB.FILE_READONLY);
    DBMS_LOB.LOADFROMFILE(p_blob, p_bfile, DBMS_LOB.GETLENGTH(p_bfile));
    DBMS_LOB.FILECLOSE(p_bfile);
    COMMIT ;
    END ;
    <<<<<
    Now when we try to download the same file using pl/sql web toolkit (code pasted
    below), the file downloads fine (with exact same file size as before), but no
    longer can open the file in Reports Builder anymore. Get "Cannot open file"
    error in reports builder. Is it getting corrupt or am I doing something wrong?
    >>>>
    CREATE OR REPLACE PROCEDURE filedownload(p_rpt IN VARCHAR2) AS
    p_file blob;
    p_mime_type varchar2(50);
    p_offset integer := 1;
    p_len number;
    p_buf RAW(32000);
    p_buf_size integer:= 32000;
    BEGIN
    SELECT rptmodule, 'application/x-zip'
    INTO p_file, p_mime_type
    FROM rptide
    WHERE rptid = p_rpt ;
    OWA_UTIL.MIME_HEADER(p_mime_type);
    p_len := DBMS_LOB.GETLENGTH(p_file);
    WHILE p_offset < p_len LOOP
    DBMS_LOB.READ(p_file, p_buf_size, p_offset, p_buf);
    HTP.PRN(UTL_RAW.CAST_TO_VARCHAR2(p_buf));
    p_offset := p_offset + p_buf_size;
    END LOOP;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN HTP.PRN('No document specified') ;
    WHEN OTHERS THEN HTP.P('filedownload: '||SQLERRM);
    END filedownload ;
    <<<<<

    The answer to this problem was to set the NLS_LANGUAGE for the DAD to an 8-bit character set since the database charset was 8-bit. It seems, by default, the web toolkit assumes a 7-bit character set.

  • FRM-10044 Can not create a file URGENT PLEASE!!

    I installed Oracle 8i and Forms 6i in a pentium 4 changing the symcjit.dll -> symcjit.old.
    Now I want to use the same scripts and Forms that I have saved using my old machine but I can't save new forms or update the old ones.
    FRM 10044 Can not create the file
    I can run the scripts in SQL.
    Please Help me it is urgent.
    I have installed and uninstalled the Data Base many times and I have read previous posts.
    Thank you a lot.

    Hi,
    "Cannot Create File" means forms failed to create/save the file. Check the following
    * Do you have full access to the drive?
    * Did you mark either the form or its directory as read only?
    Regards,
    Momen.
    Hi Helena,
    How are you? We are into Arabic development environment. I am trying to migrate from 6i (CS) to 9i (web). Everything went fine but when I run the report, the browser is displaying junk characters.
    Did you experience this problem?
    If you have any suggestions you can mail me on [email protected]
    Regards,
    Momen.

  • Generating text file using PL/SQL

    can any body send sample program how to generate text file using PL/SQL program.I want to store table data into that text file.

    Hi,
    try this.
    Thanks
    CREATE OR REPLACE procedure write_index (TABLE_NAME_ACCEPT VARCHAR2) IS
    id UTL_FILE.FILE_TYPE;
    name VARCHAR2(20) := 'e:\db_coca\input';      
    err VARCHAR2(100);      
    ColNameLength Integer;
    NumberoFColumns Integer;
    num NUMBER;           
    i integer;
    loc_query VARCHAR2(2000);
    cursor_name INTEGER;
    ret INTEGER;
    l_const_name VARCHAR2(30);
    CURSOR c_columns(i_Constraint_name VARCHAR2) IS
         SELECT *
         FROM     all_cons_columns
         WHERE     CONSTRAINT_NAME = i_Constraint_name
         order by table_name;
    BEGIN
    DBMS_OUTPUT.PUT_LINE('BEFORe OPEN');
    --id := UTL_FILE.FOPEN('e:\db_coca\input',name,'w');          
         --IF UTL_FILE.IS_OPEN(id) THEN
         --     DBMS_OUTPUT.PUT_LINE('Opened');
         --ELSE
         --     DBMS_OUTPUT.PUT_LINE('Still Closed');           
         --END IF;          
    DBMS_OUTPUT.PUT_LINE('AFTER OPEN');
    --The table generation script
         loc_query := 'Select CONSTRAINT_NAME from user_constraints ';
         loc_query := loc_query || ' where owner = ' || '''CPS''';
         loc_query := loc_query || ' AND CONSTRAINT_TYPE = ' || '''P''';
         dbms_output.put_line('TABLE_NAME_ACCEPT = ' || TABLE_NAME_ACCEPT);
         IF NOT (TABLE_NAME_ACCEPT IS NULL ) THEN
              loc_query := loc_query || ' AND TABLE_NAME like ''';
              loc_query := loc_query || TABLE_NAME_ACCEPT ;
              loc_query := loc_query || '''';
         END IF;
         cursor_name := DBMS_SQL.OPEN_CURSOR;
    dbms_output.put_line('Query = ' || loc_query);
         DBMS_SQL.PARSE(cursor_name, loc_query, DBMS_SQL.v7);
    dbms_output.put_line('After parse');
         dbms_sql.DEFINE_COLUMN(cursor_name, 1,l_const_name, 30);
         ret := DBMS_SQL.EXECUTE(cursor_name);
    --     IF ret > 0 THEN
         LOOP
         dbms_output.put_line('return = ' || ret);
              IF DBMS_SQL.FETCH_ROWS(cursor_name) > 0 THEN
                   dbms_sql.COLUMN_VALUE(cursor_name, 1,l_const_name);
              --     dbms_sql.BIND_VARIABLE(cursor_name,
    l_const_name,CONSTRAINT_NAME);
              --     FOR C10 in Table_Loop Loop          --The cursor
    for the table name
                   Select COunt(*) INTO NumberoFColumns from
                   all_cons_columns
                   Where CONSTRAINT_NAME = l_const_name;
         --          FOR C11 IN c_columns(l_const_name) LOOP
         --          End loop;
         --          UTL_FILE.PUT(id, ');');
              ELSE EXIT;
              END if;     --THe 1 st cursor if is closed
         End Loop;     --The table loop ends here
              DBMS_SQL.CLOSE_CURSOR(cursor_name);
    --     END IF;     
    --     UTL_FILE.PUT_LINE(id,name);
    --     UTL_FILE.PUT(id,'It worked and wrote to this file');
         UTL_FILE.FCLOSE(id);
         DBMS_OUTPUT.PUT_LINE('Successful write to file');          
    EXCEPTION     
    WHEN OTHERS THEN               
         err := SQLERRM;          
         num := SQLCODE;
         DBMS_OUTPUT.PUT_LINE(err);          
         DBMS_OUTPUT.PUT_LINE(num);
         DBMS_OUTPUT.PUT_LINE('Error in writing to file');     
    END write_index;

Maybe you are looking for

  • Unable to run Crystal Report due to error code called "database code:102

    I have created a View on the SQL server and Now I am trying to run crystal report using that view. However, I get Database Vendor Code error message 102. Need your help, How can I ran a report using SQL veiws in Crystal? thanks! Mansoor

  • Managing 2 iPhones with iTunes and one iTunes account and computer...

    Hello All! I already have a 16GB 3G iPhone and we're going to be getting another 3G for my wife (whether it is 8GB or 16GB is still to be decided). On my phone, I have about 13GB used, with the primary source being music. We intend the same iTunes ac

  • Why is the page not the size of the screen?

    when I open Firefox whether in full screen or not the page only uses the center of the screen.I>E> always has a 5 inch border on both sides. The menu bars go accross the whole screen. Even using zoom doesn't cure this. very irritating if this cannot

  • HELP AIRPORT CARD

    I have a powerbook g4|800 mHz, a adsl connection to internet connected to a wireless smc network wich is plug to a imac which dont have a airport card. So fare i could use my imac (via ethernet) and my power book G4 (via airport) with no trouble, alw

  • Publish web services with SAP 7.1

    hello everybody, i'm working with a sap installation netweaver 7.1 i want publish some functions as web services. I made it many time with NW 7.0 without problem. At the moment i'm using the same procedure: SE37 - function name - Utilities - create w