Converting varchar list to number

hi everybody,
can anyone help me to convert the varchar to number
ex
the input arg is varchar in this query below
select * from student where rollno in ('1,2,3,4');
in this example the roll no is of type number.when i use to_number function it shows error.
how can i conver to number list?
so that the query can change like this
select * from student where rollno in (1,2,3,4);
thanks
Message was edited by:
user542111

It worked for me.
SQL> select to_number('542111') from dual;
TO_NUMBER('542111')
542111
SQL>
Try to run this (Assumeing rollno is varchar2)
SQL> select to_number(rollno) from student where rollno in ('1','2','3','4');

Similar Messages

  • Hi my question abt 2 convert a list into pdf format

    hi
    experts
    i had problem to convert displayed list into pdf format showing an error cannot open the file file format not supported, but i am have downloaded the file in .pdf format
    please help me
    thank you all

    Hi,
    check out this program. this might help:
    report zabap_pdf.
    tables:
      tsp01.
    data:
      mstr_print_parms like pri_params,
      mc_valid(1)      type c,
      mi_bytecount     type i,
      mi_length        type i,
      mi_rqident       like tsp01-rqident.
    *-- INTERNAL TABLES
    data:
      mtab_pdf    like tline occurs 0 with header line,
      mc_filename like rlgrap-filename.
    *-- SELECTION SCREEN
    parameters:
      p_repid like sy-repid, " Report to execute
      p_linsz like sy-linsz default 132, " Line size
      p_paart like sy-paart default 'X_65_132'.  " Paper Format
    start-of-selection.
    concatenate 'c:\'
                p_repid
                '.pdf'
      into mc_filename.
    *-- Setup the Print Parmaters
      call function 'GET_PRINT_PARAMETERS'
       exporting
         authority= space
         copies   = '1'
         cover_page                   = space
         data_set = space
         department                   = space
         destination                  = space
         expiration                   = '1'
         immediately                  = space
         in_archive_parameters        = space
         in_parameters                = space
         layout   = space
         mode     = space
         new_list_id                  = 'X'
         no_dialog= 'X'
         user     = sy-uname
       importing
         out_parameters               = mstr_print_parms
         valid    = mc_valid
       exceptions
         archive_info_not_found       = 1
         invalid_print_params         = 2
         invalid_archive_params       = 3
         others   = 4.
    *-- Make sure that a printer destination has been set up
    *-- If this is not done the PDF function module ABENDS
      if mstr_print_parms-pdest = space.
        mstr_print_parms-pdest = 'LOCL'.
      endif.
    *-- Explicitly set line width, and output format so that
    *-- the PDF conversion comes out OK
      mstr_print_parms-linsz = p_linsz.
      mstr_print_parms-paart = p_paart.
      submit (p_repid) to sap-spool without spool dynpro
                       spool parameters mstr_print_parms
                       via selection-screen
                       and return.
    *-- Find out what the spool number is that was just created
      perform get_spool_number using sy-repid
                 sy-uname
        changing mi_rqident.
    *-- Convert Spool to PDF
      call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
        exporting
          src_spoolid= mi_rqident
          no_dialog  = space
          dst_device = mstr_print_parms-pdest
        importing
          pdf_bytecount                  = mi_bytecount
        tables
          pdf        = mtab_pdf
        exceptions
          err_no_abap_spooljob           = 1
          err_no_spooljob                = 2
          err_no_permission              = 3
          err_conv_not_possible          = 4
          err_bad_destdevice             = 5
          user_cancelled                 = 6
          err_spoolerror                 = 7
          err_temseerror                 = 8
          err_btcjob_open_failed         = 9
          err_btcjob_submit_failed       = 10
          err_btcjob_close_failed        = 11
          others     = 12.
    call function 'DOWNLOAD'
         exporting
              bin_filesize            = mi_bytecount
              filename                = mc_filename
              filetype                = 'BIN'
         importing
              act_filename            = mc_filename
         tables
              data_tab                = mtab_pdf.
          FORM get_spool_number *
          Get the most recent spool created by user/report              *
    -->  F_REPID               *
    -->  F_UNAME               *
    -->  F_RQIDENT             *
    form get_spool_number using f_repid
         f_uname
                    changing f_rqident.
      data:
        lc_rq2name like tsp01-rq2name.
      concatenate f_repid+0(8)
                  f_uname+0(3)
        into lc_rq2name separated by '_'.
      select * from tsp01 where  rq2name = lc_rq2name
      order by rqcretime descending.
        f_rqident = tsp01-rqident.
        exit.
      endselect.
      if sy-subrc ne 0.
        clear f_rqident.
      endif.
    endform." get_spool_number

  • Convert ABAP list output to PDF without spool

    Hi All,
    We have used the FM 'CONVERT_ABAPSPOOLJOB_2_PDF' to convert the list output to PDF. It creates the spool number in SP01 and PDF is getting generated.
    But, in our SAP ECC 6.0 server all spools are redirected to printer by default and get printed because it configured like that. We requested BASIS people to reconfigure but they said no for a single report.
    So we need to find the alternate solution to generate the PDF without spool. We have searched in sdn, but didnot get any alternate solution.
    Please help us in this regard.
    Thanks in advance.

    data: begin of i_list occurs 0,
    line(255),
    end of i_list.
    data:i_mara like mara occurs 0 with header line.
    parameters: p_matnr like mara-matnr.
    start-of-selection.
    set pf-status 'PDFFILE'.
    select *
         from mara
         into table i_mara
        where matnr = p_matnr.
    loop at i_mara.
      write:i_mara-matnr,i_mara-ernam,i_mara-pstat.
      endloop.
    at user-command.
    if sy-ucomm = 'PDF'.
    DO.
    READ LINE SY-INDEX.
    IF SY-SUBRC NE 0.
    EXIT.
    ELSE.
    I_LIST = SY-LISEL.
    APPEND I_LIST.
    ENDIF.
    ENDDO.
    NEW-PAGE PRINT ON DESTINATION 'LP03' IMMEDIATELY ' ' COVER TEXT ' ' KEEP IN SPOOL 'X' NEW LIST IDENTIFICATION 'X' LINE-SIZE 132 LINE-COUNT 65 NO DIALOG.
    LOOP AT I_LIST.
    IF I_LIST-LINE IS INITIAL.
    SKIP.
    ELSE.
    at first.
      write: TEXT-001.
      endat.
    WRITE: I_LIST-LINE+0(132).
    ENDIF.
    ENDLOOP.
    NEW-PAGE PRINT OFF.
    data:filename like RLGRAP-filename value 'C:\PDFFILE.PDF'.
    DATA: SPOOL TYPE TSP01-RQIDENT.
    SPOOL = SY-SPONO.
    SUBMIT rstxpdft4
    WITH spoolno = spool
    WITH download = 'X'
    WITH p_file = filename
    AND RETURN.
    if sy-subrc = 0.
    write: 'pdf file generated'.
    else.
      write:'pdf file not generated'.
      EXIT.
      endif.
          endif.
    please paste this code and check once ,if it works modify the code according to ur requirement.
    regards,
    padmaja

  • How to convert varchar to int in MSSQL?

    Hi,
    I am using mssql. how can i convert varchar to int type.
    for eg.
    id (int) txt(varchar)
    1 ---------10
    2 ---------10a
    3 ---------10b
    i want to convert varchar to int. HOw? pls explain with query.
    Thanks
    edward

    "10a" wouldn't normally be considered a number. So what sort of number do you expect it to be?
    Other than that you can look at the substring and convert/cast functions.

  • Convert varchar to decimal - arithmetic overflow

    I'm using SQL Server 2014 and I'm trying to convert data from a staging table over to a production table. I seem to be getting an Arithmetic overflow error converting varchar to numeric on the decimal conversion. I'm sure I've overlooked something with the
    syntax of the CONVERT.
    This is the staging table:
    CREATE TABLE [dbo].[staging_table](
    [TimeIndex] [varchar](100) NULL,
    [Cluster] [varchar](100) NULL,
    [AvgMem] [varchar](100) NULL,
    [AvgCPU] [varchar](100) NULL,
    [TotalMemory] [varchar](100) NULL,
    [TotalCPU] [varchar](100) NULL,
    [Datacenter] [varchar](100) NULL,
    [vCenter] [varchar](100) NULL
    ) ON [PRIMARY]
    This is the prod table I'm moving it to:
    CREATE TABLE [dbo].[Clusters](
    [ClusterID] [int] IDENTITY(1,1) NOT NULL,
    [ClusterName] [varchar](25) NULL,
    [DatacenterName] [varchar](25) NULL,
    [TimeIndex] [datetime] NULL,
    [AvgCPU] [decimal](5, 2) NULL,
    [AvgMem] [decimal](5, 2) NULL,
    [TotalCPU] [decimal](8, 2) NULL,
    [TotalMem] [decimal](8, 2) NULL,
    [vCenterID] [int] NULL,
    CONSTRAINT [PK_Clusters_1] PRIMARY KEY CLUSTERED
    [ClusterID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    and here's an example INSERT INTO statement throwing the error:
    INSERT INTO [dbo].[Clusters] (ClusterName,DatacenterName,TimeIndex,AvgCPU,AvgMem,TotalCPU,TotalMem,vCenterID)
    SELECT SUBSTRING(Cluster,1,25) AS ClusterName,
    SUBSTRING(Datacenter,1,25) AS DatacenterName,
    CONVERT(datetime,TimeIndex,103) AS TimeIndex,
    CONVERT(decimal(5,2),AvgCPU) AS AvgCPU,
    CONVERT(decimal(5,2),AvgMem) AS AvgMem,
    CONVERT(decimal(8,2),TotalCPU) AS TotalCPU,
    CONVERT(decimal(8,2),TotalMemory) AS TotalMem,
    '3' FROM [dbo].[staging_table]
    Sample data is 0.00 to 100.00 in fields AvgCPU and AvgMem, and TotalCPU and TotalMem usually goes up to about 7 digits with no decimal (eg. 7543253) but could be 8 and although I've never seen a decimal I wouldn't rule it out so decided to account for it.
    I assume it's something I've overlooked with the syntax but any ideas would help.
    Thanks
    Adam

    The problem is your precision and scale you are assigning to your decimals.
    decimal(5,2) = this is a total of 5 digits, 3 digits for the whole number and 2 for the fractional.
    decimal(8,2) = this is a total of 8 digits, 6 digits for the whole number and 2 for the fractional. 
    So converting a varchar of 7 or 8 digits for TotalCPU or TotalMem will give you an error because your definition will actually only allow for 6 digits of storage. You could test this by doing decimal(8,0) or decimal(10,2) both which will allow for up to
    8 whole numbers.
    If you are worried about space Sql Server will allocate a set number of bytes for ranges based on the precision (first number in the parenthesis). See this page which explains in detail how much space each range takes up and also further details on
    decimal and numerics.
    -Igor

  • Convert abap list to DOC

    how do i convert abap list to DOC .
    Rendi

    hi,
    this program to convert abap list to PDF file.
    *& Report  ZWARUN_TEST4
    REPORT  ZWARUN_TEST4.
    tables:mara,bseg.
    data:begin of itab occurs 2,
         matnr like mara-matnr,
         ernam like mara-ernam,
        end of itab.
    data:begin of it_bseg occurs 2,
         bukrs like bseg-bukrs,
         belnr like bseg-belnr,
         gjahr like bseg-gjahr,
         shkzg like bseg-shkzg,
         dmbtr like bseg-dmbtr,
        blart like bkpf-blart,
         end of it_bseg.
    data: lv_numbytes type i,
          lv_spoolno type tsp01-rqident,
          c_layout like pri_params-paart value 'X_65_132',
          C_X type c value 'X',
          numbers type i,
          cancel.
    data:it_pdf like tline occurs 10 with header line.
    data:p_down like rlgrap-filename.
    *at selection-screen.
    selection-screen:begin of  block blk with frame.
    select-options:s_matnr for mara-matnr,
                   s_bukrs for bseg-bukrs.
    parameter: download as checkbox default 'X',
               p_file like rlgrap-filename default 'c:\warun.pdf'.
              p_down LIKE RLGRAP-FILENAME DEFAULT 'c:\warun2.txt'.
    selection-screen:end of block blk .
    selection-screen pushbutton 12(20) push user-command cl1.
    at selection-screen.
      perform validate.
    top-of-page.
      write:/10 sy-repid inverse color 3.
      write:/2 'Date:' , sy-datum,
             40 'Time:' , sy-uzeit.
      write:/2 sy-uline.
    end-of-page.
      write:/50 'Intelligroup Asia Pvt'.
      write:/20 sy-pagno.
    start-of-selection.
      select matnr
             ernam
             into table itab
             from mara
             where matnr in s_matnr.
      if sy-subrc = 0.
        sort itab by matnr.
      endif.
      perform besg_data.
    set pf-status 'PUSH'.
    at user-command.
    if sy-ucomm = 'DOWNLOAD'.
      if download = space.
        perform get_file.
      endif.
    end-of-selection.
      if download = 'X'.
        perform PDFfile.
      ENDIF.
    *&      Form  validate
    FORM validate .
      data: v_temp(40).
      select single
             matnr
             into v_temp
             from mara
             where matnr in s_matnr.
      if sy-subrc <> 0.
        message e000(zz) with 'no data found'.
      endif.
    ENDFORM.                    " validate
    at line-selection.
      set parameter ID 'MAT' FIELD ITAB-MATNR.
      CALL TRANSACTION 'MM03' .
      WRITE:/ 'Material data displayed' .
      write:/2 itab-matnr.
    *&      Form  PDFfile
    FORM PDFfile .
      data:lk_params type pri_params,
            lv_valid.
    All the parameters passed are constants, so exceptions
    doesn't get raised
      call function 'GET_PRINT_PARAMETERS'
        EXPORTING
          immediately    = ' '
          layout         = c_layout                             "'X_65_132'
          no_dialog      = c_x
        IMPORTING
          out_parameters = lk_params
          valid          = lv_valid.
      if lv_valid <> space .
        new-page print on parameters lk_params no dialog.
    *--To display the final report
        perform print_report.
        new-page print off.
    *---To convert the download to PDF
        perform conv_to_pdf_download.
        perform download.
      endif.
    endif.
    *--To display the final report
      perform print_report.
    ENDFORM.                    " PDFfile
    *&      Form  print_report
    FORM print_report .
      loop at itab.
        write:/2 sy-vline,
               4 itab-matnr  color 4 HOTSPOT,
               40 sy-vline ,
               41 itab-ernam color 5,
               55 sy-vline.
        HIDE: ITAB-MATNR.
      endloop.
    ENDFORM.                    " print_report
    *&      Form  conv_to_pdf_download
    FORM conv_to_pdf_download .
      wait up to 2 seconds.
      lv_spoolno = sy-spono.
      call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
        exporting
          src_spoolid                    =  lv_spoolno
         no_dialog                      = ''
       DST_DEVICE                     =
       PDF_DESTINATION                =
       importing
         pdf_bytecount                  = lv_numbytes
       PDF_SPOOLID                    = pdfspoolid
       LIST_PAGECOUNT                 =
       BTC_JOBNAME                    = jobname
       BTC_JOBCOUNT                   = jobcount
       tables
         pdf                            = it_pdf.
    ENDFORM.                    " conv_to_pdf_download
    *&      Form  download
    FORM download .
      check download = 'X'.
      call function 'DOWNLOAD'
        EXPORTING
          bin_filesize = lv_numbytes
          filename     = p_file
          filetype     = 'BIN'
        IMPORTING
          act_filename = p_file
          filesize     = lv_numbytes
          cancel       = cancel
        TABLES
          data_tab     = it_pdf.
      if cancel = space.
        write: / lv_numbytes, p_file.
      endif.
    ENDFORM.                    " download
    *&      Form  get_file
    FORM get_file .
      Data: s_filename like rlgrap-filename,
            s_filepath like rlgrap-filename,
            tm_filepath like rlgrap-filename.
      CALL FUNCTION 'WS_FILENAME_GET'
       EXPORTING
         DEF_FILENAME           = s_filename
         DEF_PATH               = s_filepath
            MASK                   = ' '
            MODE                   = ' '
            TITLE                  = ' '
       IMPORTING
         FILENAME               =  tm_filepath
      IF SY-SUBRC = 0.
        p_down = tm_filepath.
        perform download2.
      endif.
    ENDFORM.                    " get_file
    *&      Form  download2
    FORM download2 .
      DATA: LV_STRING TYPE STRING.
      LV_STRING = P_DOWN.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          FILENAME                        = LV_STRING
         FILETYPE                        = 'ASC'
      APPEND                          = ' '
         WRITE_FIELD_SEPARATOR           = 'X'
        TABLES
          DATA_TAB                        = itab
       EXCEPTIONS
         FILE_WRITE_ERROR                = 1
         NO_BATCH                        = 2
         GUI_REFUSE_FILETRANSFER         = 3
         INVALID_TYPE                    = 4
         NO_AUTHORITY                    = 5
         UNKNOWN_ERROR                   = 6
         HEADER_NOT_ALLOWED              = 7
         SEPARATOR_NOT_ALLOWED           = 8
         FILESIZE_NOT_ALLOWED            = 9
         HEADER_TOO_LONG                 = 10
         DP_ERROR_CREATE                 = 11
         DP_ERROR_SEND                   = 12
         DP_ERROR_WRITE                  = 13
         UNKNOWN_DP_ERROR                = 14
         ACCESS_DENIED                   = 15
         DP_OUT_OF_MEMORY                = 16
         DISK_FULL                       = 17
         DP_TIMEOUT                      = 18
         FILE_NOT_FOUND                  = 19
         DATAPROVIDER_EXCEPTION          = 20
         CONTROL_FLUSH_ERROR             = 21
         OTHERS                          = 22
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                                                    " download2
    *&      Form  besg_data
    FORM besg_data .
    if itab is initial.
    select bukrs
           belnr
           gjahr
           shkzg
           dmbtr
          into corresponding fields of table it_bseg
           from bseg
          where bukrs in s_bukrs.
    endif.
    ENDFORM.                    " besg_data
    regards
    warun

  • Not able to convert string attribute to number and date please help me out

    not able to convert string attribute to number and date attribute. While using string to date conversion it shows result as failure.As I am reading from a text file. please help me out

    Hi,
    You need to provide an example value that's failing and the date formats in the reference data you're using. It's more than likely you don't have the correct format in your ref data.
    regards,
    Nick

  • Move data from multiple Tables to a Single Table & Convert the list to ALV.

    Hi,
    My aim is to get the list of Materials with their descriptions, with MRP Controller, with Unrestriced Qty. & the Reorder Qty. So, I have to fetch the data from different tables. But finally I am not able to copy or move the fetched data from multiple tables into the single final table.
    Also tell me how to convert this list into ALV.
    Below is the program code.
    *& Report  Y_REORDER_REPORT
    REPORT  Y_REORDER_REPORT.
    tables : marc,makt, mard.
    DATA: Begin of i_final occurs 0,
            matnr type marc-matnr,
            maktx type makt-maktx,
            DISPO type marc-DISPO,
            MINBE type marc-MINBE,
            LABST type mard-LABST,
          end of i_final.
    DATA: Begin of i_marc occurs 0,
           matnr type marc-matnr,
           DISPO type marc-DISPO,
           MINBE type marc-MINBE,
          end of i_marc.
    DATA: Begin of i_makt occurs 0,
           matnr type makt-matnr,
           maktx type makt-maktx,
          end of i_makt.
    DATA: Begin of i_mard occurs 0,
           matnr type mard-matnr,
           LABST type mard-LABST,
           LGORT TYPE MARD-LGORT,
          end of i_mard.
    SELECT  matnr
            dispo
            minbe from marc
            into corresponding fields of table i_marc
            where dispo EQ 'STR'.
    SORT I_MARC by MATNR.
    WRITE: /10  'Material',
            75  'MRP',
            80  'Reorder Qty.'.
    LOOP at i_marc.
    Write: /10  i_marc-matnr,
            75  i_marc-dispo,
            80  i_marc-minbe.
    ENDLOOP.
    write: /.
    SELECT  matnr
            MAKTX from makt
            into corresponding fields of table i_makt
            for all entries in i_marc
            where matnr = i_marc-matnr.
    LOOP at i_makt.
    Write: /10 i_makt-matnr,
            30 i_makt-maktx.
    ENDLOOP.
    SELECT  matnr
            LGORT
            LABST from mard
            into corresponding fields of table i_mard
            for all entries in i_marc
            where matnr = i_marc-matnr.
    LOOP at i_mard.
    Write: /10 i_mard-matnr,
            30 I_MARD-LGORT,
            40 i_mard-labst.
    ENDLOOP.
    move  i_mard-matnr to i_final-matnr.
    move  i_marc-dispo to i_final-dispo.
    move  i_marc-minbe to i_final-minbe.
    move  i_makt-maktx to i_final-maktx.
    move  i_mard-labst to i_final-labst.
    WRITE: /10  'Material',
            30  'Material Desc.',
            75  'MRP',
            80  'Reorder Qty.',
            105 'Current Stock'.
    LOOP at i_final.
    Write: /10  i_final-matnr,
            30  i_final-maktx,
            75  i_final-dispo,
            80  i_final-minbe,
            105 i_final-labst.
    ENDLOOP.
    *LOOP at i_mard.
    *Write: /10  i_mard-matnr,
           30  i_makt-maktx,
           75  i_marc-dispo,
           80  i_marc-minbe,
           105 i_mard-labst.
    *ENDLOOP.
    Regards,
    Vishal

    Change like this,
    SELECT matnr
    lgort
    labst FROM mard
    INTO CORRESPONDING FIELDS OF TABLE i_mard
    FOR ALL ENTRIES IN i_marc
    WHERE matnr = i_marc-matnr.
    LOOP AT i_mard.
       WRITE: /10 i_mard-matnr,
       30 i_mard-lgort,
       40 i_mard-labst.
    ENDLOOP.
    LOOP AT i_marc.
       READ TABLE i_mard WITH KEY matnr =  i_marc-matnr.
       READ TABLE i_makt WITH KEY matnr =  i_marc-matnr.
       MOVE i_mard-matnr TO i_final-matnr.
       MOVE i_marc-dispo TO i_final-dispo.
       MOVE i_marc-minbe TO i_final-minbe.
       MOVE i_makt-maktx TO i_final-maktx.
       MOVE i_mard-labst TO i_final-labst.
       APPEND i_final.
    ENDLOOP.
    WRITE: /10 'Material',
    30 'Material Desc.',
    75 'MRP',
    80 'Reorder Qty.',
    105 'Current Stock'.

  • My music list is listed in number order instead of in alphabetic order like it's suppose to be. What do I do to get it back to being in alphabetic order?

    My music list is listed in number order instead of in alphabetic order like it's suppose to be. What do I do to get it back to be in alphabetic order?

    You should be importing all pics taken with the iphone to your computer regularly as you would with any digital camera.
    iOS: Importing personal photos and videos from iOS devices to your computer

  • How to convert varchar to date datatype while insert or update in table

    Hai All
    I need to convert to varchar to date.
    I have two Tables T1,T2
    T1 Structure
    Code varchar
    Time varchar
    Date varchar
    T2 Structure
    Empname var
    Empcode var
    Intime date
    Outtime date
    Intrin date
    Introut date
    Att_date
    Now i need to move Time form T1 to T2 Intime,outtime,intrin,introut according some condition
    So now i need to convert Varchar to Date while insert or update
    I have tried something
    Insert into T1 (code,intime,att_date)values
    (code,To_date(Date||time,'dd-mon-yyyy hh24mi'),att_date);
    OR While update
    Update T2 set Outtime=To_date(Date||time,'dd-mon-yyyy hh24mi') where...
    I got an error Ora-01861
    Regards
    Srikkanth.M

    You didn't show any example of your date or time values, butyou might need to add a space between them, like
    To_date(Date || ' ' || time,'dd-mon-yyyy hh24mi')

  • Pass a list of number values to a pl/sql function

    I would like to pass a list of number values to a pl/sql function where the list will be used in an IN clause. Ideally I would like to do the following:
    CREATE OR REPLACE FUNCTION ( dept_list in varchar2) is
    begin
    select ... where dept in (dept_list) ;
    usage: process_list ( '7730,7735,7740,7745') ;
    I can not find an example of doing this in pl/sql function but it seems feasible.
    Is there a way to do this?

    user12088323 wrote:
    I would like to pass a list of number values to a pl/sql function where the list will be used in an IN clause.
    usage: process_list ( '7730,7735,7740,7745') ;The first thing is you need an appropriate data type to store a list of numbers. A single character value that looks to you like a list of numbers, is not in fact a list of numbers but a single character value.
    This example uses the built in data type odcinumberlist in a procedure, you can do the same in function
    Re: Passing an array to an Oracle stored procedure
    If you have an old version of the database you may need to create your own type with the same definition of odcinumberlist.

  • Convert from date to number

    Hi,
    I want to convert from date to number. How can I do?
    Thanks
    [email protected]

    That rather depends on what sort of number you want.
    You can probably get what you want by a combination of to_char and to_number.

  • Convert varchar(20) date to date that looks like mm/dd/yyyy

    Good afternoon,
    I am a total novice at SQL and have been tasked to change a varchar(20) date column (shows up as m/dd/yy) to show up as mm/dd/yyyy. I've looked at the previous posts, but being a novice, it's difficult to wade through the non-applicable stuff. The column
    that needs to be changed is field2, but I'm not sure how to construct a statement to reflect my objective.
    Thank you in advance. 

    The sample uses a table variable. You can program it the same way for a table:
    DECLARE @t TABLE (dt VARCHAR(20))
    INSERT INTO @t
    VALUES ('1/2/12')
    ,('3/10/10')
    ,('7/23/9')
    ,('aa')
    ,('12/31/99')
    ,('10/20/00')
    ,('10/20/01')
    SET DATEFORMAT mdy
    SELECT dt
    ,CONVERT(VARCHAR(10), CASE
    WHEN isdate(dt) = 0
    THEN NULL
    ELSE cast(dt AS DATE)
    END, 101) AS newDt
    FROM @t;/******** TRY_CONVERT() method ************/
    SELECT dt, newDt=CONVERT(varchar(10),TRY_CONVERT(date,dt),101) FROM @t;
    GO
    dt newDt
    1/2/12 01/02/2012
    3/10/10 03/10/2010
    7/23/9 07/23/2009
    aa NULL
    12/31/99 12/31/1999
    10/20/00 10/20/2000
    10/20/01 10/20/2001
    dt newDt
    1/2/12 01/02/2012
    3/10/10 03/10/2010
    7/23/9 07/23/2009
    aa NULL
    12/31/99 12/31/1999
    10/20/00 10/20/2000
    10/20/01 10/20/2001
    Starting with SQL Server 2012 you can use TRY_CONVERT().
    You can start studying datetime functions here:
    http://www.sqlusa.com/bestpractices/datetimeconversion/
    Kalman Toth Database & OLAP Architect
    T-SQL Scripts at sqlusa.com
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Convert varchar(255) to varchar(50)

    I want to transfer data from a staging table to another table. The staging table has columns with datatypes I don't always want, and I'm converting them like so:
    INSERT INTO [dbo].[my_table]
    SELECT CONVERT(datetime,TimeIndex,103),
    CONVERT(decimal(6,3),Network_In,3),
    CONVERT(decimal(6,3),Network_Out,3),
    CONVERT(decimal(6,3),Network_Total,3)
    FROM [dbo].[staging_table]
    How would I convert varchar(255) to varchar(50)?
    Thanks in advance
    Adam

    Using substring is returning the column so thanks but now I can't convert datetime for some reason:
    INSERT INTO [dbo].[mytable]
    SELECT SUBSTRING(ClusterName,1,50) AS 'ClusterName',
    CONVERT(datetime,TimeIndex,103),
    ClusterID,
    CONVERT(decimal(3,2),Memory,3),
    CONVERT(decimal(3,2),CPU,3),
    CONVERT(int,CPUTotal),
    CONVERT(int,MemoryTotal)
    FROM [dbo].[stagingtable]
    GO
    Now I get an error I didn't get before:
    Implicit conversion from data type datetime to decimal is not allowed. Use the CONVERT function to run this query.
    But if I run the datetime convert on it's own as a single column select then it works okay. Any ideas where I've gone wrong there?
    To sum up - the above fails but the below works:
    SELECT CONVERT(datetime,TimeIndex,103) AS 'TimeIndex'
    FROM [dbo].[stagingtable]
    Thanks
    Adam

  • Replace and convert varchar to decimal

    Hi all
    What could be the easiest way to replace and convert varchar(50) to decimal
    My string   '21 807,00'  Need to have it in db as  21807.00
    Thanks
    AKE

    On any version you can use somple convert with replace:
    declare @MyStr varchar(10) = '21 807,00'
    SELECT CONVERT(decimal(10,2), REPLACE(REPLACE(@MyStr, ',','.'),' ',''))
    but if there is a different format and the convert will not work, then you will get error. Therefore it is best (as mentioned) to use TRY_CONVERT on newer server or use Try block on old servers
    [Personal Site] [Blog] [Facebook]

Maybe you are looking for

  • How can I make Firefox my browser instead of IE?

    I've been trying to get rid of Internet Explorer as my browser and use Firefox instead but it's just not happening so any assistance on how to make this happen would be gratefully appreciated!

  • XK99 lsmw or BDC program to copy vendors doesn´t update db records

    Hello people I am facing a requirement to copy a list of existing vendors into about 10 new company codes. Vendors all exist in the "main" company code, so I figured it would be a good idea to use the XK99 transaction as a basis for a mass upload via

  • How can i put two domains with IAS

    Hi!! I have IAS in Win NT and i publish www.mycompany.com published with it, but now i want to publish other domain www.myproduct.com in the same machine and i dont know how because in the http.conf servername parameter i only can put one server, if

  • Cross company sales without intercompany billing

    Hello, We are trying to set up cross-company sales without intercompany billing. Here is our scenario: Company code 1000, Sales area 1000 Company code 2000, Sales area 2000 Sales order is entered in sales area 2000, but is delivering from a plant in

  • ADOBE FLASH and Silverlight

    accidentally deleted adobe flash player and silverlight plug in. Netflix and videos on Facebook will no longer load. I reinstalled both but it's like nothing happened neither one work. what's the issue?