Fetching into a double from pro*c program

Hi,
I want to fetch data from number column (value is 100400000664137.68) into double host variable in a pro*c program. When i fetch and print, the value is getting rounded as 100400000664138.000000. I dont want this rounding off to happen as i have some calculations based on this value. Pls suggest me how can i avoid this rounding off problem?
I tested this on oracle 9.2.0.4.0 (proc release 9.2.0.4.0) and oracle 8.0.5.0.0
versions (pro*c version 8.0.5.0.0).
Thanks in advance.
Giridhar

It might help to confirm that the NUMBER column is defined as type FLOAT (SQLT_FLT) in OCIDefineByPos. As listed in the Table 3-2 (External Datatypes and Codes) in Chapter 3 of the OCI Programmer's Guide, this is the proper Oracle Datatype for the double program variable.
If this already the case in your program, please paste the code that you are using to fetch/define the data. This can help us get a better idea of the problem you are having.
Hope that helps.

Similar Messages

  • How to fetch into any type of record

    Hi,
    I have a problem. I have to create a procedure to which any query is given it is able to execute and then fetch into the record create based on the cursor. here is the code
    procedure execute_query(p_sql varchar2) is
    type t_rc is ref cursor;
    l_rc t_rc;
    v_t_record l_rc%rowtype;
    begin
    --dbms_lock.sleep(10);
    open l_rc for p_sql;
    loop
    fetch l_rc
    into v_t_record;
    dbms_output.put_line(v_t_record.object_name);
    exit when l_rc%notfound;
    end loop;
    v_query_row_count := l_rc%rowcount;
    -- dbms_output.put_line(v_query_row_count);
    end execute_query;
    constraints:
    i can specify return clause in ref cursor.
    I have to fetch into the records from different queries
    thanks
    Regards
    nick
    Edited by: Nick Naughty on Dec 21, 2008 5:16 AM

    Yes, as I already mentioned, you could use DBMS.SQL:
    create or replace
      procedure p1(
                   p_query varchar2
      is
          c           number;
          d           number;
          col_cnt     integer;
          f           boolean;
          rec_tab     dbms_sql.desc_tab;
          v_number    number;
          v_string    varchar2(4000);
          v_date      date;
          v_rownum    number;
      begin
          c := dbms_sql.open_cursor;
          dbms_sql.parse(c,p_query, dbms_sql.native);
          dbms_sql.describe_columns(c,col_cnt,rec_tab);
          for col_num in 1..rec_tab.count loop
            if rec_tab(col_num).col_type = 1
              then
                dbms_sql.define_column(c,col_num,v_string,rec_tab(col_num).col_max_len);
            elsif rec_tab(col_num).col_type = 2
              then
                dbms_sql.define_column(c,col_num,v_number);
            elsif rec_tab(col_num).col_type = 12
              then
                dbms_sql.define_column(c,col_num,v_date);
              else raise_application_error(-20900,'unsupported data type');
            end if;
          end loop;
          d := dbms_sql.execute(c);
          v_rownum := 0;
          loop
            exit when dbms_sql.fetch_rows(c) = 0;
            v_rownum := v_rownum + 1;
            dbms_output.put_line('row ' || v_rownum);
            for col_num in 1..rec_tab.count loop
              if rec_tab(col_num).col_type = 1
                then
                  dbms_sql.column_value(c,col_num,v_string);
                  dbms_output.put_line('  ' || rec_tab(col_num).col_name || ' = ' || v_string);
              elsif rec_tab(col_num).col_type = 2
                then
                  dbms_sql.column_value(c,col_num,v_number);
                  dbms_output.put_line('  ' || rec_tab(col_num).col_name || ' = ' || v_number);
              elsif rec_tab(col_num).col_type = 12
                then
                  dbms_sql.column_value(c,col_num,v_date);
                  dbms_output.put_line('  ' || rec_tab(col_num).col_name || ' = ' || v_date);
                else
                  raise_application_error(-20900,'unsupported data type');
              end if;
            end loop;
          end loop;
          dbms_sql.close_cursor(c);
        exception
          when others
            then
              if dbms_sql.is_open(c)
                then
                  dbms_sql.close_cursor(c);
              end if;
              raise;
    end;
    set serveroutput on format wrapped
    exec p1('select ename,sal,hiredate from emp');
    SQL> create or replace
      2    procedure p1(
      3                 p_query varchar2
      4                )
      5    is
      6        c           number;
      7        d           number;
      8        col_cnt     integer;
      9        f           boolean;
    10        rec_tab     dbms_sql.desc_tab;
    11        v_number    number;
    12        v_string    varchar2(4000);
    13        v_date      date;
    14        v_rownum    number;
    15    begin
    16        c := dbms_sql.open_cursor;
    17        dbms_sql.parse(c,p_query, dbms_sql.native);
    18        dbms_sql.describe_columns(c,col_cnt,rec_tab);
    19        for col_num in 1..rec_tab.count loop
    20          if rec_tab(col_num).col_type = 1
    21            then
    22              dbms_sql.define_column(c,col_num,v_string,rec_tab(col_num).col_max_len);
    23          elsif rec_tab(col_num).col_type = 2
    24            then
    25              dbms_sql.define_column(c,col_num,v_number);
    26          elsif rec_tab(col_num).col_type = 12
    27            then
    28              dbms_sql.define_column(c,col_num,v_date);
    29            else raise_application_error(-20900,'unsupported data type');
    30          end if;
    31        end loop;
    32        d := dbms_sql.execute(c);
    33        v_rownum := 0;
    34        loop
    35          exit when dbms_sql.fetch_rows(c) = 0;
    36          v_rownum := v_rownum + 1;
    37          dbms_output.put_line('row ' || v_rownum);
    38          for col_num in 1..rec_tab.count loop
    39            if rec_tab(col_num).col_type = 1
    40              then
    41                dbms_sql.column_value(c,col_num,v_string);
    42                dbms_output.put_line('  ' || rec_tab(col_num).col_name || ' = ' || v_string);
    43            elsif rec_tab(col_num).col_type = 2
    44              then
    45                dbms_sql.column_value(c,col_num,v_number);
    46                dbms_output.put_line('  ' || rec_tab(col_num).col_name || ' = ' || v_number);
    47            elsif rec_tab(col_num).col_type = 12
    48              then
    49                dbms_sql.column_value(c,col_num,v_date);
    50                dbms_output.put_line('  ' || rec_tab(col_num).col_name || ' = ' || v_date);
    51              else
    52                raise_application_error(-20900,'unsupported data type');
    53            end if;
    54          end loop;
    55        end loop;
    56        dbms_sql.close_cursor(c);
    57      exception
    58        when others
    59          then
    60            if dbms_sql.is_open(c)
    61              then
    62                dbms_sql.close_cursor(c);
    63            end if;
    64            raise;
    65  end;
    66  /
    Procedure created.
    SQL> set serveroutput on format wrapped
    SQL> exec p1('select ename,sal,hiredate from emp');
    row 1
      ENAME = SMITH
      SAL = 800
      HIREDATE = 17-DEC-80
    row 2
      ENAME = ALLEN
      SAL = 1600
      HIREDATE = 20-FEB-81
    row 3
      ENAME = WARD
      SAL = 1250
      HIREDATE = 22-FEB-81
    row 4
      ENAME = JONES
      SAL = 2975
      HIREDATE = 02-APR-81
    row 5
      ENAME = MARTIN
      SAL = 1250
      HIREDATE = 28-SEP-81
    row 6
      ENAME = BLAKE
      SAL = 2850
      HIREDATE = 01-MAY-81
    row 7
      ENAME = CLARK
      SAL = 2450
      HIREDATE = 09-JUN-81
    row 8
      ENAME = SCOTT
      SAL = 3000
      HIREDATE = 19-APR-87
    row 9
      ENAME = KING
      SAL = 5000
      HIREDATE = 17-NOV-81
    row 10
      ENAME = TURNER
      SAL = 1500
      HIREDATE = 08-SEP-81
    row 11
      ENAME = ADAMS
      SAL = 1100
      HIREDATE = 23-MAY-87
    row 12
      ENAME = JAMES
      SAL = 950
      HIREDATE = 03-DEC-81
    row 13
      ENAME = FORD
      SAL = 3000
      HIREDATE = 03-DEC-81
    row 14
      ENAME = MILLER
      SAL = 1300
      HIREDATE = 23-JAN-82
    PL/SQL procedure successfully completed.
    SQL> SY.

  • Fetching of multiple files from Application Server into SAP Program

    Hi All,
    I have a issue related <b>Fetching of multiple files from Application Server into SAP Program</b>.
    Actual issue is as below.
    In the <b>selection screen</b> of <b>my program</b> i will give <b>Application Server Path</b> as :
    <b>/PW/DATA/SAP/D1S/PP/DOWN/eppi0720*</b>
    Then the based on above input it should pick up all the files that are matching <b>eppi0720*</b> criteria.
    Suppose if i am having <b>5</b> files with above scenario, i have to fetch all those <b>5</b> files at a time and place in my SAP Program.
    All those 5 file's data should come into SAP at a time.
    Can anybody tell me how can we solve above issue.
    If any body has come across same issue please provide me with solution.
    Thanks in advance.
    Thanks & Regards,
    Rayeez.

    If you want to get around the authorization check, you can do something like this.
    report zrich_0001 .
    parameters: p_path type epsf-epsdirnam
                      default '/usr/sap/TST/SYS/global'.
    parameters: p_file type epsf-epsfilnam default 'CO*'.
    start-of-selection.
    perform get_file_list.
    *       FORM get_file_list                                            *
    form get_file_list.
      types: name_of_dir(1024)        type c,
             name_of_file(260)        type c,
             name_of_path(1285)       type c.
      data: begin of file_list occurs 100,
              dirname     type name_of_dir,  " name of directory. (possibly
                                             " truncated.)
              name        type name_of_file, " name of entry. (possibly
                                             " truncated.)
              type(10)    type c,            " type of entry.
              len(8)      type p,            " length in bytes.
              owner(8)    type c,            " owner of the entry.
            mtime(6)    type p, " last modification date, seconds since 1970
              mode(9)     type c, " like "rwx-r-x--x": protection mode.
              useable(1)  type c,
              subrc(4)    type c,
              errno(3)    type c,
              errmsg(40)  type c,
              mod_date    type d,
              mod_time(8) type c,            " hh:mm:ss
              seen(1)     type c,
              changed(1)  type c,
            end of file_list.
      data: begin of file,
              dirname     type name_of_dir,  " name of directory. (possibly
                                             " truncated.)
              name        type name_of_file, " name of entry. (possibly
                                             " truncated.)
              type(10)    type c,            " type of entry.
              len(8)      type p,            " length in bytes.
              owner(8)    type c,            " owner of the entry.
            mtime(6)    type p, " last modification date, seconds since 1970
              mode(9)     type c, " like "rwx-r-x--x": protection mode.
              useable(1)  type c,
              subrc(4)    type c,
              errno(3)    type c,
              errmsg(40)  type c,
              mod_date    type d,
              mod_time(8) type c,            " hh:mm:ss
              seen(1)     type c,
              changed(1)  type c,
            end of file.
      call 'C_DIR_READ_FINISH'             " just to be sure
           id 'ERRNO'  field file_list-errno
           id 'ERRMSG' field file_list-errmsg.
      call 'C_DIR_READ_START' id 'DIR'    field p_path
                              id 'FILE'   field p_file
                              id 'ERRNO'  field file-errno
                              id 'ERRMSG' field file-errmsg.
      if sy-subrc <> 0.
        sy-subrc = 4.
        exit.
      endif.
    * Read the file list and add to internal table.
      do.
        clear file.
        call 'C_DIR_READ_NEXT'
          id 'TYPE'   field file-type
          id 'NAME'   field file-name
          id 'LEN'    field file-len
          id 'OWNER'  field file-owner
          id 'MTIME'  field file-mtime
          id 'MODE'   field file-mode
          id 'ERRNO'  field file-errno
          id 'ERRMSG' field file-errmsg.
        if sy-subrc =  1.
          exit.
        endif.
        append file to file_list.
      enddo.
    * Write out the file list
      loop at file_list.
        write:/ file_list-name.
      endloop.
    endform.
    Regards,
    Rich Heilman

  • Can not query from v$instance and v$session from within Pro*C program

    Hi there,
    We have Oracle 10.2.0.1 enterprise edition running on Linux (Red Hat 4 ES)
    Our Pro*C developer tries to query the version from v$instance view and is getting errors when compiling his Pro*C programs.
    The related Oracle user account has the SELECT ANY DICTIONARY privilege, so if he tries from the sqlplus, he has no problem querying the v$instance or v$session views. His problem is when he is trying to compile his Pro*C program against the very same Oracle account.
    Any help/input is greatly appreciated.
    R/ Zafer
    Here are the errors he is getting:
    Pro*C/C++: Release 10.2.0.1.0 - Production on Thu Jun 24 12:54:04 2010
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    System default option values taken from:
    /home/oracle/product/10.2.0/Linux6
    4/precomp/admin/pcscfg.cfg
    Error at line 150, column 4 in file ../database.pc
    EXEC SQL SELECT version INTO :inputLine FROM V$INSTANCE;
    ...1
    PLS-S-00201, identifier 'V$INSTANCE' must be declared
    Error at line 150, column 4 in file ../database.pc
    EXEC SQL SELECT version INTO :inputLine FROM V$INSTANCE;
    ...1
    PLS-S-00000, SQL Statement ignored
    Semantic error at line 150, column 4, file ../database.pc:
    EXEC SQL SELECT version INTO :inputLine FROM V$INSTANCE;
    ...1
    PCC-S-02346, PL/SQL found semantic errors

    I issued FULL DB EXPORT / IMPORT privilege to the related Oracle user account and it works now.

  • Possibility to execute Acrobat Pro's "Combine files into PDF" function from within SAP?

    Good day.
    Presently, a company uses Acrobat Pro to manually combine files such as *.pdf, *.jpg, *.doc, which have been downloaded from SAP's Document Management System, into one pdf file. I would like to know if it is possible to automatically execute Acrobat Pro's "Combine files into PDF" function from within SAP (ECC 6.0) application system. I'm wondering if this could be achieved from a program via OLE (Object Linking and Embedding) or RFC (remote function call).
    Thanks in advance for your thoughts and inputs.

    Yes, you can combine PDF files via IAC/COM methods.

  • Extracting into Flat Files Using OCI or Pro*C Programs

    Data Extraction into Flat Files from a database Using OCI or Pro*C Programs - please provide me a sample code. It is urgent. Thank you in advance.

    This problem is very simple to solve. Simply use Pro*C, issue an SQL select into a host variable, then use unix "printf" to output the result. An alternative is to use the provided sqlplus utility to grab the data in a script, disabling headers, etc.
    Sadly, this area is a huge, basic hole in the Oracle product offering. While they have an import utility, there is no export utility, except for one that makes binary files not usable outside Oracle. Every other RDBMS I've seen has this. In Informix, you can say something like "export to <filename> select * from <table>", but that syntax is not offered by Oracle Corporation.

  • I want to take files from my PC (using a Seagate external hard drive) then plug this Seagate External hard drive into my Mac Book Pro and move the files from the Seagate External Hard drive onto my Time Capsule. I do not want to put these files on my Mac

    I want to take files from my PC (using a Seagate external hard drive) then plug this Seagate External hard drive into my Mac Book Pro and move the files from the Seagate External Hard drive onto my Time Capsule. I do not want to put these files on my Mac. How do I do this? Where do I put these files on my Time Capsule? Will it affect the functioning of my Time Capsule?

    Mixing files with data is not always great idea.
    See info here.
    Q3 http://pondini.org/TM/Time_Capsule.html
    Why not just connect the PC directly to the TC by ethernet and copy the files over?
    It is hugely faster and much less mucking around.
    In windows load the airport utility for windows.. if you have not already as this will help you access the drive.
    There is more info here.
    http://support.apple.com/kb/HT1331

  • Insert into SAP table from external program

    Hi Gurus,
    I need to perform an insert of several records into a couple of SAP tables from an external program.
    Do you know of an RFC (if it is remote enabled the better) that allows me to specify the table and records to perfom an insert?
    Many thanks
    Mauricio Pego

    I don't know ABAP and wanted to avoid writing my own function if one standard exists.
    My requirement stands like this, I have a few z tables that need to populate from my C# application by use of the .Net connector.
    I haven't found a BAPI or RFC that allows me to add records to any table, but I don't know all the RFCs.
    May be one of you passed throu this already.
    Mauricio

  • How do I install CS5 from CDs into my new MacBook Pro?

    How do I install CS5 from CDs into my new MacBook Pro?

    Buy a cheap external DVD drive, connect via USB and then install
    Download CS5 Trial version from http://prodesigntools.com/all-adobe-cs5-direct-download-links.html then activate with your CS5 serial number to convert to a permanent version

  • Piping into pager (less) from C program

    I am trying to write output to "less" from a C program to allow paging.  I have tried using popen (3), similar as in the following simple test program:
    #include <stdio.h>
    int main(int argc, char **argv)
    FILE *out;
    int i;
    out= popen("/usr/bin/less", "w");
    for( i= 0; i< 512; ++i )
    fprintf(out, "This is line %d\n", i);
    pclose(out);
    This mostly works, but behaves differently from other programs that do the same thing.  In particular, you cannot use Ctrl-C to stop skipping to the end of the output without killing both less and the original program.  (Apparently less normally catches the signal, but is prevented from doing so when I start it as above.)
    Both when typing "| less" in the shell and when using "man", this works.  I have looked at the output of pstree and noticed the following differences:  When piping into less from the shell, the less process is a child of the shell, so this is clearly different from what I can get with popen().  But when man is running, the less process is also a child of man, but it still behaves correctly.
    Has anyone done this kind of thing before or has any ideas?

    You want to play with pipe/fork:
    #include <stdlib.h>
    #include <stdio.h>
    #include <unistd.h>
    void work(void) {
    int i;
    for (i=0; i<512; i++) {
    printf("Line %d\n", i);
    int main(void) {
    int pfds[2];
    pid_t pid;
    if (pipe(pfds) < 0) {
    perror("pipe failed");
    return EXIT_FAILURE;
    pid = fork();
    if (pid < 0) {
    perror("fork failed");
    return EXIT_FAILURE;
    } else if (pid == 0) { /* child */
    close(pfds[0]); /* close unused read end */
    /* set write end of pipe as stdout for this child process */
    dup2(pfds[1], STDOUT_FILENO);
    close(pfds[1]);
    work();
    } else /* if (pid > 0) */ { /* parent */
    char *args[] = { "less", NULL };
    close(pfds[1]); /* close unused write end */
    /* set read end of pipe as stdin for this process */
    dup2(pfds[0], STDIN_FILENO);
    close(pfds[0]); /* already redirected to stdin */
    execvp(args[0], args);
    perror("exec failed");
    exit(EXIT_FAILURE);
    return EXIT_SUCCESS;
    Hint for the future, you can use strace to observe how programs work. For pipes:
    strace -o log.txt -f sh -c 'echo 1337 | less'
    (`-o log.txt` writes to that file, `-f` takes forks into account)

  • My computer keyboard has a bad "M" key so I cannot login into my computer from boot     is there a way to bypass the login to reset my macbook pro

    my computer keyboard has a bad "M" key so I cannot login into my computer from boot     is there a way to bypass the login to reset my macbook pro

    Late reply, but if anyone is experiencing the same problem, I've found a solution. For whatever reason, some macbooks don't recognize usb flash drives during the boot-up phase, even though the usb ports themselves are powered (I tested this with a multimeter). The solution then, was to use an external USB hard drive that has its own power supply to install Snow Leopard. I don't know why, but it's the only way I got my macbook (Macbook 2,1/A1181) to recognize the install drive. Every was smooth sailing from there!

  • Can I transfer the hard drive from my Macbook into a new Macbook Pro?

    I have been planning on purchasing a Macbook Pro for quite sometime now, however I find that the storage space on the base models is quite small. I currently have a 500gb hard drive on my Macbook, and I was wondering if there's any way I could transfer this hard drive into a new Macbook Pro.

    If you are considering to purchase Mac Book Pro is not Retina, you can get 1TB HDD as option with +$50.

  • Trouble merging exposures from Lightroom 5 into Photoshop CC HDR Pro

    I'm a new member to Photoshop CC and I'm trying to merge 3 exposures into Photoshop CC HDR Pro. When the exposures move over to the initial adjustments window, there is a large white line running vertically through the image. I'm missing about 40% of the image. This makes it difficult to accurately adjust the HDR. However, when I accept my adjustments and go to the main Photoshop workspace, the entire image is once again available to make subsequent adjustments or add layers.
    I work on a 15" MacBook Pro w/ Retina and I'm running OSX Mavericks (if any of that matters).
    I look forward to your response and resolution to my problem.
    Thank you.

    I am also having this issue with the "Merge to HDR Pro" function in both LR5.2 and PSCC. When the image is viewed at 50% image size in the HDR app everything appears fine. However, once you start to zoom in the image begins to crop out segements starting on the right hand side. See the screen shots below:
    Image at 50%
    Image at 66%
    Image at 100%
    MacBook Pro 2.7 GHz Intel Core i7 16GB RAM 512GB SSD (early 2013) NVidia GT650M Mac OS X 10.9

  • Pro*C program to use a REF CURSOR returned by a DB Function

    Hi,
    Please help me with this.
    I have a pro*c program that should call a
    database function which returns a ref cursor.
    This is the sample code i have :-
    EXEC SQL BEGIN DECLARE SECTION;
    SQL_CURSOR emptycabin_cursor;
    int cabinid;
    EXEC SQL END DECLARE SECTION;
    EXEC SQL ALLOCATE :emptycabin_cursor;
    EXEC SQL EXECUTE BEGIN
    :emptycabin_cursor:=posremptycabin(:voy,:segid);
    END;END-EXEC;
    /* more_records = 1*/
    while (more_records)
    EXEC SQL FETCH :emptycabin_cursor INTO :cabinid;
    if (SQLCODE==NOTFOUND)
    {more_records=FALSE;break;}
    EXEC SQL close :emptycabin_cursor;
    When I execute I keep getting fetch out of sequence error.
    Can someone let me know whats wrong with this code?
    When I execute the function from sqlplus
    variable ref_cur refcursor ;
    exec :ref_cur:=posremptycabin(232,'CC');
    print :ref_cur;
    I get the data properly displayed.So nothing wrong with the function.
    Thanks for your help

    I know nothing about Pro*C, but Tom Kyte's Pro*C example for ref cursors fetches the cursor with a loop that looks like:
    for( ;; )
            EXEC SQL WHENEVER NOTFOUND DO break;
            EXEC SQL FETCH :my_cursor INTO :ename, empno;
            printf( "'%.*s', %d\n", ename.len, ename.arr, empno );
        EXEC SQL CLOSE :my_cursor;http://asktom.oracle.com/~tkyte/ResultSets/index.html
    Hope this helps.

  • Problem while fetching more records in SAP ABAP report program

    Hello Frinds,
    I have SAP ABAP report program which fetches data from usr02 table
    Now, program is working fine with less number of records, bot in production there are more than 200000 records and either report gets timed out or there is run time error like buffer area not available.
    Below is the fetch statement
    SELECT bname FROM usr02 INTO TABLE lt_user
    So, do I need to take records in small chunks, I do not think it is needed as I have worked on number of othere databases where there are number of records in single fetch statement and database itself take care of this.
    Please provide me some approach to resolve this problem.

    This will be very difficult for you.....
    Since you are getting a time out error....it looks like, you are runnning this report in foreground....................
    Try running it in background it will work...
    ELSE....you have to fetch in small chunks....but the question is how will you do it. Since the USR02 only has BNAME as primary key...
    Either put the BNAME as part of selection screen and fetch the data.....it will solve your problem....
    Only fetch for those BNAME which is entered in the selection screen...
    Hope it helps!

Maybe you are looking for