T-SQL Handle OLE DB Warnings

I run this query as dynamic t-sql:
SELECT name from [ANYSQLSERVERNAME].master.sys.servers where server_id =0
I got something like this when server is not available:
OLE DB provider "SQLNCLI11" for linked server "ANYSQLSERVERNAME" returned message "Login timeout expired".
OLE DB provider "SQLNCLI11" for linked server "ANYSQLSERVERNAMET" returned message "A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible.
Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.".
The question is how I can handle this information in t-sql code, for example  insert it into table.

1. Make sure SQL Server Service is running
2. If a named instance, make sure SQL Server browser service is running
3. Make sure SQL Server is configured to allow remote connections
4. Examine the SQL Server error log for messages confirming that SQL is listening on the expected network interfaces and ports
5. Test server connectivity with PING from the client machine
6. Test port connectivity using TELNET or PowerShell to the server and port (from step 4) from the client machine.  For example
a. TELNET <server-name> 1433
b. PowerShell: 1433 | % { echo ((new-object Net.Sockets.TcpClient).Connect("YourServerName",$_)) "server listening on TCP port $_" }
7. Check firewall settings if step 5 or 6 connectivity test fails
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence

Similar Messages

  • Execute SQL Task, OLE DB, Stored Procedure, Returns unexpected value upon second run

    when debugging SSIS, the "Execute SQL Task" runs a stored procedure and returns the expected value. When running the package a second time, the task returns an unexpected value. When running in VS2012 SQL editor, everything operates as expected.
    Please help me debug how to get the stored proc to return the same value every time the SSIS Package is run. thanks!
    Here is the sequence of events and what happens....
    Look for a Positor that matches the Application, Host, and User
    No matching PositorId is found, Creates new Positor row, returns that new PositorId
    Use PositorId to upload some data (Every thing works)
    re-run/debug the ssis pacakge
    Look for a Positor that matches the Application, Host, and User 
    <No clue what is happening>
    Returns -1 (SHOULD BE the same PositorId value returned in #2)
    "Execute SQL Task" Setup: No edits to Result Set nor Expressions
    "Execute SQL Task" Setup: GENERAL
    "Execute SQL Task" Setup: PARAMETER MAPPING
    SP called by "Execute SQL Task"
    CREATE PROCEDURE [posit].[Return_PositorId]
    AS
    BEGIN
    DECLARE @PositorId INT = [posit].[Get_PositorId]();
    IF (@PositorId IS NULL)
    BEGIN
    DECLARE @ProcedureDesc NVARCHAR(257) = OBJECT_SCHEMA_NAME(@@PROCID) + N'.' + OBJECT_NAME(@@PROCID);
    DECLARE @PositorNote NVARCHAR(348) = N'Automatically created by: ' + @ProcedureDesc;
    EXECUTE @PositorId = [posit].[Insert_Positor] @PositorNote;
    END;
    RETURN @PositorId;
    END;
    Supporting SQL Objects:
    CREATE FUNCTION [posit].[Get_PositorId]
    RETURNS INT
    AS
    BEGIN
    DECLARE @PositorId INT = NULL;
    SELECT TOP 1
    @PositorId = [p].[PO_PositorId]
    FROM [posit].[PO_Positor] [p]
    WHERE [p].[PO_PositorApp] = APP_NAME()
    AND [p].[PO_PositorHost] = HOST_NAME()
    AND [p].[PO_PositorUID] = SUSER_ID();
    RETURN @PositorId;
    END;
    GO
    CREATE PROCEDURE [posit].[Insert_Positor]
    @PositorNote NVARCHAR(348) = NULL
    AS
    BEGIN
    DECLARE @ProcedureDesc NVARCHAR(257) = OBJECT_SCHEMA_NAME(@@PROCID) + N'.' + OBJECT_NAME(@@PROCID);
    SET @PositorNote = COALESCE(@PositorNote, N'Automatically created by: ' + @ProcedureDesc);
    DECLARE @Id TABLE
    [Id] INT NOT NULL
    INSERT INTO [posit].[PO_Positor]([PO_PositorNote])
    OUTPUT [INSERTED].[PO_PositorId]
    INTO @Id([Id])
    VALUES(@PositorNote);
    RETURN (SELECT TOP 1 [Id] FROM @Id);
    END;
    GO
    CREATE TABLE [posit].[PO_Positor]
    [PO_PositorId] INT NOT NULL IDENTITY(0, 1),
    [PO_PositorApp] NVARCHAR(128) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorApp] DEFAULT(APP_NAME()),
    CONSTRAINT [CL__PO_Positor_PO_PositorApp] CHECK([PO_PositorApp] <> ''),
    [PO_PositorName] NVARCHAR(256) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorName] DEFAULT(SUSER_SNAME()),
    CONSTRAINT [CL__PO_Positor_PO_PositorName] CHECK([PO_PositorName] <> ''),
    [PO_PositorHost] NVARCHAR(128) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorHost] DEFAULT(HOST_NAME()),
    CONSTRAINT [CL__PO_Positor_PO_PositorHost] CHECK([PO_PositorHost] <> ''),
    [PO_PositorSID] VARBINARY(85) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorSID] DEFAULT(SUSER_SID()),
    [PO_PositorUID] INT NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorUID] DEFAULT(SUSER_ID()),
    [PO_PositorNote] VARCHAR(348) NULL CONSTRAINT [CL__PO_Positor_PO_PositorNote] CHECK([PO_PositorNote] <> ''),
    [PO_tsInserted] DATETIMEOFFSET(7) NOT NULL CONSTRAINT [DF__PO_Positor_PO_tsInserted] DEFAULT(SYSDATETIMEOFFSET()),
    [PO_RowGuid] UNIQUEIDENTIFIER NOT NULL CONSTRAINT [DF__PO_Positor_PO_RowGuid] DEFAULT(NEWSEQUENTIALID()) ROWGUIDCOL,
    CONSTRAINT [UX__PO_Positor_PO_RowGuid] UNIQUE NONCLUSTERED([PO_RowGuid]),
    CONSTRAINT [UK__Positor] UNIQUE CLUSTERED ([PO_PositorApp] ASC, [PO_PositorHost] ASC, [PO_PositorUID] ASC),
    CONSTRAINT [PK__Positor] PRIMARY KEY ([PO_PositorId] ASC)
    GO
    ssd

    The error is in item 7: Returns -1 (SHOULD BE the same PositorId value returned in #2); but no error message is returned or thrown from SSIS.
    The error message indicated referential integrity is not upheld when inserting records. This error message occurs AFTER the Execute SQL Task successfully completes; the E.SQL Task returns -1.  The executed SQL code will not allow values less than 0
    ([PO_PositorId] INT NOT NULL IDENTITY(0, 1),)
    [Platts Valid [41]] Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E2F.
    An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 11.0"  Hresult: 0x80040E2F  Description: "The statement has been terminated.".
    An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 11.0"  Hresult: 0x80040E2F  Description:
    "The INSERT statement conflicted with the FOREIGN KEY constraint "FK__PricingPlatts_Posit_PositorId". The conflict occurred in database "Pricing", table "posit.PO_Positor", column 'PO_PositorId'.".
    The aforementioned FOREIGN KEY constraint is due to the value being returned by the Execute SQL Task.; therefore, the error lies in the value returned by the Execute SQL Task.

  • PL/SQL will compile with warnings but will not run

    I have a pl/sql package that will compile with warnings but no errors but when i try to run it I get an ORA-6508 error telling me there is an error somewhere in the package but I can't find it.
    I have two user schemas that use 2 slightly different versions of the package. I had to make slight code changes to one of the versions and when I made those changes it stopped running. The second version compiles and runs correctly.
    After going through a line by line comparison the first copy was still not running. I copied the second version of the code into the broken schema and commented out the additional lines of code that are not needed in this version.
    When I tried to compile and run this version it still fails with the same error.
    I am using Oracle XE and the databases are small.
    I can send on the code if necessary.
    Can anyone point me in the right direction?
    Thanks
    Susan

    I tried doing what you suggested but there are no errors as it is compiling correctly.
    It is only when I run the package through the debugger that I get the error. I have posted it below
    Connecting to the database Hess S3.
    Executing PL/SQL: ALTER SESSION SET PLSQL_DEBUG=TRUE
    Executing PL/SQL: CALL DBMS_DEBUG_JDWP.CONNECT_TCP( '127.0.0.1', '2086' )
    Debugger accepted connection from database on port 2086.
    Processing 59 classes that have already been prepared...
    Finished processing prepared classes.
    Exception breakpoint occurred at line 10 of BnmSkOTQ3jz5I52ZOxC4QNw.pls.
    $Oracle.EXCEPTION_ORA_6508:
    ORA-04063: package body "SHIPPING.LIFTINGSCHEDULE" has errors
    ORA-06508: PL/SQL: could not find program unit being called: "SHIPPING.LIFTINGSCHEDULE"
    ORA-06512: at line 10
    Process exited.
    Disconnecting from the database Hess S3.
    Debugger disconnected from database.
    Regards
    susan

  • "Cant edit NetworkLayer" when I choose SQL Server OLE DB

    Post Author: d.tiles
    CA Forum: General Feedback
    Hi,I have a problem with the BO Supervisor 6.5: I can't connect to my local Microsoft Sql Server 2003 using OLE DB, but only  with ODBC...The system hangs for a while after I've choosen this option, and then I receive this error message: "Cant edit NetworkLayer" Any idea? Thank you  Daniele Tiles

    Hi,
    Thanks for posting here.
    Connecting to Microsoft Azure SQL Database by using OLE DB or ADO is not supported on SQL Azure.
    Ref: http://www.connectionstrings.com/sql-azure/
    Microsoft does not announce support for OLE DB connections to Azure and there are limitations. Some required OLE DB schema rowsets are not available from an Azure connection, and some properties that identify features in SQL Server are not adjusted to represent
    SQL Azure limitations. For most common connect/query/update tasks it seems to work fine.
    Provider=SQLNCLI11;Password=myPassword;User ID=[username]@[servername];
    Initial Catalog=databasename;Data Source=tcp:[servername].database.windows.net;
    Ref: http://msdn.microsoft.com/en-us/library/azure/ee336245.aspx
    You can also check
    Connectivity Considerations for SQL Server in Azure Virtual Machines
    Hope this helps you.
    Girish Prajwal

  • DB SCHEMA INFO error when connecting to AZURE SQL through OLE DB

    Created a virtual machine in Azure and connected to Azure SQL server. I have been able to access the Azure SQL server through 2014 SQL Server Management Studio. 
    I have connected my program to the Azure SQL through a OLE DB connection. I am able to connect and create a new database through this connection, however when I try to connect to the newly created database, i get the following error: 
     Error creating connection: Not a Market(our product) database: Invalid object name 'db_schema_info'.
    I am not sure what is going on and why this error is showing up. Is it because of the OLE DB connection? The fact that the login mysql.database.windows.net has periods and a login login@mysql? I have had issues with punctuation in the past when connecting
    through OLE DB. Please help me to either find the right code or another work around option. 
    I can connect my program to a local SQL server hosted on the VM the same process as above without any issues. This is not a viable option as I need to connect multiple VMs to the same SQL server. 

    Hi,
    Thanks for posting here.
    Connecting to Microsoft Azure SQL Database by using OLE DB or ADO is not supported on SQL Azure.
    Ref: http://www.connectionstrings.com/sql-azure/
    Microsoft does not announce support for OLE DB connections to Azure and there are limitations. Some required OLE DB schema rowsets are not available from an Azure connection, and some properties that identify features in SQL Server are not adjusted to represent
    SQL Azure limitations. For most common connect/query/update tasks it seems to work fine.
    Provider=SQLNCLI11;Password=myPassword;User ID=[username]@[servername];
    Initial Catalog=databasename;Data Source=tcp:[servername].database.windows.net;
    Ref: http://msdn.microsoft.com/en-us/library/azure/ee336245.aspx
    You can also check
    Connectivity Considerations for SQL Server in Azure Virtual Machines
    Hope this helps you.
    Girish Prajwal

  • How to use SP_transaction_notification in SQL to provide SAP warnings?

    Hi Guys,
    I use SP_transaction_notification in SQL to block certain event and give error messages on sap screens.  Anyone knows how to provide a warning only using the same technique?
    For example if a user doesn't enter customer reference number on a order , can you provide a warning?
    Thanks

    Hi,
    As an addt. info, this link seems unavailable :
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid /53cefa6a-0a01-0010-cd8e-e7c189cb6519
    I've tested it after browsing the link.
    Rgds,

  • Possibility to register Pre-/Post-Procedures for an SQL Template Handler

    I would appreciate to see the possibility to register pre-/post-procedures for an SQL template handler in ORDS 3.0.
    Why:
    We use Oracle VPD/Row-Level-Security to secure data access. Hence a trigger sets a couple of attributes in the database session context at login time which are then used in static RLS predicates to limit which records the user can see/modify.
    With ORDS 3.0 all sessions are opened under the same technical user (e.g. APEX_REST_PUBLIC_USER), hence all users have the same/no attributes in the session context and could see/modify all data.
    To avoid this situation, I need to set the attributes (e.g. the authenticated user) in the database session context before the actual query/plsql handler is executed.
    Also, resetting the session context after the handler is executed would be good.
    This scenario is in line with scenarios 'One Big Application User' and 'Web-based applications' in http://docs.oracle.com/cd/B28359_01/network.111/b28531/vpd.htm#DBSEG98291.
    Different solution approach:
    Kris suggested to write a PL/SQL handler where the pre-procedure is called before the business logic procedure/query. This is ok for me as long as I modify data and only need to return no or little data.
    As soon as I need to return a lot of data (e.g. select c1, c19, c30 from t1), this approach will force me to write a lot of code in the PL/SQL handler in order to marshal the c1, c19 and c30 to JSON and put it in the HTTP response.
    But this is the beauty of ORDS - I can simply define a template, write a GET SQL Handler 'select c1, c19, c30 from t1'  and have the data available as REST service, without writing any code to write JSON marshaled data in the HTTP response.

    I tried to log the request at Oracle REST Data Services (ORDS) but I could only start a new discussion: Possibility to register Pre-/Post-Procedures for an SQL Template Handler
    As I mentioned there, the PL/SQL handler approach works for me as long as I have no or only little data to send back to the client (e.g. put/post/delete succeeded or an error message why the call failed).
    If I need to return a lot of data from the PL/SQL handler I would need to, as far as I understand, to marshal the data to JSON and write it to the response body in the PL/SQL handler.
    I don't want to do the marshaling, because ORDS does it better.
    However, this works for me:
    I write a pipelined stored procedure that takes as input the attributes I need to set in the session context. I then can reference it in the SQL handler:
    select * from table(my_pipelined_function(:USER, ....)
    Now the JSON/HTTP response is created by ORDS again.
    I still needed to code a couple of lines, but it is way better than duplicating the functionality already existing in ORDS.
    With the hooks it would be perfect because I would not have to write any code (apart from the procedure to set the session context attributes), just configure the REST services in ORDS.

  • Crystal report 9 Sql Server 2008 R2 compatability

    Can we use Crystal report version 9 in Sql server 2008 R2 to generate reports in web server.
    Kindly tell us about the compatability of  these two. If there is any support issue between these two kindly mention the same.
    Edited by: Deepan1 on Jun 7, 2011 5:32 PM

    Upgrade to CR 2008 SP 4 is your only option.
    The Platforms file was on the CR CD or it may be in the Documents folder on install. I don't have it installed any more so I can't say exactly where it is. Search your PC for platforms.
    The problem is SQL 2008 uses a new Client engine and MS renamed the DLL do CR isn't aware of it. Using the MDAC version of SQL Server OLE DB Provider may work but it won't be supported if you find errors.
    If you do upgrade to CR 2008 then install the MS SQL Server 2008 Client Tools from the CD or download the MSI from Microsoft and then use the MS SQL Server Native 10 client and it should all work for you.
    Thank you
    Don

  • Restful service unable to insert data using PL/SQL.

    Hi all,
    Am running: AL 2.01 standalone mode on OEL 4.8 in VM box A.
    Oracle database 10.2.0.4 with Apex 4.2.0.00.27 on OEL4.8 in VM box B.
    Able to performed oracle.example.hr Restful services with no problem.
    Unable to insert data using AL 2.0.1 but works on AL 1.1.4.
    which uses the following table (under schema: scott):
    create table json_demo ( title varchar2(20), description varchar2(1000) );
    grant all on json_demo to apex_public_user; and below procedure ( scott's schema ):
    CREATE OR REPLACE
    PROCEDURE post(
        p_url     IN VARCHAR2,
        p_message IN VARCHAR2,
        p_response OUT VARCHAR2)
    IS
      l_end_loop BOOLEAN := false;
      l_http_req utl_http.req;
      l_http_resp utl_http.resp;
      l_buffer CLOB;
      l_data       VARCHAR2(20000); 
      C_USER_AGENT CONSTANT VARCHAR2(4000) := 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)';
    BEGIN
      -- source: http://awads.net/wp/2005/11/30/http-post-from-inside-oracle/
      -- Ask UTL_HTTP not to raise an exception for 4xx and 5xx status codes,
      -- rather than just returning the text of the error page.
      utl_http.set_response_error_check(false);
      -- Begin the post request
      l_http_req := utl_http.begin_request (p_url, 'POST', utl_http.HTTP_VERSION_1_1);
      -- Set the HTTP request headers
      utl_http.set_header(l_http_req, 'User-Agent', C_USER_AGENT);
      utl_http.set_header(l_http_req, 'content-type', 'application/json;charset=UTF-8');
      utl_http.set_header(l_http_req, 'content-length', LENGTH(p_message));
      -- Write the data to the body of the HTTP request
      utl_http.write_text(l_http_req, p_message);
      -- Process the request and get the response.
      l_http_resp := utl_http.get_response (l_http_req);
      dbms_output.put_line ('status code: ' || l_http_resp.status_code);
      dbms_output.put_line ('reason phrase: ' || l_http_resp.reason_phrase);
      LOOP
        EXIT
      WHEN l_end_loop;
        BEGIN
          utl_http.read_line(l_http_resp, l_buffer, true);
          IF(l_buffer IS NOT NULL AND (LENGTH(l_buffer)>0)) THEN
            l_data    := l_data||l_buffer;
          END IF;
        EXCEPTION
        WHEN utl_http.end_of_body THEN
          l_end_loop := true;
        END;
      END LOOP;
      dbms_output.put_line(l_data);
      p_response:= l_data;
      -- Look for client-side error and report it.
      IF (l_http_resp.status_code >= 400) AND (l_http_resp.status_code <= 499) THEN
        dbms_output.put_line('Check the URL.');
        utl_http.end_response(l_http_resp);
        -- Look for server-side error and report it.
      elsif (l_http_resp.status_code >= 500) AND (l_http_resp.status_code <= 599) THEN
        dbms_output.put_line('Check if the Web site is up.');
        utl_http.end_response(l_http_resp);
        RETURN;
      END IF;
      utl_http.end_response (l_http_resp);
    EXCEPTION
    WHEN OTHERS THEN
      dbms_output.put_line (sqlerrm);
      raise;
    END; and executing in sqldeveloper 3.2.20.09 when connecting directly to box B as scott:
    SET serveroutput ON
    DECLARE
      l_url      VARCHAR2(200)   :='http://MY_IP:8585/apex/demo';
      l_json     VARCHAR2(20000) := '{"title":"thetitle","description":"thedescription"}';
      l_response VARCHAR2(30000);
    BEGIN
      post( p_url => l_url, p_message =>l_json, p_response => l_response);
    END;which resulted in :
    anonymous block completed
    status code: 200
    reason phrase: OK
    with data inserted. Setup using 2.0.1
       Workspace : wsdemo
    RESTful Service Module:  demo/
              URI Template:      test
                    Method:  POST
               Source Type:  PL/SQLand executing in sqldeveloper 3.2.20.09 when connecting directly to box B as scott:
    SET serveroutput ON
    DECLARE
      l_url      VARCHAR2(200)   :='http://MY_IP:8585//apex/wsdemo/demo/test';
      l_json     VARCHAR2(20000) := '{"title":"thetitle","description":"thedescription"}';
      l_response VARCHAR2(30000);
    BEGIN
      post( p_url => l_url, p_message =>l_json, p_response => l_response);
    END;which resulted in :
    status code: 500
    reason phrase: Internal Server Error
    Listener's log:
    Request Path passes syntax validation
    Mapping request to database pool: PoolMap [_poolName=apex, _regex=null, _workspaceIdentifier=WSDEMO, _failed=false, _lastUpdate=1364313600000, _template=/wsdemo/, _type=BASE_PATH]
    Applied database connection info
    Attempting to process with PL/SQL Gateway
    Not processed as PL/SQL Gateway request
    Attempting to process as a RESTful Service
    demo/test matches: demo/test score: 0
    Choosing: oracle.dbtools.rt.resource.templates.jdbc.JDBCResourceTemplateDispatcher as current candidate with score: Score [handle=JDBCURITemplate [scopeId=null, templateId=2648625079503782|2797815111031405, uriTemplate=demo/test], score=0, scope=SecurityConfig [constraint=none, realm=NONE, logonConfig=LogonConfig [logonForm=null, logonFailed=null]], originsAllowed=[], corsEnabled=true]
    Determining if request can be dispatched as a Tenanted RESTful Service
    Request path has one path segment, continuing processing
    Tenant Principal already established, cannot dispatch
    Chose oracle.dbtools.rt.resource.templates.jdbc.JDBCResourceTemplateDispatcher as the final candidate with score: Score [handle=JDBCURITemplate [scopeId=null, templateId=2648625079503782|2797815111031405, uriTemplate=demo/test], score=0, scope=SecurityConfig [constraint=none, realm=NONE, logonConfig=LogonConfig [logonForm=null, logonFailed=null]], originsAllowed=[], corsEnabled=true] for: POST demo/test
    demo/test is a public resource
    Using generator: oracle.dbtools.rt.plsql.AnonymousBlockGenerator
    Performing JDBC request as: SCOTT
    Mar 28, 2013 1:29:28 PM oracle.dbtools.common.jdbc.JDBCCallImpl execute
    INFO: Error occurred during execution of: [CALL, begin
    insert into scott.json_demo values(/*in:title*/?,/*in:description*/?);
    end;, [title, in, class oracle.dbtools.common.stmt.UnknownParameterType], [description, in, class oracle.dbtools.common.stmt.UnknownParameterType]]with values: [thetitle, thedescription]
    Mar 28, 2013 1:29:28 PM oracle.dbtools.common.jdbc.JDBCCallImpl execute
    INFO: ORA-06550: line 1, column 6:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
       begin case declare exit for goto if loop mod null pragma
       raise return select update while with <an identifier>
       <a double-quoted delimited-identifier> <a bind variable> <<
       close current delete fetch lock insert open rollback
       savepoint set sql execute commit forall merge pipe
    The symbol "" was ignored.
    ORA-06550: line 2, column 74:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
       begin case declare end exception exit for goto if loop mod
       null pragma raise return select update while with
       <an identifier> <a double-quoted delimited-id
    java.sql.SQLException: ORA-06550: line 1, column 6:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
       begin case declare exit for goto if loop mod null pragma
       raise return select update while with <an identifier>
       <a double-quoted delimited-identifier> <a bind variable> <<
       close current delete fetch lock insert open rollback
       savepoint set sql execute commit forall merge pipe
    The symbol "" was ignored.
    ORA-06550: line 2, column 74:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
       begin case declare end exception exit for goto if loop mod
       null pragma raise return select update while with
       <an identifier> <a double-quoted delimited-id
            at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447)
            at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
            at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879)
            at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:505)
            at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:223)
            at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
            at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:205)
            at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1043)
            at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1336)
            at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3612)
            at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3713)
            at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4755)
            at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1378)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at oracle.ucp.jdbc.proxy.StatementProxyFactory.invoke(StatementProxyFactory.java:242)
            at oracle.ucp.jdbc.proxy.PreparedStatementProxyFactory.invoke(PreparedStatementProxyFactory.java:124)
            at oracle.ucp.jdbc.proxy.CallableStatementProxyFactory.invoke(CallableStatementProxyFactory.java:101)
            at $Proxy46.execute(Unknown Source)
            at oracle.dbtools.common.jdbc.JDBCCallImpl.execute(JDBCCallImpl.java:44)
            at oracle.dbtools.rt.plsql.AnonymousBlockGenerator.generate(AnonymousBlockGenerator.java:176)
            at oracle.dbtools.rt.resource.templates.v2.ResourceTemplatesDispatcher$HttpResourceGenerator.response(ResourceTemplatesDispatcher.java:309)
            at oracle.dbtools.rt.web.RequestDispatchers.dispatch(RequestDispatchers.java:88)
            at oracle.dbtools.rt.web.HttpEndpointBase.restfulServices(HttpEndpointBase.java:412)
            at oracle.dbtools.rt.web.HttpEndpointBase.service(HttpEndpointBase.java:162)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
            at com.sun.grizzly.http.servlet.ServletAdapter$FilterChainImpl.doFilter(ServletAdapter.java:1059)
            at com.sun.grizzly.http.servlet.ServletAdapter$FilterChainImpl.invokeFilterChain(ServletAdapter.java:999)
            at com.sun.grizzly.http.servlet.ServletAdapter.doService(ServletAdapter.java:434)
            at oracle.dbtools.standalone.SecureServletAdapter.doService(SecureServletAdapter.java:65)
            at com.sun.grizzly.http.servlet.ServletAdapter.service(ServletAdapter.java:379)
            at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
            at com.sun.grizzly.tcp.http11.GrizzlyAdapterChain.service(GrizzlyAdapterChain.java:196)
            at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
            at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
            at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
            at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
            at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
            at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
            at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
            at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
            at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
            at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
            at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
            at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
            at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
            at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
            at java.lang.Thread.run(Thread.java:662)
    Error during evaluation of resource template: ORA-06550: line 1, column 6:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
       begin case declare exit for goto if loop mod null pragma
       raise return select update while with <an identifier>
       <a double-quoted delimited-identifier> <a bind variable> <<
       close current delete fetch lock insert open rollback
       savepoint set sql execute commit forall merge pipe
    The symbol "" was ignored.
    ORA-06550: line 2, column 74:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
       begin case declare end exception exit for goto if loop mod
       null pragma raise return select update while with
       <an identifier> <a double-quoted delimited-idPlease advise.
    Regards
    Zack

    Zack.L wrote:
    Hi Andy,
    Sorry, forgot to post the Source that's use by both AL1.1.4 and AL2.0.1.
    Source
    begin
    insert into scott.json_demo values(:title,:description);
    end;
    it's failing during the insert?
    Yes, it failed during insert using AL2.0.1.
    So the above statement produces the following error message:
    The symbol "" was ignored.
    ORA-06550: line 2, column 74:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <an identifier> <a double-quoted delimited-idThis suggests to me that an unprintable character (notice how there is nothing between the double quotes - "") has worked its way into your PL/SQL Handler. Note how the error is reported to be a column 74 on line 2, yet line 2 of the above block should only have 58 characters, so at a pure guess somehow there's extra whitespace on line 2, that is confusing the PL/SQL compiler, I suggest re-typing the PL/SQL handler manually and seeing if that cures the problem.

  • PL/SQL Block with Cursor

    I was trying to create a PL/SQL block where I am trying to call all the SQL Plans and then drop them one by one. Here is how I am doung -
    SET SERVEROUT ON;
    DECLARE
    EXECSTR VARCHAR2(50);
    v_plans_dropped pls_integer;
    CURSOR C1 IS SELECT SQL_HANDLE FROM DBA_SQL_PLAN_BASELINES;
    BEGIN
    FOR I IN C1 LOOP
    EXECSTR := ''''||I.SQL_HANDLE||'''';
    v_plans_dropped:=dbms_spm.drop_sql_plan_baseline(sql_handle=>EXECSTR);
    END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('ERROR while dropping SQL PLAN: ' || SQLCODE || ' : ' || SQLERRM);
    END;
    This is giving me error like - ERROR while dropping SQL PLAN: -38131 : ORA-38131: specified SQL handle
    'SYS_SQL_1470897e7b72c982' does not exist
    Whereas this SQL Plan is there in the baseline - SELECT sql_handle FROM dba_sql_plan_baselines;
    SQL_HANDLE
    SYS_SQL_1470897e7b72c982
    SYS_SQL_75ac336a8071cb06
    SYS_SQL_269cdcd4862f8685
    SYS_SQL_269cdcd4862f8685
    SYS_SQL_0ffdb3bddbe422e2
    SYS_SQL_14d81bbae4a7cc93
    SYS_SQL_5c512b58e7795ba2
    SYS_SQL_33515785e80b75d0
    Above PL/SQL block should be same as like deleting it one by one -
    DECLARE
    v_plans_dropped pls_integer;
    BEGIN
    v_plans_dropped:=dbms_spm.drop_sql_plan_baseline(sql_handle=>'SYS_SQL_1470897e7b72c982');
    END;
    If I run this then it will be sucessul but when I run under a PL/SQL block using cursor then it is giving me error ORA-38131.
    Can you please tell me where I am going wrong here.
    Thanks for your time!

    I have this PL/SQL block -
    DECLARE
    v_plans_dropped pls_integer;
    CURSOR C1 IS SELECT SQL_HANDLE FROM DBA_SQL_PLAN_BASELINES;
    BEGIN
    FOR I IN C1 LOOP
    v_plans_dropped:=dbms_spm.drop_sql_plan_baseline(sql_handle=>I.SQL_HANDLE);
    END LOOP;
    END;
    Requirement - This PL/SQL block should read all the records from DBA_SQL_PLAN_BASELINES table and drop all the plans one by one.
    Problem - It gives me error like this -
    SQL> 2 3 4 5 6 7 8 9 DECLARE
    ERROR at line 1:
    ORA-38131: specified SQL handle SYS_SQL_45c1170505dda9a9 does not exist
    ORA-06512: at "SYS.DBMS_SPM", line 2444
    ORA-06512: at line 6
    Analysis: When I ran it 4 times, it showed me that the remaining records after the pl/sql run was like -
    SQL> SELECT COUNT(*) FROM DBA_SQL_PLAN_BASELINES;
    After First Run -
    COUNT(*)
    33429
    After Second Run -
    COUNT(*)
    33255
    After Third Run -
    COUNT(*)
    33228
    After Fourth Run -
    COUNT(*)
    32988
    So, it deletes records but errors out in between. Is it because the PL/SQL block/cursor is not structured properly?
    Thanks for your advice!

  • Oracle OLE DB 8.1.7.3 entry point kpcddtasg in oracommon8.dll

    I have encountered a problem while installing Oracle OLE DB provider. I have Oracle 8.1.6 server installed.
    After I installed the software the oracle service failed to start and the following error message was given
    "the proceedure entry point kpcddtasg could not be found in the dynamic link library oracommon8.dll"
    Has A.O. else encounered resolved this problem?
    Henry.

    oh ... I forgot to say ..
    when I run query under Enterprise Manager as
    select * from Openquery (db, 'select * from table')
    then it will show me a pop-up message
    "Query Designer encountered a MS Design Tools error:
    ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]OLE DB provider 'OraOLEDB.Oracle' reported an error.
    [Microsoft][ODBC SQL server Driver][SQL Server][OLE/DB provider returned message: ORA-12545: Connect failed because target host or object does not exist]
    And I follow support.microsoft.com/support/complus/mtsandoracle.asp?SD=GN&LN=EN-US&gssnb=1,setting as follow
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSDTC\MTxOCI]
    "OracleXaLib"="oraclient8.dll"
    "OracleSqlLib"="orasql8.dll"
    "OracleOciLib"="oci.dll"

  • How to export sql table data to Excel/PDf using Storedprocedure?

    Hi ,
            I have one table in sqlserver2008R2 that named "Customer" so that table hold the 1 Lac rows. Now I want send this table data to Excel/pdf with Columns using Storedprocedure.
       I have tried this using xp_cmdshell so This is not working for me.
    finally i want to get data in Excel and pdf also.
    Please guide me

    You can actually run an Excel Macro to grab the data from the SQL Server DB.  Below are some samples.
    Sub ADOExcelSQLServer()
    ' Carl SQL Server Connection
    ' FOR THIS CODE TO WORK
    ' In VBE you need to go Tools References and check Microsoft Active X Data Objects 2.x library
    Dim Cn As ADODB.Connection
    Dim Server_Name As String
    Dim Database_Name As String
    Dim User_ID As String
    Dim Password As String
    Dim SQLStr As String
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    Server_Name = "Excel-PC\SQLEXPRESS" ' Enter your server name here
    Database_Name = "Northwind" ' Enter your database name here
    User_ID = "" ' enter your user ID here
    Password = "" ' Enter your password here
    SQLStr = "SELECT * FROM dbo.Orders" ' Enter your SQL here
    Set Cn = New ADODB.Connection
    Cn.Open "Driver={SQL Server};Server=" & Server_Name & ";Database=" & Database_Name & _
    ";Uid=" & User_ID & ";Pwd=" & Password & ";"
    rs.Open SQLStr, Cn, adOpenStatic
    ' Dump to spreadsheet
    With Worksheets("sheet1").Range("a1:z500") ' Enter your sheet name and range here
    .ClearContents
    .CopyFromRecordset rs
    End With
    ' Tidy up
    rs.Close
    Set rs = Nothing
    Cn.Close
    Set Cn = Nothing
    End Sub
    Sub ADOExcelSQLServer()
    Dim Cn As ADODB.Connection
    Dim Server_Name As String
    Dim Database_Name As String
    Dim User_ID As String
    Dim Password As String
    Dim SQLStr As String
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    Server_Name = "LAPTOP\SQL_EXPRESS" ' Enter your server name here
    Database_Name = "Northwind" ' Enter your database name here
    User_ID = "" ' enter your user ID here
    Password = "" ' Enter your password here
    SQLStr = "SELECT * FROM Orders" ' Enter your SQL here
    Set Cn = New ADODB.Connection
    Cn.Open "Driver={SQL Server};Server=" & Server_Name & ";Database=" & Database_Name & _
    ";Uid=" & User_ID & ";Pwd=" & Password & ";"
    rs.Open SQLStr, Cn, adOpenStatic
    With Worksheets("Sheet1").Range("A2:Z500")
    .ClearContents
    .CopyFromRecordset rs
    End With
    rs.Close
    Set rs = Nothing
    Cn.Close
    Set Cn = Nothing
    End Sub
    Sub TestMacro()
    ' Create a connection object.
    Dim cnPubs As ADODB.Connection
    Set cnPubs = New ADODB.Connection
    ' Provide the connection string.
    Dim strConn As String
    'Use the SQL Server OLE DB Provider.
    strConn = "PROVIDER=SQLOLEDB;"
    'Connect to the Pubs database on the local server.
    strConn = strConn & "DATA SOURCE=(local);INITIAL CATALOG=NORTHWIND.MDF;"
    'Use an integrated login.
    strConn = strConn & " INTEGRATED SECURITY=sspi;"
    'Now open the connection.
    cnPubs.Open strConn
    ' Create a recordset object.
    Dim rsPubs As ADODB.Recordset
    Set rsPubs = New ADODB.Recordset
    With rsPubs
    ' Assign the Connection object.
    .ActiveConnection = cnPubs
    ' Extract the required records.
    .Open "SELECT * FROM Categories"
    ' Copy the records into cell A1 on Sheet1.
    Sheet1.Range("A1").CopyFromRecordset rsPubs
    ' Tidy up
    .Close
    End With
    cnPubs.Close
    Set rsPubs = Nothing
    Set cnPubs = Nothing
    End Sub
    Finally, you can run a SProc in SQL Server, from Excel, if you want the SProc to do the export.
    Option Explicit
    Sub Working2()
    'USE [Northwind]
    'GO
    'DECLARE @return_value int
    'EXEC @return_value = [dbo].[TestNewProc]
    ' @ShipCountry = NULL
    'SELECT 'Return Value' = @return_value
    'GO
    Dim con As Connection
    Dim rst As Recordset
    Dim strConn As String
    Set con = New Connection
    strConn = "Provider=SQLOLEDB;"
    strConn = strConn & "Data Source=LAPTOP\SQL_EXPRESS;"
    strConn = strConn & "Initial Catalog=Northwind;"
    strConn = strConn & "Integrated Security=SSPI;"
    con.Open strConn
    'Put a country name in Cell E1
    Set rst = con.Execute("Exec dbo.TestNewProc '" & ActiveSheet.Range("E1").Text & "'")
    'The total count of records is returned to Cell A5
    ActiveSheet.Range("A5").CopyFromRecordset rst
    rst.Close
    con.Close
    End Sub
    Sub Working()
    'USE [Northwind]
    'GO
    'DECLARE @return_value int
    'EXEC @return_value = [dbo].[Ten Most Expensive Products]
    'SELECT 'Return Value' = @return_value
    'GO
    Dim con As Connection
    Dim rst As Recordset
    Set con = New Connection
    con.Open "Provider=SQLOLEDB;Data Source=LAPTOP\SQL_EXPRESS;Initial Catalog=Northwind;Integrated Security=SSPI;"
    Set rst = con.Execute("Exec dbo.[Ten Most Expensive Products]")
    'Results of SProc are returned to Cell A1
    ActiveSheet.Range("A1").CopyFromRecordset rst
    rst.Close
    con.Close
    End Sub
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

  • PL/SQL cursors vs. SQL*plus Select statement

    Hi folks, hope you're doing well,
    Here is a question that kept me wondering:
    Why would I use cursors when i can achieve the same thing with a SQL+ Select statement which is much easier to formulate than a cursor (e.g. you need no declaration, loops etc)?.
    Thanks so much,
    -a

    There is no such thing as a SQL*Plus SELECT statement. The SELECT command is part of the SQL Language - not part of the SQL*Plus (very limited small vocabulary) macro language.
    All SQL SELECTs (from client languages) winds up in the SQL Engine as SQL cursors. A SQL Cursor is basically the:
    - SQL source code
    - SQL "compiled" code (instructions on how to fetch the rows)
    On the client side, client cursors (not to be confused with SQL cursors) are used. A client cursor is created in the client language when it makes SQL calls via the database client driver (called the OCI/Oracle Call Interface for Oracle clients).
    Typically this is what a client does. It makes a connection to the database and gets a database handler in return. The database handler is the "communication channel" from the client to the db. In Oracle, the database handler in the client refers to the Oracle session (for that client) on db server.
    A SQL statement (source code) is used by the client. This can be a SELECT statement you type in at the SQL*Plus command line. It can be a SELECT statement for the PL/SQL cursor command in a stored procedure.
    The client creates a SQL handle for this SQL statement, by calling the Oracle client driver. Note that this SQL handle is a client handle - a client cursor for that SQL statement.
    E.g.
    a) sqlHandle = CreateSQL( databaseHandle, 'SELECT ... FROM ...')
    b) sqlHandle.Parse
    c) sqlHandle.Execute
    After the SQL handle (client cursor) has been executed, the client can fetch rows from it.
    This is what SQL*Plus does automatically for you, without you having to write the code to do it. SQL*Plus CONNECT command create a database connection handle. You enter a SELECT statement and SQL*Plus creates a SQL handle (client cursor), executes it, fetches from it, displays the rows, and closes the SQL handle when done.
    The same applies to PL/SQL. You can use a SELECT statement just like that in PL/SQL. E.g.
    declare
      i integer;
    begin
      select count(*) into i from emp where deptid = 123;
    end;This is called an implicit cursor. PL/SQL creates (just like SQL*Plus) an implicit client cursor. It creates and disposes of that client SQL handle for you - you do not need to do it.
    Or, you can create an explicit cursor. E.g. declare
      cursor c is select count(*) from emp where deptid = 123;
      i integer;
    begin
      open c;
      fetch c into i;
      close c;
    end;The question as to when to use implicit (client) cursors versus explicit (client) cursors depends on your requirements. Do you need to cycle through the results of the SQL? Etc.
    And keep in mind that in either case, the SQL Engine creates a SQL cursor anyway on its side.

  • ORDS 3.0 - How to set VPD Context before executing SQL Template?

    I need to set a couple of attributes in an Oracle Session Context before the SQL/PLSQL template handler is executed, as we rely on Oracle VPD/Row-Level-Security for the data access.
    Is there a hook/functionality in ORDS 3.0 where I can register a PL/SQL (e.g. set_security_context(authenticated_user)) procedure, so this 'set_security_context' procedure is executed before and for each execution of a SQL/PLSQL template handler?

    I tried to log the request at Oracle REST Data Services (ORDS) but I could only start a new discussion: Possibility to register Pre-/Post-Procedures for an SQL Template Handler
    As I mentioned there, the PL/SQL handler approach works for me as long as I have no or only little data to send back to the client (e.g. put/post/delete succeeded or an error message why the call failed).
    If I need to return a lot of data from the PL/SQL handler I would need to, as far as I understand, to marshal the data to JSON and write it to the response body in the PL/SQL handler.
    I don't want to do the marshaling, because ORDS does it better.
    However, this works for me:
    I write a pipelined stored procedure that takes as input the attributes I need to set in the session context. I then can reference it in the SQL handler:
    select * from table(my_pipelined_function(:USER, ....)
    Now the JSON/HTTP response is created by ORDS again.
    I still needed to code a couple of lines, but it is way better than duplicating the functionality already existing in ORDS.
    With the hooks it would be perfect because I would not have to write any code (apart from the procedure to set the session context attributes), just configure the REST services in ORDS.

  • OLE automation

    Auteur : Corinne Ribeyre-F085785 &agrave; _CARPO04
    I need help with OLE Automation implementation (Excel,
    CrystalReport,Word ...)
    I generate Excel project with OleGen but no documentation exist for
    this project. So I made severals tests (with Excel).
    I can do (see examples):
    - open a file
    - open Excel Application
    - open WorkBook, WoorkSheet
    - Write and Read a Cell (but I am not sure it's the more efficient
    method to do this)
    - run a macro with parameters
    But, I CAN'T do:
    - run a command with parameters like PivotTableWizard (tableau croise
    dynamique)
    Does a Documentation exist about Forte project generated by Olegen
    Tool (Excel..) ?
    Does a Documentation exist about Forte/Crystal Report ?
    Thank You for all answers and examples,
    Corinne
    Examples
    -- Open Excel
    theApplication : Excel . Application = New;
    theApplication . CreateUsingProgID(NX('excel.application'));
    --- Excel Visible /not visible
    theApplication . Visible = VariantBoolean(Value = False);
    -- Get all WorkBooks of Excel Application
    theWorkBooks : Excel . WorkBooks = New;
    theWorkBooks . SetDispatchObject(theApplication . Workbooks());
    -- Open File.xls (added with previous Application)
    theWorkBooks . Open (VariantString(Value = 'C:\\temp\\File.xls'));
    -- Link file with a WorkBook
    aWorkBook : Excel . WorkBook = New;
    aWorkBook . SetDispatchObject(theApplication .
    Workbooks(VariantString(value='File.xls')));
    -- Link a Folder (Sheet1) from File with WorkSheet
    aWorksheet : Excel . Worksheet = New;
    aWorksheet . SetDispatchObject(aWorkBook .
    Worksheets(VariantString(value='Sheet1')));
    aRange : Excel . Range = New;
    -- Fill Cell (1,1) with 'Article'
    TitreArt : VariantString = VariantString(Value = 'Article');
    aRange . SetDispatchObject(aWorksheet . Cells(VariantInteger(Value =
    1), VariantInteger(Value = 1)));
    aRange . Value = titreArt;
    -- Fill Cell (1,2) with 'Date'
    TitreDate : VariantString = VariantString(Value = 'Date');
    aRange . SetDispatchObject(aWorksheet . Cells(VariantInteger(Value =
    1), VariantInteger(Value = 2)));
    aRange . Value = TitreDate;
    -- Run a Macro
    theApplication . Run(VariantString(Value = NX('MacroName')),
    VariantInteger(Value = 65),
    VariantInteger(Value = 7));
    -- Page Setup
    -- Link a Folder (Sheet2) from File with WorkSheet
    aWorksheet . SetDispatchObject(aWorkBook .
    Worksheets(VariantString(value='Sheet2')));
    aPageSetup : Excel . PageSetUp = New;
    aPageSetup . SetDispatchObject(aWorksheet.PageSetup);
    aPageSetup . PrintTitleRows = VariantString (Value = '');
    aPageSetup . PrintTitleColumns = VariantString (Value = '');
    aPageSetup . LeftHeader = VariantString (Value = 'MICKEY');
    aPageSetup . CenterHeader = VariantString (Value = 'MOUSE');
    aPageSetup . RightHeader = VariantString (Value = '&J &H'); --
    Attention J H en Excel Fran&ccedil;ais; D T en Anglais
    aPageSetup . LeftFooter = VariantString (Value = '');
    aPageSetup . CenterFooter = VariantString (Value = 'DISNEYLAND
    PARIS');
    aPageSetup . RightFooter = VariantString (Value = '&P / &T');
    aPageSetup . LeftMargin = VariantInteger(Value = 1);
    aPageSetup . RightMargin = VariantInteger(Value = 1);
    aPageSetup . TopMargin = VariantInteger(Value = 1);
    aPageSetup . BottomMargin = VariantInteger(Value = 1);
    aPageSetup . HeaderMargin = VariantDouble(Value = 0.5);
    aPageSetup . FooterMargin = VariantDouble(Value = 0.5);
    aPageSetup . PrintHeadings = VariantBoolean(Value = False);
    aPageSetup . PrintGridlines = VariantBoolean(Value = False);
    aPageSetup . PrintNotes = VariantBoolean(Value = False);
    aPageSetup . CenterHorizontally = VariantBoolean(Value = True);
    aPageSetup . CenterVertically = VariantBoolean(Value = True);
    aPageSetup . Orientation = VariantInteger(Value = 2); --
    (1:xlPortrait, 2:xlLandscape)
    aPageSetup . Draft = VariantBoolean(Value = False);
    aPageSetup . PaperSize = VariantInteger(Value = 9);
    -- (8: xlPaperA3, 9: xlPaperA4)
    aPageSetup . FirstPageNumber = VariantInteger(Value = -4105);
    -- xlAutomatic
    aPageSetup . Order = VariantInteger(Value = 1);
    -- xlDownThenOver
    aPageSetup . BlackAndWhite = VariantBoolean(Value = True);
    aPageSetup . Zoom = VariantBoolean(Value = False);
    aPageSetup . FitToPagesWide = VariantInteger(Value = 1);
    aPageSetup . FitToPagesTall = VariantInteger(Value = 1);
    -- Save File
    aFilename : VariantString = VariantString(Value =
    NX('C:/Temp/Essai.xls'));
    aWorkBook . SaveAS(FileName = aFilename);
    -- Print File
    PrintOptions : PrintOptionsDesc;
    PrintOptions = Self . Window . WindowSystem . DefaultPrintOptions .
    Clone (Deep = True);
    If (self.Window.PrintDialog (PrintOptions= PrintOptions,
    ShowSetupDialog = TRUE,
    ShowJobDialog = FALSE) = BV_OK) Then
    aWorksheet . PrintOut();
    End If;
    -- Unlink
    aWorkBook . RunAutoMacros(VariantInteger(Value = 2)); --xlAutoFermer 
    -- Cf doc VBA
    aWorkBook . Close(variantboolean (Value = False));
    TheApplication . Quit();
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    Hi all, forget this silly question...
    I studied a little bit and learned how to handle OLEs properly...
    Many thanks

Maybe you are looking for