Need help :  Select in statement

Hi all,
i am passing a query from SQL server to Oracle using the openquery..
i need to pass a variable as a string that has more than one parameter ..here is the example i ma uding for one value..
DECLARE @OBJECTID varchar(max);
SET @OBJECTID = '423_23';
SET @OBJECTID =' ''423_23''' '+','+' ''423_24'' '; this is giving error when usingmore than 1 string value
-- here is the query that works just fine using only one value :
@MYSTRING ='SELECT * FROM OPENQUERY(LINKED_PCTIDM,''SELECT p1.* FROM ADM.day p1 WHERE p1.time_key >= ''''' + @Report_Date + ''''' and p1.time_key <= ''''' + @Report_Date2 + ''''' and p1.QUEUE <> ''''' + @zerocall + ''''' and p1.object_id in ''''' + @OBJECTID + ''''' '')'
EXEC (@MYSTRING)
what i want : is to add the '' select in'' statement where the @OBJECTID='423_23','423_24','423_25'; (more than one value)..
i am getting error on the sql statement
incorrect syntax...
the regular select instatement should be like this : select * in ('value1,'value2',....)
any help to fix that will be appreciated...

it shoud be:
SET @OBJECTID = '''''423_23'''',''''423_24''''' ;
@MYSTRING ='SELECT * FROM OPENQUERY(LINKED_PCTIDM,''SELECT p1.* FROM ADM.day p1 WHERE p1.time_key >= ''''' + @Report_Date + ''''' and p1.time_key <= ''''' + @Report_Date2 + ''''' and p1.QUEUE <> ''''' + @zerocall + ''''' and p1.object_id in (' + @OBJECTID + ') '')'

Similar Messages

  • Need Help ASAP  my State tax form is in a PDF file and the attachment in my email says Please wait

    Need Help ASAP  my State tax form is in a PDF file and the attachment in my email says Please wait...
    I tried downloading updates like it said to but it still will not display the document.  How do I print the PDF file ASAP

    Can you give us a LOT more info?
    What email client? What version of Reader (I can only assume you even have Reader at this point)?
    Please wait? I'm sure it says more than that, right?
    Have you tried simply saving the PDF (it IS a PDF correct?) to your desktop and opening it from there?
    Did you get this form from the IRS or did it come from somewhere else? If the IRS again, what version of Reader?
    Help us help you.

  • I Need Help Selecting A Mainboard!!!!!!!!!

    i need help selecting a motherboard
    the baord has to run an IDE HDD, support DDR2 ram(and preferably DDR1 aswell but not absolutely needed), on board sound and graphics, Celeron D CPU (3.0Ghz) can anyone suggest a board that i can use??????
    thank you for the help
    please email me if you can help  [email protected]
    thanks again

      go for the 945p neo2-f  main board it will allow you to upgrade  for future cpus! if not the 945 go for the 955 main boards ! 915 combos are good but  your not going to be able to upgraded to the cedar mill cpus when you get ready to use them !

  • Need help on case statements to validate records

    Hi Experts ,
    My table :
    seq_num
    col2
    col3
    col4
    1
    A
    12345
    P
    2
    B
    1
    123%23
    3
    C
    1
    23AB
    4
    D
    1
    20131001
    5
    E
    1
    6
    A
    13245
    Q
    7
    B
    1
    12345
    8
    C
    2
    1234*AB
    9
    D
    5
    20140112
    10
    E
    1
    00020
    my output
    seq_num
    col2
    col3
    col4
    Status
    Reason
    1
    A
    12345
    P
    Valid
    2
    B
    1
    123%23
    invalid
    Special Character for col4
    3
    C
    1
    23AB
    Valid
    4
    D
    1
    20131001
    Valid
    5
    E
    1
    invalid
    null for col4
    6
    A
    13245
    Q
    invalid
    Invalid character col4 || invalid number for col3
    7
    B
    1
    12345
    Valid
    8
    C
    2
    1234*AB
    Invalid
    Special Character col4 ||invalid col3
    9
    D
    5
    20140112
    invalid
    Future dates col4 ||invalid col3
    10
    E
    1
    00020
    Valid
    Sql :
    with t as
    ( select 1 as seq_num,'A' as col2 ,12345 as col3 ,'P' as col4 from dual
    union all
    select 2 ,'B',1,'123%23' from dual
    union all
    select 3,'C',1,'23AB' from dual
    union all
    select 4,'D',1,'21-02-2013' from dual
    union all
    select 5,'E',1,null from dual
    union all
    select 6,'A,13245,'Q' from dual
    union all
    select 7,'B',1,12345 from dual
    union all
    select 8,'C',2,'1234*AB' from dual
    union all
    select 9,'D',5,'25-01-2014' from dual
    union all
    select 10,'E',1,20 from dual
    I am applying rules on col3 and col4 for each records row-wise.
    I need case statements to populate status and reason columns after applying below rules
    Rules
    Col3 :
    For A record ,it should be 12345 always .
    For B,C,D,E , record should be always 1
    col4
    For A record , it should be either P or R
    No null values for all A, B,C,D,E records
    for B record , it dont contain special charecters
    for C RECORD ,  it dont contain special charecters
    for D record ,it should not contain future dates (dates are in yyyymmdd format and  less than  sysdates are valid )
    I have other columns as well ,as i not included here
    .It would be great if you Could  help on case statements
    Thanks and Regards,
    Sumanth

    I've adjusted Gregs nice example a bit. This should work:
    with w_base as (
          select seq_num, col2, col3, col4,
                 case when (col2 = 'A'                 AND col3 = 12345 )
                        OR (col2 in ('B','C','D','E')  AND col3 = 1)
                            then '' else '||invalid col3' end ||
                 case when (col2 = 'A'        AND col4 not IN ( 'P', 'R' ) )
                            then '||invalid col4' else '' end ||
                 case when (col2 IN ( 'B', 'C' )   AND col4 != translate(col4, 'a!@#$%^*()','a') )
                            then '||special character for col4' else '' end ||
                 case when (col2 = 'D'        AND col4 >= to_char(sysdate,'yyyymmdd') )
                            then '||future dates col4' else '' end
                   reason
          from ( select 1 as seq_num, 'A' as col2, 12345 as col3, 'P' as col4  from dual union all
                 select 2,            'B',         1,             '123%23'     from dual union all
                 select 3,            'C',         1,             '23AB'       from dual union all
                 select 4,            'D',         1,             '20130212'   from dual union all
                 select 5,            'E',         1,             null         from dual union all
                 select 6,            'A',         13245,         'Q'          from dual union all
                 select 7,            'B',         1,             '12345'      from dual union all
                 select 8,            'C',         2,             '1234*AB'    from dual union all
                 select 9,            'D',         5,             '20140125'   from dual union all
                 select 10,           'E',         1,             '20'         from dual )
    Select seq_num, col2, col3, col4,
           case when reason is null then 'Valid' else 'Invalid' end status,
           substr(reason, 3 ) reason
    from w_base
    It returns
    SEQ_NUM
    COL2
    COL3
    COL4
    STATUS
    REASON
    1
    A
    12345
    P
    Valid
    2
    B
    1
    123%23
    Invalid
    special character for col4
    3
    C
    1
    23AB
    Valid
    4
    D
    1
    20130212
    Valid
    5
    E
    1
    Valid
    6
    A
    13245
    Q
    Invalid
    invalid col3||invalid col4
    7
    B
    1
    12345
    Valid
    8
    C
    2
    1234*AB
    Invalid
    invalid col3||special character for col4
    9
    D
    5
    20140125
    Invalid
    invalid col3||future dates col4
    10
    E
    1
    20
    Valid
    edited some bugs :) now it should be fine! really

  • Need Help On SQL Statement

    I am using Sybase as my back end database. I need help on my SQL statement regarding datetime. The datetime is store as a 9 digit integer in the database (...I believe it is a Decimal(30,6) format, let me know if I am wrong).
    If I do this, "select * from mytable;" It works out fine (except I don't know what the date means e.g. 998919534)
    If I do this, "select * from mytable where datetime_col < '9/5/2002' ; I got an error. I even tried '9/5/02 11:00 000 am' but it didn't help.
    How do I specify a date or datetime in my query?
    Thanks in advance.

    I execute the sql statement
    select * from mytable where datetim_col < convert(datetime, '3/4/2002', 101) ;
    I got mix result. I got an error message "cannot convert 10375584 to a date.
    Yet, he statistics window of the I-sql says
    "estimated 493 rows in query (I/O estimate 87)
    PLan> mytable (seq)"
    It looks like I my the SQL statement is correct and then the system can't display it in the Data window.
    Any thought ?

  • Need help for sql statement

    Hi,
    Need help to write sql statement.
    create table t_dt ( dt_start date, dt_end date, amount number);
    insert into t_dt values('1-Jan-10','10-Feb-10',12);
    insert into t_dt values('11-Feb-10','10-Mar-10',10);
    insert into t_dt values('11-Mar-10','20-Apr-10',8);
    insert into t_dt values('21-Apr-10','28-Jun-10',10);
    insert into t_dt values('29-Jun-10','20-Sep-10',10);
    insert into t_dt values('21-Sep-10','10-Oct-10',10);
    insert into t_dt values('11-Oct-10','31-Dec-10',8);
    insert into t_dt values('1-Jan-11','10-Feb-11',8);
    insert into t_dt values('11-Feb-11','10-Mar-11',7);
    insert into t_dt values('11-Mar-11','20-Apr-11',6);
    insert into t_dt values('21-Apr-11','28-Jun-11',6);
    insert into t_dt values('29-Jun-11','20-Sep-11',6);
    insert into t_dt values('21-Sep-11','10-Oct-11',4);
    insert into t_dt values('11-Oct-11','31-Dec-11',8);
    Result should be like below..
    dt_start     dt_end     Amount
    1-Jan-10     10-Feb-10     12
    11-Feb-10     10-Mar-10     10
    11-Mar-10     20-Apr-10     8
    21-Apr-10     10-Oct-10     10
    11-Oct-10     10-Feb-11     8
    11-Feb-11     10-Mar-11     7
    11-Mar-11     20-Sep-11     6
    21-Sep-11     10-Oct-11     4
    11-Oct-11     31-Dec-11     8
    Just to explain the example, take a row with start date as 21-Apr-10 in the above insert statements, since it has the same amount for next two rows (i.e. with start date '29-Jun-10' and '21-Sep-10') these 3 rows should be converted to represent only 1 row in the result and the start date and end date should be changed per the result shown above.
    Thanks.

    Hello
    I think this gives yuo what you need....
    SELECT
        MIN(dt_start),
        MAX(dt_end),
        amount
    FROM
        (   SELECT
                dt_start,
                dt_end,
                MAX(marker) OVER(ORDER BY dt_start) marker,
                amount
            FROM
                    Select
                        dt_start,
                        dt_end,
                        amount,
                        CASE
                            WHEN LAG(amount) OVER(ORDER BY dt_start) <> amount THEN
                                ROW_NUMBER() OVER(ORDER BY dt_start)
                        END marker
                    from t_dt
    GROUP BY
         amount,
         marker
    order by     
         MIN(dt_start)
    MIN(DT_START)        MAX(DT_END)              AMOUNT
    01-JAN-2010 00:00:00 10-FEB-2010 00:00:00         12
    11-FEB-2010 00:00:00 10-MAR-2010 00:00:00         10
    11-MAR-2010 00:00:00 20-APR-2010 00:00:00          8
    21-APR-2010 00:00:00 10-OCT-2010 00:00:00         10
    11-OCT-2010 00:00:00 10-FEB-2011 00:00:00          8
    11-FEB-2011 00:00:00 10-MAR-2011 00:00:00          7
    11-MAR-2011 00:00:00 20-SEP-2011 00:00:00          6
    21-SEP-2011 00:00:00 10-OCT-2011 00:00:00          4
    11-OCT-2011 00:00:00 31-DEC-2011 00:00:00          8
    9 rows selected.HTH
    David
    Edited by: Bravid on Feb 23, 2012 12:08 PM
    Beaten to it by Frank! :-)

  • Need help on SQL Statement for UDF

    Hi,
    as I am not so familiar with SQL statements on currently selected values, I urgently need help.
    The scenario looks as follows:
    I have defined two UDFs named Subgroup1 and Subgroup2 which represent the subgroups dependent on my article groups. So for example: When the user selects article group "pianos", he only sees the specific subgroups like "new pianos" and "used pianos" in field "Subgroup1". After he has selected one of these specific values, he sees only the specific sub-subgroups in field "Subgroup2", like "used grand pianos".
    I have defined UDTs for both UDFs. The UDT for field "Subgroup1" has a UDF called "ArticleGroup" which represents the relation to the article group codes. The UDT for field "Subgroup2" has a UDF called "Subgroup1" which represents the relation to the subgroups one level higher.
    The SQL statement for the formatted search in field "Subgroup1" looks as follows:
    SELECT T0.[Name] FROM [dbo].[@B_SUBGROUP1]  T0 WHERE T0.[U_ArticleGroup]  = (SELECT $[OITM.ItmsGrpCod])
    It works fine.
    However, I cannot find the right statement for the formatted search in field "Subgroup2".
    Unfortunately this does NOT WORK:
    SELECT T0.[Name] FROM [dbo].[@B_SUBGROUP2]  T0 WHERE T0.[U_Subgroup1]  = (SELECT $[OITM.U_Subgroup1])
    I tried a lot of others that didn't work either.
    Then I tried the following one:
    SELECT T0.[Name] FROM [dbo].[@B_SUBGROUP2]  T0 WHERE T0.[U_Subgroup1] = (SELECT T1.[Code] FROM [dbo].[@B_SUBGROUP1] T1 WHERE T1.[U_ArticleGroup] = (SELECT $[OITM.ItmsGrpCod]))
    Unfortunately that only works as long as there is only one specific subgroup1 for the selected article group.
    I would be sooooo happy if there is anyone who can tell me the correct statement for my second UDF!
    Thanks so much in advance!!!!
    Edited by: Corinna Hochheim on Jan 18, 2010 10:16 PM
    Please ignore the "http://" in the above statements - it is certainly not part of my SQL.
    Please also ignore the strikes.

    Hello Dear,
    Use the below queries to get the values:
    Item Sub Group on the basis of Item Group
    SELECT T0.[Name] FROM [dbo].[@SUBGROUP]  T0 WHERE T0.[U_GroupCod] =$[OITM.ItmsGrpCod]
    Item Sub Group 1 on the basis of item sub group
    SELECT T0.[Name] FROM [dbo].[@SUBGROUP1]  T0 WHERE T0.[U_SubGrpCod]=(SELECT T0.[Code] FROM [dbo].[@SUBGROUP]  T0 WHERE T0.[Name] =$[OITM.U_ItmsSubgrp])
    Sub group 2 on the basis of sub group 1
    SELECT T0.[Name] FROM [dbo].[@SUBGROUP2]  T0 WHERE T0.[U_SubGrpCod1]=(SELECT T0.[Code] FROM [dbo].[@SUBGROUP1]  T0 WHERE T0.[Name] =$[OITM.U_ItmsSubgrp1])
    this will help you.
    regards,
    Neetu

  • Need help with provide statement in pnp progrm

    hi experts,
    i need to select all the records that :
    1. pa00014-sunty in so_subty.
    base on the records that he found' i need to select from pa0001:
    p0014-endda = > p0001-begda and
    p0014-begda = < p0001-endda and
    p0001-persk ne so_persk.
    what i did:
    provide * from p0001
    from p0014
    between pn-begda and pn-endda
    where p0014-subty = so_subty  and
    p0014-endda = > p0001-begda and
    p0014-begda = < p0001-endda and
    p0001-persk ne so_persk.
    check p0001_valid = 'X'.
    endprovide.
    i got 2 problems:
    1. i not recognize the syntax: check p0001_valid = 'X'.
    2. the syntax for the provide is not good.
    i new in pnp thing.
    i hope i was clear.
    thanks in advanced,
    Michal.

    Hi,
       May be this code will help you.
    infotypes: 0001,0002,0008,0000,1000,0021,0041,0587 .
    PROVIDE ename BTRTL PLANS STELL ORGEH ABKRS FROM P0001 BETWEEN PN-BEGDA AND PN-ENDDA  .
    if p0001-begda = '20070801' .
          IT_FINAL-ORGEH = P0001-ORGEH .
          IT_FINAL-STELL = P0001-STELL .                            "   JOB
          IT_FINAL-PLANS = P0001-PLANS .                            "   POSITION
          IT_FINAL-ename = P0001-ename .                            "   personnel name
          IT_FINAL-BTRTL = P0001-BTRTL .                            "   DEPARTMENT
          IT_FINAL-ABKRS = P0001-ABKRS .                            "   PAYROLL AREA
          APPEND IT_FINAL .
    endif .
    ENDPROVIDE.
    PROVIDE GBDAT GESCH FROM P0002 BETWEEN PN-BEGDA AND PN-ENDDA .
           IT_FINAL-GBDAT = P0002-GBDAT  .                            "   DOB
           IT_FINAL-GESCH = P0002-GESCH  .                            "   ***
         IF IT_FINAL-GESCH = 1   .
           IT_FINAL-GTXT  = 'M'  .
         ELSE.
           IT_FINAL-GTXT  = 'F'  .
         ENDIF .
           APPEND IT_FINAL .
    ENDPROVIDE .
    PROVIDE TRFST FROM P0008 BETWEEN PN-BEGDA AND PN-ENDDA.
            IT_FINAL-TRFST = P0008-TRFST .                          "   personnel level
            APPEND IT_FINAL .
    ENDPROVIDE.
    PROVIDE  FAVOR FANAM FROM P0021 BETWEEN PN-BEGDA AND PN-ENDDA where P0021-pernr = pernr-pernr
      and  p0021-SUBTY = '11' .
           IT_FINAL-FAVOR  = P0021-FAVOR .                          "   FATHER'S NAME
           IT_FINAL-FANAM  = P0021-FANAM .
           CONCATENATE IT_FINAL-FAVOR IT_FINAL-FANAM  INTO IT_FINAL-FNAME .
           APPEND IT_FINAL .
    ENDPROVIDE.
    Regards,
    Himanshu

  • I need help in sql statement

    Hello all,
    im working in hr schema
    i need sql statement to answer my question
    i need all employees information
    where average salary = average salary department 50
    sorry i can't speak english very well
    thank's all

    There is no need to do it in two queries. All you need is:
    select  *
      from  (
             select  e.*,
                     avg(case department_id when 50 then salary end) over() dept_50_avg_sal
               from  hr.employees e
      where salary <= dept_50_avg_sal
    EMPLOYEE_ID FIRST_NAME           LAST_NAME                 EMAIL                     PHONE_NUMBER         HIRE_DATE JOB_ID         SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID DEPT_50_AVG_SAL
            198 Donald               OConnell                  DOCONNEL                  650.507.9833         21-JUN-07 SH_CLERK         2600                       124            50      3475.55556
            199 Douglas              Grant                     DGRANT                    650.507.9844         13-JAN-08 SH_CLERK         2600                       124            50      3475.55556
            115 Alexander            Khoo                      AKHOO                     515.127.4562         18-MAY-03 PU_CLERK         3100                       114            30      3475.55556
            116 Shelli               Baida                     SBAIDA                    515.127.4563         24-DEC-05 PU_CLERK         2900                       114            30      3475.55556
            117 Sigal                Tobias                    STOBIAS                   515.127.4564         24-JUL-05 PU_CLERK         2800                       114            30      3475.55556
            118 Guy                  Himuro                    GHIMURO                   515.127.4565         15-NOV-06 PU_CLERK         2600                       114            30      3475.55556
            119 Karen                Colmenares                KCOLMENA                  515.127.4566         10-AUG-07 PU_CLERK         2500                       114            30      3475.55556
            125 Julia                Nayer                     JNAYER                    650.124.1214         16-JUL-05 ST_CLERK         3200                       120            50      3475.55556
            126 Irene                Mikkilineni               IMIKKILI                  650.124.1224         28-SEP-06 ST_CLERK         2700                       120            50      3475.55556
            127 James                Landry                    JLANDRY                   650.124.1334         14-JAN-07 ST_CLERK         2400                       120            50      3475.55556
            128 Steven               Markle                    SMARKLE                   650.124.1434         08-MAR-08 ST_CLERK         2200                       120            50      3475.55556
    EMPLOYEE_ID FIRST_NAME           LAST_NAME                 EMAIL                     PHONE_NUMBER         HIRE_DATE JOB_ID         SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID DEPT_50_AVG_SAL
            129 Laura                Bissot                    LBISSOT                   650.124.5234         20-AUG-05 ST_CLERK         3300                       121            50      3475.55556
            130 Mozhe                Atkinson                  MATKINSO                  650.124.6234         30-OCT-05 ST_CLERK         2800                       121            50      3475.55556
            131 James                Marlow                    JAMRLOW                   650.124.7234         16-FEB-05 ST_CLERK         2500                       121            50      3475.55556
            132 TJ                   Olson                     TJOLSON                   650.124.8234         10-APR-07 ST_CLERK         2100                       121            50      3475.55556
            133 Jason                Mallin                    JMALLIN                   650.127.1934         14-JUN-04 ST_CLERK         3300                       122            50      3475.55556
            134 Michael              Rogers                    MROGERS                   650.127.1834         26-AUG-06 ST_CLERK         2900                       122            50      3475.55556
            135 Ki                   Gee                       KGEE                      650.127.1734         12-DEC-07 ST_CLERK         2400                       122            50      3475.55556
            136 Hazel                Philtanker                HPHILTAN                  650.127.1634         06-FEB-08 ST_CLERK         2200                       122            50      3475.55556
            138 Stephen              Stiles                    SSTILES                   650.121.2034         26-OCT-05 ST_CLERK         3200                       123            50      3475.55556
            139 John                 Seo                       JSEO                      650.121.2019         12-FEB-06 ST_CLERK         2700                       123            50      3475.55556
            140 Joshua               Patel                     JPATEL                    650.121.1834         06-APR-06 ST_CLERK         2500                       123            50      3475.55556
    EMPLOYEE_ID FIRST_NAME           LAST_NAME                 EMAIL                     PHONE_NUMBER         HIRE_DATE JOB_ID         SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID DEPT_50_AVG_SAL
            142 Curtis               Davies                    CDAVIES                   650.121.2994         29-JAN-05 ST_CLERK         3100                       124            50      3475.55556
            143 Randall              Matos                     RMATOS                    650.121.2874         15-MAR-06 ST_CLERK         2600                       124            50      3475.55556
            144 Peter                Vargas                    PVARGAS                   650.121.2004         09-JUL-06 ST_CLERK         2500                       124            50      3475.55556
            180 Winston              Taylor                    WTAYLOR                   650.507.9876         24-JAN-06 SH_CLERK         3200                       120            50      3475.55556
            181 Jean                 Fleaur                    JFLEAUR                   650.507.9877         23-FEB-06 SH_CLERK         3100                       120            50      3475.55556
            182 Martha               Sullivan                  MSULLIVA                  650.507.9878         21-JUN-07 SH_CLERK         2500                       120            50      3475.55556
            183 Girard               Geoni                     GGEONI                    650.507.9879         03-FEB-08 SH_CLERK         2800                       120            50      3475.55556
            186 Julia                Dellinger                 JDELLING                  650.509.3876         24-JUN-06 SH_CLERK         3400                       121            50      3475.55556
            187 Anthony              Cabrio                    ACABRIO                   650.509.4876         07-FEB-07 SH_CLERK         3000                       121            50      3475.55556
            190 Timothy              Gates                     TGATES                    650.505.3876         11-JUL-06 SH_CLERK         2900                       122            50      3475.55556
            191 Randall              Perkins                   RPERKINS                  650.505.4876         19-DEC-07 SH_CLERK         2500                       122            50      3475.55556
    EMPLOYEE_ID FIRST_NAME           LAST_NAME                 EMAIL                     PHONE_NUMBER         HIRE_DATE JOB_ID         SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID DEPT_50_AVG_SAL
            194 Samuel               McCain                    SMCCAIN                   650.501.3876         01-JUL-06 SH_CLERK         3200                       123            50      3475.55556
            195 Vance                Jones                     VJONES                    650.501.4876         17-MAR-07 SH_CLERK         2800                       123            50      3475.55556
            196 Alana                Walsh                     AWALSH                    650.507.9811         24-APR-06 SH_CLERK         3100                       124            50      3475.55556
            197 Kevin                Feeney                    KFEENEY                   650.507.9822         23-MAY-06 SH_CLERK         3000                       124            50      3475.55556
    37 rows selected.
    SQL> SY.

  • Need Help on Insert Statement

    Hi,
    I want to insert the data into table dynamically. insert into number of columns depends on number of selected column statements.
    Table in which data needs to be enetered is table with generic coulmn.
    THanks
    --K                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    for ex. I have a table with generic colums. col1,col2,col3.col4,col5,col6.......................col255
    I want the number of column selected while inserting depends upon the select stmt.
    like
    insert into t1(col1,col2,col3)values
    (select a,b,c from t2)
    but if if I have select a,b,c,d,e from t2 then
    insert into t1(col1,col2,col3,col4).
    THanks

  • Need Help In SQL Statement

    Hi,
    I need to combine many table only in one select statement.
    This is my table name
    - L20060101
    - L20060102
    - L20060103
    - L20060104
    - L20060105
    - L20060131
    - L20060201
    I dont how to do select statement to select all this table
    This is the wrong select statement.
    Select * from like '%L200601%
    Can i do like that?
    Can any body help me on how to solve my problem?

    You could do something like
    create or replace procedure sp_create_monthly_tabs
         (p_month in varchar2) is
    v_sql varchar2(32767);
    v_cnt number:=0;
    begin
    v_sql := null;
    for c1 in (select table_name from user_tables
    ---   put in the condition to select the tables by the month
    ---  passed in as the parameters
                  ) loop
       if v_cnt = 0 then
          v_sql := 'Create or replace VIEW Mon_Tab'||p_month ||
                       'AS Select * from '||C1.Table_Name ||' ' ;
       else
          v_sql := v_sql||'Union All '||'Select * from '||C1.Table_Name ||' ' ;
       end if;
       v_cnt := v_cnt + 1;
    end loop;
    execute immediate(v_sql)
    end;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Need help with update statement with multiple joins

    I've got the following select statement that is pulling 29 records:
    SELECT
    PPA.PROJECT_ID,
    PPA.SEGMENT1,
    peia.expenditure_item_id,
    peia.expenditure_type,
    pec.expenditure_comment
    FROM PA.PA_PROJECTS_ALL PPA,
    pa.pa_expenditure_items_all peia,
    pa.pa_expenditure_comments pec
    where PPA.segment1 < '2008' and
    PPA.project_id = 52 and -- just run for project # 20077119 for testing
    peia.expenditure_type = 'PAYROLL' and
    peia.project_id = ppa.project_id and
    PEC.EXPENDITURE_ITEM_ID = PEIA.EXPENDITURE_ITEM_ID;
    I need to update the pec.expenditure_comments to a static field for those 29 records. I assume I should start with the following, but not sure how to complete the where:
    update
    pa.pa_expenditure_comments pec
    set pec.expenditure_comment = 'REFERENCE HD#728'
    where
    First time that we've ever needed to update, so any and all help appreciated.

    Try using exists:
    update pa.pa_expenditure_comments pec
    set    pec.expenditure_comment = 'REFERENCE HD#728'
    where exists ( select null
                   from   pa.pa_projects_all ppa
                   ,      pa.pa_expenditure_items_all peia
                   ,      pa.pa_expenditure_comments pec2
                   where  ppa.segment1 < ''    -- not sure what you posted here, so for next time:
                                               -- please put your examples between the code tags.
                   and    ppa.project_id = 52  -- just run for project # 20077119 for testing
                   and    peia.expenditure_type = 'PAYROLL'
                   and    peia.project_id = ppa.project_id
                   and    pec2.expenditure_item_id = peia.expenditure_item_id
                   and    pec2.expenditure_item_id = pec.expenditure_item_id
                 );

  • Need help - select data from NCLOB column problem

    Hi,
    Im having problem retrieving data from NCLOB columns via ODBC. After SQLExecdirect on my SELECT statement call to SQLFetch gives me following error:
    ORA-24806 LOB form mismatch
    I tried following two ways of data retrieval:
    SQLExecDirect(hstmt,(SQLTCHAR*)szSQLStatement,SQL_NTS);
    SQLBindCol(hstmt,3,SQL_C_TCHAR,chBuffer,sizeof(chBuffer),&iDataLen);
    SQLFetch(hstmt);
    OR
    SQLExecDirect(hstmt,(SQLTCHAR*)szSQLStatement,SQL_NTS);
    SQLFetch(hstmt);
    SQLGetData(hstmt,3,SQL_C_TCHAR,chBuffer,sizeof(chBuffer),&iDataLen);
    Both times call to SQLFetch gives me ORA-24806 LOB form mismatch error.
    INSERT and UPDATE for this table works just fine.
    If I change NCLOB type to CLOB works just fine, but I will be storing Unicode data, so using CLOB cant be a solution
    Any ideas appreciated.
    Thanks in advance,
    Vlad
    Server:
    Oracle 9.2 database on Windows 2000 Server
    NLS_LANGUAGE = AMERICAN
    NLS_TERRITORY = AMERICA
    NLS_CHARACTERSET = WE8MSWIN1252
    NLS_NCHAR_CHARACTERSET = AL16UTF16
    Client:
    Unicode C++ application, connects via Oracle 9.2 ODBC driver on Windows XP
    NLS_LANG = AMERICAN_AMERICA.WE8MSWIN1252
    CREATE TABLE my_nclob_table (
         id number (10,0) NOT NULL ,
         name nvarchar2 (255) NOT NULL ,
         description nvarchar2 (255) NULL ,
         definition nclob NOT NULL ,
         creation date NOT NULL ,
         lastmodified date NOT NULL ,
         CONSTRAINT PK_cat_pricelist PRIMARY KEY
              id
    #define     nil NULL
    #define     null NULL
    #define     SQL_ERR(__sqlerr__)     (((__sqlerr__) != SQL_SUCCESS) && ((__sqlerr__) != SQL_SUCCESS_WITH_INFO))
    #define     STOP_IF_SQL_ERR(__sqlerr__)                                                                 \
                                                      do                                                       \
                                                           if (SQL_ERR(__sqlerr__)) goto stop_;     \
                                                      } while (false)                                                  
    void eqTestOracleLOBSelect(void)
         SQLHENV henv     = null;
         SQLHDBC hdbc     = null;
         SQLHSTMT hstmt     = null;
         SQLRETURN retcode     = SQL_SUCCESS;
         TCHAR          szSQLStatement[]     = T("select id, name, definition from mynclob_table");
         int               iFetchedRows = 0;
         TCHAR          szMsg[512];
         TCHAR          chBuffer[2049];
         SQLLEN          iDataLen = 0;
         try
              retcode = eqOpenConnectionODBC(_T("myTestDsn"),_T("user"),_T("pwd"),henv,hdbc);
              STOP_IF_SQL_ERR(retcode);
              retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
              STOP_IF_SQL_ERR(retcode);
              retcode = SQLExecDirect(hstmt,(SQLTCHAR*)szSQLStatement,SQL_NTS);
              STOP_IF_SQL_ERR(retcode);
              retcode = SQLBindCol(hstmt,3,SQL_C_TCHAR,chBuffer,sizeof(chBuffer),&iDataLen);
              STOP_IF_SQL_ERR(retcode);
                   while (retcode == SQL_SUCCESS)
                        retcode = SQLFetch(hstmt);
                        if (retcode == SQL_NO_DATA)
                             retcode = SQL_SUCCESS;
                             break;
                        STOP_IF_SQL_ERR(retcode);
                   //     retcode = SQLGetData(hstmt,3,SQL_C_TCHAR,chBuffer,sizeof(chBuffer),&iDataLen);
                   //     STOP_IF_SQL_ERR(retcode);
                        ++iFetchedRows;
         stop_:
              if (SQL_ERR(retcode))
                   MessageBox(null,_T("SQL statement execution error."),_T("Error"),MB_OK);
                   eqShowStatementError(SQL_HANDLE_STMT,hstmt,retcode);
              } else     {
                             _stprintf(szMsg,_T("SQL execution success. Fetched rows: %ld"),iFetchedRows);
                             MessageBox(null,szMsg,_T("Success"),MB_OK);
         catch(...)
              MessageBox(null,_T("Unknown exception in eqTestOracleLOBSelect"),_T("Unknown exception"),MB_OK);
         if (hstmt != null)
              SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
              hstmt = null;
         if (hdbc != nil)
              SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
              hdbc = nil;
         if (henv != nil)
              SQLFreeHandle(SQL_HANDLE_ENV, henv);
              henv = nil;
    SQLRETURN eqOpenConnectionODBC(TCHAR          *szDSN,
                                       TCHAR          *szUser,
                                       TCHAR          *szPassword,
                                       SQLHENV     &henv,
                                       SQLHDBC &hdbc)
         SQLRETURN retcode;
         henv = nil;
         hdbc = nil;
         //Allocate environment handle
         retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
         STOP_IF_SQL_ERR(retcode);
         //Set the ODBC version environment attribute
         retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0);
         STOP_IF_SQL_ERR(retcode);
         // Allocate connection handle
         retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
         STOP_IF_SQL_ERR(retcode);
         // Set login timeout to 5 seconds.
         SQLSetConnectAttr(hdbc, SQL_LOGIN_TIMEOUT, (void*)5, 0);
         STOP_IF_SQL_ERR(retcode);
         retcode = SQLConnect(hdbc, (SQLTCHAR*)szDSN, SQL_NTS,
                                            (SQLTCHAR*)szUser, SQL_NTS,
                                            (SQLTCHAR*)szPassword, SQL_NTS);
    stop_:
              if (SQL_ERR(retcode))
                   MessageBox(null,_T("Connection Error."),_T("Error"),MB_OK);
                   if (hdbc != nil)
                        eqShowStatementError(SQL_HANDLE_DBC, hdbc,retcode);
                        SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
                        hdbc = nil;
                   if (henv != nil)
                        eqShowStatementError(SQL_HANDLE_ENV, henv,retcode);
                        SQLFreeHandle(SQL_HANDLE_ENV, henv);
                        henv = nil;
              } else MessageBox(null,_T("Connected."),_T("Success"),MB_OK);
         return retcode;
    void eqShowStatementError(SQLSMALLINT chHandleType, SQLHANDLE hHandle,long lErrOrig)
         SQLRETURN          nErr          = SQL_SUCCESS;
         int                    nRecNum = 1;
         SQLTCHAR          szSqlState[6];
         SQLTCHAR          szMsg[SQL_MAX_MESSAGE_LENGTH];
         SQLSMALLINT          nMsgLen;
         SQLINTEGER          nNativeError;
         while ((nErr = SQLGetDiagRec(chHandleType,hHandle,nRecNum,
                                            szSqlState, &nNativeError,
                                            szMsg, sizeof(szMsg), &nMsgLen)) != SQL_NO_DATA)
              szSqlState[5] = 0;
              MessageBox(NULL,(const TCHAR *)szMsg,_T("ODBC Error"),MB_OK);
              ++nRecNum;

    Yes, the 9.2.0.2 driver can be downloaded from OTN. I don't believe it will solve your particular problem, but it will help in general. If you don't grab the latest version, you'll probably have to chack the "Force SQL_WCHAR Support" option in the DSN configuration.
    From the help file
    "The C data type, SQL_C_WCHAR, was added to the ODBC interface to allow applications to specify that an input parameter is encoded as Unicode or to request column data returned as Unicode. The macro SQL_C_TCHAR is useful for applications that need to be built as both Unicode and ANSI. The SQL_C_TCHAR macro compiles as SQL_C_WCHAR for Unicode applications and as SQL_C_CHAR for ANSI applications."
    My first thought would be that your application is not being compiled as Unicode. If you substitute SQL_C_WCHAR for SQL_C_TCHAR when you're dealing with NCLOB columns, I suspect you'll have better luck.
    More help file
    "The SQL data types, SQL_WCHAR, SQL_WVARCHAR, and SQL_WLONGVARCHAR, were added to the ODBC interface to represent columns defined in a table as Unicode. These values are potentially returned from calls to SQLDescribeCol, SQLColAttribute, SQLColumns, and SQLProcedureColumns. In Oracle release 8.1.7.0.0 or 9.0.1.0.0, the Oracle database does not support encoding columns as Unicode. These values would not be returned from the ODBC Drivers for Oracle release 8.1.7.0.0 or for Oracle 9.0.1.0.0 databases.
    In Oracle release 9.2.0.0.0, Unicode encoding was supported for SQL column types NCHAR, NVARCHAR2, and NCLOB. In addition, Unicode encoding was also supported for SQL column types CHAR and VARCHAR2 if the character semantics were specified in the column definition.
    Starting with release 9.2.0.2.0, the ODBC Driver supports these SQL column types and maps NCHAR to the SQL data type SQL_WCHAR, NVARCHAR2 is mapped to SQL_WVARCHAR, and NCLOB is mapped to SQL_WLONGVARCHAR. The SQL CHAR column is mapped to SQL_WCHAR and the VARCHAR2 column is mapped to SQL_WVARCHAR if the character semantics are specified for the column. While the Force SQL_WCHAR Support option is still available in the 9.2.0.2.0 ODBC Driver, it is no longer required for Unicode support."
    Justin

  • Need help with If statement Please

    Hi guys,
    This is my first time posting and sorry if for some reason i post incorrectly.
    I am having trouble figuring out what I am doing with my if Statement and why the compiler is giving me an error which says 'cannot find symbol';
    Just incase you need to see the code here it is. And please any pointers would help me get back on track. And please dont laugh at the novice code i just started^^;
    import java.util.*;
    import java.text.*;
    public class Student
         public static void main(String[]args)
         Scanner scan=new Scanner(System.in);
         double std1, std2, std3, num1, num2, num3, num4;
         String a, answer1, name1;
    System.out.println("Welcome to _____ program, press any button to continue: ")
    a=scan.nextLine();
    System.out.println("Good, would you like to enter a grade for a student(y/n)?");
    answer1=scan.nextLine();
    if (answer1 == y)
         System.out.println("Please enter the students name ");
                             name1=scan.nextLine();
                             System.out.println("Please label the test number ");
                             num1=scan.nextDouble();
                             System.out.println("Please enter the grade, "+name1+" recieved");
    std1=scan.nextDouble();
    if (answer1==n)
         System.out.println("Thank you for trying my program ");
    else
    System.out.println("It's obvious you couldn't follow a simple direction good bye ");

    Thanks Flounder,
    I'll keep in mind to edit the code the way you told me too.
    As far as the code goes, what do you mean 'y' is not a string and should be a variable. All I'm trying to do is give a true false statement.
    For example
    if (input==y)
    System.out.println("________");
    And in my code it gives an error stating that y is a variable.
    I dont understand why.
    Thanks much for all your replies.

  • Need help selecting router

    Hello All,
    I need some help in selecting the best router for our wireless setup.  I have never setup a wireless network, so please forgive if I am a little lost.  I have an older laptop, HP Pavilion ze4400 (windows xp) and a brand new gateway (windows 7).  The gateway has a built in wireless adapter.  The HP came with an 802.11b cardbus thingy.  I have been told that an N router is the best, but I am concerned that it will not work with the older HP.  Will an N router be backwards compatible with the b?  If not, can I just buy a new adapter for the HP?  If so, what router and adapter should I select?

    Just about every 802.11n router sold will be able to operate in a "Mixed" mode, allowing you to use your B, G or N devices simultaneously.  An 802.11n router will allow you to take advantage of the improved wireless capabilities with any device that supports N.  So, no need to worry about backwards compatibility.
    The only thing that may be a concern (depending on how old the 802.11b adapter is) is wireless security.  Chances are it supports WPA security, but if not you can fall back to WEP or the better option, buy a newer adapter. 

Maybe you are looking for

  • HD2600XT w/X1900XT for 3rd monitor - systems freezes

    I wanted to add a 3rd monitor to my early MacPro that came with the Radeon X1900 XT. I asked and received advice in an earlier post concerning a graphics card that would be compatible with my configuration. The Radeon HD2600XT was an affordable sugge

  • Renaming files in FCP for Pro Tools

    Hoo boy! We just learned from our sound designers that Pro Tools is having some issues with illegal characters in filenames inside our OMFs. Evidently ^ ! / ( ) - ; are all no good. Mostly this presents no problem (does anyone ever use a carat?), but

  • Is auto-hyphenation included in Lightroom 5 Book module ?

    The Book module is almost very good indeed but seems to lack some basic text functions that anyone could benefit from: flowing paragraphs, as in InDesign, such that hyphenation makes for better text blocks, for instance. Or guides such that you can p

  • View to check directory created in database

    Hi, Can anyone give me the view that i can check the database created directory? Regards

  • Windows frozen when updating

    I have a Satellite A305-ST551E, Windows Vista Home Premium. The last time Windows went through its automatic updates it came to the screen that says "Configuring updates: Step 3 of 3 - 100% complete" and stopped there; I let it sit for about an hour,