Run second sql statement only if first sql statement is null.

Hey guys I seem to have a mental block here. I have two sql statements. I would like the second to run only if the first sql statement is null.I know i can potentially use PLsql but would really like to see if i can do this with straight up sql. Your responses are very very appreciated.
here is the first sql
  Select     ft.fund_code,
             ft.orgn_code,
             ft.acct_code,
             ft.amount,
             fb.owner_pidm,
             ft.prog_code     
      from ftrbremb fb , ftcractg ft
      where fb.doc_code = 'TR000038'
      and fb.ftpbport_id = ft.ftpbport_idsecond sql statement
     Select ft.fund_code,
             ft.orgn_code,
             ft.acct_code,
             ft.amount,
             fb.owner_pidm,
             ft.prog_code     
      from ftrbremb fb , ftcractg ft, ftprexps fx
      where fb.doc_code = 'TR000038'
      --and fb.ftpbport_id = ft.ftpbport_id
      and fx.ftrbremb_id = fb.id
      and ft.ftprexps_id = fx.id;How can i combine these two statements together so that when the first one is null the second one runs. As a bonus i like to get just the first row as well.
Any help would greatly appreciated. I tried to accomplish with case statement but it just dosent seem to be working for me.
Thanks

select ft.fund_code, ft.orgn_code, ft.acct_code, ft.amount, fb.owner_pidm, ft.prog_code
  from ftrbremb fb, ftcractg ft
where fb.doc_code = 'TR000038'
   and fb.ftpbport_id = ft.ftpbport_id
union all
select ft.fund_code, ft.orgn_code, ft.acct_code, ft.amount, fb.owner_pidm, ft.prog_code
  from ftrbremb fb, ftcractg ft, ftprexps fx
where fb.doc_code = 'TR000038'
   --and fb.ftpbport_id = ft.ftpbport_id
   and fx.ftrbremb_id = fb.id
   and ft.ftprexps_id = fx.id
   and not exists
         (select null
            from ftrbremb fb, ftcractg ft
           where fb.doc_code = 'TR000038'
             and fb.ftpbport_id = ft.ftpbport_id)

Similar Messages

  • When SAP run mrp, it could only identifiy first 9 characters as material?

    Hi experts
      In SAP, Could we set when we run mrp, sap will only check the first 9 chars as mateiral number ?
    eg: material 12345-67890 and 12345-6789,  Could sap consider it as same material ? If there is any configure for this ?
    Thanks
    Alice

    Hi experts
    Our purpose is we need setup two material number like aaaa-aaaa1 and aaaa-aaaa2 for same part but from different localization source.
    Since they are same part , if mrp could only reconginze the first 9 character as materail number to run requirements ?   what does it mean planning material ? It could set the first 9 character as planning material different from the normal materail ?
    Thanks
    Alice

  • Installed hotfix for error 3241 when you run RESTORE FILELISTONLY statement in SQL Server 2008 R2. But still get same errormessage.

    I ran into erro 3241 when you run RESTORE FILELISTONLY statement in SQL Server 2008 R2.
    Found the hotfix 
    Cumulative Update 13 for SQL Server 2008 R2 SP1.
    I have installed this hotfix, now running 10.50.2876.0
    But I still get the same error when trying to restore a backup.
    What else do I need to do?

    second to what bodo said Instead of installing SQL server 2012 SP1 CU13 it would be better to install
    SQL Server 2008 r2 Sp2 SP's are more throughly tested and would include all fixes for CU and Sp1
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
    My Technet Articles

  • Desc table_name statements no longer running in sql developer

    simple desc statements like desc table_name; used to run in sql developer however they no longer work.
    It was working a few days ago and now the same statements dont return any results. The tables exist as I can run select statements fine just not desc table_name;
    Any ideas how this can be fixed?

    I haven't had problems with the "desc table_name;" functionality for a long time - do you know of anything that has changed since they were working a few days ago?
    If you run the following query with :1 being the table owner and :2 being the table name, do you get the columns listed?SELECT t.column_name "Name",
      DECODE(t.nullable,'Y',NULL,'NOT NULL') "Null",
      UPPER(t.data_type)
      ||
      CASE
        WHEN ( t.data_type = 'VARCHAR' OR t.data_type = 'VARCHAR2' OR t.data_type = 'RAW' OR t.data_type = 'CHAR' )
            AND ( t.data_length != 0 AND NVL(t.data_length,-1) != -1)
        THEN
          CASE
            WHEN(t.char_used = 'C' AND 'BYTE' = (SELECT value FROM nls_session_parameters WHERE PARAMETER = 'NLS_LENGTH_SEMANTICS' ))
            THEN '(' || t.char_length || ' CHAR)'
            WHEN(t.char_used = 'B' AND 'CHAR' = (SELECT value FROM nls_session_parameters WHERE PARAMETER = 'NLS_LENGTH_SEMANTICS' ))
            THEN '(' || t.data_length || ' BYTE)'
            WHEN(t.char_used = 'C' AND 'CHAR' = (SELECT value FROM nls_session_parameters WHERE PARAMETER = 'NLS_LENGTH_SEMANTICS' ))
            THEN '(' || t.char_length || ')'
            WHEN(t.char_used = 'B' AND 'BYTE' = (SELECT value FROM nls_session_parameters WHERE PARAMETER = 'NLS_LENGTH_SEMANTICS' ))
            THEN '(' || t.data_length || ')'
            ELSE '(' || t.data_length || ' BYTE)'
          END
        WHEN (t.data_type = 'NVARCHAR2' OR t.data_type = 'NCHAR')
        THEN '(' || t.data_length/2 || ')'
        WHEN (t.data_type LIKE 'TIMESTAMP%' OR t.data_type LIKE 'INTERVAL DAY%' OR t.data_type LIKE 'INTERVAL YEAR%' OR t.data_type = 'DATE' OR(t.data_type = 'NUMBER' AND (t.data_precision       = 0 OR NVL(t.data_precision,-1) = -1)))
        THEN ''
        WHEN (t.data_scale = 0 OR NVL(t.data_scale,-1) = -1)
        THEN '(' || t.data_precision ||')'
        ELSE '(' || t.data_precision ||',' ||t.data_scale ||')'
      END "Type"
    FROM sys.all_tab_columns t,
      sys.all_col_comments c
    WHERE t.column_name = c.column_name
    AND c.owner         = t.owner
    AND c.table_name    = t.table_name
    AND UPPER(t.owner)  = UPPER(:1)
    AND t.table_name    = :2
    ORDER BY t.column_idtheFurryOne

  • Running multiple SQL statements from DBMS_SCHEDULER

    DB Version : 10.2.0.4
    After refering the following document, i am trying to create a job which will run 2 SQLs ; An INSERT and an UPDATE as shown below.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/jobtosched.htm#i1018602
    create table xyz (empid  number,empname varchar2(35),cre_dt date);
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB(
       job_name          =>  'job32',
       job_type          =>  'PLSQL_BLOCK',
       job_action        =>  'INSERT INTO XYZ VALUES (7935, ''SALLY'',SYSDATE),'UPDATE MANU.XYZ SET EMPID = 33';
       start_date        =>  SYSDATE,
       repeat_interval   =>  'FREQ = DAILY; INTERVAL = 1');
    END;
    /But i am getting errors like below, when i try to create the above job.
    ORA-01756: quoted string not properly terminated
    PLS-00103: Encountered the symbol ";" when expecting one of the following:

    You need to enclose those statements in an anonymous PL/SQL block
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB(
       job_name          =>  'job32',
       job_type          =>  'PLSQL_BLOCK',
       job_action        =>  'BEGIN INSERT INTO XYZ VALUES (7935, ''SALLY'',SYSDATE); UPDATE MANU.XYZ SET EMPID = 33; END;'
       start_date        =>  SYSDATE,
       repeat_interval   =>  'FREQ = DAILY; INTERVAL = 1');
    END;
    /

  • Sql to return second record in a query first

    I have a query that simply retruns records ordered by date
    most recent. What
    I need is to show the second record in the set only, or
    first. How would I
    do that?

    Make the inner join a LEFT JOIN
    SELECT        (ct.amount)
    FROM            dbo.card AS c WITH (NOLOCK) LEFT JOIN
                             dbo.card_transaction_log AS ct WITH (NOLOCK) ON ct.card_id = c.card_id  AND ct.transaction_response_cd = '00' AND 
                             ct.transaction_type_cd = 'REDEMPTION' AND ct.lastupdated <= '2013-12-09 11:02:00'
                             where c.card_id IN 
                             1767811,
                             1767812,
                             1767813 )
    Tom
    P.S.  Using WITH (NOLOCK) is usually a bad idea.  It amounts to saying you don't care if you might get bad data, duplicate data, missing data or unexpected errors.  If you are not having blocking problems, you don't need WITH(NOLOCK) and if
    you are having blocking problems it is usually better to look for other solutions, like improving your indexing strategy or using the SNAPSHOT transaction isolation level.
    Tom

  • Calling from the application Slow vs. Running through SQL developer Fast

    Alright, we write many applications that make use of calling stored procedures in packages to return data. This is the only time i have ever encountered this issue and have not been able to pinpoint the cause.
    This application is very data-centric and is filled with calls to stored procedures and I would say about 80% run fine as in the time required to run is about the same as in SQL Developer maybe just a little slower due to the amount of data that may be returned to the application. The other 20% run horribly slow from the application and run lighting fast in SQL Developer and i cannot figure out why.
    I have traced the code right up to the .Fill on the Oracle.DataAccess.Client.OracleDataAdapter and that is where it just holds either for a long period of time or just forever, some of these i haved waited hours for and they have not finished running.
    For Example: I created a new page in the project and it makes a request through the use of ajax, when the request file is reached it performs two stored procedures from the same package (the only two procedures in the package). Both procedures take in three varchar2's and have an in out cursor, the cursor is returned into a datatable in the VB. The first query runs in a couple seconds returns the correct data etc. The second query, which takes .2 seconds on average to run from SQL Developer, just runs and runs and i have never actually even waited for it to finish because it takes so long. The specific example i am trying only returns 1 row with 7 columns, so there is not a large amount of data being passed back.
    I have seen this sort of thing happen on occasions, but everytime it was usually because the package was not compiled and was waiting on a view to finish before compilation and after killing the view it was fine. But this issue seems to happen randomnly with certain procedures and not others all in the same package.
    This issue happens on the same procedures everytime which would lead me to believe it is the procedure, but running them in SQL Developer shows me this is incorrect because they run exceptionally fast in some cases. I even went so far as to restart the entire database just in case there was some sort of lock causing this issue but this did not fix the issue.
    I have verified parameters, cursors, debugged the procedures, stepped every line of code, tried deleting and readding the oracle.dataAccess reference. I can't seem to figure this one out.
    It is causing alot of wasted time because i am forced to wait a horribly long time for these queries in order to test. If anyone has any clues, hints, or ideas as to what this could be please let me know! If the same issue exists when the application is moved into production it will be unnacceptable and the application utterly unusable.
    Thanks in Advance for any help!
    -Jarrod

    Hi,
    This is consistently reproducible with the problem procedure/operations? Total WAG here, but I've seen cases where having support for distributed transactions enabled causes the database to disable certain optimizations. Try setting Enlist=false in your connection string.
    Otherwise, I'd recommend enabling 10046 database trace and client side sqlnet trace to capture the problem behavior for further investigation. Oracle support can certainly give you a hand with that if needed.
    Hope it helps,
    Greg

  • Msg 8631 Internal error: Server stack limit has been reached on SQL Server 2012 from T-SQL script that runs on SQL Server 2008 R2

    I have an Script mostly that is generated by SSMS which works with-out issue on SQL Server 2008, but when I attempt to run it on a new fresh install of SQL Server 2012 I get an Msg 8631. Internal error: Server stack limit has been reached. Please look for
    potentially deep nesting in your query, and try to simplify it.
    The script itself doesn't seem to be all that deep or nested.  The script is large 2600 lines and when I remove the bulk of the 2600 lines, it does run on SQL Server 2012.  I'm just really baffled why something that SQL Server generated with very
    few additions/changes AND that WORKS without issue in SQL Server 2008 R2 would suddenly be invalid in SQL Server 2012
    I need to know why my script which is working great on our current SQL Server 2008 R2 servers suddenly fails and won't run on an new SQL Server 2012 server.  This script is used to create 'bulk' Replications on a large number of DBs saving a tremendous
    amount of our time doing it the manual way.
    Below is an 'condensed' version of the script which fails.  I have removed around 2550 lines of specific sp_addarticle statements which are mostly just copy and pasted from what SQL Management Studio 'scripted' for me went I when through the Replication
    Wizard and told it to save to script.
    declare @dbname varchar(MAX), @SQL nvarchar(MAX)
    declare c_dblist cursor for
    select name from sys.databases WHERE name like 'dbone[_]%' order by name;
    open c_dblist
    fetch next from c_dblist into @dbname
    while @@fetch_status = 0
    begin
    print @dbname
    SET @SQL = 'DECLARE @dbname NVARCHAR(MAX); SET @dbname = ''' + @dbname + ''';
    use ['+@dbname+']
    exec sp_replicationdboption @dbname = N'''+@dbname+''', @optname = N''publish'', @value = N''true''
    use ['+@dbname+']
    exec ['+@dbname+'].sys.sp_addlogreader_agent @job_login = N''DOMAIN\DBServiceAccount'', @job_password = N''secret'', @publisher_security_mode = 1, @job_name = null
    -- Adding the transactional publication
    use ['+@dbname+']
    exec sp_addpublication @publication = N'''+@dbname+' Replication'', @description = N''Transactional publication of database
    '''''+@dbname+''''' from Publisher ''''MSSQLSRV\INSTANCE''''.'', @sync_method = N''concurrent'', @retention = 0, @allow_push = N''true'', @allow_pull = N''true'', @allow_anonymous = N''false'', @enabled_for_internet
    = N''false'', @snapshot_in_defaultfolder = N''true'', @compress_snapshot = N''false'', @ftp_port = 21, @allow_subscription_copy = N''false'', @add_to_active_directory = N''false'', @repl_freq = N''continuous'', @status = N''active'', @independent_agent = N''true'',
    @immediate_sync = N''true'', @allow_sync_tran = N''false'', @allow_queued_tran = N''false'', @allow_dts = N''false'', @replicate_ddl = 1, @allow_initialize_from_backup = N''true'', @enabled_for_p2p = N''false'', @enabled_for_het_sub = N''false''
    exec sp_addpublication_snapshot @publication = N'''+@dbname+' Replication'', @frequency_type = 1, @frequency_interval = 1, @frequency_relative_interval = 1, @frequency_recurrence_factor = 0, @frequency_subday = 8,
    @frequency_subday_interval = 1, @active_start_time_of_day = 0, @active_end_time_of_day = 235959, @active_start_date = 0, @active_end_date = 0, @job_login = N''DOMAIN\DBServiceAccount'', @job_password = N''secret'', @publisher_security_mode = 1
    -- There are around 2400 lines roughly the same as this only difference is the tablename repeated below this one
    use ['+@dbname+']
    exec sp_addarticle @publication = N'''+@dbname+' Replication'', @article = N''TABLE_ONE'', @source_owner = N''dbo'', @source_object = N''TABLE_ONE'', @type = N''logbased'', @description = null, @creation_script =
    null, @pre_creation_cmd = N''drop'', @schema_option = 0x000000000803509F, @identityrangemanagementoption = N''manual'', @destination_table = N''TABLE_ONE'', @destination_owner = N''dbo'', @vertical_partition = N''false'', @ins_cmd = N''CALL sp_MSins_dboTABLE_ONE'',
    @del_cmd = N''CALL sp_MSdel_dboTABLE_ONE'', @upd_cmd = N''SCALL sp_MSupd_dboTABLE_ONE''
    EXEC sp_executesql @SQL
    SET @dbname = REPLACE(@dbname, 'dbone_', 'dbtwo_');
    print @dbname
    SET @SQL = 'DECLARE @dbname NVARCHAR(MAX); SET @dbname = ''' + @dbname + ''';
    use ['+@dbname+']
    exec sp_replicationdboption @dbname = N'''+@dbname+''', @optname = N''publish'', @value = N''true''
    use ['+@dbname+']
    exec ['+@dbname+'].sys.sp_addlogreader_agent @job_login = N''DOMAIN\DBServiceAccount'', @job_password = N''secret'', @publisher_security_mode = 1, @job_name = null
    -- Adding the transactional publication
    use ['+@dbname+']
    exec sp_addpublication @publication = N'''+@dbname+' Replication'', @description = N''Transactional publication of database
    '''''+@dbname+''''' from Publisher ''''MSSQLSRV\INSTANCE''''.'', @sync_method = N''concurrent'', @retention = 0, @allow_push = N''true'', @allow_pull = N''true'', @allow_anonymous = N''false'', @enabled_for_internet
    = N''false'', @snapshot_in_defaultfolder = N''true'', @compress_snapshot = N''false'', @ftp_port = 21, @allow_subscription_copy = N''false'', @add_to_active_directory = N''false'', @repl_freq = N''continuous'', @status = N''active'', @independent_agent = N''true'',
    @immediate_sync = N''true'', @allow_sync_tran = N''false'', @allow_queued_tran = N''false'', @allow_dts = N''false'', @replicate_ddl = 1, @allow_initialize_from_backup = N''true'', @enabled_for_p2p = N''false'', @enabled_for_het_sub = N''false''
    exec sp_addpublication_snapshot @publication = N'''+@dbname+' Replication'', @frequency_type = 1, @frequency_interval = 1, @frequency_relative_interval = 1, @frequency_recurrence_factor = 0, @frequency_subday = 8,
    @frequency_subday_interval = 1, @active_start_time_of_day = 0, @active_end_time_of_day = 235959, @active_start_date = 0, @active_end_date = 0, @job_login = N''DOMAIN\DBServiceAccount'', @job_password = N''secret'', @publisher_security_mode = 1
    -- There are around 140 lines roughly the same as this only difference is the tablename repeated below this one
    use ['+@dbname+']
    exec sp_addarticle @publication = N'''+@dbname+' Replication'', @article = N''DB_TWO_TABLE_ONE'', @source_owner = N''dbo'', @source_object = N''DB_TWO_TABLE_ONE'', @type = N''logbased'', @description = null, @creation_script
    = null, @pre_creation_cmd = N''drop'', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N''manual'', @destination_table = N''DB_TWO_TABLE_ONE'', @destination_owner = N''dbo'', @vertical_partition = N''false''
    EXEC sp_executesql @SQL
    fetch next from c_dblist into @dbname
    end
    close c_dblist
    deallocate c_dblist
    George P Botuwell, Programmer

    Hi George,
    Thank you for your question. 
    I am trying to involve someone more familiar with this topic for a further look at this issue. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated. 
    Thank you for your understanding and support.
    If you have any feedback on our support, please click
    here.
    Allen Li
    TechNet Community Support

  • Several errors after running catalog.sql

    I did a fresh installation of oracle apps EBS 11.5.10.2 on Linux OEL and was trying to do an import/export and it was not working as expected. So after i looked at Oracle's documentation it said catalog.sql has to be run before using the import/export. So i ran catalog.sql first but i did not run it with SYSDBA but ran it as SYSTEM and i saw several errors like access denied etcv. after i ran the catalog.sql i was not able to login via apps or any other user except SYSTEM and was giving me erros like ORA-04065:not executed,altered or dropped stored procedure "SYS.DBMS_SESSION"
    After this to fix the issue i ran @?/rdbms/admin/catpatch.sql and @?/rdbms/admin/utlrp as SYSDBA but both executed a lot of grants etc but are haging at some point and not finishing.
    The current state of the database is that im not able to login via any user except SYSTEM and i think i corrupted the db dictionary as everywhere i see they say running catalog.sql on an existing database is a bad idea. Can anyone help?

    Hi Dheeraj,
    My db version is 9.2.0.5.0 and OS is OEL 5.7.
    The doc where it was mentioned to run catalog.sql before using import/export is below:
    http://docs.oracle.com/cd/B10501_01/server.920/a96652/ch01.htm
    Please do not follow the steps in this link and instead follow the steps in (9i Export/Import Process for Oracle Applications Release 11i [ID 230627.1]).
    Currently when im trying to login using apps or any other user below are errors i get.
    ERROR:
    ORA-00604: error occurred at recursive SQL level1
    ORA-04068: existing state of packages has been discarded
    ORA-04065: not executed, altered or dropped stored procedure "SYS.DBMS_SESSION"
    ORA-06508: PL/SQL: could not find program unit being called
    ORA-06512:at "SYS.OWA_VPD_CTX", line 5
    ORA-06512:at "SYS.PORTAL_LOGIN", line 3
    ORA-06512:at line 2
    Can you pls help me to fix this.The status of the package is invalid and you need to validate it. Connect as sysdba and issue:
    SQL> select owner, object_type, status
    from dba_objects
    where object_name = 'DBMS_SESSION';
    SQL> alter package DBMS_SESSION compile body;
    SQL> show error
    SQL> alter package DBMS_SESSION compile;
    SQL> show errorPlease also see:
    Data Dictionary Objects Invalid after Running catalog.sql, catproc.sql, utlrp.sql or catpatch.sql [ID 752783.1]
    Debug and Validate Invalid Objects [ID 300056.1]
    How to Diagnose Invalid or Missing Data Dictionary (SYS) Objects [ID 554520.1]
    Thanks,
    Hussein

  • Create trigger not audited when run from sql developer Version 3.2.20.09

    Creating or editing a trigger is not being stored in the audit table when run from sql developer.
    Here is a sample script to show the issue:
    Grant Connect,create table,create trigger To testuser Identified By testuser;
    create table testuser.testtab(t1 number);
    Select Count(*) From Dba_Audit_Trail Where Owner='TESTUSER';
    CREATE OR REPLACE TRIGGER testuser.testtab_bi_trg BEFORE
      Insert
          ON testuser.testtab FOR EACH ROW
    begin
      null;
    end;
    Select Count(*) From Dba_Audit_Trail  Where Owner='TESTUSER';
    drop user testuser cascade;
    If I run the script from sql developer the CREATE TRIGGER statement does not get audited.
    If I run the script from sql plus or All Arround Automations PL/SQL Developer the CREATE TRIGGER statement does get audited.
    If I edit the trigger from sql developer the CREATE TRIGGER statement does not get audited.
    If I edit the trigger from  All Arround Automations PL/SQL Developer the CREATE TRIGGER statement does get audited.

    DoyleFreeman wrote:
    Not sure what you mean by "perform the audit".
    Have you tested my script? Does the "Select Count(*) From Dba_Audit_Trail  Where Owner='TESTUSER';" increment by 1 after each of the ddl statements or only after the Create table statement.
    Your question doesn't have ANYTHING to do with sql developer and should be posted in the Database General forum
    https://forums.oracle.com/community/developer/english/oracle_database/general_questions
    Yes - and it works just fine once you ENABLE AUDITING. Your scripIt  does NOT include the statements or code used to ENABLE auditing and, specifically, enable auditing for triggers.
    Auditing doesn't just 'happen'; you have to enable it and you have to specify any non-default auditing that you want to perform.
    Have you read any of the extensive documentation about auditing to learn how to use it?
    See the Database Security Guide
    http://docs.oracle.com/cd/E11882_01/network.112/e16543/auditing.htm
    Also see 'Auditing Functions, Procedures, Packages, and Triggers
    http://docs.oracle.com/cd/E11882_01/network.112/e16543/auditing.htm#BCGBEAGC
    And see the AUDIT statement in the SQL language doc for how to specify auditing of specific operations.
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_4007.htm
    Select count(*) From Dba_Audit_Trail  Where (Owner='SCOTT' or username = 'SCOTT')
    and action_name = 'CREATE TRIGGER';
    COUNT(*)
    0
    audit create trigger by scott
    CREATE OR REPLACE TRIGGER emp_copy_bi_trg BEFORE
      Insert
          ON emp_copy FOR EACH ROW
    begin
      null;
    end;
    Select count(*) From Dba_Audit_Trail  Where (Owner='SCOTT' or username = 'SCOTT')
    and action_name = 'CREATE TRIGGER';
    COUNT(*)
    1

  • Credential problem while running with SQL job agent

    Hi,
    SQL job agent fails to run when I change my computer login (Password) credentials information often.
    How I can run the SQL job agent with Database login credentials.
    Regards
    Venkatesh S

    Hi Venkatesh,
    If I understand correctly, you are using a proxy account has your login credential to run a step of SQL Agent Job. So when you change the login’s password, the credential of the proxy account has an expired password, then the proxy account doesn’t work in
    your job.
    As per my understanding, we can only use SQL Server Agent Service Account or Proxy Account to run the SQL Server Integration Services Package steps in SQL Agent Job. Since the SQL Server Agent Service Account may not have required permissions to access the
    resources in the packages, we recommend use Proxy Account. To create Proxy Account, we should create a credential first. To create a credential, we should specify a Windows user account. So we cannot use a SQL Server authentication login to run the job.
    A good workaround is use a windows user account with a password that never expire or changes rarely or update the password of credential followed by your login.
    Reference:
    How to: Automate SSIS Package Execution by Using the SQL Server Agent (SQL Server Video)
    How to: Run a Package
    How to: Create a Proxy (SQL Server Management Studio
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • SQL-Command to long to run with SQL*Plus

    Hello to everyone,
    I'm creating a dynamic SQL Script to run with SQL*Plus.
    The Script contains only INSERT Command.
    The point is that the SQL*Plus supports only SQL-Strings (Commands)
    not longer than 2500 Characters.
    I've considered to split the String in Insert- and Update-Command(s),
    but I've would like first to know if there any simpler way to run these
    Commands on SQL*Plus.
    thanx in Advance
    bm

    SQL> create table t(x varchar2(4000));
    Table created.
    SQL> insert into t values (
    '1234567890........0........0........0........0........0........0........0........0......100' ||
    '1234567890........0........0........0........0........0........0........0........0......200' ||
    '1234567890........0........0........0........0........0........0........0........0......300' ||
    '1234567890........0........0........0........0........0........0........0........0......400' ||
    '1234567890........0........0........0........0........0........0........0........0......500' ||
    '1234567890........0........0........0........0........0........0........0........0......600' ||
    '1234567890........0........0........0........0........0........0........0........0......700' ||
    '1234567890........0........0........0........0........0........0........0........0......800' ||
    '1234567890........0........0........0........0........0........0........0........0......900' ||
    '1234567890........0........0........0........0........0........0........0........0.....1000' ||
    '1234567890........0........0........0........0........0........0........0........0.....1100' ||
    '1234567890........0........0........0........0........0........0........0........0.....1200' ||
    '1234567890........0........0........0........0........0........0........0........0.....1300' ||
    '1234567890........0........0........0........0........0........0........0........0.....1400' ||
    '1234567890........0........0........0........0........0........0........0........0.....1500' ||
    '1234567890........0........0........0........0........0........0........0........0.....1600' ||
    '1234567890........0........0........0........0........0........0........0........0.....1700' ||
    '1234567890........0........0........0........0........0........0........0........0.....1800' ||
    '1234567890........0........0........0........0........0........0........0........0.....1900' ||
    '1234567890........0........0........0........0........0........0........0........0.....2000' ||
    '1234567890........0........0........0........0........0........0........0........0.....2100' ||
    '1234567890........0........0........0........0........0........0........0........0.....2200' ||
    '1234567890........0........0........0........0........0........0........0........0.....2300' ||
    '1234567890........0........0........0........0........0........0........0........0.....2400' ||
    '1234567890........0........0........0........0........0........0........0........0.....2500' ||
    '1234567890........0........0........0........0........0........0........0........0.....2600' ||
    '1234567890........0........0........0........0........0........0........0........0.....2700' ||
    '1234567890........0........0........0........0........0........0........0........0.....2800' ||
    '1234567890........0........0........0........0........0........0........0........0.....2900' ||
    '1234567890........0........0........0........0........0........0........0........0.....3000'
    1 row created.try to break your query in multiple lines in order to avoid
    SP2-0027: Input is too long (> 2499 characters) - line ignored

  • Running PL/SQL in batch mode

    I need to run a few PL/SQL procedures at various time of the day and night on an Oracle 8.1.7 database. I do I go about automatically kicking off these procedures at specific times.

    DBMS_JOB is Oracle built-in packages owned by SYS.
    The following is a list of DBMS_JOB header:
    PACKAGE dbms_job IS
    any_instance CONSTANT BINARY_INTEGER := 0;
    -- Parameters are:
    -- JOB is the number of the job being executed.
    -- WHAT is the PL/SQL procedure to execute.
    -- The job must always be a single call to a procedure. The
    -- routine may take any number of hardcoded parameters.
    -- Special parameter values recognized are:
    -- job: an in parameter, the number of the current job
    -- next_date: in/out, the date of the next refresh
    -- broken: in/out, is the job broken. The IN values is FALSE.
    -- Always remember the trailing semicolon.
    -- Some legal values of WHAT (assuming the routines exist) are
    -- 'myproc( ''10-JAN-82'', next_date, broken);'
    -- 'scott.emppackage.give_raise( ''JENKINS'', 30000.00);'
    -- 'dbms_job.remove( job);'
    -- NEXT_DATE is the date at which the job will next be automatically run,
    -- assuming there are background processes attempting to run it.
    -- INTERVAL is a date function, evaluated immediately before the job starts
    -- executing. If the job completes successfully, this new date is placed
    -- in NEXT_DATE. INTERVAL is evaluated by plugging it into the statement
    -- select INTERVAL into next_date from dual;
    -- INTERVAL must evaluate to a time in the future. Legal intervals include
    -- 'sysdate + 7' -- execute once a week
    -- 'NEXT_DAY(sysdate,''TUESDAY'')' -- execute once every tuesday
    -- 'null' -- only execute once
    -- If INTERVAL evaluates to null and a job completes successfully, then
    -- the job is automatically deleted from the queue.
    PROCEDURE isubmit ( job IN BINARY_INTEGER,
    what IN VARCHAR2,
    next_date IN DATE,
    interval IN VARCHAR2 DEFAULT 'null',
    no_parse IN BOOLEAN DEFAULT FALSE);
    -- Submit a new job with a given job number.
    PROCEDURE submit ( job OUT BINARY_INTEGER,
    what IN VARCHAR2,
    next_date IN DATE DEFAULT sysdate,
    interval IN VARCHAR2 DEFAULT 'null',
    no_parse IN BOOLEAN DEFAULT FALSE,
    instance IN BINARY_INTEGER DEFAULT any_instance,
    force IN BOOLEAN DEFAULT FALSE );
    -- Submit a new job. Chooses JOB from the sequence sys.jobseq.
    -- instance and force are added for jobq queue affinity
    -- If FORCE is TRUE, then any positive integer is acceptable as the job
    -- instance. If FORCE is FALSE, then the specified instance must be running;
    -- otherwise the routine raises an exception.
    -- For example,
    -- variable x number;
    -- execute dbms_job.submit(:x,'pack.proc(''arg1'');',sysdate,'sysdate+1');
    PROCEDURE remove ( job IN BINARY_INTEGER );
    -- Remove an existing job from the job queue.
    -- This currently does not stop a running job.
    -- execute dbms_job.remove(14144);
    PROCEDURE change ( job IN BINARY_INTEGER,
    what IN VARCHAR2,
    next_date IN DATE,
    interval IN VARCHAR2,
    instance IN BINARY_INTEGER DEFAULT NULL,
    force IN BOOLEAN DEFAULT FALSE);
    -- Change any of the the user-settable fields in a job
    -- Parameter instance and force are added for job queue affinity
    -- If what, next_date,or interval is null, leave that value as-is.
    -- instance defaults to NULL indicates instance affinity is not changed.
    -- If FORCE is FALSE, the specified instance (to which the instance number
    -- change) must be running. Otherwise the routine raises an exception.
    -- If FORCE is TRUE, any positive integer is acceptable as the job instance.
    -- execute dbms_job.change( 14144, null, null, 'sysdate+3');
    PROCEDURE what ( job IN BINARY_INTEGER,
    what IN VARCHAR2 );
    -- Change what an existing job does, and replace its environment
    PROCEDURE next_date ( job IN BINARY_INTEGER,
    next_date IN DATE );
    -- Change when an existing job will next execute
    PROCEDURE instance ( job IN BINARY_INTEGER,
    instance IN BINARY_INTEGER,
    force IN BOOLEAN DEFAULT FALSE);
    -- Change job instance affinity. FORCE parameter works same as in SUBMIT
    PROCEDURE interval ( job IN BINARY_INTEGER,
    interval IN VARCHAR2 );
    -- Change how often a job executes
    PROCEDURE broken ( job IN BINARY_INTEGER,
    broken IN BOOLEAN,
    next_date IN DATE DEFAULT SYSDATE );
    -- Set the broken flag. Broken jobs are never run.
    PROCEDURE run ( job IN BINARY_INTEGER,
    force IN BOOLEAN DEFAULT FALSE);
    -- Run job JOB now. Run it even if it is broken.
    -- Running the job will recompute next_date, see view user_jobs.
    -- execute dbms_job.run(14144);
    -- Warning: this will reinitialize the current session's packages
    -- FORCE is added for job queue affinity
    -- If FORCE is TRUE, instance affinity is irrelevant for running jobs in
    -- the foreground process. If FORCE is FALSE, the job can be run in the
    -- foreground only in the specified instance. dbms_job.run will raise an
    -- exception if FORCE is FALSE and the connected instance is the wrong one.
    PROCEDURE user_export ( job IN BINARY_INTEGER,
    mycall IN OUT VARCHAR2);
    -- Produce the text of a call to recreate the given job
    PROCEDURE user_export ( job IN BINARY_INTEGER,
    mycall IN OUT VARCHAR2,
    myinst IN OUT VARCHAR2);
    -- Procedure is added for altering instance affinity (8.1+) and perserve the
    -- compatibility
    -- Return boolean value indicating whether execution is in background
    -- process or foreground process
    FUNCTION background_process RETURN BOOLEAN;
    END;
    null

  • ORA-600 [17069] error while running catrelod.sql to downgrade 11g database

    Hi,
    We are downgrading our 11.2.0.2 database to 10.2.0.4. We have successfullly run catdwgrd.sql without any errors in 11g env. While running catrelod.sql in 10g env we are facing the following error:
    SQL> @?/rdbms/admin/catrelod.sql
    TIMESTAMP
    COMP_TIMESTAMP RELOD__BGN 2013-04-24 20:15:39 2456407 72939
    DOC>#######################################################################
    DOC>#######################################################################
    DOC>  The following statement will cause an "ORA-01722: invalid number"
    DOC>  error if the database server version is not 10.0.0.
    DOC>  Shutdown ABORT and use a different script or a different server.
    DOC>#######################################################################
    DOC>#######################################################################
    DOC>#
    no rows selected
    DOC>#######################################################################
    DOC>#######################################################################
    DOC>  The following statement will cause an "ORA-01722: invalid number"
    DOC>  error if the database has not been opened for MIGRATE.
    DOC>
    DOC>  Perform a "SHUTDOWN ABORT"  and
    DOC>  restart using MIGRATE.
    DOC>#######################################################################
    DOC>#######################################################################
    DOC>#
    no rows selected
    Session altered.
    Session altered.
    no rows selected
    DECLARE
    ERROR at line 1:
    ORA-00600: internal error code, arguments: [17069], [0x170FB8CA8], [], [], [],
    [], [], []I have checked the trace file in udump but it dint give any readable information.
    Please find below environment details.
    OS : RHEL 5 64 bit
    11g Database : 11.2.0.2
    10g Database : 10.2.0.4
    Kindly assist.

    KR10822864 wrote:
    Whenever an ORA-600 error is raised a trace file is generated and an entry written to the alert.log with details of the trace file location. Starting with Oracle Database 11g Release 1, the diagnosability infrastructure was introduced which places the trace and core files into a location controlled by the DIAGNOSTIC_DEST initialization parameter when an incident, such as an ORA-600 is created. For earlier versions, the trace file will be written to either USER_DUMP_DEST (if the error was caught in a user process) or BACKGROUND_DUMP_DEST (if the error was caught in a background process like PMON or SMON). The trace file contains vital information about what led to the error condition
    please post 40 lines of alert log info .
    MOS Note:ORA-600 [17069] "Failed to pin a library cache object after 50 attempts" [ID 39616.1]
    "Look in the trace file for the text 'LIBRARY OBJECT HANDLE: handle=170fb8ca8'"
    if not found any massages like above please raise [email protected].
    Hi KR,
    Thanks for your help. As suggested I have checked the trace file to search and found the below info. I suppose it is some kind of lock but not sure about it. Please let me know if the following makes sense:
        SO: 0x21158a6e0, type: 3, owner: 0x211006f28, flag: INIT/-/-/0x00
        (call) sess: cur 211572570, rec 211572570, usr 211572570; depth: 0
          SO: 0x21158a9b8, type: 3, owner: 0x21158a6e0, flag: INIT/-/-/0x00
          (call) sess: cur 211572570, rec 0, usr 211572570; depth: 1
            SO: 0x1727a2618, type: 54, owner: 0x21158a9b8, flag: INIT/-/-/0x00
            LIBRARY OBJECT PIN: pin=1727a2618 handle=170fb8ca8 mode=S lock=171243e98
            user=211572570 session=211572570 count=1 mask=001d savepoint=0x43 flags=[00]
            SO: 0x171243e98, type: 53, owner: 0x21158a9b8, flag: INIT/-/-/0x00
            LIBRARY OBJECT LOCK: lock=171243e98 handle=170fb8ca8 mode=S
            call pin=0x1727a2618 session pin=(nil) hpc=0000 hlc=0000
            htl=0x171243f18[0x17278a310,0x17278a310] htb=0x17278a310 ssga=0x172789928
            user=211572570 session=211572570 count=1 flags=PNC/[0400] savepoint=0x43
            LIBRARY OBJECT HANDLE: handle=170fb8ca8 mtx=0x170fb8dd8(0) cdp=0
            name=SYS.STANDARD
            hash=51570e225ed8a9a803b7318f191e0a8d timestamp=04-18-2006 00:00:00
            namespace=TABL flags=KGHP/TIM/SML/[02000000]
            kkkk-dddd-llll=0000-001d-001d lock=S pin=S latch#=3 hpc=0004 hlc=0004
            lwt=0x170fb8d50[0x170fb8d50,0x170fb8d50] ltm=0x170fb8d60[0x170fb8d60,0x170fb8d60]
            pwt=0x170fb8d18[0x170fb8d18,0x170fb8d18] ptm=0x170fb8d28[0x170fb8d28,0x170fb8d28]
            ref=0x170fb8d80[0x170fb8d80,0x170fb8d80] lnd=0x170fb8d98[0x170f05b50,0x170fa6858]
              LIBRARY OBJECT: object=170e82de8
              type=PCKG flags=EXS/LOC[0005] pflags=NST/IVR[0201] status=VALD load=0
              DATA BLOCKS:
              data#     heap  pointer    status pins change whr
                  0 170e831f8 170e82fc0 I/P/A/-/-    0 NONE   00
          SO: 0x21158e470, type: 5, owner: 0x21158a6e0, flag: INIT/-/-/0x00
          (enqueue) CU-70E88BC0-00000001    DID: 0001-001F-00000004
          lv: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  res_flag: 0x2
          res: 0x17677adc8, mode: X, lock_flag: 0x0
          own: 0x211572570, sess: 0x211572570, proc: 0x211006f28, prv: 0x17677add8
          SO: 0x177f82c28, type: 59, owner: 0x21158a6e0, flag: INIT/-/-/0x00
          cursor enqueue
          child: 170e89348, flag: 53, number: 0
          parent: 170e89738

  • ORA-03113: end-of-file on communication channel while running utlrp.sql

    Hi All,
    I am getting ORA-03113: end-of-file on communication channel while running utlrp.sql.
    Actually I ran utlrp.sql before in my test database and terminated the session in middle after that when ever I am running utlrp.sql i am getting the above error.
    how to resolve the issue.
    Kiran

    Hi,
    Check as follows;
    select owner,object_name,object_type from dba_objects where object_name like
    'UTL%'The objects should only belong to SYS, if they do belong do some other user (example HR, etc). Drop objects belong to other users (not sys).
    Then connect as sys as sysdba and rerun the script utlrp.sql.
    You can also review Oracle Metalink Document: ORA-03113 Error When Executing Utlrp.sql: Doc ID: Note:413922.1
    https://metalink.oracle.com/metalink/plsql/f?p=130:14:5496440446026841247::::p14_database_id,p14_docid,p14_show_header,p14_show_help,p14_black_frame,p14_font:NOT,413922.1,1,1,1,helvetica
    Adith

Maybe you are looking for

  • How do I restore the App Store icon on my MacBook Pro?

    I wanted to use a custom icon but since doing so, all I see is a blank PNG icon instead of its image. How can I revert it back to the original icon file? I've deleted the custom icon image files and folders already. Thanks for your time and assistanc

  • Web services in OBIEE 11g

    Hello, I have few Questions on webservices usage in OBIEE 11g(11.1.1.7.0). Can we use/invoke the web service in OBIEE 11g?If yes,please provide me details. If we install OBIEE 11g ,can we get the BI publisher as free product or do i need to configure

  • How to set property for Cluster Environment for JMS Adapter

    Hi All, I am moving from DEV to Prod environment which is cluster. Can you Please explain me what property I need to Set for Cluster Environment for JMS Adapter, so that I could avoid race condition for Dequeue/enqueue. I am using soa suite 10.1..3.4

  • Touch displays PLAY icon while in safari then crashes....

    Not sure if you are having this problem too! However - when Im surfing the touch I notice that I get a little PLAY icon beside my battery, which is indicating that I am listening to music while surfing which you CANNOT do. The only way to fix this pr

  • Indisign scripting and cross-media export - Xhtml / Dreamweaver

    Hi. I've searched for the solution but haven't found it yet. Hope you'll help me. I need to write a script which will transform all indd files in the selected folder to xhtml. But I cannot find methods for exporting files to xhtml in JS (like menu ->