"Log on failed" with ODBC and Stored Procedure

I am in the process of porting our application from CR10 to CR.NET and am having some trouble setting the log on info.
I have a report that was designed against a stored procedure and a development database.  The connection at design time is ODBC to a SQL Server.  At runtime I want to set the database and logon credentials to that of the production server, set the stored procedure parameters, and then display the report.  No matter what I do always get "Log on failed" error.
After having considerable trouble with ApplyLogOnInfo on the tables where it seemed to not actually apply my changes, I finally found code which appeared to work elsewhere on this forum.  So this is the code that I have now, but the call to VerifyDatabase on the report always throws the Log on Failed exception:-
void SomeClass::SetLogOnInfoForReportRecursively(ReportDocument^ ReportObj)
        CrystalDecisions::Shared::TableLogOnInfo^ l_pTableLogOnInfoToSet = gcnew CrystalDecisions::Shared::TableLogOnInfo();
        CrystalDecisions::Shared::ConnectionInfo^ l_pConnectionInfo = l_pTableLogOnInfoToSet->ConnectionInfo;
        l_pConnectionInfo->AllowCustomConnection = true;
        l_pConnectionInfo->ServerName = gcnew String(m_strServerName);
        l_pConnectionInfo->DatabaseName = gcnew String(m_strDatabaseName);
        l_pConnectionInfo->UserID = gcnew String(m_strUserID);
        l_pConnectionInfo->Password = gcnew String(m_strPassword);
        DbConnectionAttributes^ l_pConnectionAttributes = gcnew DbConnectionAttributes();
        l_pConnectionAttributes->Collection->Set("Database DLL", "crdb_odbc.dll");
        l_pConnectionAttributes->Collection->Set("QE_DatabaseName", String::Empty);
        l_pConnectionAttributes->Collection->Set("QE_DatabaseType", "ODBC (RDO)");
        l_pConnectionAttributes->Collection->Set("QE_SQLDB", true);
        l_pConnectionAttributes->Collection->Set("SSO Enabled", false);
        l_pConnectionInfo->Attributes = l_pConnectionAttributes;
        //main connection
        ReportObj->SetDatabaseLogon(l_pConnectionInfo->UserID, l_pConnectionInfo->Password, l_pConnectionInfo->ServerName, l_pConnectionInfo->DatabaseName, false);
        //other connections
        for each(CrystalDecisions::Shared::IConnectionInfo^ pConnection in ReportObj->DataSourceConnections)
            pConnection->SetConnection(l_pConnectionInfo->ServerName, l_pConnectionInfo->DatabaseName, l_pConnectionInfo->UserID, l_pConnectionInfo->Password);
            //pConnection->SetLogon(l_pConnectionInfo->UserID, l_pConnectionInfo->Password);
            pConnection->LogonProperties->Set("Data Source", l_pConnectionInfo->ServerName);
            pConnection->LogonProperties->Set("Initial Catalog", l_pConnectionInfo->DatabaseName);
        // Now we need to set the log on info for any subreports otherwise they will always look for the datasource they were set up with.
        if (!ReportObj->IsSubreport)
        for each (ReportDocument^ l_pSubReport in ReportObj->Subreports)
             SetLogOnInfoForReportRecursively(l_pSubReport);
        for each (CrystalDecisions::CrystalReports::Engine::Table^ l_pTable in ReportObj->Database->Tables)
            TableLogOnInfo^ l_pCurentTableLogOnInfo = l_pTable->LogOnInfo;
            l_pCurentTableLogOnInfo->ConnectionInfo = l_pTableLogOnInfoToSet->ConnectionInfo;
            l_pTable->ApplyLogOnInfo(l_pCurentTableLogOnInfo);
            if (!l_pTable->TestConnectivity())
               // handle error situation
... then the calling code
SetLogOnInfoForReportRecursively( pReportObj );
// l_Parameters contains the stored proc param name/values pairs to set at runtime
for each (KeyValuePair<String^, String^> param in l_Parameters)
        pReportObj->SetParameterValue(param.Key, param.Value);
pReportObj->VerifyDatabase();
which then fails.  Can anyone see what I am doing wrong?
Thanks

Hi Paul,
Are you using CR for VS SP 13? If not you can get it here:
SAP Crystal Reports, developer version for Microsoft Visual Studio: Updates & Runtime Downloads
And MS SQL Server does not use a blank database name:
l_pConnectionAttributes->Collection->Set("QE_DatabaseName", String::Empty);
Set it to a database used in the report.
And you don't need to call .Verify, unless the reports are not up to date, which is not recommended, you should be using ReplaceConnection. ( Search for this, KBA's and posts on how to use it )
So rather that call .Verify try CRTable.TestConnectivity();
If that fails then you know your log on failed also.
Curious, if you try to preview the report it should prompt for log on info, if the Server and Database names are grayed out ( not editable ) then CR can't find the client either.
And MS recommends using the client that matches the version of SQL Server, So if 2005 and less you can use the MDAC SQL Client driver, for MS 2008 then use the SQL Native 10 or above.
Don

Similar Messages

  • DAC task with Informatica mapping and stored procedure (very slow)

    Hello,
    We have a DAC task that launch an Informatica Workflow with a simple query and stored procedure, like this:
    SQL QUERY
    ==========================
    SELECT
    W_ACTIVITY_F.ROW_WID,
    W_AGREE_D.AGREE_NUM,
    W_PRODUCT_D.ATTRIB_51,
    W_SRVREQ_D.ATTRIB_05,
    W_ORG_DH.TOP_LVL_NAME,
    W_ORG_D.ATTRIB_06,
    W_PRODUCT_GROUPS_D.PRODUCT_LINE,
    W_PRODUCT_D.PROD_NAME
    FROM
    W_AGREE_D,
    W_SRVREQ_F,
    W_ACTIVITY_F,
    W_PRODUCT_D LEFT OUTER JOIN W_PRODUCT_GROUPS_D ON W_PRODUCT_D.PR_PROD_LN = W_PRODUCT_GROUPS_D.PRODUCT_LINE,
    W_ORG_D,
    W_SRVREQ_D,
    W_ORG_DH
    WHERE
    W_SRVREQ_F.AGREEMENT_WID = W_AGREE_D.ROW_WID AND
    W_SRVREQ_F.SR_WID = W_ACTIVITY_F.SR_WID AND
    W_SRVREQ_F.PROD_WID = W_PRODUCT_D.ROW_WID AND
    W_SRVREQ_F.ACCNT_WID = W_ORG_D.ROW_WID AND
    W_SRVREQ_F.SR_WID = W_SRVREQ_D.ROW_WID AND
    W_ORG_D.ROW_WID = W_ORG_DH.ROW_WID
    STORED PROCEDURE
    ===========================
    ConvSubProy(W_AGREE_D.AGREE_NUM,
    W_PRODUCT_D.ATTRIB_51,
    W_SRVREQ_D.ATTRIB_05,
    W_ORG_DH.TOP_LVL_NAME,
    W_ORG_D.ATTRIB_06,
    W_PRODUCT_GROUPS_D.PRODUCT_LINE,
    W_PRODUCT_D.PROD_NAME)
    The mapping is very simple:
    Source Qualifier -> Stored procedure -> Update strategy (only two ports: ROW_WID and custom column) -> Target Table
    When I launch the DAC Execution Plan the corresponding task take much time (40 minuts). But when I launch the corresponding Workflow from Informatica PowerCenter Workflow Manager this only take 50 seconds... when I see the log session for the task I can see that much time is spent on the time of the updates. For example, when DAC is running the writer updates 10000 records every 6/7 minuts, but when Workflow Manager is running thw writer updates 10000 records every 8/9 seconds.
    So, what happens (in the DAC) to that so much time difference? Is there a way to reduce the execution time when the task is launched from DAC?
    Thanks
    Best Regards
    Benjamin Tey

    Have you tried using bulk load type?
    In Workflow Manager can you open the associated task, navigate to the mapping tab and seled the target table.
    What is the value for "Target load type" and which of the following boxes are checked: Insert, Update as Update, Update as Insert, Update else Insert, Delete?

  • SQL Server 2008 R2 - Report Builder 3.0 - timeout using shared data source and stored procedure

    I select the shared datasource from the data source propeties dialog, test the connection and everything is good.
    I add a dataset by selecting "use a dataset embedded in my report" option within the Dataset properties dialog.
    I select the newly added data source, click the "Stored procedure" query type and drop down the list box and select my intended stored procedure.
    the timeout for the dataset is "0" seconds.
    I click the "OK" button and I'm presented with the parameters to the stored procedure.
    I enter valid data for the parameters and click the "OK" button.
    I then get the following error message after 30 seconds:
    The problem is, all of the timeouts, that I'm aware of, have values of zero (no timeout) or high enough values that 30 seconds isn't even close to the timeout.
    I think the smallest timeout we have is 120 seconds.
    I have searched this site and many others and the solutions all involve altering the stored procedure to get the fields into report builder and then revert the stored procedure back to its original form.
    To me, this is NOT a solution.  
    I have too many stored procedures that need to be brought into Report Builder.
    I need a real solution.
    Thank you for you time, Tim Caldwell.
    Timothy E Caldwell

    I don't mean to be rude, but really, check to see if the stored procedure can return data rows???
    Maybe I'm not being clear enough.
    The stored procedure runs perfectly fine.
    it runs perfectly fine in the production environment and the test environment.
    I can access the stored procedure in several ways and have it return correct data.
    I can even trick report builder into creating a dataset with parameters and run the stored procedure that way.
    What I cannot do, is to get report builder to not timeout after 30 seconds on the initial creation of a dataset with a Query type of stored procedure.
    I have seen this issues posted again and again and again on may different sites and the "solution" is to simplifiy the stored procedure by creating a stored procedure that has a create table and a select in the stored procedure and that's it.  After
    report builder creates the dataset the developer then has to replace the simplified stored procedure with the actual stored procedure and everything works fine after that.
    HOWEVER, having to go through this process for 70 or more stored procedures is ridiculous.
    It would appear that there is something within report builder itself that is causing this issue.
    The SQL Script included is an example of a stored procedure that will not create fields create a dataset with fields and parameters in Report Builder 3.0:
    USE [CRUM_IT]
    GO
    /****** Object: StoredProcedure [dbo].[COGNOS_Level5ScriptSP] Script Date: 11/17/2014 08:02:26 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER procedure [dbo].[COGNOS_Level5ScriptSP]
    @CompanyCode varchar(8) = null,
    @GetSiblings varchar(1) = 'N'
    as
    Begin
    -- get emergency contact info
    select *
    into #tmp_Contacts
    from
    (select
    ConEEID,
    con.connamelast as [Emer Contact Last Name],
    con.connamefirst as [Emer Contact First Name],
    con.connamemiddle as [Emer Contact Middle Initial/Name]--,
    ,ROW_NUMBER() over (Partition by ConEEID order by ConNameLast)as rn
    ,ISNULL(
    case when con.conphonepreferred = 'H'
    then '(' + substring(con.conphonehomenumber, 1, 3) + ')' + substring(con.conphonehomenumber, 4, 3) + '-' + substring(con.conphonehomenumber, 7, 4)
    else '(' + substring(con.conphoneothernumber , 1, 3) + ')' + substring(con.conphoneothernumber , 4, 3) + '-' + substring(con.conphoneothernumber , 7, 4)
    end,
    ) as [Emergency Phone]
    from [ultiprosqlprod1].[ultipro_crum].dbo.Contacts con
    where con.ConIsEmergencyContact='y'
    and con.ConIsActive='y'
    ) A
    where A.rn = 1
    CREATE TABLE #tmp_CompanyCodes (CompanyCode varchar(8))
    If @GetSiblings = 'Y'
    Begin
    INSERT INTO #tmp_CompanyCodes (CompanyCode)
    EXEC [z_GetClientNumbers_For_ParentOrg_By_ClientNumber] @CompanyCode
    End
    INSERT INTO #tmp_CompanyCodes
    values (@CompanyCode)
    select *
    into #tmp_Company
    from [ultiprosqlprod1].[ultipro_crum].dbo.Company
    where cmpcompanycode in (select CompanyCode from #tmp_CompanyCodes)
    select distinct
    cmpcompanycode as [Client ID],
    CmpCompanyDBAName as [Client Name],
    eec.eecEmplStatus AS [Employment Status],
    eec.eecEmpNo AS [Employee Num],
    rtrim(eep.eepNameLast) AS [Last Name],
    rtrim(eep.eepNameFirst) AS [First Name],
    isnull(rtrim(ltrim(eep.eepNameMiddle)), '') AS [Middle Initial/Name],
    rtrim(eep.eepAddressLine1) AS [Address Line 1],
    isnull(rtrim(eep.eepAddressLine2), '') AS [Address Line 2],
    eep.eepAddressCity AS [City],
    eep.eepAddressState AS [State],
    CASE
    WHEN len(eep.eepAddressZipCode) > 5 and charindex(eep.eepAddressZipCode, '-', 1) = 0
    THEN substring(eep.eepAddressZipCode, 1, 5)
    ELSE rtrim(eep.eepAddressZipCode)
    END AS [Zip code],
    CASE
    WHEN len(eep.eepAddressZipCode) > 5 and charindex(eep.eepAddressZipCode, '-', 1) = 0
    THEN substring(eep.eepAddressZipCode, 6, 4)
    WHEN len(eep.eepAddressZipCode) > 5 and charindex(eep.eepAddressZipCode, '-', 1) > 0
    THEN substring(eep.eepAddressZipCode, charindex(eep.eepAddressZipCode, '-', 1) + 1, 4)
    WHEN len(eep.eepAddressZipCode) <= 5
    THEN ''
    END AS [ZIP + 4],
    substring(eep.eepSSN, 1, 3) + '-' + substring(eep.eepSSN, 4, 2) + '-' + substring(eep.eepSSN, 6, 4) AS [SSN],
    isnull(convert(VARCHAR(10), eep.eepDateOfBirth, 101), '') AS [Date Of Birth],
    eetFED.TAXCODE AS [FED Tax Code],
    eetFED.FILINGSTATUS AS [Fed Filing Status],
    eetFED.EXEMPTIONS AS [Fed Exemption Allowance],
    eetFED.ADDITIONAL AS [Additional Fed Withholding],
    eetSIT.TAXCODE AS [SIT Tax Code],
    eetSIT.FILINGSTATUS AS [State Filing Status],
    eetSIT.EXEMPTIONS AS [State Exemption Allowance],
    eetSIT.ADDITIONAL AS [Additional State Withholding],
    isnull('(' + substring(eep.eepPhoneHomeNumber, 1, 3) + ')' + substring(eep.eepPhoneHomeNumber, 4, 3) + '-' + substring(eep.eepPhoneHomeNumber, 7, 4), '') AS [Home Phone],
    isnull((SELECT cod.codDesc
    FROM [ultiprosqlprod1].[ultipro_crum].dbo.Codes cod WITH (NOLOCK)
    WHERE cod.codCode = eep.eepEthnicID
    AND cod.codDosTable = 'ETHNICCODE'), '') AS [Race-Origin], --eep.eepEthnicID AS [Race-Origin],
    eep.eepGender AS [Gender],
    isnull(convert(VARCHAR(10), eec.eecDateOfOriginalHire, 101), '') AS [Original Hire Date],
    isnull(convert(VARCHAR(10), eec.eecDateOfSeniority, 101), '') AS [Seniority Date],
    isnull(convert(VARCHAR(10), eec.eecDateOfTermination, 101), '') AS [Termination Date],
    isnull(eecTermType,'') as [Termination Type],
    isnull(TchDesc, '') as [Termination Reason],
    rtrim(eec.eecJobCode) AS [WC Code],
    isnull(eec.eecJobTitle, '') AS [Job Title],
    pgr.pgrPayFrequency AS [Pay Frequency],
    eec.eecFullTimeOrPartTime AS [Full/Part Time],
    eec.eecSalaryOrHourly AS [Pay Type],
    isnull(convert(MONEY, eec.eecHourlyPayRate), 0.00) AS [Hourly Rate],
    isnull(eec.eecAnnSalary, 0.00) AS [Annual Salary],
    [YTD Hours],
    isnull(eep.eepNameFormer, '') AS [Maiden Name],
    eec.eecLocation AS [Location ID],
    rtrim(eec.eecOrgLvl1) AS [Department ID],
    eec.eecorglvl2 AS [Cost Item],
    eec.eecorglvl3 as [Client Project],
    eec.eecPayGroup as [Pay Group],
    isnull(eepAddressEMail,' ') as [Email Address],
    isNull(BankName1,' ') as PrimaryBank,
    isNull(BankRoute1,' ') as PrimaryRouteNum,
    isNull(Account1,' ') as PrimaryAccount,
    isNull(AcctType1,' ') as PrimaryAcctType,
    isNull(DepositRule1,' ') as PrimaryDepositRule,
    isNull(BankName2,' ') as SecondaryBank,
    isNull(BankRoute2,' ') as SecondaryRouteNum,
    isNull(Account2,' ') as SecondaryAccount,
    isNull(AcctType2,' ') as SecondaryAcctType,
    isNull(DepositRule2,' ') as SecondaryDepositRule,
    isNull(
    CASE
    WHEN DepositRule2 = 'D'
    THEN '$' + convert(varchar, cast(EddAmtOrPct2 AS decimal(10,2)))
    WHEN DepositRule2 = 'P'
    THEN convert(varchar, cast((EddAmtOrPct2*100) AS decimal(10,0))) + '%'
    ELSE null
    END,' ') as SecondaryDepositAmount,
    isNull(BankName3,' ') as ThirdBank,
    isNull(BankRoute3,' ') as ThirdRouteNum,
    isNull(Account3,' ') as ThirdAccount,
    isNull(AcctType3,' ') as ThirdAcctType,
    isNull(DepositRule3,' ') as ThirdDepositRule,
    isNull(
    CASE
    WHEN DepositRule3 = 'D'
    THEN '$' + convert(varchar, cast(EddAmtOrPct3 AS decimal(10,2)))
    WHEN DepositRule3 = 'P'
    THEN convert(varchar, cast((EddAmtOrPct3*100) AS decimal(10,0))) + '%'
    ELSE null
    END,' ') as ThirdDepositAmount,
    Supervisor,
    eec.eecEEID AS [Employee EEID],
    eec.EecJobCode As [Job Code],
    isnull(eec.EecTimeclockID,' ') As [Time Clock ID],
    con.[Emer Contact Last Name],
    con.[Emer Contact First Name],
    con.[Emer Contact Middle Initial/Name],
    con.[Emergency Phone]
    from [ultiprosqlprod1].[ultipro_crum].dbo.empPers eep WITH (NOLOCK)
    inner join [ultiprosqlprod1].[ultipro_crum].dbo.empComp eec WITH (NOLOCK)
    ON eep.eepEEID = eec.eecEEID
    inner join #tmp_Company cmp WITH (NOLOCK)
    ON eec.eecCOID = cmp.cmpCOID
    inner join [ultiprosqlprod1].[ultipro_crum].dbo.PayGroup pgr WITH (NOLOCK)
    ON eec.eecPayGroup = pgr.pgrPayGroup
    left outer join [ultiprosqlprod1].[ultipro_crum].dbo.TrmReasn
    on tchCode = eecTermReason
    left join (select CAST(sum(isnull(eee.eeeYTDHrs,0.00))AS DECIMAL(18,2)) as [YTD Hours],
    eeeEEID,
    eeeCOID
    from [ultiprosqlprod1].[ultipro_crum].dbo.EmpEarn eee with (NOLOCK)
    group by eeeCOID,eeeEEID)eee
    on eec.eecEEID = eee.eeeEEID
    and eec.eecCOID = eee.eeeCOID
    left join (SELECT eetCOID AS COID,
    eetEEID AS EEID,
    eetTaxCode AS TAXCODE,
    eetFilingStatus AS FILINGSTATUS,
    eetExemptions AS EXEMPTIONS,
    eetExtraTaxDollars AS ADDITIONAL
    FROM [ultiprosqlprod1].[ultipro_crum].dbo.empTax WITH (NOLOCK)
    WHERE eetTaxCode = 'USFIT'
    )eetFED
    ON eec.eecCOID = eetFED.COID
    and eec.eecEEID = eetFED.EEID
    left join (SELECT eetCOID AS COID,
    eetEEID AS EEID,
    eetTaxCode AS TAXCODE,
    eetFilingStatus AS FILINGSTATUS,
    eetExemptions AS EXEMPTIONS,
    eetExtraTaxDollars AS ADDITIONAL
    FROM [ultiprosqlprod1].[ultipro_crum].dbo.empTax WITH (NOLOCK)
    WHERE eetTaxCode like '%SIT'
    AND eetIsWorkInTaxCode = 'Y'
    )eetSIT
    ON eec.eecCOID = eetSIT.COID
    and eec.eecEEID = eetSIT.EEID
    left outer join (SELECT eddCOID,
    eddEEID,
    eddEEBankName BankName1,
    eddEEBankRoute BankRoute1,
    eddAcct Account1,
    EddAcctType AcctType1,
    EddDepositRule DepositRule1,
    EddAmtOrPct EddAmtOrPct1
    FROM [ultiprosqlprod1].[ultipro_crum].dbo.EmpDirDp WITH (NOLOCK)
    WHERE eddSequence = '99')edd
    ON eec.eecCOID = edd.eddCOID
    and eec.eecEEID = edd.eddEEID
    left outer join (SELECT eddCOID,
    eddEEID,
    eddEEBankName BankName2,
    eddEEBankRoute BankRoute2,
    eddAcct Account2,
    EddAcctType AcctType2,
    EddDepositRule DepositRule2,
    EddAmtOrPct EddAmtOrPct2
    FROM [ultiprosqlprod1].[ultipro_crum].dbo.EmpDirDp WITH (NOLOCK)
    WHERE eddSequence = '01')edd2
    ON eec.eecCOID = edd2.eddCOID
    and eec.eecEEID = edd2.eddEEID
    left outer join (SELECT eddCOID,
    eddEEID,
    eddEEBankName BankName3,
    eddEEBankRoute BankRoute3,
    eddAcct Account3,
    EddAcctType AcctType3,
    EddDepositRule DepositRule3,
    EddAmtOrPct EddAmtOrPct3
    FROM [ultiprosqlprod1].[ultipro_crum].dbo.EmpDirDp WITH (NOLOCK)
    WHERE eddSequence = '02')edd3
    ON eec.eecCOID = edd3.eddCOID
    and eec.eecEEID = edd3.eddEEID
    left outer join (SELECT eecCOID,
    eecEEID,
    rtrim(eepNameLast) + ', ' +
    rtrim(eepNameFirst) + ' ' +
    isnull(rtrim(ltrim(eepNameMiddle)), '') AS [Supervisor]
    FROM [ultiprosqlprod1].[ultipro_crum].dbo.EmpComp WITH (NOLOCK)
    join [ultiprosqlprod1].[ultipro_crum].dbo.EmpPers with (NoLock)
    on eeceeid = eepeeid)eec2
    ON eec.eecSupervisorID = eec2.eecEEID
    left outer join #tmp_Contacts con
    on eep.eepEEID = con.ConEEID
    order by [Client ID],
    [Last Name],
    [First Name]
    drop table #tmp_Contacts
    END
    Timothy E Caldwell

  • EJB 3.0 Persistence API and Stored Procedures

    Does the EJB 3.0 Persistence API in any way prescribe or facilitate the use of Stored Procedure calls? Given the recent popularity of using (database) server APIs consisting of Stored Procedures that are addressed by ORM frameworks for performing the DML operations and of course the general usefulness of stored procedures for specific data related operations, there definitely is a need for clarity on using the straightforward Persistence operations in combination with calls to Stored Procedures. Can we use the Native Query for executing CallableStatements? Can we get to a Connection instance from the EntityManager? Can we easily use the results from a Stored Procedure invocation to refresh our Domain Objects - or is that all application logic in which the EntityManager cannot help us?
    If the spec does not help us at this point, do you know how TopLink will deal with this topic?
    Thanks for any help you can give me!
    Best regards,
    Lucas Jellema

    I'm am also interested in a response to this post. I've just upgraded to JDeveloper 10.1.3.1 and am interested in making calls to stored procedures.
    I've found examples of just creating my own session beans but it seems I would have to hard code the datasource name. Does anyone know if I can get around this using the entity manager supplied by the tool?
    thanks,
    Dan

  • Multithreading and stored procedures

    Hi,
    Does anyone know of any problems with calling a stored procedure that returns a reference cursor in a multithreading application? In other words, if I have multiple threads calling the same stored procedure is the reference cursor guarenteed to be unique to each thread/thread safe?
    Thanks in advance,
    Glenn

    That should work fine and each call will get a separate ref cursor as long as the app is written properly and is managing it's threads anbd handles properly. Are you seeing some behaviour that suggests this is not the case?
    Chris

  • Database updation using XML and stored Procedure?

    Hello,
    I want to perform updation in multiple tables using XML files.Please suggest can I do updation using xml and stored procedure.
    If yes then which is more efficient and takes less time.
    1.Updation using xml files only
    2.Updation using xml files with stored procedure.
    3.Stored procedure alone.
    If direct xml and stored procedure communication is possible.then please write how.
    Thanks in advance for any help.

    Here's a sample. The next code drop of the XSQL Servlet will make the easy-to-do from within XSQL Pages:
    package package1;
    import org.w3c.dom.*;
    import java.sql.*;
    import oracle.jdbc.driver.*;
    import oracle.xml.sql.query.OracleXMLQuery;
    public class Class1 extends Object {
    public static void main( String[] arg ) throws Exception {
    Connection conn = getConnection();
    CallableStatement ocs = conn.prepareCall("begin ? := App.HotItems('PAUL'); end;");
    ocs.registerOutParameter(1,OracleTypes.CURSOR);
    ocs.execute();
    ResultSet rs = ((OracleCallableStatement)ocs).getCursor(1);
    OracleXMLQuery oxq = new OracleXMLQuery(conn,rs);
    System.out.println(oxq.getXMLString());
    oxq.close();
    rs.close();
    ocs.close();
    conn.close();
    public static Connection getConnection() throws Exception {
    String username = "scott";
    String password = "tiger";
    String dburl = "jdbc:oracle:thin:@localhost:1521:xml";
    String driverClass = "oracle.jdbc.driver.OracleDriver";
    Driver d = (Driver)Class.forName(driverClass).newInstance();
    return DriverManager.getConnection(dburl,username,password);
    null

  • Help with running a stored procedure

    Hi, could anybody help me with debugging this stored procedure:
    extraction_date in varchar2
    as
    begin
    execute immediate '
         declare
         /* Output file handler */
         fileHandler UTL_FILE.FILE_TYPE;
         asset_id VARCHAR2(60) := '''';
    cursor c_table is
         SELECT "ASSET ID"
         FROM REUT_MAIN_BOND
         WHERE MATURITY > TO_DATE(' || extraction_date || ', "MM-DD-YYYY");
         row c_table%ROWTYPE;
    begin
    fileHandler := UTL_FILE.FOPEN(''TEMP'', ''northfielddescupdate.in'', ''w'',32000);
         for row in c_table
         loop
         asset_id := row.ASSET;
         UTL_FILE.PUTF(fileHandler, ''asset_id'', ''\n'');
    end loop;
         UTL_FILE.FCLOSE(fileHandler);
    end;';
    commit;     
    end;
    when I run it - SQL> exec create_in_file('08102004')
    it gives me the following errors:
    ERROR at line 1:
    ORA-06550: line 8, column 11:
    PL/SQL: ORA-06553: PLS-103: Encountered the symbol "CALL" when expecting one of
    the following:
    <an identifier> <a double-quoted delimited-identifier>
    ORA-06553: PLS-112: end-of-line in quoted identifier
    ORA-06550: line 7, column 2:
    PL/SQL: SQL Statement ignored
    ORA-06550: line 6, column 8:
    PLS-00341: declaration of cursor 'C_TABLE' is incomplete or malformed
    ORA-06550: line 10, column 5:
    PL/SQL: Item ignored
    ORA-06550: line 15, column 14:
    PLS-00364: loop index variable 'ROW' use is invalid
    ORA-06550: line 15, column 2:
    PL/SQL: Statement ignored
    ORA-06512: at "PETAR_NORTHFIELD.CREATE_IN_FILE", line 6
    ORA-06512: at line 1
    Thank you for your help

    Q #1 (and possibly the only question) - why are you using NDS for this?

  • Result Sets and Stored Procedure

    In advance one question in general - since I never know: What actually is a result set???
    Is it a cursor with a direct connection to the server-side database-data ? Or is it just a copy of the results once "loaded" by the query and delivered by the Server to the client ???
    Second: I have a Stored Procedure on a MS SQL Server 2000
    I try to call the stored procedure via jdbc. The last query in the Stored Proc is a query relying on local temporary tables. If I execute the stored procedure by my java-class, i get a
    java.sql.SQLException: [Microsoft][SQLServer JDBC Driver]No ResultSet set was produced.
    The usual "Select, Update and Insert-stuff" works fine with JDBC.
    Stored Procedures WITHOUT resultset work fine too.
    But this one just refuses to give me the results.
    Executing the same stored procedure in 'MS SQL-QUERYANALYZER' gives me my expected results.
    Any ideas?
    Sven

    In advance one question in general - since I never
    know: What actually is a result set???
    Is it a cursor with a direct connection to the
    server-side database-data ? Or is it just a copy of
    the results once "loaded" by the query and delivered
    by the Server to the client ???The first one, more or less. It relies on the connection to retrieve the results, .. if the connection is lost, so is the data in the ResultSet.
    Second: I have a Stored Procedure on a *MS SQL Server
    2000*
    I try to call the stored procedure via jdbc. The last
    query in the Stored Proc is a query relying on local
    temporary tables. If I execute the stored procedure by
    my java-class, i get a
    java.sql.SQLException: [Microsoft][SQLServer JDBC
    Driver]No ResultSet set was produced.Have you tried a basic stored procedure that should return a ResultSet?.. maybe one that doesn't rely on the temporary tables? You may want to also check with the support for the driver you're using since that's really where the ability to use stored procedures resides.

  • Approval Procedures and Stored Procedures

    Hi All
    I have a problem with approval procedures and stored procedures.
    I created an approval procedure to check if a value in the udf is selected or not . if not then a messge is produced to ask the user to select the person to approve the PO.
    Biut now the problem is the PO's are linked approval templates to the error messge don't show before the approval template screen.
    Please assist.
    Thanks
    Bongani Dlamini

    Hi Gordon
    The stored procedure is just for validating if the user has selected the udf value.
    It is not for approval*
    I created an approval template for this purpose. So my problem is when I add the Po to the system the SP doesn't kick-in and alert the user to select the person to approve the PO.
    Process Flow.
    User captures PO then select the value on the UDF Field ( Approver) The value selected is linked to a query which is used by the Approval Template
    If this method is still not supported then please let me know .
    Thanks
    Bongani Dlamini

  • Logs are generating with owner and group as 'root'

    Hi,
    In our newly installed and configured Oracle application server(10.1.3.5), the logs are generating with owner and group as 'root'.
    Location: $ORACLE_HOME/Apache/Apache/logs
    -rw-r----- 1 root root 6700 Apr 3 02:03 access_log.1364947200
    -rw-r----- 1 root root 430 Apr 3 02:04 error_log.1364947200
    We have configured it on port 80. For this the '.apachectl' ownership and permissions are changed as below:
    -rwsr-s--- 1 root dba 1703780 Jul 21 2009 .apachectl
    Kindly let me know what are the changes to be made, for the logs to be generated with the group as 'dba' instead of 'root'.
    Thanks.
    Edited by: 985284 on Apr 3, 2013 3:14 AM
    Edited by: 985284 on Apr 3, 2013 4:22 AM

    Ok - that is quit weird then. If you want to run the HTTP Server on a privileged port, you basically change the ownership of the .apachectl executable :
    cd ORACLE_HOME/Apache/Apache/bin
    chown root .apachectl
    chmod 6750 .apachectlas per [url http://docs.oracle.com/cd/B25221_05/core.1013/b25209/ports.htm#CIHJEEJH]documentation.
    Your user and group directive should be set to :
    User oracle
    Group dbaUpon starting, the http server would start as root and then switch the effective userid of the process from root to oracle. In the process list (ps -ef | grep httpd), you should see oracle.
    Do you have the same configuration and what do you see in the process list?

  • Oracle Enteprise 11g, java procedure, fail with ENUM and @anotation tags...

    Hello,
    I have a problem with java sources on database (java stored procedures)..
    My sources uses anotation and Enumerator...
    When i try to load java sources to my db with loadjava I get some errors like:
    loading : source INSURANCE2.org/mozilla/universalchardet/Constants
    Error while determining classes contained in org/mozilla/universalchardet/prober/Big5Prober.java
    Exception oracle.aurora.sqljdecl.ParseException: Lexical error at line 75, column 5. Encountered: "@" (64), after : ""
    creating : INSURANCE2.org/mozilla/universalchardet/prober/Big5Prober.java
    Error while determining classes contained in org/mozilla/universalchardet/prober/CharsetProber.java
    Exception oracle.aurora.sqljdecl.ParseException: Encountered "{" at line 63, column 5.
    Was expecting one of:
    "=" ...
    here is some sample of my source compiled with JDK 1.5.0_00
    public abstract class CharsetProber
        // constants
        public static final float   SHORTCUT_THRESHOLD = 0.95f;
        public static final int     ASCII_A = 0x61; // 'a'
        public static final int     ASCII_Z = 0x7A; // 'z'
        public static final int     ASCII_A_CAPITAL = 0x41; // 'A'
        public static final int     ASCII_Z_CAPITAL = 0x5A; // 'Z'
        public static final int     ASCII_LT = 0x3C; // '<'
        public static final int     ASCII_GT = 0x3E; // '>'
        public static final int     ASCII_SP = 0x20; // ' '
        // inner types
        public enum ProbingState
            DETECTING,
            FOUND_IT,
            NOT_ME
        // methods
        public CharsetProber()
        public abstract String getCharSetName();
        public abstract ProbingState handleData(final byte[] buf, int offset, int length);
        public abstract ProbingState getState();
        public abstract void reset();
        public abstract float getConfidence();
        public abstract void setOption();On my database I think (correct me if not) I have java 1.5.0_10
      select f_vrni_parameter('java.version') from dual
    CREATE OR REPLACE function INSURANCE2.f_vrni_parameter(p_vhodni in varchar2) return varchar2 as language java name  'java.lang.System.getProperty(java.lang.String) return java.lang.String';What I'am doing wrong or what is the right way to upload java source or classes on db? (i will try to upload compiler classes with jdk 1.5.0)
    thank you

    Solved..
    I have uploaded compiled java sources (classes) in a single jar archive into database...

  • ORA-03113 with pool and stored proc

    We are experiencing a strange error when calling a stored procedure using a
    connection pool (WLS 5.1 SP10, Oracle 8). Everything works fine until the
    stored procedure raises a user-defined exception. When the connection is
    used again, we get the 03113 error. It appears that the connection is OK
    due to the testConnsOnReserve not returning an error, but on the next stored
    procedure call, the error happens. The database guys have no answers. Does
    anyone have a clue?
    Here is an ouput log showing what happens (this was done with a pool with
    only one connection):
    Got the exception for no BPI Record
    getConnection returning
    driver[className=weblogic.jdbc.pool.Driver,weblogic.jdbc.pool.Driver@d6b11fc
    7]
    Executing: begin pkg_BPI.p_getBPITrckIdForDataTblPk(:1, :2, :3, :4, :5, :6,
    :7, :8); end;
    SQLException: SQLState() vendor code(20003)
    java.sql.SQLException: ORA-20003: Error at step- Select..,procedure
    p_getBPITrckIdForDataTblPk No BPI Record Found...
    ORA-01403: no data found
    ORA-06512: at "CIFPROC.PKG_UTIL", line 381
    ORA-06512: at "CIFPROC.PKG_BPI", line 901
    ORA-06512: at line 1
    at weblogic.db.oci.OciCursor.getCDAException(OciCursor.java:230)
    at weblogic.jdbcbase.oci.Statement.executeUpdate(Statement.java,
    Compiled Code)
    at weblogic.jdbcbase.oci.Statement.execute(Statement.java, Compiled
    Code)
    at
    weblogic.jdbc.pool.PreparedStatement.execute(PreparedStatement.java,
    Compiled Code)
    at com.juniper.core.comm.JDBCProcHelper.execute(JDBCProcHelper.java,
    Compiled Code)
    at
    com.juniper.core.tracking.BusinessProcess.loadByKey(BusinessProcess.java,
    Compiled Code)
    at
    com.juniper.core.tracking.BusinessProcess.findProcessByKey(BusinessProcess.j
    ava, Compiled Code)
    at
    com.juniper.core.tracking.test.TestBusinessProcess.doGet(TestBusinessProcess
    .java, Compiled Code)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :120)
    at
    weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
    l.java:922)
    at
    weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
    l.java:886)
    at
    weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
    Manager.java:269)
    at
    weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:380)
    at
    weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:268)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
    Code)
    Release test worked!
    Parsing: select count(*) from dual
    Executing: select count(*) from dual
    Obtain the connection again
    DriverManager.getConnection("jdbc:weblogic:pool:CifPool")
    trying
    driver[className=weblogic.jdbc.pool.Driver,weblogic.jdbc.pool.Driver@d6b11fc
    7]
    Reserve test worked!
    Parsing: select count(*) from dual
    Executing: select count(*) from dual
    getConnection returning
    driver[className=weblogic.jdbc.pool.Driver,weblogic.jdbc.pool.Driver@d6b11fc
    7]
    Calling stored proc and get comm error
    Executing: begin pkg_BPI.p_getBPITrckIdForDataTblPk(:1, :2, :3, :4, :5, :6,
    :7, :8); end;
    SQLException: SQLState() vendor code(3113)
    java.sql.SQLException: ORA-03113: end-of-file on communication channel
    at weblogic.db.oci.OciCursor.getCDAException(OciCursor.java:230)
    at weblogic.jdbcbase.oci.Statement.executeUpdate(Statement.java,
    Compiled Code)
    at weblogic.jdbcbase.oci.Statement.execute(Statement.java, Compiled
    Code)
    at
    weblogic.jdbc.pool.PreparedStatement.execute(PreparedStatement.java,
    Compiled Code)
    at com.juniper.core.comm.JDBCProcHelper.execute(JDBCProcHelper.java,
    Compiled Code)
    at
    com.juniper.core.tracking.BusinessProcess.loadByKey(BusinessProcess.java,
    Compiled Code)
    at
    com.juniper.core.tracking.BusinessProcess.findProcessByKey(BusinessProcess.j
    ava, Compiled Code)
    at
    com.juniper.core.tracking.test.TestBusinessProcess.doGet(TestBusinessProcess
    .java, Compiled Code)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :120)
    at
    weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
    l.java:922)
    at
    weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
    l.java:886)
    at
    weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
    Manager.java:269)
    at
    weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:380)
    at
    weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:268)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
    Code)
    Release test fails!
    Parsing: select count(*) from dual
    SQLException: SQLState() vendor code(3114)
    java.sql.SQLException: ORA-03114: not connected to ORACLE
    at weblogic.db.oci.OciCursor.getCDAException(OciCursor.java:230)
    at weblogic.jdbcbase.oci.Statement.execute(Statement.java, Compiled
    Code)
    at
    weblogic.jdbc.common.internal.ConnectionEnv.test(ConnectionEnv.java,
    Compiled Code)
    at
    weblogic.common.internal.ResourceAllocator.release(ResourceAllocator.java,
    Compiled Code)
    at
    weblogic.common.internal.ResourceAllocator.release(ResourceAllocator.java,
    Compiled Code)
    at
    weblogic.jdbc.common.internal.ConnectionPool.release(ConnectionPool.java,
    Compiled Code)
    at weblogic.jdbcbase.pool.Connection.close(Connection.java, Compiled
    Code)
    at
    com.juniper.core.comm.JDBCProcHelper.closeConnection(JDBCProcHelper.java,
    Compiled Code)
    at
    com.juniper.core.tracking.BusinessProcess.closeConnection(BusinessProcess.ja
    va, Compiled Code)
    at
    com.juniper.core.tracking.BusinessProcess.loadByKey(BusinessProcess.java,
    Compiled Code)
    at
    com.juniper.core.tracking.BusinessProcess.findProcessByKey(BusinessProcess.j
    ava, Compiled Code)
    at
    com.juniper.core.tracking.test.TestBusinessProcess.doGet(TestBusinessProcess
    .java, Compiled Code)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :120)
    at
    weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
    l.java:922)
    at
    weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
    l.java:886)
    at
    weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
    Manager.java:269)
    at
    weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:380)
    at
    weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:268)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
    Code)
    Regenerating connection
    DriverManager.getDriver("jdbc20:weblogic:oracle:DCIF")
    trying
    driver[className=weblogic.jdbc.pool.Driver,weblogic.jdbc.pool.Driver@d6b11fc
    7]
    trying
    driver[className=weblogic.jdbc20.oci.Driver,weblogic.jdbc20.oci.Driver@d63d1
    fcf]
    getDriver returning
    driver[className=weblogic.jdbc20.oci.Driver,weblogic.jdbc20.oci.Driver@d63d1
    fcf]
    weblogic.jdbcbase.oci.Driver checking: jdbc20:weblogic:oracle:DCIF
    Connecting to database using: bmgr/********@DCIF at 0
    SQLException: SQLState() vendor code(1012)
    java.sql.SQLException: ORA-01012: not logged on - (bmgr/********@DCIF)
    at
    weblogic.db.oci.OciConnection.getLDAException(OciConnection.java:143)
    at weblogic.jdbcbase.oci.Driver.connect(Driver.java:157)
    at
    weblogic.jdbc.common.internal.ConnectionEnvFactory.makeConnection(Connection
    EnvFactory.java:153)
    at
    weblogic.jdbc.common.internal.ConnectionEnvFactory.refreshResource(Connectio
    nEnvFactory.java:207)
    at
    weblogic.jdbc.common.internal.ConnectionEnv.refresh(ConnectionEnv.java:677)
    at
    weblogic.common.internal.ResourceAllocator.resetThisOne(ResourceAllocator.ja
    va, Compiled Code)
    at
    weblogic.common.internal.ResourceAllocator.release(ResourceAllocator.java,
    Compiled Code)
    at
    weblogic.common.internal.ResourceAllocator.release(ResourceAllocator.java,
    Compiled Code)
    at
    weblogic.jdbc.common.internal.ConnectionPool.release(ConnectionPool.java,
    Compiled Code)
    at weblogic.jdbcbase.pool.Connection.close(Connection.java, Compiled
    Code)
    at
    com.juniper.core.comm.JDBCProcHelper.closeConnection(JDBCProcHelper.java,
    Compiled Code)
    at
    com.juniper.core.tracking.BusinessProcess.closeConnection(BusinessProcess.ja
    va, Compiled Code)
    at
    com.juniper.core.tracking.BusinessProcess.loadByKey(BusinessProcess.java,
    Compiled Code)
    at
    com.juniper.core.tracking.BusinessProcess.findProcessByKey(BusinessProcess.j
    ava, Compiled Code)
    at
    com.juniper.core.tracking.test.TestBusinessProcess.doGet(TestBusinessProcess
    .java, Compiled Code)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :120)
    at
    weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
    l.java:922)
    at
    weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
    l.java:886)
    at
    weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
    Manager.java:269)
    at
    weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:380)
    at
    weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:268)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
    Code)
    weblogic.jdbcbase.oci.Driver checking: jdbc20:weblogic:oracle:DCIF
    Connecting to database using: bmgr/********@DCIF at 0
    Connected to database at: 160
    Parsing: select length(SYSDATE) from dual
    Executing: select length(SYSDATE) from dual
    Parsing: select VALUE from V$NLS_PARAMETERS where
    PARAMETER='NLS_NUMERIC_CHARACTERS'
    Executing: select VALUE from V$NLS_PARAMETERS where
    PARAMETER='NLS_NUMERIC_CHARACTERS'
    Done logging in at: 170
    Connection: using OCI API: OCI8
    Done with connection regen
    DriverManager.getConnection("jdbc:weblogic:pool:CifPool")
    trying
    driver[className=weblogic.jdbc.pool.Driver,weblogic.jdbc.pool.Driver@d6b11fc
    7]
    Parsing: select count(*) from dual
    Executing: select count(*) from dual
    getConnection returning
    driver[className=weblogic.jdbc.pool.Driver,weblogic.jdbc.pool.Driver@d6b11fc
    7]
    Parsing: begin pkg_BPI.p_getBPITrckIdForDataTblPk(:1, :2, :3, :4, :5, :6,
    :7, :8); end;
    Executing: begin pkg_BPI.p_getBPITrckIdForDataTblPk(:1, :2, :3, :4, :5, :6,
    :7, :8); end;
    Parsing: select count(*) from dual
    Executing: select count(*) from dual
    DriverManager.getConnection("jdbc:weblogic:pool:CifPool")
    trying
    driver[className=weblogic.jdbc.pool.Driver,weblogic.jdbc.pool.Driver@d6b11fc
    7]
    Parsing: select count(*) from dual
    Executing: select count(*) from dual
    getConnection returning
    driver[className=weblogic.jdbc.pool.Driver,weblogic.jdbc.pool.Driver@d6b11fc
    7]
    Parsing: begin pkg_BPI.p_getBPIStates(:1, :2); end;
    Executing: begin pkg_BPI.p_getBPIStates(:1, :2); end;
    Parsing: select count(*) from dual
    Executing: select count(*) from dual
    DriverManager.getConnection("jdbc:weblogic:pool:CifPool")
    trying
    driver[className=weblogic.jdbc.pool.Driver,weblogic.jdbc.pool.Driver@d6b11fc
    7]
    Parsing: select count(*) from dual

    Well, this seems to do the trick. We'll keep testing, but the errors have
    now disappeared for all instances of this problem.
    Thanks for the help!
    JDB
    "John Bauer" <[email protected]> wrote in message
    news:[email protected]...
    We'll try this, but it seems to be connection-oriented. If we have a pool
    of 5 connections, and an exception happens, only that connection seems tobe
    affected. The other connections in the pool work fine, and the proc works
    for those connections.
    "Joseph Weinstein" <[email protected]> wrote in message
    news:[email protected]...
    Hi.
    The issue is likely related to our caching of PreparedStatements
    for performance. If some DBMS failure occurs which could invalidate
    a PreparedStatement/cursor such that it could never be re-used,
    even after clearParameters) are called etc, then this case might
    occur. Please take the attached jar file, and add it to the
    weblogic.classpath ahead of the standard weblogic stuff, by
    editing your startWebLogic script. This will turn off caching, and
    should make the problem go away. Let me know...
    Joe
    John Bauer wrote:
    Here is our configuration.
    weblogic.jdbc.connectionPool.CifPool=\
    url=jdbc20:weblogic:oracle:QCIF,\
    driver=weblogic.jdbc20.oci.Driver,\
    loginDelaySecs=1,\
    initialCapacity=5,\
    maxCapacity=20,\
    capacityIncrement=2,\
    allowShrinking=true,\
    shrinkPeriodMins=30,\
    testTable=dual,\
    testConnsOnRelease=true,\
    props=user=BMGR;password=djr0t$
    We are using OCI 8.1.6
    "Maria Salzberger" <[email protected]> wrote in message
    news:[email protected]...
    Hi John,
    I have researched about this - but could not find a known issue
    which
    may
    be
    related to this.
    Which JDBC driver are you using?
    Kind Regards
    Maria Salzberger
    Developer Relations Engineer
    BEA Customer Support
    John Bauer schrieb in Nachricht <[email protected]>...
    We are experiencing a strange error when calling a stored procedure
    using
    a
    connection pool (WLS 5.1 SP10, Oracle 8). Everything works fine
    until
    the
    stored procedure raises a user-defined exception. When the
    connection is
    used again, we get the 03113 error. It appears that the connectionis OK
    due to the testConnsOnReserve not returning an error, but on the
    next
    stored
    procedure call, the error happens. The database guys have no
    answers.
    Does
    anyone have a clue?
    Here is an ouput log showing what happens (this was done with a
    pool
    with
    only one connection):
    Got the exception for no BPI Record
    getConnection returningdriver[className=weblogic.jdbc.pool.Driver,weblogic.jdbc.pool.Driver@d6b11f
    c
    7]
    Executing: begin pkg_BPI.p_getBPITrckIdForDataTblPk(:1, :2, :3, :4,
    :5,
    :6,
    :7, :8); end;
    SQLException: SQLState() vendor code(20003)
    java.sql.SQLException: ORA-20003: Error at step- Select..,procedure
    p_getBPITrckIdForDataTblPk No BPI Record Found...
    ORA-01403: no data found
    ORA-06512: at "CIFPROC.PKG_UTIL", line 381
    ORA-06512: at "CIFPROC.PKG_BPI", line 901
    ORA-06512: at line 1
    at
    weblogic.db.oci.OciCursor.getCDAException(OciCursor.java:230)
    atweblogic.jdbcbase.oci.Statement.executeUpdate(Statement.java,
    Compiled Code)
    at weblogic.jdbcbase.oci.Statement.execute(Statement.java,Compiled
    Code)
    at
    weblogic.jdbc.pool.PreparedStatement.execute(PreparedStatement.java,
    Compiled Code)
    atcom.juniper.core.comm.JDBCProcHelper.execute(JDBCProcHelper.java,
    Compiled Code)
    at
    com.juniper.core.tracking.BusinessProcess.loadByKey(BusinessProcess.java,
    Compiled Code)
    at
    com.juniper.core.tracking.BusinessProcess.findProcessByKey(BusinessProcess.
    j
    ava, Compiled Code)
    at
    com.juniper.core.tracking.test.TestBusinessProcess.doGet(TestBusinessProces
    s
    .java, Compiled Code)
    at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    atjavax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    atweblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.jav
    a
    :120)
    at
    weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextIm
    p
    l.java:922)
    at
    weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextIm
    p
    l.java:886)
    at
    weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContex
    t
    Manager.java:269)
    at
    weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:380)
    atweblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:268)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java,Compiled
    Code)
    Release test worked!
    Parsing: select count(*) from dual
    Executing: select count(*) from dual
    Obtain the connection again
    DriverManager.getConnection("jdbc:weblogic:pool:CifPool")
    tryingdriver[className=weblogic.jdbc.pool.Driver,weblogic.jdbc.pool.Driver@d6b11f
    c
    7]
    Reserve test worked!
    Parsing: select count(*) from dual
    Executing: select count(*) from dual
    getConnection returning
    driver[className=weblogic.jdbc.pool.Driver,weblogic.jdbc.pool.Driver@d6b11f
    c
    7]
    Calling stored proc and get comm error
    Executing: begin pkg_BPI.p_getBPITrckIdForDataTblPk(:1, :2, :3, :4,
    :5,
    :6,
    :7, :8); end;
    SQLException: SQLState() vendor code(3113)
    java.sql.SQLException: ORA-03113: end-of-file on communication
    channel
    atweblogic.db.oci.OciCursor.getCDAException(OciCursor.java:230)
    atweblogic.jdbcbase.oci.Statement.executeUpdate(Statement.java,
    Compiled Code)
    at weblogic.jdbcbase.oci.Statement.execute(Statement.java,Compiled
    Code)
    at
    weblogic.jdbc.pool.PreparedStatement.execute(PreparedStatement.java,
    Compiled Code)
    atcom.juniper.core.comm.JDBCProcHelper.execute(JDBCProcHelper.java,
    Compiled Code)
    at
    com.juniper.core.tracking.BusinessProcess.loadByKey(BusinessProcess.java,
    Compiled Code)
    at
    com.juniper.core.tracking.BusinessProcess.findProcessByKey(BusinessProcess.
    j
    ava, Compiled Code)
    at
    com.juniper.core.tracking.test.TestBusinessProcess.doGet(TestBusinessProces
    s
    .java, Compiled Code)
    at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    atjavax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    atweblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.jav
    a
    :120)
    at
    weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextIm
    p
    l.java:922)
    at
    weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextIm
    p
    l.java:886)
    at
    weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContex
    t
    Manager.java:269)
    at
    weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:380)
    atweblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:268)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java,Compiled
    Code)
    Release test fails!
    Parsing: select count(*) from dual
    SQLException: SQLState() vendor code(3114)
    java.sql.SQLException: ORA-03114: not connected to ORACLE
    atweblogic.db.oci.OciCursor.getCDAException(OciCursor.java:230)
    at weblogic.jdbcbase.oci.Statement.execute(Statement.java,Compiled
    Code)
    at
    weblogic.jdbc.common.internal.ConnectionEnv.test(ConnectionEnv.java,
    Compiled Code)
    atweblogic.common.internal.ResourceAllocator.release(ResourceAllocator.java,
    Compiled Code)
    atweblogic.common.internal.ResourceAllocator.release(ResourceAllocator.java,
    Compiled Code)
    atweblogic.jdbc.common.internal.ConnectionPool.release(ConnectionPool.java,
    Compiled Code)
    at weblogic.jdbcbase.pool.Connection.close(Connection.java,Compiled
    Code)
    at
    com.juniper.core.comm.JDBCProcHelper.closeConnection(JDBCProcHelper.java,
    Compiled Code)
    at
    com.juniper.core.tracking.BusinessProcess.closeConnection(BusinessProcess.j
    a
    va, Compiled Code)
    at
    com.juniper.core.tracking.BusinessProcess.loadByKey(BusinessProcess.java,
    Compiled Code)
    at
    com.juniper.core.tracking.BusinessProcess.findProcessByKey(BusinessProcess.
    j
    ava, Compiled Code)
    at
    com.juniper.core.tracking.test.TestBusinessProcess.doGet(TestBusinessProces
    s
    .java, Compiled Code)
    at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    atjavax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    atweblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.jav
    a
    :120)
    at
    weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextIm
    p
    l.java:922)
    at
    weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextIm
    p
    l.java:886)
    at
    weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContex
    t
    Manager.java:269)
    at
    weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:380)
    atweblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:268)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java,Compiled
    Code)
    Regenerating connection
    DriverManager.getDriver("jdbc20:weblogic:oracle:DCIF")
    tryingdriver[className=weblogic.jdbc.pool.Driver,weblogic.jdbc.pool.Driver@d6b11f
    c
    7]
    trying
    driver[className=weblogic.jdbc20.oci.Driver,weblogic.jdbc20.oci.Driver@d63d
    1
    fcf]
    getDriver returning
    driver[className=weblogic.jdbc20.oci.Driver,weblogic.jdbc20.oci.Driver@d63d
    1
    fcf]
    weblogic.jdbcbase.oci.Driver checking: jdbc20:weblogic:oracle:DCIF
    Connecting to database using: bmgr/********@DCIF at 0
    SQLException: SQLState() vendor code(1012)
    java.sql.SQLException: ORA-01012: not logged on -
    (bmgr/********@DCIF)
    atweblogic.db.oci.OciConnection.getLDAException(OciConnection.java:143)
    at weblogic.jdbcbase.oci.Driver.connect(Driver.java:157)
    atweblogic.jdbc.common.internal.ConnectionEnvFactory.makeConnection(Connectio
    n
    EnvFactory.java:153)
    at
    weblogic.jdbc.common.internal.ConnectionEnvFactory.refreshResource(Connecti
    o
    nEnvFactory.java:207)
    at
    weblogic.jdbc.common.internal.ConnectionEnv.refresh(ConnectionEnv.java:677)
    atweblogic.common.internal.ResourceAllocator.resetThisOne(ResourceAllocator.j
    a
    va, Compiled Code)
    at
    weblogic.common.internal.ResourceAllocator.release(ResourceAllocator.java,
    Compiled Code)
    atweblogic.common.internal.ResourceAllocator.release(ResourceAllocator.java,
    Compiled Code)
    atweblogic.jdbc.common.internal.ConnectionPool.release(ConnectionPool.java,
    Compiled Code)
    at weblogic.jdbcbase.pool.Connection.close(Connection.java,Compiled
    Code)
    at
    com.juniper.core.comm.JDBCProcHelper.closeConnection(JDBCProcHelper.java,
    Compiled Code)
    at
    com.juniper.core.tracking.BusinessProcess.closeConnection(BusinessProcess.j
    a
    va, Compiled Code)
    at
    com.juniper.core.tracking.BusinessProcess.loadByKey(BusinessProcess.java,
    Compiled Code)
    at
    com.juniper.core.tracking.BusinessProcess.findProcessByKey(BusinessProcess.
    j
    ava, Compiled Code)
    at
    com.juniper.core.tracking.test.TestBusinessProcess.doGet(TestBusinessProces
    s
    .java, Compiled Code)
    at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    atjavax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    atweblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.jav
    a
    :120)
    at
    weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextIm
    p
    l.java:922)
    at
    weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextIm
    p
    l.java:886)
    at
    weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContex
    t
    Manager.java:269)
    at
    weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:380)
    atweblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:268)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java,Compiled
    Code)
    weblogic.jdbcbase.oci.Driver checking: jdbc20:weblogic:oracle:DCIF
    Connecting to database using: bmgr/********@DCIF at 0
    Connected to database at: 160
    Parsing: select length(SYSDATE) from dual
    Executing: select length(SYSDATE) from dual
    Parsing: select VALUE from V$NLS_PARAMETERS where
    PARAMETER='NLS_NUMERIC_CHARACTERS'
    Executing: select VALUE from V$NLS_PARAMETERS where
    PARAMETER='NLS_NUMERIC_CHARACTERS'
    Done logging in at: 170
    Connection: using OCI API: OCI8
    Done with connection regen
    DriverManager.getConnection("jdbc:weblogic:pool:CifPool")
    tryingdriver[className=weblogic.jdbc.pool.Driver,weblogic.jdbc.pool.Driver@d6b11f
    c
    7]
    Parsing: select count(*) from dual
    Executing: select count(*) from dual
    getConnection returning
    driver[className=weblogic.jdbc.pool.Driver,weblogic.jdbc.pool.Driver@d6b11f
    c
    7]
    Parsing: begin pkg_BPI.p_getBPITrckIdForDataTblPk(:1, :2, :3, :4,
    :5,
    :6,
    :7, :8); end;
    Executing: begin pkg_BPI.p_getBPITrckIdForDataTblPk(:1, :2, :3, :4,:5,
    :6,
    :7, :8); end;
    Parsing: select count(*) from dual
    Executing: select count(*) from dual
    DriverManager.getConnection("jdbc:weblogic:pool:CifPool")
    trying
    driver[className=weblogic.jdbc.pool.Driver,weblogic.jdbc.pool.Driver@d6b11f
    c
    7]
    Parsing: select count(*) from dual
    Executing: select count(*) from dual
    getConnection returning
    driver[className=weblogic.jdbc.pool.Driver,weblogic.jdbc.pool.Driver@d6b11f
    c
    7]
    Parsing: begin pkg_BPI.p_getBPIStates(:1, :2); end;
    Executing: begin pkg_BPI.p_getBPIStates(:1, :2); end;
    Parsing: select count(*) from dual
    Executing: select count(*) from dual
    DriverManager.getConnection("jdbc:weblogic:pool:CifPool")
    trying
    driver[className=weblogic.jdbc.pool.Driver,weblogic.jdbc.pool.Driver@d6b11f
    c
    7]
    Parsing: select count(*) from dual
    B.E.A. is now hiring! (12/14/01) If interested send a resume to
    [email protected]
    DIRECTOR OF PRODUCT PLANS AND STRATEGY San Francisco,
    CA
    E-SALES BUSINESS DEVELOPMENT REPRESENTATIVE Dallas, TX
    SOFTWARE ENGINEER (DBA) Liberty Corner,NJ
    SENIOR WEB DEVELOPER San Jose, CA
    SOFTWARE ENGINEER (ALL LEVELS), CARY, NORTHCAROLINA San Jose, CA
    SR. PRODUCT MANAGER Bellevue, WA
    SR. WEB DESIGNER San Jose, CA
    Channel Marketing Manager - EMEA Region London, GBR
    DIRECTOR OF MARKETING STRATEGY, APPLICATION SERVERS San Jose, CA
    SENIOR SOFTWARE ENGINEER (PLATFORM) San Jose, CA
    E-COMMERCE INTEGRATION ARCHITECT San Jose, CA
    QUALITY ASSURANCE ENGINEER Redmond, WA
    Services Development Manager (Business Development Manager - Services)Paris, FRA; Munich, DEU
    SENIOR SOFTWARE ENGINEER (PLATFORM) Redmond, WA
    E-Marketing Programs Specialist EMEA London, GBR
    BUSINESS DEVELOPMENT DIRECTOR - E COMMERCE INTEGRATION San Jose, CA
    MANAGER, E-SALES Plano, TX

  • BACKUP LOG suddenly failed with Msg 35250, Level 16, State 11 The connection to the primary replica is not active. The command cannot be processed.

    I have AlwaysOn SQL 2012 Enterprise set-up using Windows Failover Clustering Services (not FCI), and have 1 Primary node (P), 1 Synchronous Commit Auto Failover (SC), and 1 Asynchronous Commit Manual Failover (AC) node.  It is set up to prefer secondary,
    with the highest priority given to AC node.
    I am using Ola Hollengren's scripts for Database Maintenance jobs, including a native BACKUP LOG job for the transaction logs of all user databases on a 1 minute schedule.  His scripts already consider AlwaysOn, and although the job is set-up on all
    3 nodes, only ever runs on AC node.
    The job has been running successfully since initial set-up almost 1 year ago, but suddenly yesterday morning started to fail with the following error, only on 1 of the 13 databases in my availability group:
    Date and time: 2014-06-08 09:36:11
    Command: BACKUP LOG [my_db] TO DISK = N'E:\MSSQL\\Transaction Dumps\my_db\MySQLCL$MySQLAG_my_db_20140608_093610_U_LOG.trn' WITH CHECKSUM, COMPRESSION
    Msg 35250, Level 16, State 11, Server AC, Line 1
    The connection to the primary replica is not active.  The command cannot be processed.
    Msg 3013, Level 16, State 1, Server AC, Line 1
    BACKUP LOG is terminating abnormally.
    Outcome: Failed
    Duration: 00:01:00
    The other 12 databases continued to backup successfully.
    Checking the Availability Group dashboard, windows event logs, and SQL Server error logs, including Failover Cluster events showed no issues.
    However, monitoring software (Idera SQLdm) showed blocked sessions on P node.  When I ran sp_who2, it showed that a background process was being blocked by another background process with an HADR BACKUP LOCK.
    Since both processes were background processes, I was unable to kill either process.  I temporarily disabled the transaction log backup job, but the blocked process was still active.
    I ran DBCC CHECKDB (my_db) WITH all_errormsgs, no_infomsgs, data_purity on both P and AC nodes, with no errors.  However, on AC node, it also showed 1 transaction rolled forward and 0 transactions rolled back.  This also had the effect of releasing
    the blocked background process, but another background process was now blocking with the same HADR BACKUP LOCK.
    I tried to restart SQL Server Agent on AC node, which did not immediately seem to work.  However, after a few minutes, I noticed that the block had disappeared.  I re-enabled the transaction log backup job on AC and it started working normally
    again.  The error has not occurred again, but I am at a loss as to what happened, and how to prevent it from happening again.
    Any help would be greatly appreciated.
    Diane

    And here is part 2 of the stored procedure:
    --// Execute backup commands //--
    WHILE EXISTS (SELECT * FROM @tmpDatabases WHERE Selected = 1 AND Completed = 0)
    BEGIN
    SELECT TOP 1 @CurrentDBID = ID,
    @CurrentDatabaseName = DatabaseName,
    @CurrentDatabaseNameFS = DatabaseNameFS,
    @CurrentDatabaseType = DatabaseType
    FROM @tmpDatabases
    WHERE Selected = 1
    AND Completed = 0
    ORDER BY ID ASC
    SET @CurrentDatabaseID = DB_ID(@CurrentDatabaseName)
    IF DATABASEPROPERTYEX(@CurrentDatabaseName,'Status') = 'ONLINE'
    BEGIN
    IF EXISTS (SELECT * FROM sys.database_recovery_status WHERE database_id = @CurrentDatabaseID AND database_guid IS NOT NULL)
    BEGIN
    SET @CurrentIsDatabaseAccessible = 1
    END
    ELSE
    BEGIN
    SET @CurrentIsDatabaseAccessible = 0
    END
    END
    ELSE
    BEGIN
    SET @CurrentIsDatabaseAccessible = 0
    END
    SELECT @CurrentDifferentialBaseLSN = differential_base_lsn
    FROM sys.master_files
    WHERE database_id = @CurrentDatabaseID
    AND [type] = 0
    AND [file_id] = 1
    -- Workaround for a bug in SQL Server 2005
    IF @Version >= 9 AND @Version < 10
    AND EXISTS(SELECT * FROM sys.master_files WHERE database_id = @CurrentDatabaseID AND [type] = 0 AND [file_id] = 1 AND differential_base_lsn IS NOT NULL AND differential_base_guid IS NOT NULL AND differential_base_time IS NULL)
    BEGIN
    SET @CurrentDifferentialBaseLSN = NULL
    END
    SELECT @CurrentDifferentialBaseIsSnapshot = is_snapshot
    FROM msdb.dbo.backupset
    WHERE database_name = @CurrentDatabaseName
    AND [type] = 'D'
    AND checkpoint_lsn = @CurrentDifferentialBaseLSN
    IF DATABASEPROPERTYEX(@CurrentDatabaseName,'Status') = 'ONLINE'
    BEGIN
    SELECT @CurrentLogLSN = last_log_backup_lsn
    FROM sys.database_recovery_status
    WHERE database_id = @CurrentDatabaseID
    END
    SET @CurrentBackupType = @BackupType
    IF @ChangeBackupType = 'Y'
    BEGIN
    IF @CurrentBackupType = 'LOG' AND DATABASEPROPERTYEX(@CurrentDatabaseName,'Recovery') <> 'SIMPLE' AND @CurrentLogLSN IS NULL AND @CurrentDatabaseName <> 'master'
    BEGIN
    SET @CurrentBackupType = 'DIFF'
    END
    IF @CurrentBackupType = 'DIFF' AND @CurrentDifferentialBaseLSN IS NULL AND @CurrentDatabaseName <> 'master'
    BEGIN
    SET @CurrentBackupType = 'FULL'
    END
    END
    IF @CurrentBackupType = 'LOG'
    BEGIN
    SELECT @CurrentLatestBackup = MAX(backup_finish_date)
    FROM msdb.dbo.backupset
    WHERE [type] IN('D','I')
    AND is_damaged = 0
    AND database_name = @CurrentDatabaseName
    END
    IF @Version >= 11 AND @Cluster IS NOT NULL
    BEGIN
    SELECT @CurrentAvailabilityGroup = availability_groups.name,
    @CurrentAvailabilityGroupRole = dm_hadr_availability_replica_states.role_desc
    FROM sys.databases databases
    INNER JOIN sys.availability_databases_cluster availability_databases_cluster ON databases.group_database_id = availability_databases_cluster.group_database_id
    INNER JOIN sys.availability_groups availability_groups ON availability_databases_cluster.group_id = availability_groups.group_id
    INNER JOIN sys.dm_hadr_availability_replica_states dm_hadr_availability_replica_states ON availability_groups.group_id = dm_hadr_availability_replica_states.group_id AND databases.replica_id = dm_hadr_availability_replica_states.replica_id
    WHERE databases.name = @CurrentDatabaseName
    END
    IF @Version >= 11 AND @Cluster IS NOT NULL AND @CurrentAvailabilityGroup IS NOT NULL
    BEGIN
    SELECT @CurrentIsPreferredBackupReplica = sys.fn_hadr_backup_is_preferred_replica(@CurrentDatabaseName)
    END
    SELECT @CurrentDatabaseMirroringRole = UPPER(mirroring_role_desc)
    FROM sys.database_mirroring
    WHERE database_id = @CurrentDatabaseID
    IF EXISTS (SELECT * FROM msdb.dbo.log_shipping_primary_databases WHERE primary_database = @CurrentDatabaseName)
    BEGIN
    SET @CurrentLogShippingRole = 'PRIMARY'
    END
    ELSE
    IF EXISTS (SELECT * FROM msdb.dbo.log_shipping_secondary_databases WHERE secondary_database = @CurrentDatabaseName)
    BEGIN
    SET @CurrentLogShippingRole = 'SECONDARY'
    END
    -- Set database message
    SET @DatabaseMessage = 'Date and time: ' + CONVERT(nvarchar,GETDATE(),120) + CHAR(13) + CHAR(10)
    SET @DatabaseMessage = @DatabaseMessage + 'Database: ' + QUOTENAME(@CurrentDatabaseName) + CHAR(13) + CHAR(10)
    SET @DatabaseMessage = @DatabaseMessage + 'Status: ' + CAST(DATABASEPROPERTYEX(@CurrentDatabaseName,'Status') AS nvarchar) + CHAR(13) + CHAR(10)
    SET @DatabaseMessage = @DatabaseMessage + 'Standby: ' + CASE WHEN DATABASEPROPERTYEX(@CurrentDatabaseName,'IsInStandBy') = 1 THEN 'Yes' ELSE 'No' END + CHAR(13) + CHAR(10)
    SET @DatabaseMessage = @DatabaseMessage + 'Updateability: ' + CAST(DATABASEPROPERTYEX(@CurrentDatabaseName,'Updateability') AS nvarchar) + CHAR(13) + CHAR(10)
    SET @DatabaseMessage = @DatabaseMessage + 'User access: ' + CAST(DATABASEPROPERTYEX(@CurrentDatabaseName,'UserAccess') AS nvarchar) + CHAR(13) + CHAR(10)
    SET @DatabaseMessage = @DatabaseMessage + 'Is accessible: ' + CASE WHEN @CurrentIsDatabaseAccessible = 1 THEN 'Yes' ELSE 'No' END + CHAR(13) + CHAR(10)
    SET @DatabaseMessage = @DatabaseMessage + 'Recovery model: ' + CAST(DATABASEPROPERTYEX(@CurrentDatabaseName,'Recovery') AS nvarchar) + CHAR(13) + CHAR(10)
    IF @CurrentAvailabilityGroup IS NOT NULL SET @DatabaseMessage = @DatabaseMessage + 'Availability group: ' + @CurrentAvailabilityGroup + CHAR(13) + CHAR(10)
    IF @CurrentAvailabilityGroup IS NOT NULL SET @DatabaseMessage = @DatabaseMessage + 'Availability group role: ' + @CurrentAvailabilityGroupRole + CHAR(13) + CHAR(10)
    IF @CurrentAvailabilityGroup IS NOT NULL SET @DatabaseMessage = @DatabaseMessage + 'Is preferred backup replica: ' + CASE WHEN @CurrentIsPreferredBackupReplica = 1 THEN 'Yes' WHEN @CurrentIsPreferredBackupReplica = 0 THEN 'No' ELSE 'N/A' END + CHAR(13) + CHAR(10)
    IF @CurrentDatabaseMirroringRole IS NOT NULL SET @DatabaseMessage = @DatabaseMessage + 'Database mirroring role: ' + @CurrentDatabaseMirroringRole + CHAR(13) + CHAR(10)
    IF @CurrentLogShippingRole IS NOT NULL SET @DatabaseMessage = @DatabaseMessage + 'Log shipping role: ' + @CurrentLogShippingRole + CHAR(13) + CHAR(10)
    SET @DatabaseMessage = @DatabaseMessage + 'Differential base LSN: ' + ISNULL(CAST(@CurrentDifferentialBaseLSN AS nvarchar),'N/A') + CHAR(13) + CHAR(10)
    SET @DatabaseMessage = @DatabaseMessage + 'Differential base is snapshot: ' + CASE WHEN @CurrentDifferentialBaseIsSnapshot = 1 THEN 'Yes' WHEN @CurrentDifferentialBaseIsSnapshot = 0 THEN 'No' ELSE 'N/A' END + CHAR(13) + CHAR(10)
    SET @DatabaseMessage = @DatabaseMessage + 'Last log backup LSN: ' + ISNULL(CAST(@CurrentLogLSN AS nvarchar),'N/A') + CHAR(13) + CHAR(10)
    SET @DatabaseMessage = REPLACE(@DatabaseMessage,'%','%%') + ' '
    RAISERROR(@DatabaseMessage,10,1) WITH NOWAIT
    IF DATABASEPROPERTYEX(@CurrentDatabaseName,'Status') = 'ONLINE'
    AND NOT (DATABASEPROPERTYEX(@CurrentDatabaseName,'UserAccess') = 'SINGLE_USER' AND @CurrentIsDatabaseAccessible = 0)
    AND DATABASEPROPERTYEX(@CurrentDatabaseName,'IsInStandBy') = 0
    AND NOT (@CurrentBackupType = 'LOG' AND (DATABASEPROPERTYEX(@CurrentDatabaseName,'Recovery') = 'SIMPLE' OR @CurrentLogLSN IS NULL))
    AND NOT (@CurrentBackupType = 'DIFF' AND @CurrentDifferentialBaseLSN IS NULL)
    AND NOT (@CurrentBackupType IN('DIFF','LOG') AND @CurrentDatabaseName = 'master')
    AND NOT (@CurrentAvailabilityGroup IS NOT NULL AND @CurrentBackupType = 'FULL' AND @CopyOnly = 'N' AND (@CurrentAvailabilityGroupRole <> 'PRIMARY' OR @CurrentAvailabilityGroupRole IS NULL))
    AND NOT (@CurrentAvailabilityGroup IS NOT NULL AND @CurrentBackupType = 'FULL' AND @CopyOnly = 'Y' AND (@CurrentIsPreferredBackupReplica <> 1 OR @CurrentIsPreferredBackupReplica IS NULL))
    AND NOT (@CurrentAvailabilityGroup IS NOT NULL AND @CurrentBackupType = 'DIFF' AND (@CurrentAvailabilityGroupRole <> 'PRIMARY' OR @CurrentAvailabilityGroupRole IS NULL))
    AND NOT (@CurrentAvailabilityGroup IS NOT NULL AND @CurrentBackupType = 'LOG' AND @CopyOnly = 'N' AND (@CurrentIsPreferredBackupReplica <> 1 OR @CurrentIsPreferredBackupReplica IS NULL))
    AND NOT (@CurrentAvailabilityGroup IS NOT NULL AND @CurrentBackupType = 'LOG' AND @CopyOnly = 'Y' AND (@CurrentAvailabilityGroupRole <> 'PRIMARY' OR @CurrentAvailabilityGroupRole IS NULL))
    AND NOT ((@CurrentLogShippingRole = 'PRIMARY' AND @CurrentLogShippingRole IS NOT NULL) AND @CurrentBackupType = 'LOG')
    BEGIN
    -- Set variables
    SET @CurrentDate = GETDATE()
    IF @CleanupTime IS NULL OR (@CurrentBackupType = 'LOG' AND @CurrentLatestBackup IS NULL) OR @CurrentBackupType <> @BackupType
    BEGIN
    SET @CurrentCleanupDate = NULL
    END
    ELSE
    IF @CurrentBackupType = 'LOG'
    BEGIN
    SET @CurrentCleanupDate = (SELECT MIN([Date]) FROM(SELECT DATEADD(hh,-(@CleanupTime),@CurrentDate) AS [Date] UNION SELECT @CurrentLatestBackup AS [Date]) Dates)
    END
    ELSE
    BEGIN
    SET @CurrentCleanupDate = DATEADD(hh,-(@CleanupTime),@CurrentDate)
    END
    SELECT @CurrentFileExtension = CASE
    WHEN @BackupSoftware IS NULL AND @CurrentBackupType = 'FULL' THEN 'bak'
    WHEN @BackupSoftware IS NULL AND @CurrentBackupType = 'DIFF' THEN 'bak'
    WHEN @BackupSoftware IS NULL AND @CurrentBackupType = 'LOG' THEN 'trn'
    WHEN @BackupSoftware = 'LITESPEED' AND @CurrentBackupType = 'FULL' THEN 'bak'
    WHEN @BackupSoftware = 'LITESPEED' AND @CurrentBackupType = 'DIFF' THEN 'bak'
    WHEN @BackupSoftware = 'LITESPEED' AND @CurrentBackupType = 'LOG' THEN 'trn'
    WHEN @BackupSoftware = 'SQLBACKUP' AND @CurrentBackupType = 'FULL' THEN 'sqb'
    WHEN @BackupSoftware = 'SQLBACKUP' AND @CurrentBackupType = 'DIFF' THEN 'sqb'
    WHEN @BackupSoftware = 'SQLBACKUP' AND @CurrentBackupType = 'LOG' THEN 'sqb'
    WHEN @BackupSoftware = 'HYPERBAC' AND @CurrentBackupType = 'FULL' AND @Encrypt = 'N' THEN 'hbc'
    WHEN @BackupSoftware = 'HYPERBAC' AND @CurrentBackupType = 'DIFF' AND @Encrypt = 'N' THEN 'hbc'
    WHEN @BackupSoftware = 'HYPERBAC' AND @CurrentBackupType = 'LOG' AND @Encrypt = 'N' THEN 'hbc'
    WHEN @BackupSoftware = 'HYPERBAC' AND @CurrentBackupType = 'FULL' AND @Encrypt = 'Y' THEN 'hbe'
    WHEN @BackupSoftware = 'HYPERBAC' AND @CurrentBackupType = 'DIFF' AND @Encrypt = 'Y' THEN 'hbe'
    WHEN @BackupSoftware = 'HYPERBAC' AND @CurrentBackupType = 'LOG' AND @Encrypt = 'Y' THEN 'hbe'
    WHEN @BackupSoftware = 'SQLSAFE' AND @CurrentBackupType = 'FULL' THEN 'safe'
    WHEN @BackupSoftware = 'SQLSAFE' AND @CurrentBackupType = 'DIFF' THEN 'safe'
    WHEN @BackupSoftware = 'SQLSAFE' AND @CurrentBackupType = 'LOG' THEN 'safe'
    END
    INSERT INTO @CurrentDirectories (ID, DirectoryPath, CreateCompleted, CleanupCompleted)
    SELECT ROW_NUMBER() OVER (ORDER BY ID), DirectoryPath + CASE WHEN RIGHT(DirectoryPath,1) = '\' THEN '' ELSE '\' END + CASE WHEN @CurrentBackupType = 'LOG' THEN '\Transaction Dumps\' + @CurrentDatabaseNameFS ELSE '' END, 0, 0
    FROM @Directories
    ORDER BY ID ASC
    SET @CurrentFileNumber = 0
    SET @CurrentMirrorFilePath = NULL
    WHILE @CurrentFileNumber < @NumberOfFiles
    BEGIN
    SET @CurrentFileNumber = @CurrentFileNumber + 1
    SELECT @CurrentDirectoryPath = DirectoryPath
    FROM @CurrentDirectories
    WHERE @CurrentFileNumber >= (ID - 1) * (SELECT @NumberOfFiles / COUNT(*) FROM @CurrentDirectories) + 1
    AND @CurrentFileNumber <= ID * (SELECT @NumberOfFiles / COUNT(*) FROM @CurrentDirectories)
    SET @CurrentFilePath = @CurrentDirectoryPath + '\' + CASE WHEN @CurrentAvailabilityGroup IS NOT NULL THEN @Cluster + '$' + @CurrentAvailabilityGroup ELSE REPLACE(CAST(SERVERPROPERTY('servername') AS nvarchar),'\','$') END + '_' + @CurrentDatabaseNameFS + '_' + REPLACE(REPLACE(REPLACE((CONVERT(nvarchar,@CurrentDate,120)),'-',''),' ','_'),':','') + CASE WHEN @NumberOfFiles > 1 AND @NumberOfFiles <= 9 THEN '_' + CAST(@CurrentFileNumber AS nvarchar) WHEN @NumberOfFiles >= 10 THEN '_' + RIGHT('0' + CAST(@CurrentFileNumber AS nvarchar),2) ELSE '' END + '_' + @CurrentDatabaseType + '_' + UPPER(@CurrentBackupType) + CASE WHEN @ReadWriteFileGroups = 'Y' THEN '_PARTIAL' ELSE '' END + CASE WHEN @CopyOnly = 'Y' THEN '_COPY_ONLY' ELSE '' END + '.' + @CurrentFileExtension
    IF LEN(@CurrentFilePath) > 257
    BEGIN
    SET @CurrentFilePath = @CurrentDirectoryPath + '\' + CASE WHEN @CurrentAvailabilityGroup IS NOT NULL THEN @Cluster + '$' + @CurrentAvailabilityGroup ELSE REPLACE(CAST(SERVERPROPERTY('servername') AS nvarchar),'\','$') END + '_' + LEFT(@CurrentDatabaseNameFS,CASE WHEN (LEN(@CurrentDatabaseNameFS) + 257 - LEN(@CurrentFilePath) - 3) < 20 THEN 20 ELSE (LEN(@CurrentDatabaseNameFS) + 257 - LEN(@CurrentFilePath) - 3) END) + '...' + '_' + REPLACE(REPLACE(REPLACE((CONVERT(nvarchar,@CurrentDate,120)),'-',''),' ','_'),':','') + CASE WHEN @NumberOfFiles > 1 AND @NumberOfFiles <= 9 THEN '_' + CAST(@CurrentFileNumber AS nvarchar) WHEN @NumberOfFiles >= 10 THEN '_' + RIGHT('0' + CAST(@CurrentFileNumber AS nvarchar),2) ELSE '' END + '_' + @CurrentDatabaseType + '_' + UPPER(@CurrentBackupType) + CASE WHEN @ReadWriteFileGroups = 'Y' THEN '_PARTIAL' ELSE '' END + CASE WHEN @CopyOnly = 'Y' THEN '_COPY_ONLY' ELSE '' END + '.' + @CurrentFileExtension
    END
    IF @CurrentFileNumber = 1 AND LEN(@MirrorDirectory) > 0
    BEGIN
    SET @CurrentMirrorFilePath = @MirrorDirectory + CASE WHEN RIGHT(@MirrorDirectory,1) = '\' THEN '' ELSE '\' END + CASE WHEN @CurrentBackupType = 'LOG' THEN '\Transaction Dumps\' + @CurrentDatabaseNameFS ELSE '' END + '\' + CASE WHEN @CurrentAvailabilityGroup IS NOT NULL THEN @Cluster + '$' + @CurrentAvailabilityGroup ELSE REPLACE(CAST(SERVERPROPERTY('servername') AS nvarchar),'\','$') END + '_' + @CurrentDatabaseNameFS + '_' + REPLACE(REPLACE(REPLACE((CONVERT(nvarchar,@CurrentDate,120)),'-',''),' ','_'),':','') + CASE WHEN @NumberOfFiles > 1 AND @NumberOfFiles <= 9 THEN '_' + CAST(@CurrentFileNumber AS nvarchar) WHEN @NumberOfFiles >= 10 THEN '_' + RIGHT('0' + CAST(@CurrentFileNumber AS nvarchar),2) ELSE '' END + '_' + @CurrentDatabaseType + '_' + UPPER(@CurrentBackupType) + CASE WHEN @ReadWriteFileGroups = 'Y' THEN '_PARTIAL' ELSE '' END + CASE WHEN @CopyOnly = 'Y' THEN '_COPY_ONLY' ELSE '' END + '.' + @CurrentFileExtension
    IF LEN(@CurrentFilePath) > 257
    BEGIN
    SET @CurrentMirrorFilePath = @MirrorDirectory + CASE WHEN RIGHT(@MirrorDirectory,1) = '\' THEN '' ELSE '\' END + CASE WHEN @CurrentBackupType = 'LOG' THEN '\Transaction Dumps\' + @CurrentDatabaseNameFS ELSE '' END + '\' + CASE WHEN @CurrentAvailabilityGroup IS NOT NULL THEN @Cluster + '$' + @CurrentAvailabilityGroup ELSE REPLACE(CAST(SERVERPROPERTY('servername') AS nvarchar),'\','$') END + '_' + LEFT(@CurrentDatabaseNameFS,CASE WHEN (LEN(@CurrentDatabaseNameFS) + 257 - LEN(@CurrentFilePath) - 3) < 20 THEN 20 ELSE (LEN(@CurrentDatabaseNameFS) + 257 - LEN(@CurrentFilePath) - 3) END) + '...' + '_' + REPLACE(REPLACE(REPLACE((CONVERT(nvarchar,@CurrentDate,120)),'-',''),' ','_'),':','') + CASE WHEN @NumberOfFiles > 1 AND @NumberOfFiles <= 9 THEN '_' + CAST(@CurrentFileNumber AS nvarchar) WHEN @NumberOfFiles >= 10 THEN '_' + RIGHT('0' + CAST(@CurrentFileNumber AS nvarchar),2) ELSE '' END + '_' + @CurrentDatabaseType + '_' + UPPER(@CurrentBackupType) + CASE WHEN @ReadWriteFileGroups = 'Y' THEN '_PARTIAL' ELSE '' END + CASE WHEN @CopyOnly = 'Y' THEN '_COPY_ONLY' ELSE '' END + '.' + @CurrentFileExtension
    END
    END
    INSERT INTO @CurrentFiles (CurrentFilePath)
    SELECT @CurrentFilePath
    SET @CurrentDirectoryPath = NULL
    SET @CurrentFilePath = NULL
    END
    -- Create directory
    WHILE EXISTS (SELECT * FROM @CurrentDirectories WHERE CreateCompleted = 0)
    BEGIN
    SELECT TOP 1 @CurrentDirectoryID = ID,
    @CurrentDirectoryPath = DirectoryPath
    FROM @CurrentDirectories
    WHERE CreateCompleted = 0
    ORDER BY ID ASC
    SET @CurrentCommandType01 = 'xp_create_subdir'
    SET @CurrentCommand01 = 'DECLARE @ReturnCode int EXECUTE @ReturnCode = [master].dbo.xp_create_subdir N''' + REPLACE(@CurrentDirectoryPath,'''','''''') + ''' IF @ReturnCode <> 0 RAISERROR(''Error creating directory.'', 16, 1)'
    EXECUTE @CurrentCommandOutput01 = [dbo].[CommandExecute] @Command = @CurrentCommand01, @CommandType = @CurrentCommandType01, @Mode = 1, @DatabaseName = @CurrentDatabaseName, @LogToTable = @LogToTable, @Execute = @Execute
    SET @Error = @@ERROR
    IF @Error <> 0 SET @CurrentCommandOutput01 = @Error
    IF @CurrentCommandOutput01 <> 0 SET @ReturnCode = @CurrentCommandOutput01
    UPDATE @CurrentDirectories
    SET CreateCompleted = 1,
    CreateOutput = @CurrentCommandOutput01
    WHERE ID = @CurrentDirectoryID
    SET @CurrentDirectoryID = NULL
    SET @CurrentDirectoryPath = NULL
    SET @CurrentCommand01 = NULL
    SET @CurrentCommandOutput01 = NULL
    SET @CurrentCommandType01 = NULL
    END
    -- Perform a backup
    IF NOT EXISTS (SELECT * FROM @CurrentDirectories WHERE CreateOutput <> 0 OR CreateOutput IS NULL)
    BEGIN
    IF @BackupSoftware IS NULL
    BEGIN
    SELECT @CurrentCommandType02 = CASE
    WHEN @CurrentBackupType IN('DIFF','FULL') THEN 'BACKUP_DATABASE'
    WHEN @CurrentBackupType = 'LOG' THEN 'BACKUP_LOG'
    END
    SELECT @CurrentCommand02 = CASE
    WHEN @CurrentBackupType IN('DIFF','FULL') THEN 'BACKUP DATABASE ' + QUOTENAME(@CurrentDatabaseName)
    WHEN @CurrentBackupType = 'LOG' THEN 'BACKUP LOG ' + QUOTENAME(@CurrentDatabaseName)
    END
    IF @ReadWriteFileGroups = 'Y' SET @CurrentCommand02 = @CurrentCommand02 + ' READ_WRITE_FILEGROUPS'
    SET @CurrentCommand02 = @CurrentCommand02 + ' TO'
    SELECT @CurrentCommand02 = @CurrentCommand02 + ' DISK = N''' + REPLACE(CurrentFilePath,'''','''''') + '''' + CASE WHEN ROW_NUMBER() OVER (ORDER BY CurrentFilePath ASC) <> @NumberOfFiles THEN ',' ELSE '' END
    FROM @CurrentFiles
    ORDER BY CurrentFilePath ASC
    SET @CurrentCommand02 = @CurrentCommand02 + ' WITH '
    IF @CheckSum = 'Y' SET @CurrentCommand02 = @CurrentCommand02 + 'CHECKSUM'
    IF @CheckSum = 'N' SET @CurrentCommand02 = @CurrentCommand02 + 'NO_CHECKSUM'
    IF @Compress = 'Y' SET @CurrentCommand02 = @CurrentCommand02 + ', COMPRESSION'
    IF @Compress = 'N' AND @Version >= 10 SET @CurrentCommand02 = @CurrentCommand02 + ', NO_COMPRESSION'
    IF @CurrentBackupType = 'DIFF' SET @CurrentCommand02 = @CurrentCommand02 + ', DIFFERENTIAL'
    IF @CopyOnly = 'Y' SET @CurrentCommand02 = @CurrentCommand02 + ', COPY_ONLY'
    IF @BlockSize IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', BLOCKSIZE = ' + CAST(@BlockSize AS nvarchar)
    IF @BufferCount IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', BUFFERCOUNT = ' + CAST(@BufferCount AS nvarchar)
    IF @MaxTransferSize IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', MAXTRANSFERSIZE = ' + CAST(@MaxTransferSize AS nvarchar)
    IF @Description IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', DESCRIPTION = N''' + REPLACE(@Description,'''','''''') + ''''
    END
    IF @BackupSoftware = 'LITESPEED'
    BEGIN
    SELECT @CurrentCommandType02 = CASE
    WHEN @CurrentBackupType IN('DIFF','FULL') THEN 'xp_backup_database'
    WHEN @CurrentBackupType = 'LOG' THEN 'xp_backup_log'
    END
    SELECT @CurrentCommand02 = CASE
    WHEN @CurrentBackupType IN('DIFF','FULL') THEN 'DECLARE @ReturnCode int EXECUTE @ReturnCode = [master].dbo.xp_backup_database @database = N''' + REPLACE(@CurrentDatabaseName,'''','''''') + ''''
    WHEN @CurrentBackupType = 'LOG' THEN 'DECLARE @ReturnCode int EXECUTE @ReturnCode = [master].dbo.xp_backup_log @database = N''' + REPLACE(@CurrentDatabaseName,'''','''''') + ''''
    END
    SELECT @CurrentCommand02 = @CurrentCommand02 + ', @filename = N''' + REPLACE(CurrentFilePath,'''','''''') + ''''
    FROM @CurrentFiles
    ORDER BY CurrentFilePath ASC
    SET @CurrentCommand02 = @CurrentCommand02 + ', @with = '''
    IF @CheckSum = 'Y' SET @CurrentCommand02 = @CurrentCommand02 + 'CHECKSUM'
    IF @CheckSum = 'N' SET @CurrentCommand02 = @CurrentCommand02 + 'NO_CHECKSUM'
    IF @CurrentBackupType = 'DIFF' SET @CurrentCommand02 = @CurrentCommand02 + ', DIFFERENTIAL'
    IF @CopyOnly = 'Y' SET @CurrentCommand02 = @CurrentCommand02 + ', COPY_ONLY'
    IF @BlockSize IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', BLOCKSIZE = ' + CAST(@BlockSize AS nvarchar)
    SET @CurrentCommand02 = @CurrentCommand02 + ''''
    IF @ReadWriteFileGroups = 'Y' SET @CurrentCommand02 = @CurrentCommand02 + ', @read_write_filegroups = 1'
    IF @CompressionLevel IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', @compressionlevel = ' + CAST(@CompressionLevel AS nvarchar)
    IF @BufferCount IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', @buffercount = ' + CAST(@BufferCount AS nvarchar)
    IF @MaxTransferSize IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', @maxtransfersize = ' + CAST(@MaxTransferSize AS nvarchar)
    IF @Threads IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', @threads = ' + CAST(@Threads AS nvarchar)
    IF @Throttle IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', @throttle = ' + CAST(@Throttle AS nvarchar)
    IF @Description IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', @desc = N''' + REPLACE(@Description,'''','''''') + ''''
    IF @EncryptionType IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', @cryptlevel = ' + CASE
    WHEN @EncryptionType = 'RC2-40' THEN '0'
    WHEN @EncryptionType = 'RC2-56' THEN '1'
    WHEN @EncryptionType = 'RC2-112' THEN '2'
    WHEN @EncryptionType = 'RC2-128' THEN '3'
    WHEN @EncryptionType = '3DES-168' THEN '4'
    WHEN @EncryptionType = 'RC4-128' THEN '5'
    WHEN @EncryptionType = 'AES-128' THEN '6'
    WHEN @EncryptionType = 'AES-192' THEN '7'
    WHEN @EncryptionType = 'AES-256' THEN '8'
    END
    IF @EncryptionKey IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', @encryptionkey = N''' + REPLACE(@EncryptionKey,'''','''''') + ''''
    SET @CurrentCommand02 = @CurrentCommand02 + ' IF @ReturnCode <> 0 RAISERROR(''Error performing LiteSpeed backup.'', 16, 1)'
    END
    IF @BackupSoftware = 'SQLBACKUP'
    BEGIN
    SET @CurrentCommandType02 = 'sqlbackup'
    SELECT @CurrentCommand02 = CASE
    WHEN @CurrentBackupType IN('DIFF','FULL') THEN 'BACKUP DATABASE ' + QUOTENAME(@CurrentDatabaseName)
    WHEN @CurrentBackupType = 'LOG' THEN 'BACKUP LOG ' + QUOTENAME(@CurrentDatabaseName)
    END
    IF @ReadWriteFileGroups = 'Y' SET @CurrentCommand02 = @CurrentCommand02 + ' READ_WRITE_FILEGROUPS'
    SET @CurrentCommand02 = @CurrentCommand02 + ' TO'
    SELECT @CurrentCommand02 = @CurrentCommand02 + ' DISK = N''' + REPLACE(CurrentFilePath,'''','''''') + '''' + CASE WHEN ROW_NUMBER() OVER (ORDER BY CurrentFilePath ASC) <> @NumberOfFiles THEN ',' ELSE '' END
    FROM @CurrentFiles
    ORDER BY CurrentFilePath ASC
    SET @CurrentCommand02 = @CurrentCommand02 + ' WITH '
    IF @CheckSum = 'Y' SET @CurrentCommand02 = @CurrentCommand02 + 'CHECKSUM'
    IF @CheckSum = 'N' SET @CurrentCommand02 = @CurrentCommand02 + 'NO_CHECKSUM'
    IF @CurrentBackupType = 'DIFF' SET @CurrentCommand02 = @CurrentCommand02 + ', DIFFERENTIAL'
    IF @CopyOnly = 'Y' SET @CurrentCommand02 = @CurrentCommand02 + ', COPY_ONLY'
    IF @CompressionLevel IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', COMPRESSION = ' + CAST(@CompressionLevel AS nvarchar)
    IF @Threads IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', THREADCOUNT = ' + CAST(@Threads AS nvarchar)
    IF @MaxTransferSize IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', MAXTRANSFERSIZE = ' + CAST(@MaxTransferSize AS nvarchar)
    IF @Description IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', DESCRIPTION = N''' + REPLACE(@Description,'''','''''') + ''''
    IF @EncryptionType IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', KEYSIZE = ' + CASE
    WHEN @EncryptionType = 'AES-128' THEN '128'
    WHEN @EncryptionType = 'AES-256' THEN '256'
    END
    IF @EncryptionKey IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', PASSWORD = N''' + REPLACE(@EncryptionKey,'''','''''') + ''''
    SET @CurrentCommand02 = 'DECLARE @ReturnCode int EXECUTE @ReturnCode = [master].dbo.sqlbackup N''-SQL "' + REPLACE(@CurrentCommand02,'''','''''') + '"''' + ' IF @ReturnCode <> 0 RAISERROR(''Error performing SQLBackup backup.'', 16, 1)'
    END
    IF @BackupSoftware = 'HYPERBAC'
    BEGIN
    SET @CurrentCommandType02 = 'BACKUP_DATABASE'
    SELECT @CurrentCommand02 = CASE
    WHEN @CurrentBackupType IN('DIFF','FULL') THEN 'BACKUP DATABASE ' + QUOTENAME(@CurrentDatabaseName)
    WHEN @CurrentBackupType = 'LOG' THEN 'BACKUP LOG ' + QUOTENAME(@CurrentDatabaseName)
    END
    IF @ReadWriteFileGroups = 'Y' SET @CurrentCommand02 = @CurrentCommand02 + ' READ_WRITE_FILEGROUPS'
    SET @CurrentCommand02 = @CurrentCommand02 + ' TO'
    SELECT @CurrentCommand02 = @CurrentCommand02 + ' DISK = N''' + REPLACE(CurrentFilePath,'''','''''') + '''' + CASE WHEN ROW_NUMBER() OVER (ORDER BY CurrentFilePath ASC) <> @NumberOfFiles THEN ',' ELSE '' END
    FROM @CurrentFiles
    ORDER BY CurrentFilePath ASC
    SET @CurrentCommand02 = @CurrentCommand02 + ' WITH '
    IF @CheckSum = 'Y' SET @CurrentCommand02 = @CurrentCommand02 + 'CHECKSUM'
    IF @CheckSum = 'N' SET @CurrentCommand02 = @CurrentCommand02 + 'NO_CHECKSUM'
    IF @CurrentBackupType = 'DIFF' SET @CurrentCommand02 = @CurrentCommand02 + ', DIFFERENTIAL'
    IF @CopyOnly = 'Y' SET @CurrentCommand02 = @CurrentCommand02 + ', COPY_ONLY'
    IF @BlockSize IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', BLOCKSIZE = ' + CAST(@BlockSize AS nvarchar)
    IF @BufferCount IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', BUFFERCOUNT = ' + CAST(@BufferCount AS nvarchar)
    IF @MaxTransferSize IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', MAXTRANSFERSIZE = ' + CAST(@MaxTransferSize AS nvarchar)
    IF @Description IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', DESCRIPTION = N''' + REPLACE(@Description,'''','''''') + ''''
    END
    IF @BackupSoftware = 'SQLSAFE'
    BEGIN
    SET @CurrentCommandType02 = 'xp_ss_backup'
    SET @CurrentCommand02 = 'DECLARE @ReturnCode int EXECUTE @ReturnCode = [master].dbo.xp_ss_backup @database = N''' + REPLACE(@CurrentDatabaseName,'''','''''') + ''''
    SELECT @CurrentCommand02 = @CurrentCommand02 + ', ' + CASE WHEN ROW_NUMBER() OVER (ORDER BY CurrentFilePath ASC) = 1 THEN '@filename' ELSE '@backupfile' END + ' = N''' + REPLACE(CurrentFilePath,'''','''''') + ''''
    FROM @CurrentFiles
    ORDER BY CurrentFilePath ASC
    IF @CurrentMirrorFilePath IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', @mirrorfile = N''' + @CurrentMirrorFilePath + ''''
    SET @CurrentCommand02 = @CurrentCommand02 + ', @backuptype = ' + CASE WHEN @CurrentBackupType = 'FULL' THEN '''Full''' WHEN @CurrentBackupType = 'DIFF' THEN '''Differential''' WHEN @CurrentBackupType = 'LOG' THEN '''Log''' END
    IF @ReadWriteFileGroups = 'Y' SET @CurrentCommand02 = @CurrentCommand02 + ', @readwritefilegroups = 1'
    SET @CurrentCommand02 = @CurrentCommand02 + ', @checksum = ' + CASE WHEN @CheckSum = 'Y' THEN '1' WHEN @CheckSum = 'N' THEN '0' END
    SET @CurrentCommand02 = @CurrentCommand02 + ', @copyonly = ' + CASE WHEN @CopyOnly = 'Y' THEN '1' WHEN @CopyOnly = 'N' THEN '0' END
    IF @CompressionLevel IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', @compressionlevel = ' + CASE WHEN @CompressionLevel = 5 THEN N'ispeed' WHEN @CompressionLevel = 6 THEN N'isize' ELSE CAST(@CompressionLevel AS nvarchar) END
    IF @RetryWrites IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', @retrywrites = N''' + @RetryWrites + ''''
    IF @Threads IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', @threads = ' + CAST(@Threads AS nvarchar)
    IF @Description IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', @desc = N''' + REPLACE(@Description,'''','''''') + ''''
    IF @EncryptionType IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', @encryptiontype = N''' + CASE
    WHEN @EncryptionType = 'AES-128' THEN 'AES128'
    WHEN @EncryptionType = 'AES-256' THEN 'AES256'
    END + ''''
    IF @EncryptionKey IS NOT NULL SET @CurrentCommand02 = @CurrentCommand02 + ', @encryptedbackuppassword = N''' + REPLACE(@EncryptionKey,'''','''''') + ''''
    SET @CurrentCommand02 = @CurrentCommand02 + ' IF @ReturnCode <> 0 RAISERROR(''Error performing SQLsafe backup.'', 16, 1)'
    END
    EXECUTE @CurrentCommandOutput02 = [dbo].[CommandExecute] @Command = @CurrentCommand02, @CommandType = @CurrentCommandType02, @Mode = 1, @DatabaseName = @CurrentDatabaseName, @LogToTable = @LogToTable, @Execute = @Execute
    SET @Error = @@ERROR
    IF @Error <> 0 SET @CurrentCommandOutput02 = @Error
    IF @CurrentCommandOutput02 <> 0 SET @ReturnCode = @CurrentCommandOutput02
    END
    -- Verify the backup
    IF @CurrentCommandOutput02 = 0 AND @Verify = 'Y'
    BEGIN
    IF @BackupSoftware IS NULL
    BEGIN
    SET @CurrentCommandType03 = 'RESTORE_VERIFYONLY'
    SET @CurrentCommand03 = 'RESTORE VERIFYONLY FROM'
    SELECT @CurrentCommand03 = @CurrentCommand03 + ' DISK = N''' + REPLACE(CurrentFilePath,'''','''''') + '''' + CASE WHEN ROW_NUMBER() OVER (ORDER BY CurrentFilePath ASC) <> @NumberOfFiles THEN ',' ELSE '' END
    FROM @CurrentFiles
    ORDER BY CurrentFilePath ASC
    SET @CurrentCommand03 = @CurrentCommand03 + ' WITH '
    IF @CheckSum = 'Y' SET @CurrentCommand03 = @CurrentCommand03 + 'CHECKSUM'
    IF @CheckSum = 'N' SET @CurrentCommand03 = @CurrentCommand03 + 'NO_CHECKSUM'
    END
    IF @BackupSoftware = 'LITESPEED'
    BEGIN
    SET @CurrentCommandType03 = 'xp_restore_verifyonly'
    SET @CurrentCommand03 = 'DECLARE @ReturnCode int EXECUTE @ReturnCode = [master].dbo.xp_restore_verifyonly'
    SELECT @CurrentCommand03 = @CurrentCommand03 + ' @filename = N''' + REPLACE(CurrentFilePath,'''','''''') + '''' + CASE WHEN ROW_NUMBER() OVER (ORDER BY CurrentFilePath ASC) <> @NumberOfFiles THEN ',' ELSE '' END
    FROM @CurrentFiles
    ORDER BY CurrentFilePath ASC
    SET @CurrentCommand03 = @CurrentCommand03 + ', @with = '''
    IF @CheckSum = 'Y' SET @CurrentCommand03 = @CurrentCommand03 + 'CHECKSUM'
    IF @CheckSum = 'N' SET @CurrentCommand03 = @CurrentCommand03 + 'NO_CHECKSUM'
    SET @CurrentCommand03 = @CurrentCommand03 + ''''
    IF @EncryptionKey IS NOT NULL SET @CurrentCommand03 = @CurrentCommand03 + ', @encryptionkey = N''' + REPLACE(@EncryptionKey,'''','''''') + ''''
    SET @CurrentCommand03 = @CurrentCommand03 + ' IF @ReturnCode <> 0 RAISERROR(''Error verifying LiteSpeed backup.'', 16, 1)'
    END
    IF @BackupSoftware = 'SQLBACKUP'
    BEGIN
    SET @CurrentCommandType03 = 'sqlbackup'
    SET @CurrentCommand03 = 'RESTORE VERIFYONLY FROM'
    SELECT @CurrentCommand03 = @CurrentCommand03 + ' DISK = N''' + REPLACE(CurrentFilePath,'''','''''') + '''' + CASE WHEN ROW_NUMBER() OVER (ORDER BY CurrentFilePath ASC) <> @NumberOfFiles THEN ',' ELSE '' END
    FROM @CurrentFiles
    ORDER BY CurrentFilePath ASC
    SET @CurrentCommand03 = @CurrentCommand03 + ' WITH '
    IF @CheckSum = 'Y' SET @CurrentCommand03 = @CurrentCommand03 + 'CHECKSUM'
    IF @CheckSum = 'N' SET @CurrentCommand03 = @CurrentCommand03 + 'NO_CHECKSUM'
    IF @EncryptionKey IS NOT NULL SET @CurrentCommand03 = @CurrentCommand03 + ', PASSWORD = N''' + REPLACE(@EncryptionKey,'''','''''') + ''''
    SET @CurrentCommand03 = 'DECLARE @ReturnCode int EXECUTE @ReturnCode = [master].dbo.sqlbackup N''-SQL "' + REPLACE(@CurrentCommand03,'''','''''') + '"''' + ' IF @ReturnCode <> 0 RAISERROR(''Error verifying SQLBackup backup.'', 16, 1)'
    END
    IF @BackupSoftware = 'HYPERBAC'
    BEGIN
    SET @CurrentCommandType03 = 'RESTORE_VERIFYONLY'
    SET @CurrentCommand03 = 'RESTORE VERIFYONLY FROM'
    SELECT @CurrentCommand03 = @CurrentCommand03 + ' DISK = N''' + REPLACE(CurrentFilePath,'''','''''') + '''' + CASE WHEN ROW_NUMBER() OVER (ORDER BY CurrentFilePath ASC) <> @NumberOfFiles THEN ',' ELSE '' END
    FROM @CurrentFiles
    ORDER BY CurrentFilePath ASC
    SET @CurrentCommand03 = @CurrentCommand03 + ' WITH '
    IF @CheckSum = 'Y' SET @CurrentCommand03 = @CurrentCommand03 + 'CHECKSUM'
    IF @CheckSum = 'N' SET @CurrentCommand03 = @CurrentCommand03 + 'NO_CHECKSUM'
    END
    IF @BackupSoftware = 'SQLSAFE'
    BEGIN
    SET @CurrentCommandType03 = 'xp_ss_verify'
    SET @CurrentCommand03 = 'DECLARE @ReturnCode int EXECUTE @ReturnCode = [master].dbo.xp_ss_verify @database = N''' + REPLACE(@CurrentDatabaseName,'''','''''') + ''''
    SELECT @CurrentCommand03 = @CurrentCommand03 + ', ' + CASE WHEN ROW_NUMBER() OVER (ORDER BY CurrentFilePath ASC) = 1 THEN '@filename' ELSE '@backupfile' END + ' = N''' + REPLACE(CurrentFilePath,'''','''''') + ''''
    FROM @CurrentFiles
    ORDER BY CurrentFilePath ASC
    SET @CurrentCommand03 = @CurrentCommand03 + ' IF @ReturnCode <> 0 RAISERROR(''Error verifying SQLsafe backup.'', 16, 1)'
    END
    EXECUTE @CurrentCommandOutput03 = [dbo].[CommandExecute] @Command = @CurrentCommand03, @CommandType = @CurrentCommandType03, @Mode = 1, @DatabaseName = @CurrentDatabaseName, @LogToTable = @LogToTable, @Execute = @Execute
    SET @Error = @@ERROR
    IF @Error <> 0 SET @CurrentCommandOutput03 = @Error
    IF @CurrentCommandOutput03 <> 0 SET @ReturnCode = @CurrentCommandOutput03
    END
    -- Delete old backup files
    IF (@CurrentCommandOutput02 = 0 AND @Verify = 'N' AND @CurrentCleanupDate IS NOT NULL)
    OR (@CurrentCommandOutput02 = 0 AND @Verify = 'Y' AND @CurrentCommandOutput03 = 0 AND @CurrentCleanupDate IS NOT NULL)
    BEGIN
    WHILE EXISTS (SELECT * FROM @CurrentDirectories WHERE CleanupCompleted = 0)
    BEGIN
    SELECT TOP 1 @CurrentDirectoryID = ID,
    @CurrentDirectoryPath = DirectoryPath
    FROM @CurrentDirectories
    WHERE CleanupCompleted = 0
    ORDER BY ID ASC
    IF @BackupSoftware IS NULL
    BEGIN
    SET @CurrentCommandType04 = 'xp_delete_file'
    SET @CurrentCommand04 = 'DECLARE @ReturnCode int EXECUTE @ReturnCode = [master].dbo.xp_delete_file 0, N''' + REPLACE(@CurrentDirectoryPath,'''','''''') + ''', ''' + @CurrentFileExtension + ''', ''' + CONVERT(nvarchar(19),@CurrentCleanupDate,126) + ''' IF @ReturnCode <> 0 RAISERROR(''Error deleting files.'', 16, 1)'
    END
    IF @BackupSoftware = 'LITESPEED'
    BEGIN
    SET @CurrentCommandType04 = 'xp_slssqlmaint'
    SET @CurrentCommand04 = 'DECLARE @ReturnCode int EXECUTE @ReturnCode = [master].dbo.xp_slssqlmaint N''-MAINTDEL -DELFOLDER "' + REPLACE(@CurrentDirectoryPath,'''','''''') + '" -DELEXTENSION "' + @CurrentFileExtension + '" -DELUNIT "' + CAST(DATEDIFF(mi,@CurrentCleanupDate,GETDATE()) + 1 AS nvarchar) + '" -DELUNITTYPE "minutes" -DELUSEAGE'' IF @ReturnCode <> 0 RAISERROR(''Error deleting LiteSpeed backup files.'', 16, 1)'
    END
    IF @BackupSoftware = 'SQLBACKUP'
    BEGIN
    SET @CurrentCommandType04 = 'sqbutility'
    SET @CurrentCommand04 = 'DECLARE @ReturnCode int EXECUTE @ReturnCode = [master].dbo.sqbutility 1032, N''' + REPLACE(@CurrentDatabaseName,'''','''''') + ''', N''' + REPLACE(@CurrentDirectoryPath,'''','''''') + ''', ''' + CASE WHEN @CurrentBackupType = 'FULL' THEN 'D' WHEN @CurrentBackupType = 'DIFF' THEN 'I' WHEN @CurrentBackupType = 'LOG' THEN 'L' END + ''', ''' + CAST(DATEDIFF(hh,@CurrentCleanupDate,GETDATE()) + 1 AS nvarchar) + 'h'', ' + ISNULL('''' + REPLACE(@EncryptionKey,'''','''''') + '''','NULL') + ' IF @ReturnCode <> 0 RAISERROR(''Error deleting SQLBackup backup files.'', 16, 1)'
    END
    IF @BackupSoftware = 'HYPERBAC'
    BEGIN
    SET @CurrentCommandType04 = 'xp_delete_file'
    SET @CurrentCommand04 = 'DECLARE @ReturnCode int EXECUTE @ReturnCode = [master].dbo.xp_delete_file 0, N''' + REPLACE(@CurrentDirectoryPath,'''','''''') + ''', ''' + @CurrentFileExtension + ''', ''' + CONVERT(nvarchar(19),@CurrentCleanupDate,126) + ''' IF @ReturnCode <> 0 RAISERROR(''Error deleting files.'', 16, 1)'
    END
    IF @BackupSoftware = 'SQLSAFE'
    BEGIN
    SET @CurrentCommandType04 = 'xp_ss_delete'
    SET @CurrentCommand04 = 'DECLARE @ReturnCode int EXECUTE @ReturnCode = [master].dbo.xp_ss_delete @filename = N''' + REPLACE(@CurrentDirectoryPath,'''','''''') + '\*.' + @CurrentFileExtension + ''', @age = ''' + CAST(DATEDIFF(mi,@CurrentCleanupDate,GETDATE()) + 1 AS nvarchar) + 'Minutes'' IF @ReturnCode <> 0 RAISERROR(''Error deleting SQLsafe backup files.'', 16, 1)'
    END
    EXECUTE @CurrentCommandOutput04 = [dbo].[CommandExecute] @Command = @CurrentCommand04, @CommandType = @CurrentCommandType04, @Mode = 1, @DatabaseName = @CurrentDatabaseName, @LogToTable = @LogToTable, @Execute = @Execute
    SET @Error = @@ERROR
    IF @Error <> 0 SET @CurrentCommandOutput04 = @Error
    IF @CurrentCommandOutput04 <> 0 SET @ReturnCode = @CurrentCommandOutput04
    UPDATE @CurrentDirectories
    SET CleanupCompleted = 1,
    CleanupOutput = @CurrentCommandOutput04
    WHERE ID = @CurrentDirectoryID
    SET @CurrentDirectoryID = NULL
    SET @CurrentDirectoryPath = NULL
    SET @CurrentCommand04 = NULL
    SET @CurrentCommandOutput04 = NULL
    SET @CurrentCommandType04 = NULL
    END
    END
    END
    -- Update that the database is completed
    UPDATE @tmpDatabases
    SET Completed = 1
    WHERE Selected = 1
    AND Completed = 0
    AND ID = @CurrentDBID
    -- Clear variables
    SET @CurrentDBID = NULL
    SET @CurrentDatabaseID = NULL
    SET @CurrentDatabaseName = NULL
    SET @CurrentBackupType = NULL
    SET @CurrentFileExtension = NULL
    SET @CurrentFileNumber = NULL
    SET @CurrentDifferentialBaseLSN = NULL
    SET @CurrentDifferentialBaseIsSnapshot = NULL
    SET @CurrentLogLSN = NULL
    SET @CurrentLatestBackup = NULL
    SET @CurrentDatabaseNameFS = NULL
    SET @CurrentDatabaseType = NULL
    SET @CurrentDate = NULL
    SET @CurrentCleanupDate = NULL
    SET @CurrentIsDatabaseAccessible = NULL
    SET @CurrentAvailabilityGroup = NULL
    SET @CurrentAvailabilityGroupRole = NULL
    SET @CurrentIsPreferredBackupReplica = NULL
    SET @CurrentDatabaseMirroringRole = NULL
    SET @CurrentLogShippingRole = NULL
    SET @CurrentCommand02 = NULL
    SET @CurrentCommand03 = NULL
    SET @CurrentCommandOutput02 = NULL
    SET @CurrentCommandOutput03 = NULL
    SET @CurrentCommandType02 = NULL
    SET @CurrentCommandType03 = NULL
    DELETE FROM @CurrentDirectories
    DELETE FROM @CurrentFiles
    END
    --// Log completing information //--
    Logging:
    SET @EndMessage = 'Date and time: ' + CONVERT(nvarchar,GETDATE(),120)
    SET @EndMessage = REPLACE(@EndMessage,'%','%%')
    RAISERROR(@EndMessage,10,1) WITH NOWAIT
    IF @ReturnCode <> 0
    BEGIN
    RETURN @ReturnCode
    END
    END
    GO
    ALTER AUTHORIZATION ON [dbo].[DatabaseBackup] TO SCHEMA OWNER
    GO
    Diane

  • Trouble with calling a stored procedure with VARCHAR parameter from trigger

    Hi everybody,
    today I ran across a problem with stored procedures and triggers that try to call them. Background info: I want to log changes in certain tables to another table in a trigger, so I can replicate the changes to another (non-Oracle) database in an asynchronous way. As an example I have the first data table "bak_s3_berufliste" and the table to store the changes in is "bak_s3_change_request".
    DROP TABLE BAK_S3_BERUFLISTE;
    CREATE TABLE bak_s3_berufliste (
    id_bl NUMBER(27,0) NOT NULL,
    berufsbez VARCHAR2(255),
    CONSTRAINT PK_BAK_S3_BERUFLISTE PRIMARY KEY (id_bl) ENABLE);
    DROP TABLE bak_s3_change_request;
    CREATE TABLE bak_s3_change_request (
    ID_CR NUMBER(27,0) NOT NULL,
    TABELLE_NAME VARCHAR2(50) NOT NULL,
    TABELLE_ID_ALT NUMBER(27,0),
    TABELLE_ID_NEU NUMBER(27,0),
    CONSTRAINT PK_BAK_S3_CHANGE_REQUEST PRIMARY KEY (ID_CR) ENABLE);
    DROP SEQUENCE seq_bak_s3_change_request;
    CREATE SEQUENCE seq_bak_s3_change_request;
    For testing purposes I created the following stored procedure and trigger:
    CREATE OR REPLACE PROCEDURE schreibe_cr (t_id_alt IN NUMBER, t_id_neu IN NUMBER) IS
    BEGIN
    INSERT INTO bak_s3_change_request(ID_CR, TABELLE_NAME, TABELLE_ID_ALT, TABELLE_ID_NEU)
    VALUES (seq_bak_s3_change_request.NEXTVAL, t_name, t_id_alt, t_id_neu);
    END;
    CREATE OR REPLACE TRIGGER trg_bak_s3_berufliste
    BEFORE INSERT OR UPDATE OR DELETE ON bak_s3_berufliste
    FOR EACH ROW
    call schreibe_cr(:old.id_bl,:new.id_bl)
    *... and everything worked perfectly - except from the fact that I need to know which table had changed of course. So I added another parameter to the stored procedure:*
    CREATE OR REPLACE PROCEDURE schreibe_cr (t_name IN VARCHAR2, t_id_alt IN NUMBER, t_id_neu IN NUMBER) IS
    BEGIN
    INSERT INTO bak_s3_change_request(ID_CR, TABELLE_NAME, TABELLE_ID_ALT, TABELLE_ID_NEU)
    VALUES (seq_bak_s3_change_request.NEXTVAL, t_name, t_id_alt, t_id_neu);
    END;
    and tested it:
    CALL schreibe_cr('Test',1,2);
    *... successfully. So I also added the parameter to the trigger:*
    CREATE OR REPLACE TRIGGER trg_bak_s3_berufliste
    BEFORE INSERT OR UPDATE OR DELETE ON bak_s3_berufliste
    FOR EACH ROW
    call schreibe_cr('Tabellenname',1,2)
    and what i get is:
    Error starting at line 31 in command:
    CREATE OR REPLACE TRIGGER trg_bak_s3_berufliste
    BEFORE INSERT OR UPDATE OR DELETE ON bak_s3_berufliste
    FOR EACH ROW
    call schreibe_cr('Tabellenname',1,2)
    When I try to insert something into that table I get the following error:
    insert into bak_s3_berufliste (id_bl, berufsbez) values (seq_bak_s3_change_request.NEXTVAL, 'tueduelue');
    Error report:
    ORA-00911: Ungültiges Zeichen
    00911. 00000 - "invalid character"
    Cause: identifiers may not start with any ASCII character other than
    letters and numbers. $#_ are also allowed after the first
    character. Identifiers enclosed by doublequotes may contain
    any character other than a doublequote. Alternative quotes
    (q'#...#') cannot use spaces, tabs, or carriage returns as
    delimiters. For all other contexts, consult the SQL Language
    Reference Manual.
    Action:
    I tried everything that came to my mind, like using double-quotes (") instead of quotes (') in the trigger code or escaping the quotes (\'), but nothing worked. Can anybody help my and tell me what's wrong? After googling for hours I'm outta ideas :-(
    Any ideas appreciated!
    Thanks in advance,
    Jens

    Why?
    Are you looking for this?
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:01.61
    satyaki>
    satyaki>
    satyaki>create table aud_dup_emp
      2     as
      3       select empno, ename
      4       from dup_emp
      5       where 1=2;
    Table created.
    Elapsed: 00:00:01.86
    satyaki>
    satyaki>select * from dup_emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       7000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
    18 rows selected.
    Elapsed: 00:00:00.10
    satyaki>
    satyaki>
    satyaki>create or replace procedure ins_aud_dup(eno in number, enm in varchar2)
      2     is
      3     begin
      4       insert into aud_dup_emp(empno,ename) values(eno,enm);
      5     end;
      6  /
    Procedure created.
    Elapsed: 00:00:03.36
    satyaki>
    satyaki>
    satyaki>
    satyaki>ed
    Wrote file afiedt.buf
      1  create or replace trigger trg_aud_dup
      2  before insert on dup_emp
      3     for each row
      4     begin
      5       ins_aud_dup(:old.empno,:new.ename);
      6*    end;
    satyaki>/
    Trigger created.
    Elapsed: 00:00:01.47
    satyaki>
    satyaki>
    satyaki>select * from aud_dup_emp;
    no rows selected
    Elapsed: 00:00:00.10
    satyaki>
    satyaki>
    satyaki>insert into dup_emp(empno,ename,deptno) values(8855,'BILLY',40);
    1 row created.
    Elapsed: 00:00:00.19
    satyaki>
    satyaki>commit;
    Commit complete.
    Elapsed: 00:00:00.03
    satyaki>
    satyaki>
    satyaki>select * from dup_emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       7000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          8855 BILLY                                                                   40
    19 rows selected.
    Elapsed: 00:00:00.20
    satyaki>
    satyaki>select * from aud_dup_emp;
         EMPNO ENAME
               BILLY
    Elapsed: 00:00:00.09
    satyaki>Regards.
    Satyaki De.

  • Crystal Report and stored procedure calls

    Hi,
    1.   I am trying to access a Stored Procedure through Crystal Reports 2008. I have 3 Parameters in it and now I need the 2 Parameters from the stored Procedure to be given by User and the 3rd Parameter should be passed from the backend code. Please help me with the setps that would help me do this.
    2.I also have another Stored procedure where I have 3 parameters and in addition to that I should provide two other parameters for user to enter. Now the total number of parameters will be 5 Parameters. Can any one let me know how to implement all these parameters.
    3. In another Storedprocedure I have two Parameters which are discrete and multi select and both of them are cascaded. How do I implement those.
    Thanks
    Pradeep

    Please re-post if this is still an issue or purchase a case and have a dedicated support engineer work with you directly:
    http://store.businessobjects.com/store/bobjamer/DisplayProductByTypePage&parentCategoryID=&categoryID=11522300?resid=-Z5tUwoHAiwAAA8@NLgAAAAS&rests=1254701640551

Maybe you are looking for