How to save datas automaticly making use of SQL Toolkit ?

Hello !
I have amounts of datas to be saved automaticly,so I want to use database.I've  registered ODBC data source in my computer.
As the test datas are saved automaticly,I only write a function to save the datas into database.
//write datas into database
void WriteYBdata(char* FileName)
char *time1;
char *date1;
char date[27];
int hstmt,id,status;
date1 = DateStr ();
time1 = TimeStr ();
Fmt(date,"%s<%d[w4p0]/%d[w2p0]/%d[w2p0]",date1,time1);
hstmt = DBActivateSQL (hdbc, "SELECT * FROM ybdata");
DBBindColInt (hstmt, 1, &id, &status);
DBBindColChar (hstmt, 2, 27, date, &status, "");
DBBindColFloat (hstmt, 3, &CH4, &status);
DBBindColFloat (hstmt, 4, &CO2, &status);
DBBindColFloat (hstmt, 5, &O2, &status);
DBBindColFloat (hstmt, 6, &CO, &status);
DBBindColFloat (hstmt, 7, &H2S, &status);
DBBindColInt (hstmt, 8, &TEM, &status);
DBBindColInt (hstmt, 9, &HUM, &status);
DBCreateRecord(hstmt);
DBPutRecord(hstmt);
DBDeactivateSQL(hstmt);
void WritePSMdata(char* FileName)
char *time2;
char *date2;
char date[27];
int hstmt,id,status;
date2 = DateStr ();
time2 = TimeStr ();
Fmt(date,"%s<%d[w4p0]/%d[w2p0]/%d[w2p0]",date2,time2);
hstmt = DBActivateSQL (hdbc, "SELECT * FROM psmdata");
DBBindColInt (hstmt, 1, &id, &status);
DBBindColChar (hstmt, 2, 27, date, &status, "");
DBBindColInt (hstmt, 3, &wy_voltage,&status);
DBBindColFloat (hstmt, 4, &zy_y1, &status);
DBBindColFloat (hstmt, 5, &zl_i1, &status);
DBBindColInt (hstmt, 6, &wx, &status);
DBBindColInt (hstmt, 7, &wg, &status);
DBBindColInt (hstmt, 8, &ws, &status);
DBCreateRecord(hstmt);
DBPutRecord(hstmt);
DBDeactivateSQL(hstmt);
 I connect the database in the main function.
I've been debug the program and it communicates normally, but it does not save datas into the database.
The attachment is my program.It is my first time to use SQL Toolkit and I'm not familiar with it.  I would appreciate it very much if you could give me some help..
Best regards.
xiepei
I wouldn't care success or failure,for I will only struggle ahead as long as I have been destined to the distance.
Attachments:
Sava All Data.zip ‏37 KB

Hi !
Thank you very much for your reply.
That line I want to set the time format and it could use the funtion  
DBBindColChar (hstmt, 2, 27, date, &status, "");
I do not know it is right or wrong.I could not see any response in this line.
My original idea is recording the date and time when saving the datas.
Would you have any good idea according to it ?
I wouldn't care success or failure,for I will only struggle ahead as long as I have been destined to the distance.

Similar Messages

  • How to insert data in tables using loops sql

    Oracle 10.2g
    using Oracle sql*plus
    Table student is
    create table student(id)
    as
    select distinct student_id
    from students_table;now
    desc student; will retrieve
    student
    ======
    Name         Null?    Type
    ===========================
    ID                  VARCHAR2(10)Now creating a sequence
    create sequence st_seq;
    alter table student add column no;
    select * from student
    no       id
    =========
            234
            298
    This is the main part
    There are 100 student id in the table
    now i want to populate the table with sequences using seq.next_val
    how to use a loop to insert 100 auto generated numbers in the table.
    Thank you.
    Expected result
    Select * from student
    no     id
    =========
    1     234
    2     298
    .........Why i am doing this way instead of
    create table student(no,id)
    as
    select st_se.nextval,student_id
    from students;This will cause duplication of upn
    using distinct would throw an error.
    create table student(st_id,id)
    as select distinct st_seq.nextval,academicyear
    from student
    as select distinct st_seq.nextval,academicyear
    ERROR at line 2:
    ORA-02287: sequence number not allowed hereThank you.

    Follow the example:
    SQL> create table students_table (student_id number);
    Table created.
    SQL> insert into students_table values(10);
    1 row created.
    SQL> insert into students_table values(10);
    1 row created.
    SQL> insert into students_table values(20);
    1 row created.
    SQL> insert into students_table values(30);
    1 row created.
    SQL> insert into students_table values(40);
    1 row created.
    SQL>
    SQL> commit;
    Commit complete.
    SQL> select *
    2 from students_table;
    STUDENT_ID
    10
    10
    20
    30
    40
    SQL> create sequence st_seq;
    Sequence created.
    SQL> create table student(no,id)
    2 as
    3 with distinct_table as
    4 (
    5 select distinct student_id
    6 from students_table
    7 order by student_id
    8 )
    9 select st_seq.nextval, student_id
    10 from distinct_table
    11 ;
    Table created.
    SQL> select *
    2 from student;
    NO ID
    1 10
    2 20
    3 30
    4 40
    SQL>
    Cheers,
    Davide

  • How to get data from Oracle using Native SQL in SAP.. Problem with date

    Hi Masters.
    I'm trying to get data from an Oracle DB. I was able to connect to Oracle using tcode DBCO. The connetion works fine
    I wrote this code and it works fine without the statement of where date > '01-09-2010'
    But i need that statement on the select. I read a lot about this issue, but no answer.
    My code is (this code is in SAP ECC 6.0)
    DATA: BEGIN OF datos OCCURS 0,
          id_numeric(10),
          component_name(40),
          comuna(10),
          record_id(10),
          status,
          sampled_date(10),
          END OF datos.
    DATA: c TYPE cursor.
    EXEC SQL.
      connect to 'LIM' as 'MYDB'
    ENDEXEC.
    EXEC SQL.
      SET CONNECTION 'MYDB'
    ENDEXEC.
    EXEC SQL PERFORMING loop_output.
      SELECT ID_NUMERIC, COMPONENT_NAME, COMUNA, RECORD_ID, STATUS, SAMPLED_DATE
      into :datos from lims.SAMP_TEST_RESULT
      where     date > '01-09-2010'
    ENDEXEC.
    EXEC SQL.
      disconnect 'MYDB'
    ENDEXEC.
    How can i get the data from that date?? If i delete the where statemet, the program works well, it takes 30 mins and show all the data, I just need the data from that date.
    Any help
    Regards

    Please refer the example in this link which deals with Oracle date format.
    You can finnd a command DECODE which is used for date formats. If you have a look at whole theory then you will get an idea.
    Link:[Bulk insert SQL command to transfer data from SAP to Oracle|http://sap.ittoolbox.com/groups/technical-functional/sap-dev/bulk-insert-sql-command-to-transfer-data-from-sap-to-oracle-cl_sql_connection-3780804]

  • Could u plz help me to find simple example for how to save data file in a spread sheet or any other way in the real time controller for Sbrio 9642 using memory or usb flash memory

    Could u plz help me to find simple example for how to save data file in a spread sheet or any other way in the real time controller for Sbrio 9642 using memory or usb flash memory

    Here are a few Links to a helpful Knowledge Base article and a White Paper that should help you out: http://digital.ni.com/public.nsf/allkb/BBCAD1AB08F1B6BB8625741F0082C2AF and http://www.ni.com/white-paper/10435/en/ . The methods for File IO in Real Time are the same for all of the Real Time Targets. The White Paper has best practices for the File IO and goes over how to do it. 
    Alex D
    Applications Engineer
    National Instruments

  • How to save data in ztable after editing in alv report

    how to save data in ztable after editing in alv report?

    Hi,
        Please find the attachment below.This may be usefull to you.
         [http://wiki.sdn.sap.com/wiki/display/Snippets/ALV-Editingandsavingtheeditedvaluesin+Database%28OOPS%29]
    Regards,
    Ramakrishna Yella.

  • How to upload data into IT0000 using ABAP-HR program

    Hello,
    I'm required to upload data into multiple infotypes [IT000, 0001, 0002, etc] using single input text file. Can anyone able to guide me, how to upload data into IT0000 using ABAP program ?
    Thanks in advance.
    Regards
    Prabhakar.
    Message was edited by:
            Prabhakara Muthyal

    Example code for HR_MAINTAIN_MASTERDATA to COPY IT0002
    DATA: INT_0002_FINAL TYPE STANDARD TABLE OF PA0002 WITH HEADER LINE.
    DATA: VALUES        LIKE PPROP OCCURS 10 WITH HEADER LINE,
    RETURN        LIKE BAPIRETURN1,.
    LOOP AT INT_0002_FINAL.
          VALUES-INFTY = '0002'.
          VALUES-FNAME = 'P0002-PERNR'.
          VALUES-FVAL  = INT_0002_FINAL-PERNR.
          APPEND VALUES.
          VALUES-INFTY = '0002'.
          VALUES-FNAME = 'P0002-BEGDA'.
          VALUES-FVAL  = INT_0002_FINAL-BEGDA.
          APPEND VALUES.
          VALUES-INFTY = '0002'.
          VALUES-FNAME = 'P0002-ENDDA'.
          VALUES-FVAL  = INT_0002_FINAL-ENDDA.
          APPEND VALUES.
          VALUES-INFTY = '0002'.
          VALUES-FNAME = 'P0002-nachn'.
          VALUES-FVAL  = INT_0002_FINAL-NACHN.
          APPEND VALUES.
          VALUES-INFTY = '0002'.
          VALUES-FNAME = 'P0002-gblnd'.
          VALUES-FVAL  = INT_0002_FINAL-GBLND.
          APPEND VALUES.
          VALUES-INFTY = '0002'.
          VALUES-FNAME = 'P0002-vorna'.
          VALUES-FVAL  = INT_0002_FINAL-VORNA.
          APPEND VALUES.
          VALUES-INFTY = '0002'.
          VALUES-FNAME = 'P0002-rufnm'.
          VALUES-FVAL  = INT_0002_FINAL-RUFNM.
          APPEND VALUES.
          VALUES-INFTY = '0002'.
          VALUES-FNAME = 'P0002-name2'.
          VALUES-FVAL  = INT_0002_FINAL-NAME2.
          APPEND VALUES.
          VALUES-INFTY = '0002'.
          VALUES-FNAME = 'P0002-inits'.
          VALUES-FVAL  = INT_0002_FINAL-INITS.
          APPEND VALUES.
          VALUES-INFTY = '0002'.
          VALUES-FNAME = 'P0002-famst'.
          VALUES-FVAL  = INT_0002_FINAL-FAMST.
          APPEND VALUES.
          VALUES-INFTY = '0002'.
          VALUES-FNAME = 'P0002-gbdat'.
          VALUES-FVAL  = INT_0002_FINAL-GBDAT.
          APPEND VALUES.
          VALUES-INFTY = '0002'.
          VALUES-FNAME = 'P0002-sprsl'.
          VALUES-FVAL  = INT_0002_FINAL-SPRSL.
          APPEND VALUES.
          VALUES-INFTY = '0002'.
          VALUES-FNAME = 'P0002-anzkd'.
          VALUES-FVAL  = INT_0002_FINAL-ANZKD.
          APPEND VALUES.
          VALUES-INFTY = '0002'.
          VALUES-FNAME = 'P0002-natio'.
          VALUES-FVAL  = INT_0002_FINAL-NATIO.
          APPEND VALUES.
    * maintain master data
          CALL FUNCTION 'HR_MAINTAIN_MASTERDATA'
            EXPORTING
              PERNR           = INT_0002_FINAL-PERNR
              ACTIO           = 'COP'
              BEGDA           = INT_0002_FINAL-BEGDA
    *         ENDDA           = INT_0002_FINAL-ENDDA
              SUBTY           = SPACE
              NO_ENQUEUE      = SPACE
              DIALOG_MODE        = '0'
              TCLAS              = 'A'
            IMPORTING
              RETURN1         = RETURN
            TABLES
              PROPOSED_VALUES = VALUES
    *         MODIFIED_KEYS   =
            EXCEPTIONS
              OTHERS          = 1.
          IF RETURN IS INITIAL.
            WRITE:/' Done....'.
          ELSE.
            WRITE:/   RETURN-ID, RETURN-TYPE, RETURN-NUMBER, RETURN-MESSAGE_V1, RETURN-MESSAGE_V2, RETURN-MESSAGE_V3, RETURN-MESSAGE_V4.
          ENDIF.
          CLEAR VALUES.
          REFRESH VALUES.
        ENDLOOP.

  • How to save data model design in pdf or any format..?

    how to save data model design in pdf or any format..?
    i ve created design but not able to save it any mage or pdf format

    File -> Print Diagram -> To PDF File

  • How to save OTF to Memory using E_PRINT_PO?

    HI All,
    How to save OTF to Memory using this FM: ME_PRINT_PO.
    Please let me know.
    Ashok

    No, it should be there, becos inside that FM this fm is also calling, SAVE_OTF_TO_MEMORY. but it is calling in Enhancement point. im not able to put the break point there. i think that code is not executing.
    im getting this error: Breakpoint not set since enhancement ISAUTO_SCH_EMM_SAPLMEDRUCK is switched off.
    Please help me on this.
    Ashok..

  • How to retrieve data from MDM using java API

    hi experts
    Please explain me the step by step procedure
    how to retrieve data from MDM using java API
    and please tell me what are the
    important classes and packages in MDM Java API
    thanks
    ramu

    Hi Ramchandra,
    You can refer to following links
    MDM Java API-pdf
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/2d18d355-0601-0010-fdbb-d8b143420f49
    webinr of java API
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/89243c32-0601-0010-559d-80d5b0884d67
    Following Fourm Threads will also help.
    Java API
    Java API
    Re: usage of  java API ,
    Matching Record
    Need Java API for Matching Record
    Thanks and Regards,
    Shruti.
    Edited by: Shruti Shah on Jul 16, 2008 12:35 PM

  • How to avoid data repetation when using select statements with innerjoin

    how to avoid data repetation when using select statements with innerjoin.
    thanks in advance,
    satheesh

    you can use a query like this...
      SELECT DISTINCT
             frg~prc_group1                  "Product Group 1
             frg~prc_group2                  "Product Group 2
             frg~prc_group3                  "Product Group 3
             frg~prc_group4                  "Product Group 4
             frg~prc_group5                  "Product Group 5
             prc~product_id                  "Product ID
             txt~short_text                  "Product Description
    UP TO 10 ROWS
    INTO TABLE l_i_data
    FROM
    Joining CRMM_PR_SALESG and
    COMM_PR_FRG_ROD
    crmm_pr_salesg AS frg
    INNER JOIN comm_pr_frg_rod AS prd
    ON frgfrg_guid = prdfragment_guid
    Joining COMM_PRODUCT and
    COMM_PR_FRG_ROD
    INNER JOIN comm_product AS prc
    ON prdproduct_guid = prcproduct_guid
    Joining COMM_PRSHTEXT and
    COMM_PR_FRG_ROD
    INNER JOIN comm_prshtext AS txt
    ON prdproduct_guid = txtproduct_guid
    WHERE frg~prc_group1 IN r_zprc_group1
       AND frg~prc_group2 IN r_zprc_group2
       AND frg~prc_group3 IN r_zprc_group3
       AND frg~prc_group4 IN r_zprc_group4
       AND frg~prc_group5 IN r_zprc_group5.
    reward it it helps
    Edited by: Apan Kumar Motilal on Jun 24, 2008 1:57 PM

  • How to export data with column headers in sql server 2008 with bcp command?

    Hi all,
    I want know "how to export data with column headers in sql server 2008 with bcp command", I know how to import data with import and export wizard. when i
    am trying to import data with bcp command data has been copied but column names are not came.
    I am using the below query:-
    EXEC master..xp_cmdshell
    'BCP "SELECT  * FROM   [tempdb].[dbo].[VBAS_ErrorLog] " QUERYOUT "D:\Temp\SQLServer.log" -c -t , -T -S SERVER-A'
    Thanks,
    SAAD.

    Hi All,
    I have done as per your suggestion but here i have face the below problem, in print statment it give correct query, in EXEC ( EXEC master..xp_cmdshell @BCPCMD) it was displayed error message like below
    DECLARE @BCPCMD
    nvarchar(4000)
    DECLARE @BCPCMD1
    nvarchar(4000)
    DECLARE @BCPCMD2
    nvarchar(4000)
    DECLARE @SQLEXPRESS
    varchar(50)
    DECLARE @filepath
    nvarchar(150),@SQLServer
    varchar(50)
    SET @filepath
    = N'"D:\Temp\LDH_SQLErrorlog_'+CAST(YEAR(GETDATE())
    as varchar(4))
    +RIGHT('00'+CAST(MONTH(GETDATE())
    as varchar(2)),2)
    +RIGHT('00'+CAST(DAY(GETDATE())
    as varchar(2)),2)+'.log" '
    Set @SQLServer
    =(SELECT
    @@SERVERNAME)
    SELECT @BCPCMD1
    = '''BCP "SELECT 
    * FROM   [tempdb].[dbo].[wErrorLog] " QUERYOUT '
    SELECT @BCPCMD2
    = '-c -t , -T -S '
    + @SQLServer + 
    SET @BCPCMD
    = @BCPCMD1+ @filepath 
    + @BCPCMD2
    Print @BCPCMD
    -- Print out below
    'BCP "SELECT 
    * FROM   [tempdb].[dbo].[wErrorLog] " QUERYOUT "D:\Temp\LDH_SQLErrorlog_20130313.log" -c -t , -T -S servername'
    EXEC
    master..xp_cmdshell
    @BCPCMD
      ''BCP' is not recognized as an internal or external command,
    operable program or batch file.
    NULL
    if i copy the print ourt put like below and excecute the CMD it was working fine, could you please suggest me what is the problem in above query.
    EXEC
    master..xp_cmdshell
    'BCP "SELECT  * FROM  
    [tempdb].[dbo].[wErrorLog] " QUERYOUT "D:\Temp\LDH_SQLErrorlog_20130313.log" -c -t , -T -S servername '
    Thanks, SAAD.

  • I want to use the SQL Toolkit of NI and SQL Server as my databasis on a server. Do I need to install a client in each computer I want to handle the data into SQL tables or I need only a ODBC driver?

    I want to use the SQL Toolkit of NI and SQL Server as my databasis on a server. Do I need to install a client in each computer I want to handle the data into SQL tables or I need only a ODBC driver?

    You only need the ODBC driver on each computer. If you are distributing the SQL Toolkit app as an executable and do not install the whole toolkit on each computer, you'll need the SQL Toolkit support files. This is about a dozen files. You can get the list at http://digital.ni.com/public.nsf/websearch/b814be005f9da9258625658700550c75?OpenDocument.

  • Pop up using PL SQL Toolkit

    Hello there :
    Is there any way we can create a pop-up window using PL/SQL Toolkit.
    Thanks for the help.
    Regards,
    Mohit

    using ApEx forum may be more efficient for PL/SQL Toolkit -> Oracle Application Express (APEX)

  • How to save data aquired with NI mydaq and save it in a data base using Labview?

    i have developped with labview an interface that can control automatic irrigation station using two sensors ( humidity sesonr and temperature sensor) so i want to save data aquired during a year in a data base so i can compare these results in the next year please help me to do that in my interface labview and thanks 
    Attachments:
    PFE.vi ‏223 KB

    There is a database toolkit for LabVIEW.  I don't think it is a free download however.  With the Data Manipulation toolkit, you can integrate with most databases that use the ODBC protocol.
    If you don;t need anything fancy, you can write the values out to file using the write/read spreadsheet VIs.  If the file is [COMMA] or [TAB] delimited, you can import it into your database with ease.
    Another approach is to format you output to a text file as SQL, and import the records that way.
    INSERT INTO TEMP_HUM_TBL (Temperature, Humidity, Txn_Date)
    VALUES (30, 95, 'Dec-24-2013');
    Machine Vision, Robotics, Embedded Systems, Surveillance
    www.movimed.com - Custom Imaging Solutions

  • Offline Adobe Form using GP - How to save data to SAP

    Hi,
    I have the following requirement.
              o An offline form is sent to different users and when they fill the form and Click on Submit, the data should be saved to SAP.
              o When the data is submitted, it should be recognize the user and multiple clicks if any so that data is not duplicated
    I have used Guided Procedures for this. I have created an Interactive Form callable object with an xdp template and "Create offline Interactive form and send by e-mail" option.
    Problem:
    1. The document emailed to user can be submitted only once. My requirement is whenever form is submitted it should update the previous data.
    2. How to save this data to SAP?
    Version:
    SAP NW SP12
    Adobe Live cycle designer 7.1
    I have gone through various blogs on Adobe Offline interactive forms and GP but I could not get a solution for this. Please help.
    Thank you,
    Vasu

    Hi,
    IMHO there is no easy solution for your requirement. However there is a workaround: you can create so-called "impersonalized" forms. They can be sent or returned as many times as needed from same or different users. However the effect will be that for each form sent out and accepted by GP, GP will start a new GP process. That means that the forms are the first step of such a process - so to say.
    An offline form "in the middle" of a process can be embedded into the process as a dedicated step only. Once this form is returned to GP by the user, the process is continued and 2nd or later form returns are ignored. However there is the possibility to build an additional step into GP to check the input data and if they aren't valid to send out the form to the user once again.
    So you see that there are some possibilities but no straight forward solution for your needs. Hope I could help anyhow.
    Regards,
        Jan

Maybe you are looking for

  • VF01 - VF03

    Hello !! I have to add additional authorisations for transaction VF01,VF02,VF03. Is there any common user exit for that transactions i can use to fill my authorisations ?? BR, Jacek

  • Export scale issue - Premiere Elements 13

    When I export my video, clips which have been Scaled (In Applied Effects) are not matched to the ratio of the rest of the clips. How do I fix this? Here is a screen grab showing the problem. The clip is supposed to be zoomed in so the model's eyes ar

  • [SOLVED]Grub-Install can't Find Kernel and/or initrd, mkinitcpio Fails

    Hi all, I have recently installed Arch on my new build (with UEFI firmware). I successfully set up xorg, alsa/pulseaudio, xfce, etc... things were looking pretty good. Then, I tried to blacklist the pcspkr in order to silence the annoying beep every

  • Impact on schedule lines

    hi, i have created a sales order. and then i changed the GI date to next day. what is the direct impact on scheduling the sap system. will there be a positive impact or negative impact or no impact, particularly on the scheduling. regards, balajit

  • Hairpin VPN to another firewall

    Hi, I have a tunnel between our office and colation facility. All external http/s traffic enters the firewall in our office. I need to redirect http traffic entering the outside of the office ASA to the webserver located in the colo over the existing