Concatenate in PL/SQL

Team:
I have a requirement like this. I have to give remap_tablespace=src1:dest1,src2:dest2,src3:dest3,src4:dest1 ...etc in import using datapump in a shell script for schema cloning. I have written the below code for that, cursor get_tabspace1 for source1 & cursor get_tabspace2 for destination1. Destination cursor has only 3 tablespaces (static). Whereas source cursor has many tablespaces. While remapping for example: I have taken source tablespace1 with destination tablespace1, source  tablespace2 with destination tablespace2, source  tablespace3 with destination tablespace3, source  tablespace4 with destination tablespace1 (destination round robin method as it is static & have only 3 tablespaces), source tablespace5 with destination tablespace2 (destination round robin method as it is static & have only 3 tablespaces), source tablespace6 with destination tablespace3 (destination round robin method as it is static & have only 3 tablespaces). For the above example I have written the below code. I am having difficulty in getting the string like this src1:dest1,src2:dest2,src3:dest3,src4:dest1. Please let me know how to concatenate inside the loop to get this string. I have written the below 2 lines of code as shown below. concat:=map_tabspace_i: || remap_tabspace_i, concat:=concat || map_tabspace_i: || remap_tabspace_i, I think this will not get into this format src1:dest1,src2:dest2,src3:dest3,src4:dest1 ...etc. Please correct me what I have to write to get string like this src1:dest1,src2:dest2,src3:dest3,src4:dest1 ...etc
declare
cursor get_tabspace1 is select distinct TABLESPACE_NAME from dba_segments where owner='JOHN';
cursor get_tabspace2 is select distinct TABLESPACE_NAME from dba_segments where owner='NANCY';
begin
i:=1;
t:=1;
concat varchar2(2000);
OPEN get_tabspace1;
OPEN get_tabspace2;
   LOOP
   FETCH get_tabspace1 INTO v_tabspace_name1;
   EXIT WHEN get_tabspace1%NOTFOUND;
   while (t>3) LOOP
   CLOSE get_tabspace2;
   OPEN get_tabspace2;
   EXIT WHEN get_tabspace1%NOTFOUND;
   t:=1;
   END LOOP;
   FETCH get_tabspace2 INTO v_tabspace_name2;
   map_tabspace_i := v_tabspace_name1;
   remap_tabspace_i := v_tabspace_name2;
   concat:=map_tabspace_i: || remap_tabspace_i,
   concat:=concat || map_tabspace_i: || remap_tabspace_i,
   i:=i+1;
   t:=t+1;
   END LOOP;
CLOSE get_tabspace1;
CLOSE get_tabspace2;
exception
   WHEN OTHERS THEN
      raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
end;
Thanks in Advance for replying.

Input from the SQL script need to be passed to IMPDP - remap_tablespace command using round robin method based on the source tablespaces
impdp REMAP_SCHEMA=john:Nancy remap_tablespace=SRC_TS_1:TGT_TS_1 remap_tablespace=SRC_TS_2:TGT_TS_2 remap_tablespace=SRC_TS_3:TGT_TS_3 remap_tablespace=SRC_TS_4:TGT_TS_1 remap_tablespace=SRC_TS_5:TGT_TS_2 ..etc
Here's pl/sql version you asked. Consider API that John suggested - i would DBMS_DATAPUMP
set serveroutput on
declare
  p_schema varchar2(30) := 'JOHN';
  type    target_type  is varray(3) of varchar2(30);
  target  target_type   := target_type('TGT_TS_1', 'TGT_TS_2', 'TGT_TS_3');
  i       pls_integer   := 1;
  remap   varchar2(500);
begin
  for r in (select distinct tablespace_name from dba_segments where owner = p_schema)
  loop
    -- round robin target tablespace
    remap := remap || ' remap_tablespace ' || r.tablespace_name || ':' || target(i);
    if (i < target.count) then
      i := i + 1;
    else
      i := 1;
    end if;
  end loop;
  dbms_output.put_line(remap);
end;

Similar Messages

  • Concatenate name in select query...

    Hi Pals,
    I was wondering how to directly concetenate client name in the select query itself...
    Currently the code says :
    SELECT SINGLE NAME1 NAME2
               INTO (V_NAME1,V_NAME2)
               FROM KNA1
               WHERE KUNNR = I_PROJ-ZZCLIENT.
    CONCATENATE V_NAME1 V_NAME2 INTO I_PROJ-CLNAME SEPARATED BY SPACE.
    Can we say some thing like...
    SELECT SINGLE ( NAME1 + ' ' + NAME2 ) AS CLNAME
               INTO I_PROJ-CLNAME
               FROM KNA1
               WHERE KUNNR = I_PROJ-ZZCLIENT.
    But its giving error...
    Basically i need a single select query which would give me  space seperated clientname in I_PROJ directly
    Please help me...
    Regards,
    Abhishek B.

    Hi Abhishek,
    OPEN SQL.
    1. Sap works on the concept of Open Sql.
       ie. Sql  is database independent.
    2. ABAP Syntax does not have provision for
       using such EXPRESSIONS (like concatenate)
       directly in SQL.
    3. However u may use them in Native Sql.
    4. In open sql one can use aggregate functions
       like SUM COUNT etc.
       But Concatenate is not allowed.
    Hope u find the answer useful.
    (To newbees)
    U may please award points (if u find the reply useful)
    by clicking on the STAR on the left of the reply.
    Regards,
    Amit M.

  • Concatenate in a datatemplate with mutiple groups

    Hello,
    Our datatemplate has 4 groups who retrieve data with a simple query. The results of the groups 3,4,5 need te be concatenated in a separate group 6 depending on the results of the group3,4,5. But the concatenate does not work at all in the template. However when we try Q_6 (the concatenate group) in sql developer it works fine:
    //Q_6 in sql developer:
    select case when (:INHOUD2 = '' OR :INHOUD2 IS NULL) then
    CONCAT (:INHOUD1,:EENHEID1)
    ELSE CASE WHEN (:INHOUD3 = '' OR :INHOUD3 IS NULL) THEN
    CONCAT(CONCAT(:INHOUD1,:INHOUD2), :EENHEID2)
    else
    CONCAT(CONCAT(CONCAT(:INHOUD1,:INHOUD2), :INHOUD3),:EENHEID3) END END as INHOUDTOT
    from CRPDTA.F41002
    where UMITM = :KOPPELING
    A part of the datatemplate: Q_6 does not work
    <sqlStatement name="Q_3">
    SELECT IMITM,
    Case when (UMCONV/10000000)&lt;&gt; 0 then (UMCONV/10000000) else 0 end as INHOUD1,
    UMRUM EENHEID1
    FROM crpdta.F4101,
    crpdta.F41002
    where IMITM = :KOPPELING
    AND UMITM = IMITM
    AND UMUM = IMUOM1
    AND UMRUM = IMUOM2
    </sqlStatement>
              <sqlStatement name="Q_4">
    SELECT
    Case when (UMCONV/10000000)&lt;&gt; 0 then (UMCONV/10000000) else 0 end as INHOUD2,
    UMRUM EENHEID2
    FROM crpDTA.F41002 where UMITM =:KOPPELING
    AND LTRIM(UMUM) = :EENHEID1
    </sqlStatement>
              <sqlStatement name="Q_5">
    SELECT
    Case when (UMCONV/10000000)&lt;&gt; 0 then (UMCONV/10000000) else 0 end as INHOUD3,
    UMRUM EENHEID3
    FROM crpDTA.F41002 where UMITM =:KOPPELING
    AND LTRIM(UMUM) = :EENHEID2
    </sqlStatement>
              <sqlStatement name="Q_6">
    select case when (:INHOUD2 = '' OR :INHOUD2 IS NULL) then
    CONCAT (:INHOUD1,:EENHEID1)
    ELSE CASE WHEN (:INHOUD3 = '' OR :INHOUD3 IS NULL) THEN
    CONCAT(CONCAT(:INHOUD1,:INHOUD2), :EENHEID2)
    else
    CONCAT(CONCAT(CONCAT(:INHOUD1,:INHOUD2), :INHOUD3),:EENHEID3) END END as INHOUDTOT
    from CRPDTA.F41002
    where UMITM = :KOPPELING
    etc.

    user,
    Either explicitly defining variables in rtf template or referencing absolute paths inside concat() function should solve your issue....
    Referencing absolute path should be direct method if you can view the xml data output...
    -bifacts
    http://www.obinotes.com

  • Concatenate 4 address fields

    Hi,
    I'm using Reports6i.
    I'm generating a report based on a table, which has 4 fields addr1,addr2,addr3 and addr4.
    But in report i want to display as one field
    Suppose the data in the table is like this
    addr1       addr2       addr3       addr4
    test1       test2        test3        test4
    rep1                       rep3         rep4
                                 lane3        lane4I want to display in report as
    Address
    test1,test2
    test3,test4
    rep1
    rep3,rep4
    lane3,lane4Which way is better, to concatenate in the sql query itself or to arrange it accordingly in reports?
    But all fields may/maynot have values, so in that case in report it should adjust accordingly, like if addr1 and addr2 is null but addr3,addr4 is not, then a blank line should not come in the place of addr1 and addr2
    Suggestion Please
    Thanks

    Hi, you should concatenate it in the sql query and use decode to only display value that has adresses. I've use this to display adresses lines of vendors using this
    select vendor_id, vendor_site_code, vendor_site_id , address_line1||
    DECODE(address_line2, NULL, NULL,'-'||address_line2)||
    DECODE(address_line3, NULL, NULL,'-'||address_line3)||
    DECODE(address_line4, NULL, NULL,'-'||address_line4) address_line
    from po_vendor_sites
    This way, if address_line is null, it concatenate NULL (nothing) and if something is present, it separate line with a dash (-).
    You could use something like
    select addr1||
    DECODE(addr2, NULL, NULL,','||addr2)||
    DECODE(addr3, NULL, NULL,','||addr3)||
    DECODE(addr4, NULL, NULL,','||addre4) address_line
    from your_table

  • Usinga CLOB variable in an execute immediate

    HI,
    I'm trying to concatenate a huge sql statement and then pass the variable to an execute immediate . the sql statement could be bigger than 4000bytes and so I'm using a clob variablle. Is it possible for me to pass this clob variable to an execute immediate?
    DECLARE
    var_stmt clob;
    Begin
    var_stmt := 'The statement I want which may be more than 4000bytes'
    execute immediate var_stmt;
    END;
    This how I'm trying to do it. Has anybody come acroos something like this?
    Thanks,
    Mamata

    if your sql statement will not exceed 32K, you could use the PL/SQL VARCHAR2(32767) type variable to hold upto 32K of the SQL statement.
    DECLARE
      var_stmt LONG;
    Begin
      var_stmt := 'The statement I want which may be more than 4000bytes'
      execute immediate var_stmt;
    END;

  • Merge  with ampersand (&)

    Hi
    I exporting and importing some data of 2 tables to other schema, I used Merge Statment, but there are some data with ampersand (&), is there some way to bypass , see data below in column T$NOSN$O there are a ampersand
    MERGE INTO TRITON.TTCCOM994501 A USING
    (SELECT
      'ufeferna  ' as "T$CDUS$O",
      844 as "T$NCMP$O",
      '7647                ' as "T$CCAR$O",
      'FERNANDO MAMBRINE FERRI                           ' as "T$NOUS$O",
      'ADM VENDAS                                        ' as "T$NODP$O",
      '                    ' as "T$NUTL$O",
      TO_DATE('07/26/2006 00:00:00', 'MM/DD/YYYY HH24:MI:SS') as "T$DHCT$O",
      TO_DATE('01/01/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS') as "T$DHVD$O",
      '_m\l&E    ' as "T$NOSN$O",
      '657892962' as "T$CGCC$O",
      '    ' as "T$CGCE$O",
      20 as "T$CGCD$O",
      2 as "T$AUTO$O",
      '      ' as "T$CCUS$O",
      '                                                                                                                                    ' as "T$LCUS$O",
      '      ' as "T$SUNO$O",
      1 as "T$ASAM$O",
      '                                                                                ' as "T$EFUL$O",
      '                                                                                ' as "T$EINT$O",
      '                              ' as "T$FNAM$O",
      'NAO                           ' as "T$LNAM$O",
      0 as "T$REFCNTD",
      0 as "T$REFCNTU"
      FROM DUAL) B
    ON (A.T$CDUS$O = B.T$CDUS$O)
    WHEN NOT MATCHED THEN
    INSERT (
      T$CDUS$O, T$NCMP$O, T$CCAR$O, T$NOUS$O, T$NODP$O,
      T$NUTL$O, T$DHCT$O, T$DHVD$O, T$NOSN$O, T$CGCC$O,
      T$CGCE$O, T$CGCD$O, T$AUTO$O, T$CCUS$O, T$LCUS$O,
      T$SUNO$O, T$ASAM$O, T$EFUL$O, T$EINT$O, T$FNAM$O,
      T$LNAM$O, T$REFCNTD, T$REFCNTU)
    VALUES (
      B.T$CDUS$O, B.T$NCMP$O, B.T$CCAR$O, B.T$NOUS$O, B.T$NODP$O,
      B.T$NUTL$O, B.T$DHCT$O, B.T$DHVD$O, B.T$NOSN$O, B.T$CGCC$O,
      B.T$CGCE$O, B.T$CGCD$O, B.T$AUTO$O, B.T$CCUS$O, B.T$LCUS$O,
      B.T$SUNO$O, B.T$ASAM$O, B.T$EFUL$O, B.T$EINT$O, B.T$FNAM$O,
      B.T$LNAM$O, B.T$REFCNTD, B.T$REFCNTU)
    WHEN MATCHED THEN
    UPDATE SET
      A.T$NCMP$O = B.T$NCMP$O,
      A.T$CCAR$O = B.T$CCAR$O,
      A.T$NOUS$O = B.T$NOUS$O,
      A.T$NODP$O = B.T$NODP$O,
      A.T$NUTL$O = B.T$NUTL$O,
      A.T$DHCT$O = B.T$DHCT$O,
      A.T$DHVD$O = B.T$DHVD$O,
      A.T$NOSN$O = B.T$NOSN$O,
      A.T$CGCC$O = B.T$CGCC$O,
      A.T$CGCE$O = B.T$CGCE$O,
      A.T$CGCD$O = B.T$CGCD$O,
      A.T$AUTO$O = B.T$AUTO$O,
      A.T$CCUS$O = B.T$CCUS$O,
      A.T$LCUS$O = B.T$LCUS$O,
      A.T$SUNO$O = B.T$SUNO$O,
      A.T$ASAM$O = B.T$ASAM$O,
      A.T$EFUL$O = B.T$EFUL$O,
      A.T$EINT$O = B.T$EINT$O,
      A.T$FNAM$O = B.T$FNAM$O,
      A.T$LNAM$O = B.T$LNAM$O,
      A.T$REFCNTD = B.T$REFCNTD,
      A.T$REFCNTU = B.T$REFCNTU;

    Hi,
    You have two options:
    1. You can concatenate string after &:
    SQL> select '_m\l&'||'E    ' as "T$NOSN$O" from dual;
    T$NOSN$O
    _m\l&E 2. On SqlPlus you can SET DEFINE OFF
    SQL> set define off
    SQL> select '_m\l&E    ' as "T$NOSN$O" from dual;
    T$NOSN$O
    _m\l&EMiguel

  • Probelm with query that contains parameter and reportviewer

    Hi,
    I writing a windows application with oracle database.
    I have a query like that
    select * from table1 where table1.Field1 In (:param)
    I create my parameter like that
    Dim param as string = " 'value1', value2, 'value3' "
    When i run the query it returns nothing. I think the problem is because of the double quote (") arround the param.
    Does someone have an idea?
    Thanks

    This error is typical. Parameter is approapriate anyplace where you could use Oracle literal, e.g. instead of
    select * from table1 where table1.Field1 In (1, 2, 3) you might use
    select * from table1 where table1.Field1 In (:a1, :a2, :a3),
    but SQL like
    select * from table1 where table1.Field1 In ('1, 2, 3')
    is most likely sensless
    Generally speaking you should not use parameterized IN expression when parameters are elements of the list that is defined interactively. Better approach is to dynamically generate IN list and concatenate it to SQL string:
    stSQL = 'select * from table1 where table1.Field1 In (' || v1 || ',' || 'v2' || ')'
    and that's it.
    Usually number of variants is limited and you do not make your Oracle server to over-parse.

  • SQL - How to CONCATENATE and TRANSLATE in the same argument

    Hi,
    I am trying to CONCATENATE 7 columns into 1 and then TRANSLATE the values. I have written the below SQL, but it is throwing me error as - "invalid number of arguments". Can someone help me with the query?
    SQL
    ====
    SELECT
    A.ITEM           as PROD_NO,
    TRANSLATE(B.NON_DEL1 ||
    B.NON_DEL2 ||
    B.NON_DEL3 ||
    B.NON_DEL4 ||
    B.NON_DEL5 ||
    B.NON_DEL6 ||
    B.NON_DEL7),'YN','X ') SUPP_NON_CODE
    FROM (SELECT * FROM ITEM_DATA WHERE ITEM_TYPE = 'PRODUCT') A
    LEFT OUTER JOIN ITEM_DETAILS ITDET ON A.ITEM = B.ITEM
    ORDER BY A.ITEM;
    INPUT DATA
    ========
    ITEM_DATA table
    ITEM ITEM_TYPE
    ============
    100002 PRODUCT
    100004 PRODUCT
    100005 PRODUCT
    100006 PRODUCT
    ITEM_DETAILS table
    ITEM     NON_DEL1     NON_DEL2     NON_DEL3     NON_DEL4     NON_DEL5     NON_DEL6     NON_DEL7
    =====================================================
    100002     N     N     N     N     N     N     N
    100004     Y     Y     Y     Y     Y     Y     Y
    100005     Y     Y     N     Y     N     Y     Y
    100006     Y     N     N     Y     Y     Y     Y
    OUTPUT EXPECTED
    ITEM SUPP_NON_CODE
    =================
    100002     
    100004     XXXXXXX
    100005     XX X XX
    100006     X XXXX
    Regards
    Harsha
    Edited by: user13025253 on Apr 23, 2010 1:53 AM

    Remove the bracket after B.NON_DELIVERY_IND7.
    Urs

  • How to Concatenate Date in T-SQL using custom format?

    Hi:
    I have a column in SQL Server 2008 R2, [ENTERED_DATE].  This is a datetime, formatted like so:
    2011-01-25 07:32:21.000
    I need to display this as:  2011-01-01, where the DAY always = 01.
    I've tried all manner of CAST, CONVERT, concatenate, etc.
    I don't really want to CONVERT from datetime, just display in a custom format.
    Thanks!
    A. Wolf

    SQL Server 2012...
    SELECT FORMAT(getdate(), 'yyyy-MM-01')
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Concatenate results SQL query and CASE use Report Builder Reporting Services

    I need to concatenate the results from a SQL query that is using CASE.  The query is listed below.  I do not need permitsubtype but I need to concatenate the results from the permittype. 
    I tried deleting the permitsubtype query and it would not run correctly.  Please see the query and diagram below.  Any help is appreciated.
    select  PERMIT_NO
    ,(case when
      ISNULL(PERMITTYPE,'') = ''
      then 'Unassigned'
      else (select LTRIM(RTRIM(PERMITTYPE)))
      END) AS PERMITTYPE
    ,(case when
      ISNULL(PERMITSUBTYPE,'') = ''
      then 'Unassigned'
      else (select LTRIM(RTRIM(PERMITSUBTYPE)))
      END) AS PERMITSUBTYPE
     ,ISSUED
     ,APPLIED
     ,STATUS 
     ,SITE_ADDR 
     ,SITE_APN
     ,SITE_SUBDIVISION
     ,OWNER_NAME
     ,CONTRACTOR_NAME
     ,ISNULL(JOBVALUE,0) AS JOBVALUE
     ,FEES_CHARGED
     ,FEES_PAID
    ,BLDG_SF
    from Permit_Main
    where ISSUED between @FromDate and @ToDate

    Hi KittyCat101,
    As per my understanding, you used case when statement in the query, you do not need to display permitsubtype in the report, but when you tried to delete permitsubtype from the query, it could not run correctly. In order to improve the efficiency of troubleshooting,
    I need to ask several questions:
    “I tried deleting the permitsubtype query and it would not run correctly.” As we can see, it has no effect to delete permitsubtype from the query you provided, could you please provide complete sql query for the report?
    Could you please provide detailed information about the report? I would be appreciated it if you could provide sample data and screenshot of the report.
    Please provide some more detailed information of your requirements.
    This may be a lot of information to ask for at one time. However, by collecting this information now, it will help us move more quickly toward a solution.
    Thanks,
    Wendy Fu

  • Concatenate using SQL rather than Oracle functions Oracle 8i

    Is it possible to concatenate field values using SQL alone and not an Oracle function
    For the following dataset I would like the results to be the following
    1 User_lastname1 2,7
    2 User_lastname2 2,7
    3 User_lastname3 2
    4 User_lastname4 7
    CREATE TABLE users
    ( user_id NUMBER(10)
    , user_lastname VARCHAR2 (50)
    , workgroup NUMBER(10)
    INSERT ALL
    INTO users(user_id, user_lastname, workgroup) VALUES (1, User_lastname1, 2)
    INTO users(user_id, user_lastname, workgroup) VALUES (1, User_lastname1, 7)
    INTO users(user_id, user_lastname, workgroup) VALUES (2, User_lastname2, 2)
    INTO users(user_id, user_lastname, workgroup) VALUES (2, User_lastname2, 7)
    INTO users(user_id, user_lastname, workgroup) VALUES (3, User_lastname3, 2)
    INTO users(user_id, user_lastname, workgroup) VALUES (4, User_lastname4, 7)

    Maybe (provided a user is not a member of more than six workgroups)
    select user_id,
           user_lastname,
           max(decode(rno,1,workgroup,null)) || max(decode(rno,2,','||workgroup,null)) ||
                                                max(decode(rno,3,','||workgroup,null)) ||
                                                max(decode(rno,4,','||workgroup,null)) ||
                                                max(decode(rno,5,','||workgroup,null)) ||
                                                max(decode(rno,6,','||workgroup,null)) string
      from (select user_id,
                   user_lastname,
                   workgroup,
                   row_number() over (partition by user_id,user_lastname order by workgroup) rno
              from users
    group by user_id,
              user_lastname
    order by user_id,
              user_lastnameor (provided a user is not a member of more than five workgroups)
    select user_id,
           user_lastname,
           string
      from (select user_id,
                   user_lastname,
                   row_number() over (partition by user_id,user_lastname order by workgroup) rno,
                   workgroup || lead(','||workgroup,1) over (partition by user_id,user_lastname order by workgroup) ||
                                lead(','||workgroup,2) over (partition by user_id,user_lastname order by workgroup) ||
                                lead(','||workgroup,3) over (partition by user_id,user_lastname order by workgroup) ||
                                lead(','||workgroup,4) over (partition by user_id,user_lastname order by workgroup) string
              from users
    where rno = 1
    order by user_id,
              user_lastnameRegards
    Etbin

  • HTML-DB 1.6 SQL Query (Concatenate two columns)

    Hi everyone,
    My query look like this. But I got this message
    ORA-01403: no data found
    Sql query(.....returning ... sql
    What I can do ? I want to concatenate my two columns in one.
    <pre>
    -----Résultats de la recherche
    BEGIN
    DECLARE
    requete varchar2(5000);
    v_code_type varchar2(2000);
    v_ordre varchar2(500);
    BEGIN
    :P1_NOM_BENEFICIAIRE := REPLACE(:P1_NOM_BENEFICIAIRE,' ', '%');
    :P1_NOM_BENEFICIAIRE := REPLACE(:P1_NOM_BENEFICIAIRE,'-', '%');
    requete := 'SELECT
    (FEUI.NOM_BENEFICIAIRE || ''--'' || FEUI.PRENOM_BENEFICIAIRE) ABC,
    FEUI.VALEUR_ID_BENEFICIAIRE,
    FEUI.MONTANT,
    FEUI.CODE_TYPE_DECLARATION,
    FEUI.ANNEE_FISCALE,
    FEUI.CODE_ENTITE,
    FEUI.ID_FEUILLET_IMPOT,
    FEUI.ID_AMENDEMENT,
    FEUI.NO_RELEVE_ORIGINAL_PROV,
    FEUI.ACRONYME_ID_BENEFICIAIRE,
    TYPD.SIGNIFICATION
    FROM
    S29_FEUILLET_IMPOT FEUI,
    S29_TYPE_DECLARATION TYPD
    WHERE
    (TYPD.CODE = FEUI.CODE_TYPE_DECLARATION) AND
    (ANNEE_FISCALE = :P1_ANNEE_FISCALE) AND
    (CODE_ENTITE LIKE ''%'' || SUBSTR(:P1_CODE_ENTITE,1,3) || ''%'') OR
    (CODE_ENTITE = SUBSTR(:P1_CODE_ENTITE,1,3))
    AND
    ((:P1_NAS IS NULL) OR (:P1_NAS = VALEUR_ID_BENEFICIAIRE))
    AND
    ((:P1_NEQ IS NULL) OR (:P1_NEQ = VALEUR_ID_BENEFICIAIRE))
    AND
    ((:P1_NOM_BENEFICIAIRE IS NULL) OR
    ((UPPER(NOM_BENEFICIAIRE) || UPPER(PRENOM_BENEFICIAIRE))
    LIKE ''%'' || UPPER(:P1_NOM_BENEFICIAIRE) || ''%'') OR
    ((UPPER(PRENOM_BENEFICIAIRE) || UPPER(NOM_BENEFICIAIRE))
    LIKE ''%'' || UPPER(:P1_NOM_BENEFICIAIRE) || ''%'') OR
    ((UPPER(RAISON_SOCIALE_LIGNE_1) || UPPER(RAISON_SOCIALE_LIGNE_2))
    LIKE ''%'' || UPPER(:P1_NOM_BENEFICIAIRE) || ''%'') OR
    ((UPPER(RAISON_SOCIALE_LIGNE_2) || UPPER(RAISON_SOCIALE_LIGNE_1))
    LIKE ''%'' || UPPER(:P1_NOM_BENEFICIAIRE) || ''%'') OR
    (UPPER(SUBSTR(COORDONNEE_BENEFICIAIRE_SYGBEC,1,80))
    LIKE ''%'' || UPPER(:P1_NOM_BENEFICIAIRE) || ''%'')
    IF (:P1_CODE_RELEVE = 'A') OR
    (:P1_CODE_RELEVE = 'M') OR
    (:P1_CODE_RELEVE = 'C') THEN
    v_code_type := '(
    (FEUI.CODE_TYPE_DECLARATION = ''A'') OR
    (FEUI.CODE_TYPE_DECLARATION = ''M'') OR
    (FEUI.CODE_TYPE_DECLARATION = ''C'')
    else
    v_code_type :=
    (:P1_CODE_RELEVE = CODE_TYPE_DECLARATION) OR
    (:P1_CODE_RELEVE = ''%'')
    end if;
    WWV_FLOW.DEBUG('V_CODE_TYPE EST EGALE A :' || v_code_type);
    v_ordre := 'ORDER BY NOM_BENEFICIAIRE, VALEUR_ID_BENEFICIAIRE,
    ID_FEUILLET_IMPOT, ID_AMENDEMENT';
    requete := requete || ' AND ' || v_code_type || v_ordre;
    RETURN requete;
    END;
    END;
    </pre>
    Thanks. Bye

    Thank you Scott,
    I'm sorry, I should present you a reduce sql command.
    I had construct my "long" sql command without concatenation. But, I decide to add a column just beside the other column.
    After sending my message on OTN, I tried something else, I decided to copy my sql command without concatenation in an other region. I changed my sql command in the new region by adding my new column and this ''--'' and it works very well. Sometimes, It's really difficult to understand why it doesn't.
    Thanks. Bye,

  • Concatenate date time and update SQL datetime field

    I have a form that captures date and time in 2 separate fields data and time.
    I need to combine these fileds and UPDATE a SQL database (datetime field)
    The date field is passed like this  DSDATE={ts '2013-11-18 00:00:00'}
    The time field is passed like this   TIME_IN1=14:05
    How do I concatenate DSDATE AND TIME_IN1 so that I can insert like this 2013-11-18 14:05:00.000 ?

    The easiest way may be the best. You judge.
    <cfset DSDATE = parsedatetime('2013-11-18')>
    <cfset  TIME_IN1="14:05">
    <cfset yr = year(DSDATE)>
    <cfset mnth = month(DSDATE)>
    <cfset d = day(DSDATE)>
    <cfset hr = listGetAt(TIME_IN1,1,":")>
    <cfset mn = listGetAt(TIME_IN1,2,":")>
    <cfset datetime=createdatetime(yr,mnth,d,hr,mn,0)>
    <cfoutput>#datetime#</cfoutput>

  • Can we concatenate 2 columns of datafile into one column in sql loader

    Hi,
    Can we concatenate 2 columns of datafile into one column in sql loader?
    like
    Suppose there are two field in data file
    column1 - lastname value tiger
    column2 - firstname value scott
    Required result
    sould be concatenate of the two field into one database coulmn
    like name and value should be scott tiger.
    Thanks

    Or try this...
    My input file
    1,KARTHICK,PATTABIRAMAN,SOFTWARE
    2,VIJAY,RENGANATHAN,FINANCE
    3,VIMAL,KANTH,SALESAnd my control file.
    LOAD DATA
    INFILE 'EmpDetail.txt'
    BADFILE 'EmpDetail.bad'
    DISCARDFILE 'EmpDetail.dsc'
    INTO TABLE "EMPDETAIL"
    FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS     
      (NO,
      NAME1 BOUNDFILLER,
      NAME ":NAME1||' '||:NAME",
      DEPT) My table is.
    SQL> create table empdetail(no integer, name varchar2(50), dept varchar2(50))
      2  /
    Table created.Then i loaded the data.
    D:\karthick\Akiva\Look up\Akiva\Address Look Up>sqlldr sysadm/sysadm@akivanew empdetail.ctl
    SQL*Loader: Release 9.2.0.1.0 - Production on Mon Sep 15 12:23:42 2008
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Commit point reached - logical record count 2
    Commit point reached - logical record count 3And the output is
    SQL> select * from empdetail
      2  /
            NO NAME                                               DEPT
             1 KARTHICK PATTABIRAMAN                              SOFTWARE
             2 VIJAY RENGANATHAN                                  FINANCE
             3 VIMAL KANTH                                        SALESThanks,
    Karthick.

  • Concatenate problem for Dynamic SQL statements

    Hi Experts ,
    I am building Dynamic SQL statements depending on the values which the user enters into the select option parameters .This dynamic query is passed to cl_sql_connection object for querying from another databasse
    So i wrote dynamic values for one select option spointof for the database field ppointofdelivery.
    loop at spointof.
    CONCATENATE ' pointofdelivery between ''' spointof-low''''
    ' AND ''' spointof-high''''
    INTO where_clause .
    endloop.
    The whereclause has value pointofdelivery between '123' and '124'.(if the user has entered 123 and 124 as values)
    This works fine . But my problem is I have to pass the fieldnames and operator dynamically into where_clause depending on User input.
    when i am writing code like the below
    field_name = ' pointofdelivery '.
    operator = '='.
    CONCATENATE field_name operator '''spointof-low''' INTO where_clause .
    the where_clause contains value
    pointofdelivery = ' spointof-low '
    and not pointofdelivery = ' 123 ' as expected .
    Do you know why this is haapening as it is not taking the value.
    Thanks
    Arshad

    Hi,
    there are lot of function modules..available...to build a where clause based on the select-options..
    check the FM FREE_SELECTIONS_RANGE_2_WHERE
    Thanks
    Naren

Maybe you are looking for