Spool command through ODBC

Hi,
How do I run the oracle spool command through odbc?
If this is not possible, how do I export oracle data to a flat flie through odbc?
thanks
-bgc

I'm not aware of a way to call the spool command directly. I assume that you can call spool from a stored procedure. If so, you could create a stored procedure that calls spool, then execute the stored procedure via ODBC.
Exporting data to a flat file isn't something ODBC was designed to do. Assuming you managed to spool a file, you'd still have to get it from the database machine to the client. If you wanted to do this via ODBC, you'd have to convert the file to a B/CLOB in the database and fetch that B/CLOB via the appropriate SQL statement. The client application could then write the data back out to a file...
I suspect that you're trying to do something that ODBC isn't particularly suited for. You may want to double-check your design.
Justin

Similar Messages

  • Preserve a single space at the end of line using spool command

    Hi,
    Can you please help me to write the result of an sql query into a file with the last column of the row ending with a single space?
    For example:
    COL1DATA|COL2DATA|COL3DATA<space1>
    As mentioned in the example the col3 value in the file should end with a single space. And there should not be any delimiters at the end of the row.
    I tried with set trimspool on/off. But, it didn't work. When I say trimspool on - it is trimming all the trailing spaces.
    When I say trimspool off - it is retaining all the trailing spaces to the size of the line.
    But, I do not wish to modify the file through shell commands once it is written thru spool. I mean I do not wish to append spaces to the end of a line using shell script or any other method.
    I do not wish to use other methods like UTL_FILE also.
    Please help me how to do it using spool command?
    Thank you.
    Ramana

    My requirement is that all the trailing spaces should be truncated except the last one in the row.Why?
    As you have discovered a single column in sqlplus, is always a fixed length regardless of the size of the data, if the length of the data varies the output is padded to the maximum or line size with spaces. The trim and trimpsool commands are there to remove all the spaces from the end of a line if there are any. There are no commands to trim all the spaces except one, or even to trim all the spaces except two, or three even.
    If you want such custom processing you should post process the file in the OS using sed, awk or perl or something designed for such things.

  • Connect PostgreSQL to Oracle 10g through ODBC: can't read all_tables

    Oracle 10g is not able to read the database table names (all_tables and all_objects, es. select * from all_tables@hspostgresodbc) from PostgreSQL using ODBC (v. 08.01.0200). This functionality is essential to be able to use Oracle Warehouse Builder and import external database definitions (heterogeneous services).
    However, Oracle (SQL*Plus) is able to retrieve records when the table name is stated in the SQL query (es. select * from “my_table”).
    The problem seems to be specifically with the PostgreSQL ODBC because Oracle is able to read schemes from other databases through ODBC. I’ve done some tests with Access dbs just to be sure that the problem is not with my system (Windows XP SP2).
    The problem appears both with ANSI and UNICODE PostgreSQL drivers.
    Any suggestion of how workaround this problem?
    thanks in advance,
    Raoni

    Dear all,
    I’ve tried different tracing levels with out success. The log file does not seem to be created by Oracle.
    Looking closer to the debug and comm logs from the driver 8.01.0200, I’ve found out that the problem was generated after a table wasn’t found (the driver seems to search for the all_tables table, and just afterwards to query the scheme pg_catalog). In this case the all the following queries returned with the error “ERROR: current transaction is aborted, commands ignored until end of transaction block”. Maybe this problem is related with the bug [#1000641] http://pgfoundry.org/tracker/index.php?func=detail&aid=1000641&group_id=1000125&atid=538
    Following the Postgres odbc developers suggestion, I’ve installed the psqlODBC v 08.02.0002 and I’ve got a completely different result.
    As before, the simple query “select * from my_table@hsodbc” returns the result using SQL*Plus clearly faster than before.
    Doing the query “select * from all_tables@hsodbc” the result is OK (the name of 56 tables) but the process is very slow and burdensome. The file paging memory in the machine running Oracle and the SQL*Plus jumps from the normal 700 MB to 1.7 GB, and the query takes about 20 minutes to complete.
    Also the 1.7 GB remains allocated and the query process halted in PostGreSQL even after the on screen result of the query. The memory is freed and the process terminated after the logging out SQL*Plus.
    Probably as result of this memory explosion, the system runs out of memory and Oracle Warehouse Builder selecting data base link -> schema, after some minutes get an error similar to: “can’t read from memory address XXXXX”
    All those test where done with PostGreSQL 8.0.1 (on Linux Suse 9.0) and Oracle 10g (Windows XP SP2).
    To be sure that the problem was not related to the PostGreSQL version, we updated the server to the 8.1.3 (running in Linux Suse 9.0 with psqlODBC v 08.02.0002 ) and OWB couldn’t see any table as before and doing Select * from all_tables@hsodbc we’ve got the message:
    ERROR:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
    [Generic Connectivity Using ODBC]
    ORA-02063: preceding 2 lines from HSPG
    no rows selected
    On the other hand, with the same configuration as before (Oracle 10g under Windows XP SP1, psqlODBC v 08.02.0002) but with PostGreSQL 8.1.3 under Windows XP SP1, OWB can read table names (same tables imported from Linux PostgreSQL) but not all_tables (a minor problem, because what is important for us is to make OWB work with PostgreSQL).
    The encoding for all DBs is UTF8.
    Any ideas of where could be the problem?
    regards,
    R.

  • ACS 4.2.1: adding new AAA clients through odbc import

    Hello,
    we have added the user defined vendor RADIUS_HUAWEI to our Cisco ACS 4.2.1  Windows Server.
    Unfortunately there is a problem with importing network devices through odbc  connection using the accountactions table with the action code 220.
    The documentation tells us :
    220
    ADD_NAS
    VN, V1, V2, V3
    Adds a new AAA client (named in VN) with an IP address (V1), shared secret key  (V2), and vendor (V3). Valid vendors are:
    •VENDOR_ID_IETF_RADIUS—For IETF RADIUS.
    •VENDOR_ID_CISCO_RADIUS—For Cisco IOS/PIX RADIUS.
    •VENDOR_ID_CISCO_TACACS—For Cisco TACACS+.
    •VENDOR_ID_AIRESPACE_RADIUS—For Cisco Airespace RADIUS.
    •VENDOR_ID_ASCEND_RADIUS—For Ascend RADIUS.
    •VENDOR_ID_ALTIGA_RADIUS—For Cisco 3000/ASA/PIX 7.x+ RADIUS.
    •VENDOR_ID_AIRONET_RADIUS—For Cisco Aironet RADIUS.
    •VENDOR_ID_NORTEL_RADIUS—For Nortel RADIUS.
    •VENDOR_ID_JUNIPER_RADIUS—For Juniper RADIUS.
    •VENDOR_ID_CBBMS_RADIUS—For Cisco BBMS RADIUS.
    •VENDOR_ID_3COM_RADIUS—For Cisco 3COMUSR RADIUS.
    The new user defined vendor is:
    C:\Program Files\CiscoSecure ACS v4.2\bin>CSUtil.exe -listUDV
    CSUtil v4.2(1.15), Copyright 1997-2009, Cisco Systems Inc
    UDV 0 - RADIUS (RADIUS_HUAWEI)
    Our action code and variables look like:
    A=220
    VN="xxx"
    V1="10.10.10.10"
    V2="blabla"
    V3="VENDOR_ID_RADIUS_HUAWEI"
    Error Code is as following:
    06/22/2010,10:21:12,W03P-3413,ERROR,Parse Error: Reason - Host vendor is unknown   [A=220 UN="" GN="" AI="" VN="xxx" V1="10.10.10.10" V2="blabla"  V3="VENDOR_ID_RADIUS_HUAWEI"]
    Does anybody knows the correct name for the V3-variable to import the network  device in a correct way?
    Best regards
    Torsten Waibel

    Hello,we
    have a new acs appliance (1113) with version 4.2.1.15 and we want to
    authenticate user through ssh from routers with ios xr software.
    unfortunately this doesn't work.Here ist our configuration of the router:##################################################line template VTY
    access-class ingress abcd!tacacs-server host x.x.x.x port 49 single-connectiontacacc-server key 7 test!tacacs source-interface Loopback13!ssh server v2
    ssh timeout 60! AAA config
    aaa accounting exec default start-stop group tacacs+
    aaa accounting network default start-stop group tacacs+
    aaa accounting commands default start-stop group tacacs+
    aaa authorization exec default group tacacs+ none
    aaa authorization commands default group tacacs+ none
    aaa authentication login default group tacacs+ local##################################################does anybody has a solution for this problem?thnx and best regardsTorsten Waibel
    Hi Torsten Waibel,
    For ssh to support you should have a cryptography ios image in router and check the following command in line vty that transpot input ssh under line vty cofiguration.
    If helpful do rate the post
    Ganesh.H

  • Spool command  in form builder

    hello;
    we try this command in sql plus(ok)
    spool c:\sample.dat
    select * from employee;
    spool off
    my problem is this possible to include spool command in program units using
    form builder.
    PROCEDURE mis$atm_dat_creation IS
    BEGIN
    SPOOL C:\ETPS\PAYROLL.DAT;
    SELECT '2146260011460000000'||company_name
    ||atm_account_number,
    DECODE(LENGTH(salary),14,LPAD(salary,15,'0')
    ,13,LPAD(salary,15,'00')
    ,12,LPAD(salary,15,'000')
    ,11,LPAD(salary,15,'0000')
    ,10,LPAD(salary,15,'00000')
    ,9,LPAD(salary,15,'000000')
    ,8,LPAD(salary,15,'0000000')
    ,7,LPAD(salary,15,'00000000')
    ,6,LPAD(salary,15,'000000000')
    ,5,LPAD(salary,15,'0000000000')
    ,4,LPAD(salary,15,'00000000000')
    ,3,LPAD(salary,15,'000000000000')
    ,2,LPAD(salary,15,'0000000000000')
    ,1,LPAD(salary,15,'00000000000000')
    ,salary)||
    '900003'||TO_CHAR(effectivity_date,'MMDDYYYY')
    FROM atm_transactions;
    SPOOL OFF;
    SELECT SUM(SALARY)
    FROM atm_transactions;
    END;
    pls helps....

    SPOOL is not a SQL statement or a PL/SQL command, it is a SQL*Plus environment command.
    Using Oracle Developer, the most efficient way to produce file output is through Oracle Reports, not Forms.
    Best!

  • "no row count was produced" error using mqsl commands through Access

    "no row count was produced" error using mqsl commands through Microsoft Access. This sql statement works when I use in in the Access program but it does not work when I try and put it through Access using my Java program. Here is the block of code that I have that does the search.
    public static Game searchRecord(String search) throws SQLException{
    String query = "SELECT* " + "FROM gamefields WHERE SKU = '" + search + "' ORDER BY SKU ASC";
    Game lastGame = new Game(gamefields.getString(1),
    gamefields.getString(2),
    gamefields.getString(3),
    gamefields.getString(4),
    gamefields.getString(5),
    gamefields.getString(6),
    gamefields.getString(7),
    gamefields.getDouble(8));
    Statement statement = connection.createStatement(); //Creates connection
    //statment to database
    statement.executeUpdate(query); //Executes the delete query and Updates the database
    statement.close();
    close();
    open();
    return lastGame;

    When you use the code from java, you access access (!) through the ODBC interface. Things can be different in ODBC and Jet. When you use PrepareadStatements, you should be on the save side:
    public static Game searchRecord(String search) throws SQLException
    String query = "SELECT * FROM gamefields WHERE SKU = ? ORDER BY SKU ASC";
    PreparedStatement statement = connection.prepareStatement(query);
    statement.setString(1,  search);
    ResultSet rs = statement.executeQuery(query);
    if(rs.next()
    // if a row retuned extract the details here
    rs.close();
    statement.close();
    return lastGame;
    }

  • Unable to import tables through ODBC in obiee 11g

    Hi all,
    In obiee 11g,
    OBIEE 11g is successfully installed but when i am trying to import the tables in RPD through odbc then it is giving a problem.
    I have tried using the OCI and it is working fine but can anyone tell me why it is not happening through odbc.
    created the dSN for it and it is working fine.
    any help would be appreciated.
    thanks in advance.

    Hi,
    You need do full installation of obiee11g.
    Go through this..May help you.Not getting connected to a data source in obiee 11g
    How to install 11g ODBC client drivers to access OBIEE 11g server?
    Regards,
    Srikanth

  • Spool command in SQL Developer 3.1

    Hi,
    I am using sqldeveloper-3.1.05.97 .
    There are few scripts that I need to run on a EBS sandbox to generate txt files for a analysis tool input .
    The script is meant to be run with SQL * Plus but I am getiing a TNS listener error due to which I want to use SQL Developer.
    The Spool command is able to create file in local directory but the oputput is not the query result but the query itself. Please help if anything is wrong in the syntax below:
    ALTER SESSION SET NLS_DATE_FORMAT = 'MM/DD/YYYY';
    SET NEWPAGE 0
    SET SPACE 0
    SET PAGESIZE 0
    SET ECHO OFF
    SET FEEDBACK OFF
    SET COLSEP |
    SET MARKUP HTML OFF
    SET LINESIZE 600
    SPOOL FND_USER.txt
    SELECT USER_ID, USER_NAME, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, START_DATE, END_DATE, DESCRIPTION, LAST_LOGON_DATE, PASSWORD_DATE, PASSWORD_ACCESSES_LEFT, PASSWORD_LIFESPAN_ACCESSES, PASSWORD_LIFESPAN_DAYS, EMPLOYEE_ID, CUSTOMER_ID, SUPPLIER_ID
    FROM APPS.FND_USER;
    SPOOL OFF

    Hi Partha,
    It seems the line "SET PAGESIZE 0" is suppressing all output in SQL Developer, and not just "all headings, page breaks, titles, the initial blank line, and other formatting information" as documented for SQL*Plus. Keep in mind that SQL Developer does not yet provide full support for all SQL*Plus formatting commands. For example, without SET PAGESIZE 0, the script output tab shows these messages:
    line 2: SQLPLUS Command Skipped: set NEWPAGE 0
    line 3: SQLPLUS Command Skipped: set SPACE 0
    line 8: SQLPLUS Command Skipped: set MARKUP HTML OFF
    I will log a bug for this.
    Regards,
    Gary
    SQL Developer Team

  • Spool Command with dbms_metadata.GET_DDL function

    Hi All,
    My requirement is before applying a patch on the Database Schema, I need to take a backup of the db objects DDL script, so that incase if I want to rollback I can use it. what I am trying to use is the dbms_metadata.GET_DDL function to get the DDL script and with the help of spool command store that in a text file.
    The problem I am encountering is the whole script runs without an error but whne I check the spool file for certain big packages the DDL script is not fully exported. The below is the script that I make use of to generate the DDL script.
    set heading off
    set feedback off
    set echo off
    set term off
    set newpage none
    set space 0
    set trimout on
    set TRIMSPOOL ON
    column c1 format a4000
    set long 99999
    set lines 1000
    exec DBMS_METADATA.SET_TRANSFORM_PARAM (DBMS_METADATA.SESSION_TRANSFORM, 'PRETTY', true);
    spool c:\Rollback.sql
    select dbms_metadata.GET_DDL('FUNCTION',u.object_name) || '/' c1
    from user_objects u
    where object_type = 'FUNCTION'
    and object_name in ('FN_CALCMASTERDATA_AGE','FUNC_ASSIGNBENEFITSNONFLEX','FUNC_CHECKNEWEMPLOYEE');
    select dbms_metadata.GET_DDL('PACKAGE_SPEC',u.object_name) || '/' c1
    from user_objects u
    where object_type = 'PACKAGE'
    and object_name in('PKGT_BEN_YEAR_DETL','PKGT_BENS_TEST');
    select dbms_metadata.GET_DDL('PACKAGE_BODY',u.object_name) || '/' c1
    from user_objects u
    where object_type = 'PACKAGE'
    and object_name in ('PKGT_BEN_YEAR_DETL','PKGT_BENS_TEST','PKGT_FLEX_INITIALIZATION','PKGT_EMP');
    spool off
    Note: Database Oracle 10 g,
    Client Machine Windows XP from where the script is ran.
    Is there any limitation in amount of data that can be spooled? or is there is any better way to accomplish this task, please help.
    Thanks
    Saami

    set long longer ;-)
    set long 1000000 longchunksize 1000000 linesize 32000 pagesize 0

  • Can't view a report connecting through ODBC(RDO)  to DB with InfoView (CMC)

    Environment :
    Crystal Reports machine :
    OS :
    Windows Server 2008 64-bit
    Crystal Reports Developer 2008 SP0
    Crystal Reports Server 2008
    DB Server:
    Windows Server 2003 32-bit
    SQL Server 2000 SP3
    What is going on:
    All the reports connecting through ODBC (RDO) to the database server work fine in the developer interface (I can preview them) but cannot be accessed if I try to view them in InfoView / CMC ("Please wait while the document is being processed" message box doesn't go away...).
    I have tried both the SQL Server driver 6.00.6001.1800 and SQL Server Native Client 10.0 2007.100.1600.22 with the same results.
    PS All the reports using OLE DB work just fine, I would prefer to have the ODBC option working through the web interface because I have a few hundreds report to change otherwise ...
    Virgil Rucsandescu

    Our solution is a php web application, but this is not relevant (in my opinion), and here it is why:
    The php code should show the reports by using the direct links given by InfoView
    (like http://dev-web:8080/CrystalReports/viewrpt.cwr?id=801&apsuser=user&apspassword=password).
    Actually in this moment these links are looking different because currently we're using C.R. 10 + C.R. Server 10, but we are planning to move to CR 2008 + CR Server 2008.
    So now I am testing how these direct links do work, they're actually working perfectly till now, but only if I connect through OLEDB to the DB server (SQL Server 2000). Any attempt to do it through the 2 ODBC drivers failed until now.
    And I don't want to think about changing the data source hundreds of reports (lot of them having subreports too) ...

  • How to Use SPOOL Command with Bind Variables

    For the Following SPOOL I want the GEN_DATE to be entered by the User at the time of execution of the SQL Script. Is it possible in SPOOL Command.
    set colsep , -- separate columns with a comma
    set pagesize 1000 -- get rid of disturbing ---- between pages
    set heading on -- Print column heading
    set trimspool on -- remove trailing blanks. eliminating the spaces up to eol
    set linesize 700 -- line size should be the sum of the column widths
    spool spool_results.csv
    SELECT *
    FROM GUI_SITE_JOURNAL
    WHERE GENDATE_ BETWEEN '2012-11-01 00:00:00:00000' AND '2012-11-02 00:00:00:00000'* ORDER BY GEN_DATE;
    spool off;
    The reason is to give the ability to user so that he can enter any range without modifying the code of the script.
    Can Any one help me please.
    Edited by: user10903866 on Feb 18, 2013 7:44 PM

    Hi,
    user10903866 wrote:
    For the Following SPOOL I want the GEN_DATE to be entered by the User at the time of execution of the SQL Script. Is it possible in SPOOL Command.Do you want the user input in the SPOOL command, or do you want it in the query?
    set colsep , -- separate columns with a comma
    set pagesize 1000 -- get rid of disturbing ---- between pages
    set heading on -- Print column heading
    set trimspool on -- remove trailing blanks. eliminating the spaces up to eol
    set linesize 700 -- line size should be the sum of the column widths
    spool spool_results.csv
    SELECT *
    FROM GUI_SITE_JOURNAL
    WHERE GENDATE_ BETWEEN '2012-11-01 00:00:00:00000' AND '2012-11-02 00:00:00:00000'* ORDER BY GEN_DATE;What is the data type oif gen_date?
    If it's a string, that's a big mistake. Information about dates belongs in DATE columns.
    If it's a DATE, then don't try to compare it to strings, such as '2012-11-01 00:00:00:00000' .
    spool off;
    The reason is to give the ability to user so that he can enter any range without modifying the code of the script.
    Can Any one help me please.One way to do that is with substitution variables:
    SET     VERIFY  OFF
    ACCEPT  start_gen_date     PROMPT "Starting date (e.g., 2013-02-18 23:00:00.00000): "
    ACCEPT  end_gen_date     PROMPT "Ending date   (e.g., 2013-02-18 23:59:59.99999): "
    SPOOL  spool_results.csv
    SELECT    *
    FROM        gui_site_journal
    WHERE        gen_date  BETWEEN '&start_gen_date'
                    AND     '&end_gen_date'
    ORDER BY  gen_date;
    SPOOL  OFFThere are security considerations. Substitution variables give devious users the power to issue any SQL command, such as DROP TABLE. Users that have SQL*Plus access already have that power, anyway.

  • How to write data to existing file using spool command?

    Hi,
    I am calling a stored procedure from a shell script. This stored procedure is having a CLOB object as an OUT parameter. How to write the data in CLOB object a existing file which is there in my client system. Below is the shell and sql scripts.
    Shell script
    ( echo "hello" ) > /root/file.txt
    sqlplus -s $user/$pass@$tns @/root/proc.sql /root/file.txt << EOF
    EOFSQL script
    set pages 0
    set trimspool off
    set serveroutput off
    set feedback off
    set term off
    set echo off
    variable out CLOB
    define file='&1'
    begin
    pack.proc(:out);
    end;
    spool &file
    select :out from dual;
    spool offThis code writes contents of the OUT variable to file.txt, but my existing data ('hello') is lost. Please help me.
    I figured the it...Use append in the spool command... :)
    Edited by: Balaji on Jul 19, 2012 8:55 PM

    >
    Hi Balaji
    I figured the it...Use append in the spool command... :Please mark the thread as answered as per the FAQ.
    Paul...

  • Crystal Crashes when Creating a Connection to MySQL 5.0 through ODBC

    Post Author: [email protected]
    CA Forum: Data Connectivity and SQL
    I am using a MS Server to run BO Server.  I open Crystal Reports, create a new connection to my MySQL Database through ODBC (that is set up as a System DSN).  After i put in the log in credentials the dang thing crashes... Anyone?

    Now the problem has gone from bad to worse.
    I previously had a connection to my database but just couldn't see the tables.
    Now after I added another user I can't even make a connection. Instead I get an error message that says "An unidentified error has occured"
    My server and database are actually running. I can loginto my database through the MySQL workbench. It says it's running. The apache server also says it's running and if I key in localhost in my internet explorer it says "It works!"
    I have now deleted the new user in MySQL  that I added and now I can't even connect to the database in Dreamweaver.
    Any suggestions?
    Thank you,
    Blain

  • Print Command Through Cloud Printer

    How can i give print command through Cloud Printer

    psingh112 wrote:
    How can i give print command through Cloud Printer
    Hi,
    Unfortunately no you can't. They are all menu/panel/gui driven
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • Heterogeneous Services through ODBC

    There has been some different remarks about if Heterogeneous Services through ODBC will be available in XE. So now when we are getting close to the production release of XE I want to know what the final answer is on this feature

    For the sake of future readers: This works! I just paraphrased this approach to successfully create a dblink to my Sql Server 2000 EE running on MS W2K Svr. It took some time to sort out the details, and then to discover that the test in Tak Tang's excellent writeup did not work for me. I could not do: select table_name from all_tables@mydblink; without getting:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
    [Generic Connectivity Using ODBC]
    ORA-02063: preceding 2 lines from DBLINK_IMS
    However, when I finally woke up and tried: SELECT * FROM <MySmallTable>; I realized that it was actually working.
    I hope this hint is helpful to future readers. Many thanks to TTang for his excellent writeup. Thanks also to Oracle for an excellent product.

Maybe you are looking for