PL/SQL Equivalent for TAB in SQL

What is the equivalent of a TAB in SQL to use with a REPLACE function?
<CR><LF> = CHR(13)||CHAR(10))
what is
<TAB> = ???????
Miller

select ascii('tab') tab_val from dual ;I think we get the ascii value of 't'
Which version you are using??

Similar Messages

  • PL/SQL equivalent for networkdays function

    Hi,
    Is anyone aware of a PL/SQL equivalent for the Excel "networkdays" function, that returns the number of whole workdays between 2 dates?
    Thanks!
    Phil

    To calculate the number of days between january 1st and today, use the following.
    1* select trunc(sysdate) - trunc(to_date('01-jan-05')) from dual
    SQL> /
    TRUNC(SYSDATE)-TRUNC(TO_DATE('01-JAN-05'))
    58

  • T-SQL Equivalent For Group_Concat() Function

    Hello, I am looking for a way to do the MSSQL T-SQL equivalent of the MySQL aggregate function: group_concat().
    We are running SQL 2005 Express. Is there a pure T-SQL way to do this, or if not, a way to create a new custom aggregate function?
    EX:
    SELECT GROUP_CONCAT(FIRST_NAME) AS STUDENT_LIST FROM STUDENTS GROUP BY TEACHER
    OUTPUT:
    JOSH,JOEY,MARK,LINDA,PAM,BILL,MIKE,JUSTIN

    Can anyone help me with MS SQL equivalent code for below MySQL statement.
    select group_concat
    (Col1
    order
    by field(Col2,8,13,15,53,55,6,73,75,3,42,41,45,44))
    as FinalColumn from TestTable
    Any help is greatly appriciated... thanks in advance...

  • PL/SQL equivalent of working T-SQL Query

    Hi All,
    I am new to Oracle and trying to port some select statements written in MS SQL Server over to Oracle but I am having a few difficulties with one of them.
    The following query works OK in MS SQL Server:
    UPDATE rptPolicySnapshot
    SET NoOfLivesTotal=
    SELECT (SELECT COUNT(DISTINCT EntityID)
    FROM PolicyBeneficiary
    WHERE InfoId = 55
    AND PolicyId=P.PolicyID
    AND PolEffDate = P.EffectiveDate)
    (SELECT COUNT(DISTINCT EntityID)
    FROM PolicyBeneficiary
    WHERE InfoId = 57
    AND PolicyId=P.PolicyID
    AND PolEffDate = P.EffectiveDate)
    FROM rptPolicySnapshot P WHERE P.PolicyType = 1
    I basically want to update each individual row in the table rptPolicySnapshot with the correct information as calculated for that row (the key being PolicyID and EffectiveDate in all the tables) within the inner query, i.e. matching on PolicyID and EffectiveDate.
    As I said this works fine in SQL Server, but I cannot work out how to do this in Oracle. If I run the above query in Oracle I get the following error:
    'ORA-00923: FROM keyword not found where expected'
    Any help would be much appreciated, thanks!

    Try
    UPDATE rptPolicySnapshot P
      SET NoOfLivesTotal=
         (SELECT COUNT(DISTINCT EntityID)
          FROM PolicyBeneficiary
          WHERE InfoId = 55
          AND PolicyId=P.PolicyID
          AND PolEffDate = P.EffectiveDate)
         (SELECT COUNT(DISTINCT EntityID)
          FROM PolicyBeneficiary
          WHERE InfoId = 57
          AND PolicyId=P.PolicyID
          AND PolEffDate = P.EffectiveDate)
    WHERE P.PolicyType = 1Message was edited by:
    ascheffer

  • Using HA SQL server For 3rd Party SQL Access

    Is it possible to use the HA SQL server as the access point for SQL stored proceduers on a link
    server instead of the production SQL server. IPCC 4.0

    you can try it out and see if it works however with 4.x we have observer memory leak which crashes the boxes.
    Moreover as this type of scenario has not been tested by Cisco - TAC will state you to remove the setup before troubleshooting.
    Hope this helps
    Regards
    Anuj

  • SSIS execute single SQL Task for running multiple SQL statements on TeraData DB connection

    Hi,
    I need to run multiple statements in TeraData connection ("Go" command between the statements is not recognized). how can I execute 1 SQL task referring to those multi statements? I'm using file connection as well. all the statements located in a single
    file.
    I'm working with SSIS 2008, TERADATA 12.0.
     Thanks

    sure.
    create winbatch file (*.bat).
    in batch file set that command:
    bteq < scriptfilePath.txt (or .bteq)> LogsFolderPathOutputfile.out
    scriptfile should contain:
    .logon
    Server/user, pswd
    your script.
    if you want to set error handeling points, set the followings between yor command statements:
    .IF ERRORCODE <> 0 THEN .GOTO SqlError;
    at the end of script, set:
    -- Log successful completion
    .LOGOFF;.QUIT 0;
    .LABEL SqlError.QUIT ERRORLEVEL;
    you can view logs at the outputfile you stated above.
    enjoy.

  • Oracle equivalent for OBJECTPROPERTY

    Hi Friends,
    I want the oracle equivalent for the following sql code,
    Select @Command = 'IF OBJECTPROPERTY(object_id('''+ @TableName + '''), ''TableHasForeignRef'') = 1
                              DELETE FROM ' + @TableName + '
                          ELSE
                              TRUNCATE TABLE ' + @TableName
    EXEC sp_MSForEachTable @CommandI have tried to find out, but no use. Please help me.
    Thanks,
    Ram.

    Ram wrote:
    I have tested a table which has foreign key. But the count returned from the query is 0.
    Have I implemented your query in the right way?Same like in SQL Server, Oracle does not allow truncating table if it has a PK or UK which is referenced by FK. There are no issues truncating table with FK. Again, it is table with PK/UK where you might not be able to truncate if that PK/UK is referenced by FK. And SQL Server property TableHasForeignRef = TRUE means there is a FK (on a different table or maybe even on same table if it is self-referencing FK) which is referencing PK/UK on a table in question. Query I suggested returns 1 if table has a PK or UK which is referenced by FK. Otherwise it returns 0. So if, in your case, table MY_TABLE owned by user DBO_XYZ has just FK, 0 is correct and you can truncate it. If it would return 1, you would not be able to truncate and would have to delete.
    SY.

  • Is there an equivalent statement in Java for this PL/SQL stmt?

    Hi,
    I want to know if there is an equivalent statement
    in java for this PL/SQL statement:
    IF strTok IN('COM-1','COM-2','COM-3') Then
    /* Do Something */
    End If;
    I tried using : // This is giving me errors..
    if (strTok.equals(("COM-1") || ("COM-2") || ("COM-3") ) )
    /* Do Something */
    The above Java code is giving me errors.
    Any Help to reduce the number of steps for comparison
    is appreciated.
    thanks in adv
    Sharath

    Something like
    if (strTok.equals("COM-1") ||
        strTok.equals("COM-2") ||
        strTok.equals("COM-3") )Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Equivalent datatype in Oracle for datetime of SQL Server

    Hello Everyone,
    I'm very much new to Oracle. I have been working with SQL Server since 3yrs. Currently I'm working with Oracle 11g.
    What is the equivalent datatype in oracle for datetime in sql server with which has the format YYYY-MM-DD HH:MM:SS?
    I tried with timestamp and date which didnt solve my prob.... Please help me in using the equivalent datatype for the format provided above...
    Regards,
    Bhanu Yalamanchi.

    Oracle date format can be anything you want, either by default at the session level or preferably explicitly using to_char and a format mask.
    Format masks are documented here.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/sql_elements004.htm#CDEHIFJA
    SQL> create table t (d date);
    Table created.
    SQL> insert into t values (sysdate);
    1 row created.
    SQL> select * from t;
    D
    19-JUL-11
    SQL> alter session set nls_date_format = 'YYYY-MM-DD HH:MI:SS';
    Session altered.
    SQL> select * from t;
    D
    2011-07-19 08:27:59
    SQL> select d, to_char(d, 'YYYY-MM-DD'), to_char(d,'Day') from t;
    D                   TO_CHAR(D, TO_CHAR(D
    2011-07-19 08:27:59 2011-07-19 Tuesday
    SQL> alter session set nls_date_format = 'DD-MON-YY';
    Session altered.
    SQL> select d, to_char(d, 'YYYY-MM-DD HH24:MI:SS') from t;
    D         TO_CHAR(D,'YYYY-MM-
    19-JUL-11 2011-07-19 08:27:59

  • Displaying diff dates using PL/SQL expression for 'display only' item ?

    Hi ,
    I am having a display only item -- :P2_FROM_Date . If its Thu,Fri,Sat or Sun I want to set the date as the last Monday's date . If its Mon,Tue or Wed then it should be the present Monday's date .
    E.g: Today is Friday and the last Monday was on 18th .
    So for yesterday , today,tomorrow and Sunday , the date should be displayed as 18-JUN-2012.
    From the coming Monday to Wednesday , the date should of be the coming Monday i.e , 24-JUN-2012
    I tried it doing under 'Source ' of item using PL/SQL expression and PL/SQL function body. Not working
    Can someone help ?
    Thanks & Regards
    Umer

    Nice1 wrote:
    declare
    lv_date number;
    begin
    select to_char(sysdate,'D') into lv_date from dual;
    if lv_date=2 then
    :P2_FROM_DATE := to_char(sysdate-1);
    end if;
    end;I tried this under " PL/SQL function body " in "Source " tab of the item P2_FROM_DATE
    When I run this , nothing is displayed corresponding to the item P2_FROM_DATEExactly as expected. This code will only set a value for <tt>P2_FROM_DATE</tt> when run on Mondays in territories where the first day of the week is Sunday, and when run on Tuesdays where Monday is the first day of of the week:
    SQL> var P2_FROM_DATE varchar2(30)
    SQL> alter session set nls_date_format='Dy DD-MON-YYYY';
    Session altered.
    SQL> select sysdate from dual
    SYSDATE
    Mon 25-JUN-2012
    SQL> alter session set nls_territory='AMERICA';
    Session altered.
    SQL> declare
      2  lv_date number;
      3  begin
      4  select to_char(sysdate,'D') into lv_date from dual;
      5  if lv_date=2 then
      6  :P2_FROM_DATE := to_char(sysdate-1);
      7  end if;
      8  end;
      9  /
    PL/SQL procedure successfully completed.
    SQL> print p2_from_date
    P2_FROM_DATE
    Sun 24-JUN-2012
    SQL> alter session set nls_territory='UNITED KINGDOM';
    Session altered.
    SQL> exec :p2_from_date := null
    SQL> declare
      2  lv_date number;
      3  begin
      4  select to_char(sysdate,'D') into lv_date from dual;
      5  if lv_date=2 then
      6  :P2_FROM_DATE := to_char(sysdate-1);
      7  end if;
      8  end;
      9  /
    PL/SQL procedure successfully completed.
    SQL> print p2_from_date
    P2_FROM_DATE
    SQL>Hence the questions about language above.
    >
    I am having a display only item -- :P2_FROM_Date . If its Thu,Fri,Sat or Sun I want to set the date as the last Monday's date . If its Mon,Tue or Wed then it should be the present Monday's date .
    E.g: Today is Friday and the last Monday was on 18th .
    So for yesterday , today,tomorrow and Sunday , the date should be displayed as 18-JUN-2012.
    From the coming Monday to Wednesday , the date should of be the coming Monday i.e , 24-JUN-2012
    >
    The coming Monday is 25-JUN-2012.
    Aren't these rules equivalent to "Monday this week, where Monday is the first day of the week"? In which case the PL/SQL Expression you require is:
    trunc(sysdate, 'iw')For example:
    SQL> with t as (
      2    select date '2012-06-21' + level d from dual connect by level <= 17)
      3  select
      4            d
      5          , trunc(d, 'iw')  monday
      6  from
      7            t;
    D               MONDAY
    Fri 22-JUN-2012 Mon 18-JUN-2012
    Sat 23-JUN-2012 Mon 18-JUN-2012
    Sun 24-JUN-2012 Mon 18-JUN-2012
    Mon 25-JUN-2012 Mon 25-JUN-2012
    Tue 26-JUN-2012 Mon 25-JUN-2012
    Wed 27-JUN-2012 Mon 25-JUN-2012
    Thu 28-JUN-2012 Mon 25-JUN-2012
    Fri 29-JUN-2012 Mon 25-JUN-2012
    Sat 30-JUN-2012 Mon 25-JUN-2012
    Sun 01-JUL-2012 Mon 25-JUN-2012
    Mon 02-JUL-2012 Mon 02-JUL-2012
    Tue 03-JUL-2012 Mon 02-JUL-2012
    Wed 04-JUL-2012 Mon 02-JUL-2012
    Thu 05-JUL-2012 Mon 02-JUL-2012
    Fri 06-JUL-2012 Mon 02-JUL-2012
    Sat 07-JUL-2012 Mon 02-JUL-2012
    Sun 08-JUL-2012 Mon 02-JUL-2012
    17 rows selected.
    SQL> alter session set nls_territory='AMERICA';
    Session altered.
    SQL> alter session set nls_date_format='Dy DD-MON-YYYY';
    Session altered.
    SQL> with t as (
      2    select date '2012-06-21' + level d from dual connect by level &lt;= 17)
      3  select
      4            d
      5          , trunc(d, 'iw')  monday
      6  from
      7            t;
    D               MONDAY
    Fri 22-JUN-2012 Mon 18-JUN-2012
    Sat 23-JUN-2012 Mon 18-JUN-2012
    Sun 24-JUN-2012 Mon 18-JUN-2012
    Mon 25-JUN-2012 Mon 25-JUN-2012
    Tue 26-JUN-2012 Mon 25-JUN-2012
    Wed 27-JUN-2012 Mon 25-JUN-2012
    Thu 28-JUN-2012 Mon 25-JUN-2012
    Fri 29-JUN-2012 Mon 25-JUN-2012
    Sat 30-JUN-2012 Mon 25-JUN-2012
    Sun 01-JUL-2012 Mon 25-JUN-2012
    Mon 02-JUL-2012 Mon 02-JUL-2012
    Tue 03-JUL-2012 Mon 02-JUL-2012
    Wed 04-JUL-2012 Mon 02-JUL-2012
    Thu 05-JUL-2012 Mon 02-JUL-2012
    Fri 06-JUL-2012 Mon 02-JUL-2012
    Sat 07-JUL-2012 Mon 02-JUL-2012
    Sun 08-JUL-2012 Mon 02-JUL-2012
    17 rows selected.Also note that using the item source properties will only set the <tt>P2_FROM_DATE</tt> in the rendered page, not in session state.

  • SQL equivalent of if-statement

    What would be really useful would be if I could do an SQL equivalent of an if-statement. I'm just making the following up to show what I mean:
    SELECT CASE
              WHEN(det.user_entity_name = 'PO Header')
                 THEN (SELECT pha.segment1
                         FROM po.po_headers_all pha
                        WHERE pha.po_header_id = ad.pk1_value)
              WHEN(det.user_entity_name = 'PO Line')
                 THEN (SELECT pha.segment1
                         FROM po.po_headers_all pha
                            , po.po_lines_all pla
                        WHERE pha.po_header_id = pla.po_header_id
                          AND pla.po_line_id = ad.pk1_value)
              ELSE 'UNDEFINED'
           END doc_num
         , ad.seq_num
         , fu.description created_by
         , dt.description
         , det.user_entity_name
         , ad.creation_date
         , ad.entity_name
         , ad.pk1_value
         if dat.user_name = 'Short Text' then
         dst.short_text
         elseif dat.user_name = 'Long Text' then
         dlt.long_text
         end if
      FROM applsys.fnd_document_datatypes dat
         , applsys.fnd_document_entities_tl det
         , applsys.fnd_documents_tl dt
         , applsys.fnd_documents d
         , applsys.fnd_document_categories_tl dct
         , applsys.fnd_attached_documents ad
         if dat.user_name = 'Short Text' then
    , applsys.fnd_documents_short_text dst
         elseif dat.user_name = 'Long Text' then
         , applsys.fnd_documents_long_text dlt
         end if            
         , applsys.fnd_user fu
    WHERE d.document_id = ad.document_id
       AND dt.document_id = d.document_id
       AND dct.category_id = d.category_id
       AND d.datatype_id = dat.datatype_id
       AND ad.entity_name = det.data_object_code
         if dat.user_name = 'Short Text' then
    AND dt.media_id = dst.media_id(+)
         elseif dat.user_name = 'Long Text' then
    AND dt.media_id = dlt.media_id(+)
         end if  
       AND ad.created_by = fu.user_id
       AND d.creation_date > '01-OCT-2007'
         if dat.user_name = 'Short Text' then
    AND dat.user_name = 'Short Text'
         elseif dat.user_name = 'Long Text' then
    AND dat.user_name = 'Long Text'
         end if     
       AND dct.user_name = 'To Supplier';Is that possible, or am I just talking a load of nonsense?
    Thanks

    How to do IF in SQL:
    1) CASE
    2) DECODE
    3) UNION, UNION ALL, MINUS, INTERSECT
    4) AND + OR + ()
    5) stored functions
    6) ...
    which is best just depends on the situation. For your example I would use decode in the select clause and some UNION ALL for the from/where clauses.

  • Transaction or standard program for testing Open SQL statements

    Hi experts,
    Is there a standard program or transaction that can be used to test Open SQL statements?, I was thinking in something similar to a SQL client like sqlcli, but for Open SQL and within SAP GUI.
    I know i can write a test ABAP program for this matter but I rather a standard testing facily in this case
    Thank you for any help
    regards

    Hi Ozcan
    I tried DB02 -> Diagnosis -> SQL Command editor , but I couldn't made it work. It is for Open SQL or for Native SQL?
    I tried the following simple Open SQL statements inside the SQL Code tab there were erros
    SELECT *
    FROM /BI0/PCOMP_CODE
    error was: Incorrect syntax near '/'.
    SELECT * FROM DD03L
    error was: Invalid object name 'DD03L'.
    Where is the mistake?
    regards

  • HANA equivalent of oracle's sql%rowcount to get affected rows.

    I want to get the number of rows affected from an insert or update statement inside a stored procedure.
    Is there any equivalent to oracle's sql%rowcount that can be called after the query.
    For example:
    create procedure procedure_name
    begin
         declare l_c integer;
         insert into table values ('somevalue');
         l_c := sql%rowcount; -- This would return 1 for the row inserted.
    end;

    Yes, after the INSERT statement....
    SELECT ::ROWCOUNT into L_C FROM DUMMY;
    Cheers,
    Rich Heilman

  • Issue with Audit Vault Collector for Peoplesoft-MS Sql Server

    Experts,
    Requesting your valuable inputs regarding below issue :
    Environment:
    - Peoplesoft with SQL Server 2008
    - Oracle Audit Vault.
    Current issue with Audit Vault collector for SQL server is that it is not giving PSFT login ID instead it is giving Peoplesoft DB service Account ID.
    Is this expected ?. If yes, what is the workaround ? Can Database Firewall is a best option to capture PSFT login ID ?
    Thanks

    Hi Rabi ,
      just do one think here ..
    During data source creation , in the Additional tab area , in the SQL Engine session , select "Vendor SQL"  instead of "Open SQL".
    HOw could u create data source without selecting the driver corrsponding to MS SQL.?
    it is recommended to download the latest Driver and use this for Driver creation.
    let me know ..
                                       Regards
                                       Kishor Gopinathan

  • MS SQL equivalent query

    Hi,
    I need to show the hierarchy of account types. The parent child relationship is stored in account type table. For eg,
    acc1 child is acc2 and acc3, acc2 child is acc4. So the children for acc1 is acc2,acc3,acc4.
    I am able to do so in oracle db using below query:
    select connect_by_root(account_type_id) root_id, account_type_name,account_type_id, parent_type_id
    from account_types
    connect by prior account_type_id = parent_type_id
    I am not able to create the query for MS SQL, can anyone help me to convert above oracle query to MS SQL equivalent?

    1. It is not MS SQL forum. Most of people here does not know MS SQL.
    2. little googling helps: Recursive Queries Using Common Table Expressions http://msdn.microsoft.com/en-us/library/ms186243%28v=sql.105%29.aspx

Maybe you are looking for

  • How do I add a device in order to access itunes in icloud

    How do I add a device in order to access itunes in icloud

  • Controlling autoupdate of Adobe Flash Player ActiveX with mms.cfg file

    For several years we have suppressed Flash Player ActiveX from autoupdating by using the mms.cfg file, with the setting "AutoUpdateDisable=1" -- and it has worked without a problem. With the constant updates of Flash Player for security reasons, we d

  • Commision Vendor

    Dear All, My client is selling his finished Goods through another Party. They are taking materials from the our client and keeping in their godown. When ever an order comes they will deliver the materials and invoice it in the name of Our client. Ple

  • Remove all children from application container

    Hi guys, I have a portion of script in my flex application (.mxml) like this: public function remove_all_children():void {     var n:int = this.rawChildren.numChildren;     var i:int;     for (i=0; i<n; i++)         this.rawChildren.removeChildAt(i);

  • Convert PR to PO

    Hi i am creating PO with reference to PR (a/c assignment cat: Q ) in PO am trying add item category as "L" then it is not allowing me to save PO, getting error pl tell me the reason. Is standard SAP behaviour ? we should not change any information wh