Number returned to voltage conversion

I am writing an app to acquire data using PCI cards in VB.net with VS2010. I "assumed" that for a 16-bit card was 65536 heads available for the used range (09:50, etc.). Experience that has not been corroborated. In theory, using the above values, 10 volts volts equal to 32768 and - 10 would equal-32767. I constantly receive lower values.

Can someone tell me if this is correct: there is a 16 bit, 65536 counties map covering the entire map (INCLUDING OVER VOLTAGE RANGE)? In other words, I need 10 volts of input, take this indictment and then entry-10 volts and that would determine my range of work of the charges?

Hey Dan,

If these values are not too crazy about what I expected (not much either).

I guess that it is more a function of calibration and absolute precision.

I would check page 4 and 5 of the technical manual for the 6220:

<>http://www.NI.com/PDF/manuals/375200b.PDF >

It details the absolute precision, given a number of factors that could explain your results.

Also the installation of the samples, you must specifically include in your installation of data acquisition:

<>http://digital.NI.com/public.nsf/allkb/0EA34D565632DFE186256E7B00762DCC >

and then they can be found in the following locations:

<>http://zone.NI.com/reference/en-XX/help/370473H-01/mstudiowebhelp/HTML/locateexamples2010/#netxp >

I hope this helps!

Tags: NI Software

Similar Questions

  • Help. Temp for voltage conversion.

    I'm currently trying to find a best way to calibrate the thermocouple read outs. I would like to be able to enter any temp for all TC and labView output the corresponding voltage. So I was hoping someone would have a way to make this temp for voltage conversion. Example if I want to do 250 C I need 10.153 mV how labView could be made to calculate this.

    This will allow you to enter the temperature you want for the simulation and corresponding voltage.

  • In Keithley 2410, string number read voltage conversion

    Hello

    I want to drive the current and voltage with Keithley 2410 to read.

    However, I can read the correct voltage value in the screen of the device, I can't read the correct voltage value in the display of laboratory program. The problem occurs while the voltage read (string) is converted to a number. I use String Fract/Exp number for this. However, I can read only the first digit of the value. for example, in the screen of the device, I read 1.3784e - 5 (the actual voltage value), in the indicator of software, I have read only 1.

    I am new to laboratory. can someone help me on this you problem.

    My Magic 8-Ball says that your system settings have the comma is the decimal separator.  The Keithley instrument will always be the decimal point as the decimal separator.  Fortunately, there are a Boolean input on the Fract/Exp to string number which affects whether to use the system separator.  Make sure you set that to FALSE.

  • Serial number of modules (programmatic conversion)

    Hi all

    I am the serial number of modules of reading in my NI EtherCAT 9144 chassis by programming using the shared variable property node. The value obtained in my program is completely different from this serial number on the module. For example that I'm reading the serial number of the module NI9234, serial number that I got from the program was 25182428 the series but real present on the module number is 18040DC. Could you please see this and let me know what problem I'm facing? or y at - it all conversions that I do.  Here is the picture of my code.

    Thanks in advance

    A watch in decimal, the other is hexadecimal.

    Change the display format for your digital indicator.

  • Voltage conversion for the Module e/s-OR-5751

    The only place where I can see an example of this is the example 'NOR 5751 finished several acquisition channels'.  The conversion to the VI is illustrated below:

    It is a 14-bit digitizer, so I'm not the "16" for the resolution.

    The text in the example says: "data from the 14-bit a/d converters are represented in the CLIP as compliment of 2, MSB justified, I16.". 2 LSBs are filled with zeros. The data are multiplied by a scale factor (ADC voltage resolution = voltage range / ADC * 16 intervals) to LSB justified data and scale to volts. "This seems to be different from the code above.

    I don't understand what is the factor of 16 text. Or I do not understand how they are the same.

    Hey JP82,

    The 5751 is one of our familiarization trips that produces data MSB justified, with even two most (LSB) containing 0.

    If you changed the generetaed of data by the fam to the right by two, then you must use 14 bits resolution.

    Example of MSB justified:

    Input voltage: 1V
    Binary representation of FAM: 0111111111111100

    Sign bit ^ zero of the LSB ^ ^

    Decimal Rep: 32764

    MATH:

    2 / (2 ^16 - 1) * 32764 =

    3.05E - 5 * 32764 = 0.999302 ~ 1V

    If he was justified in LSB:

    Input voltage: 1V
    Binary representation of FAM: 0001111111111111

    Sign bit. ^

    Decimal Rep: 8191

    MATH:

    2 / (2 ^14 - 1) * 8 191 =

    1.22E - 4 * 8191 = 0.99993 ~ 1V

    I do not believe that data are two is completed, as indicated in the details.  I'll see that this gets fixed.

  • Number in hexadecimal string conversion problem

    Hello

    for a serial communication, I need to send byte-code in an ascii hexadecimal string. When I use the constants and send them by VISA to the COM port it works fine, but if I use converters numbers it doesn't. Can someone show me what I'm doing wrong?

    deepearth

    --------------------------------

    Windows XP SP3, LV 8.5.1

    Since your string indicator is set to hexadecimal display, it seems you want to a hexadecimal string, a single byte/number.

    (You are currently using a hexadecimally format string, composed exclusively of ASCII of the 2 characters/byte "0.F" characters.) This is not what you want!).

    Here is another solution using type conversion:

  • actual number returned with the comma as decimal separator

    Hello
    I installed W7 CF9 using an Access database.
    In a table, I have a monetary value of
    -488.7

    Windows is French, but I put the delimiter for the decimal AND currency values to dot instead of a comma.

    If I get this error in the CF:

    The value-488, 7 cannot be converted to number.

    CF receives the value by a comma instead of a point.

    -If I navigate on the table in Access, the value appears correctly with a point.

    -If I change the column type in teTEXT instead of real or currency, the value is converted to text with a point, and there is no error in the CF.

    Of course, a point in decimal conversion is made in another layer, but where?

    I checked the ODBC connection, and found nothing.

    Any idea?

    > If you do a simple query and cfdump the result, do you have a point or a comma?

    Yes, I want to.

    But I finally found the problem.

    The motion is produced by a trade UNION and in one of the sub selects, the column is set to '0' instead of 0. It launched a conversion of text to the same column in the following SELECTION, probably in the ODBC driver, and this conversion involves the use of a comma instead of a point. For some unknown reason, he follows the rule for the French because the version of Windows is French, but ignores the settings in Windows.

  • Error number return when and ORA: 01722 invalid

    Hi people, I posted this under another topic as well as eBusiness suite so apologies if some you've seen, but I would really appreciate the help on this one. Any suggestions are welcome.

    We strive to create a calculation that returns the number of days of absence a person has had in a given period of time. We need answer these absences which began before the period and are closed during it, lack that begins during the period and ends after she and those that open and close that it contains.

    The period is always a rolling 6 months from sysdate.

    It's the calc we found so far that works for some people, but we get the error invalid number if the absence includes a half-day - so 0.5, 1.5, etc..

    It's probably more complicated, but we are not the techno at all so learn we will!

    We use the business district of HRMS - Administration - Oracle Human Resources (Core) 10G and the folders present Absence and nobody.

    SUM (TO_NUMBER (NVL ((CASES WHERE the Attendance.Actual Absence Start Date < TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY') THEN (BOX WHEN presence Absence.)))) "" Actual end date ' > SYSDATE SO (WORKING_DAYS_BETWEEN (TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY'), SYSDATE)) else (CASE WHEN (BOX WHEN TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY') > = Absence Start Date of Attendance.Actual THEN (WORKING_DAYS_BETWEEN (TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY'), presence of Absence.)))) (("" Actual end date ")) ELSE (CASE WHEN (WORKING_DAYS_BETWEEN (Start Date of Attendance.Actual of Absence, presence of Absence." Actual end date")) IS NULL SO (WORKING_DAYS_BETWEEN (Attendance.Actual of Absence Start Date, SYSDATE)) ELSE (BOX WHEN SYSDATE < = presence Absence.) "" Actual end date ' THEN (WORKING_DAYS_BETWEEN (Attendance.Actual of Absence Start Date, SYSDATE)) ELSE (WORKING_DAYS_BETWEEN (Start Date of Attendance.Actual of Absence, presence of Absence." (((Actual end date")) END) END) END) IS NULL SO (WORKING_DAYS_BETWEEN (TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY'), SYSDATE)) else (BOX WHEN TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY') > = Absence Start Date of Attendance.Actual THEN (WORKING_DAYS_BETWEEN (TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY'), presence Absence.))) (("" Actual end date ")) ELSE (CASE WHEN (WORKING_DAYS_BETWEEN (Start Date of Attendance.Actual of Absence, presence of Absence." Actual end date")) IS NULL SO (WORKING_DAYS_BETWEEN (Attendance.Actual of Absence Start Date, SYSDATE)) ELSE (BOX WHEN SYSDATE < = presence Absence.) "" Actual end date ' THEN (WORKING_DAYS_BETWEEN (Attendance.Actual of Absence Start Date, SYSDATE)) ELSE (WORKING_DAYS_BETWEEN (Start Date of Attendance.Actual of Absence, presence of Absence." (((((Actual end date")) END) END) END) END) END) else (WHEN BOX (BOX WHEN TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY') > = Absence Start Date of Attendance.Actual THEN (WORKING_DAYS_BETWEEN (TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY'), presence Absence.)))) (("" Actual end date ")) ELSE (CASE WHEN (WORKING_DAYS_BETWEEN (Start Date of Attendance.Actual of Absence, presence of Absence." Actual end date")) IS NULL SO (WORKING_DAYS_BETWEEN (Attendance.Actual of Absence Start Date, SYSDATE)) ELSE (BOX WHEN SYSDATE < = presence Absence.) "" Actual end date ' THEN (WORKING_DAYS_BETWEEN (Attendance.Actual of Absence Start Date, SYSDATE)) ELSE (WORKING_DAYS_BETWEEN (Start Date of Attendance.Actual of Absence, presence of Absence." (((Actual end date")) END) END) END) IS NULL SO (WORKING_DAYS_BETWEEN (TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY'), SYSDATE)) else (BOX WHEN TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY') > = Absence Start Date of Attendance.Actual THEN (WORKING_DAYS_BETWEEN (TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY'), presence Absence.))) (("" Actual end date ")) ELSE (CASE WHEN (WORKING_DAYS_BETWEEN (Start Date of Attendance.Actual of Absence, presence of Absence." Actual end date")) IS NULL SO (WORKING_DAYS_BETWEEN (Attendance.Actual of Absence Start Date, SYSDATE)) ELSE (BOX WHEN SYSDATE < = presence Absence.) (("" END END END END END actual end Date ' THEN (WORKING_DAYS_BETWEEN (Attendance.Actual of Absence Start Date, SYSDATE)) ELSE (lack Attendance.Duration days))), (DAYS_BETWEEN (Start Date of Attendance.Actual of Absence, presence of Absence." ((Actual end date'))), '999999990 D 00'))

    Hello

    It could be that it's because you use SYSDATE that contains both as a fraction and not trunc (sysdate) that contains at present. It could be that your working_dates_between triggers this error.

    However, your formula is much more complicated that it should be.

    First of all, you want to watch the ADD_MONTHS (TRUNC (SYSDATE),-6) date at trunc (sysdate). So, you want to look the part of the absence which is located in the time stamp. It's the BIGGEST (Absence Attendance.Actual Start Date, ADD_MONTHS (TRUNC (SYSDATE),-6)) to LEAST (NVL (lack of attendance. (("" Actual end Date ", TRUNC (SYSDATE)), TRUNC (SYSDATE)). You may need to add 1 to the end of absence date because it is the last day of their absence, and not the date of their return. It depends on how you calculate the days between the beginning and the end
    Date of the absence. You can create calculations for the date of beginning and end of the absences in the time window of 6 months. Create the AbsenceStart calculation as

    Greatest (attendance absence. Actual Start date, ADD_MONTHS (trunc (sysdate),-6))

    and AbsenceEnd as

    LESS (NVL (lack of attendance. (("" Actual end Date ", TRUNC (SYSDATE)), TRUNC (SYSDATE))

    Next, you need to pick up only lack what part of the absence in your 6 months date window. To do this, you can use a condition in the workbook or a condition in a statement box. You must then calculate the difference between those dates and SUM all values.

    SUM (CASE WHEN AbsenceEnd > = AbsenceStart THEN WORKING_DAYS_BETWEEN (AbsenceStart, AbsenceEnd) END)

    That's all. Not so complicated after all.

    Rod West

  • voltage conversion by current in daq reading

    Hi all

    I have a pressure sensor which gives my daq output.my is read voltage.i connect the resistor as parallel analog input. But I can not yet read voltage.when I check with the ammeter to the current value is correct, but it can't convert it the voltage.

    BNC connection can carry it HAVE (-) the outside contact.  So, I (-) should be the round metal cylinder on the DAQ hardware.

  • character to number conversion of running OE example schema error

    Hi all
    I try to run the following sample code from the language reference doc demonstrating the granularity of the cache by using the example of OE schema:
    CREATE OR REPLACE FUNCTION get_product_name_2 (prod_id NUMBER, lang_id VARCHAR2)
    RETURN NVARCHAR2
    IS
    TYPE product_names IS TABLE OF NVARCHAR2(50) INDEX BY PLS_INTEGER;
    
    FUNCTION all_product_names (lang_id NUMBER) RETURN product_names
    RESULT_CACHE
    IS
    all_names product_names;
    BEGIN
    FOR c IN (SELECT * FROM Product_Descriptions WHERE LANGUAGE_ID = lang_id)
    LOOP
    all_names(c.PRODUCT_ID) := c.TRANSLATED_NAME;
    END LOOP;
    RETURN all_names;
    END;
    
    BEGIN
    RETURN all_product_names(lang_id)(prod_id);
    END;
    but I had
    SQL> variable a nvarchar2(4000)
    SQL> exec :a:=GET_PRODUCT_NAME_2(2449,'US');
    BEGIN :a:=GET_PRODUCT_NAME_2(2449,'US'); END;
    
    *
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    ORA-06512: at "OE.GET_PRODUCT_NAME_2", line 17
    ORA-06512: at line 1
    Could someone advise me what went wrong?

    Best regards
    Val

    Looks like that lang_id is first defined as character in get_product_name2().

    But in all_product_names(), it is defined as a number. For example, when you move the character value to
    all_product_names(), he's going to complain, because it expects a number.

    CREATE OR REPLACE FUNCTION get_product_name_2 (prod_id NUMBER, lang_id VARCHAR2)
    RETURN NVARCHAR2
    IS
    TYPE product_names IS TABLE OF NVARCHAR2(50) INDEX BY PLS_INTEGER;
    
    FUNCTION all_product_names (lang_id NUMBER) RETURN product_names
    

    You can try changing the all_product_names() parameter type:

    FUNCTION all_product_names (lang_id VARCHAR2) RETURN product_names
    
  • How to get a magic number for any table that returns more than 32 k?

    I'm in a unique situation where in I try to extract the values of the multiple tables and to publish as XML output. The problem is based on the condition of a few tables can retrieve more than 32 KB and less than 32 KB of data. Less than 32KB is not a problem, as the generation of XML is smooth. The minute he reached more than 32 k, it generates a runtime error. I was wondering if there is a way to make sure that the minute results of the query is greater than 32 KB, it must break say - if results is 35KO, so should I break this result 32 KB and 3 KB. Once then pass these data to appear as XML output. Again, it is not just for a table, but all the tables which are called in the function.

    Is it possible? I'm unable to get ideas, or did I do something so complex from the point of view of production support. If you'd be grateful if someone can guide me on this.

    The way it is, is the following:
    I have a table named ctn_pub_cntl


    CREATE TABLE CTNAPP.ctn_pub_cntl 
    (ctn_pub_cntl_id          NUMBER(18)
    ,table_name                  VARCHAR2(50)
    ,last_pub_tms              DATE
    ,queue_name               VARCHAR2(50)
    ,dest_system              VARCHAR2(50)
    ,frequency                  NUMBER(6)
    ,status                      VARCHAR2(8)
    ,record_create_tms          DATE
    ,create_user_id                VARCHAR2(8)
    ,record_update_tms          DATE
    ,update_user_id             VARCHAR2(8)
    ,CONSTRAINT ctn_pub_cntl_id_pk PRIMARY KEY(ctn_pub_cntl_id)
    );
    
    

    To do this, the data are:


    INSERT INTO CTNAPP.ctn_pub_cntl
    (ctn_pub_cntl_id    
     ,table_name         
     ,last_pub_tms  
    ,queue_name  
     ,dest_system        
     ,frequency          
    )
    VALUES
    (CTNAPP_SQNC.nextval
    ,'TRKFCG_SBDVSN'
    ,TO_DATE('10/2/2004 10:17:44PM','MM/DD/YYYY HH12:MI:SSPM')
    ,'UT.TSD.TSZ601.UNP'
    ,'SAP'
    ,15
    );
    
    INSERT INTO CTNAPP.ctn_pub_cntl
    (ctn_pub_cntl_id    
     ,table_name         
     ,last_pub_tms  
     ,queue_name  
     ,dest_system        
     ,frequency          
    )
    VALUES
    (CTNAPP_SQNC.nextval
    ,'TRKFCG_TRACK_SGMNT_DN'
    ,TO_DATE('02/06/2015 9:50:00AM','MM/DD/YYYY HH12:MI:SSPM')
    ,'UT.TSD.WRKORD.UNP'
    ,'SAP'
    ,30
    );
    
    INSERT INTO CTNAPP.ctn_pub_cntl
    (ctn_pub_cntl_id    
     ,table_name         
     ,last_pub_tms  
    ,queue_name  
     ,dest_system        
     ,frequency          
    )
    VALUES
    (CTNAPP_SQNC.nextval
    ,'TRKFCG_FXPLA_TRACK_LCTN_DN'
    ,TO_DATE('10/2/2004 10:17:44PM','MM/DD/YYYY HH12:MI:SSPM')
    ,'UT.TSD.YRDPLN.INPUT'
    ,'SAP'
    ,30
    ); 
    
    INSERT INTO CTNAPP.ctn_pub_cntl
    (ctn_pub_cntl_id    
     ,table_name         
     ,last_pub_tms  
    ,queue_name  
     ,dest_system        
     ,frequency          
    )
    VALUES
    (CTNAPP_SQNC.nextval
    ,'TRKFCG_FXPLA_TRACK_LCTN2_DN'
    ,TO_DATE('02/06/2015 9:50:00AM','MM/DD/YYYY HH12:MI:SSPM')
    ,'UT.TSD.TSZ601.UNP'
    ,'SAP'
    ,120
    );
    
    INSERT INTO CTNAPP.ctn_pub_cntl
    (ctn_pub_cntl_id    
     ,table_name         
     ,last_pub_tms 
    ,queue_name  
     ,dest_system        
     ,frequency          
    )
    VALUES
    (CTNAPP_SQNC.nextval
    ,'TRKFCG_FXPLA_TRACK_LCTN2_DN'
    ,TO_DATE('04/23/2015 11:50:00PM','MM/DD/YYYY HH12:MI:SSPM')
    ,'UT.TSD.YRDPLN.INPUT'
    ,'SAP'
    ,10
    );
    
    INSERT INTO CTNAPP.ctn_pub_cntl
    (ctn_pub_cntl_id    
     ,table_name         
     ,last_pub_tms 
    ,queue_name  
     ,dest_system        
     ,frequency          
    )
    VALUES
    (CTNAPP_SQNC.nextval
    ,'TRKFCG_FIXED_PLANT_ASSET'
    ,TO_DATE('04/23/2015 11:50:00AM','MM/DD/YYYY HH12:MI:SSPM')
    ,'UT.TSD.WRKORD.UNP'
    ,'SAP'
    ,10
    );
    
    INSERT INTO CTNAPP.ctn_pub_cntl
    (ctn_pub_cntl_id    
     ,table_name         
     ,last_pub_tms 
    ,queue_name  
     ,dest_system        
     ,frequency          
    )
    VALUES
    (CTNAPP_SQNC.nextval
    ,'TRKFCG_OPRLMT'
    ,TO_DATE('03/26/2015 7:50:00AM','MM/DD/YYYY HH12:MI:SSPM')
    ,'UT.TSD.WRKORD.UNP'
    ,'SAP'
    ,30
    );
    
    INSERT INTO CTNAPP.ctn_pub_cntl
    (ctn_pub_cntl_id    
     ,table_name         
     ,last_pub_tms
    ,queue_name  
     ,dest_system        
     ,frequency          
    )
    VALUES
    (CTNAPP_SQNC.nextval
    ,'TRKFCG_OPRLMT_SGMNT_DN'
    ,TO_DATE('03/28/2015 12:50:00AM','MM/DD/YYYY HH12:MI:SSPM')
    ,'UT.TSD.WRKORD.UNP'
    ,'SAP'
    ,30
    );
    
    /
    
    COMMIT;
    
    

    Once the above data are inserted and committed, then I created a feature in a package:


    CREATE OR REPLACE PACKAGE CTNAPP.CTN_PUB_CNTL_EXTRACT_PUBLISH
    IS
    
    TYPE tNameTyp IS TABLE OF ctn_pub_cntl.table_name%TYPE INDEX BY BINARY_INTEGER;
    g_tName tNameTyp;
    
    TYPE tClobTyp IS TABLE OF CLOB INDEX BY BINARY_INTEGER;
    g_tClob tClobTyp;
    
    
    FUNCTION GetCtnData(p_nInCtnPubCntlID IN CTN_PUB_CNTL.ctn_pub_cntl_id%TYPE,p_count OUT NUMBER ) RETURN tClobTyp;
    
    
    END CTNAPP.CTN_PUB_CNTL_EXTRACT_PUBLISH;
    
    
    --Package body
    
    CREATE OR REPLACE PACKAGE BODY CTNAPP.CTN_PUB_CNTL_EXTRACT_PUBLISH
    IS
    
         doc           xmldom.DOMDocument;
         main_node     xmldom.DOMNode;
         root_node     xmldom.DOMNode;
         root_elmt     xmldom.DOMElement;
         child_node    xmldom.DOMNode;
         child_elmt    xmldom.DOMElement;
         leaf_node     xmldom.DOMNode;
         elmt_value    xmldom.DOMText;
         tbl_node      xmldom.DOMNode;
         table_data    XMLDOM.DOMDOCUMENTFRAGMENT;
      
         l_ctx         DBMS_XMLGEN.CTXHANDLE;
         vStrSqlQuery  VARCHAR2(32767);
         l_clob        tClobTyp;
         --
         l_xmltype     XMLTYPE;
         --
    --Local Procedure to build XML header     
    PROCEDURE BuildCPRHeader IS
    
      BEGIN
        child_elmt := xmldom.createElement(doc, 'PUBLISH_HEADER');
        child_node  := xmldom.appendChild (root_node, xmldom.makeNode (child_elmt));
    
        child_elmt := xmldom.createElement (doc, 'SOURCE_APLCTN_ID');
        elmt_value := xmldom.createTextNode (doc, 'CTN');
        leaf_node  := xmldom.appendChild (child_node, xmldom.makeNode (child_elmt));
        leaf_node  := xmldom.appendChild (leaf_node, xmldom.makeNode (elmt_value));
        
        child_elmt := xmldom.createElement (doc, 'SOURCE_PRGRM_ID');
        elmt_value := xmldom.createTextNode (doc, 'VALUE');
        leaf_node  := xmldom.appendChild (child_node, xmldom.makeNode (child_elmt));
        leaf_node  := xmldom.appendChild (leaf_node, xmldom.makeNode (elmt_value));
    
        child_elmt := xmldom.createElement (doc, 'SOURCE_CMPNT_ID');
        elmt_value := xmldom.createTextNode (doc, 'VALUE');
        leaf_node  := xmldom.appendChild (child_node, xmldom.makeNode (child_elmt));
        leaf_node  := xmldom.appendChild (leaf_node, xmldom.makeNode (elmt_value));
    
        child_elmt := xmldom.createElement (doc, 'PUBLISH_TMS');
        elmt_value := xmldom.createTextNode (doc, TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS'));
        leaf_node  := xmldom.appendChild (child_node, xmldom.makeNode (child_elmt));
        leaf_node  := xmldom.appendChild (leaf_node, xmldom.makeNode (elmt_value));
        
    END BuildCPRHeader;
    
    --Get table data based on table name
    FUNCTION GetCtnData(p_nInCtnPubCntlID IN CTN_PUB_CNTL.ctn_pub_cntl_id%TYPE,p_Count OUT NUMBER) RETURN tClobTyp IS
        
        vTblName      ctn_pub_cntl.table_name%TYPE;
        vLastPubTms   ctn_pub_cntl.last_pub_tms%TYPE;
         
    BEGIN
                g_vProcedureName:='GetCtnData';    
                g_vTableName:='CTN_PUB_CNTL';
                
            SELECT table_name,last_pub_tms
            INTO   vTblName, vLastPubTms
            FROM   CTN_PUB_CNTL
            WHERE  ctn_pub_cntl_id=p_nInCtnPubCntlID;
        
        -- Start the XML Message generation
            doc := xmldom.newDOMDocument;
            main_node := xmldom.makeNode(doc);
            root_elmt := xmldom.createElement(doc, 'PUBLISH');
            root_node := xmldom.appendChild(main_node, xmldom.makeNode(root_elmt));
            
          --Append Table Data as Publish Header
            BuildCPRHeader;
            
          --Append Table Data as Publish Body
          
           child_elmt := xmldom.createElement(doc, 'PUBLISH_BODY');
           leaf_node  := xmldom.appendChild (root_node, xmldom.makeNode(child_elmt)); 
           
           DBMS_SESSION.SET_NLS('NLS_DATE_FORMAT','''YYYY:MM:DD HH24:MI:SS''');
           
           vStrSqlQuery := 'SELECT * FROM ' || vTblName 
                          || ' WHERE record_update_tms <= TO_DATE(''' || TO_CHAR(vLastPubTms, 'MM/DD/YYYY HH24:MI:SS') || ''', ''MM/DD/YYYY HH24:MI:SS'') ' ;
                        --  ||  ' AND rownum < 16'
                          --;
          DBMS_OUTPUT.PUT_LINE(vStrSqlQuery);
           
           l_ctx  := DBMS_XMLGEN.NEWCONTEXT(vStrSqlQuery);
          DBMS_XMLGEN.SETNULLHANDLING(l_ctx, 0);
          DBMS_XMLGEN.SETROWSETTAG(l_ctx, vTblName); 
           
          -- Append Table Data as XML Fragment
          l_clob(1):=DBMS_XMLGEN.GETXML(l_ctx);  
          elmt_value := xmldom.createTextNode (doc, l_clob(1)); 
         leaf_node  := xmldom.appendChild (leaf_node, xmldom.makeNode (elmt_value)); 
         
         xmldom.writeToBuffer (doc, l_clob(1));
         l_clob(1):=REPLACE(l_clob(1),'&lt;?xml version=&quot;1.0&quot;?&gt;', NULL);
         l_clob(1):=REPLACE(l_clob(1),'&lt;', '<');
         l_clob(1):=REPLACE(l_clob(1),'&gt;', '>');
         
         RETURN l_clob;
         
         DBMS_OUTPUT.put_line('Answer is' ||l_clob(1));
         
         EXCEPTION
            
            WHEN NO_DATA_FOUND THEN
            
            DBMS_OUTPUT.put_line('There is no data with' || SQLERRM);
            g_vProcedureName:='GetCtnData';
            g_vTableName:='CTN_PUB_CNTL';
            g_vErrorMessage:=SQLERRM|| g_vErrorMessage;
            g_nSqlCd:=SQLCODE;
            ctn_log_error('ERROR',g_vErrorMessage,'SELECT',g_nSqlCd,p_nInCtnPubCntlID,g_vPackageName,g_vProcedureName,g_vTableName);
            
            
            WHEN OTHERS THEN
           
           DBMS_OUTPUT.PUT_LINE('ERROR : ' || SQLERRM);
           ctn_log_error('ERROR',g_vErrorMessage,'OTHERS',g_nSqlCd,p_nInCtnPubCntlID,g_vPackageName,g_vProcedureName,g_vTableName);
           
    END GetCtnData;
    
    
    PROCEDURE printClob (result IN OUT NOCOPY CLOB) IS
        xmlstr   VARCHAR2 (32767);
        line     VARCHAR2 (2000);
    BEGIN
        xmlstr := DBMS_LOB.SUBSTR (result, 32767);
    
        LOOP
           EXIT WHEN xmlstr IS NULL;
           line := SUBSTR (xmlstr, 1, INSTR (xmlstr, CHR (10)) - 1);
           DBMS_OUTPUT.put_line (line);
           xmlstr := SUBSTR (xmlstr, INSTR (xmlstr, CHR (10)) + 1);
        END LOOP;
    END printClob;
    
    END CTN_PUB_CNTL_EXTRACT_PUBLISH;
    
     
    

    If you notice my query:


    vStrSqlQuery := 'SELECT * FROM ' || vTblName 
                          || ' WHERE record_update_tms <= TO_DATE(''' || TO_CHAR(vLastPubTms, 'MM/DD/YYYY HH24:MI:SS') || ''', ''MM/DD/YYYY HH24:MI:SS'') ' ;
                         ||  ' AND rownum < 16'
                        ;
    

    The minute I comment

    ||  ' AND rownum < 16' ;


    It generates an error because this query returns about 600 lines and all these lines must be published in XML format and the tragedy, is that it is a C program between institutions i.e. C calls my functions of packged and then will do all the processing. This will return the results to the C program. Then obviously C does not recognize the CLOB and somewhere in the process, I convert to VARCHAR or CLOB CLOB, I have to use VARCHAR as a return type. That's my challenge.


    Someone who can help me find the number required of magic and also a brief knows how, I understand that. Thanks in advance.

    Not that I would use it myself but your package can be simplified down, like this:

    create or replace package ctn_pub_cntl_extract_publish is
    
      C_DTFORMAT  constant varchar2(30) := 'YYYY-MM-DD HH24:MI:SS';
    
      function getXMLData (p_table_name in varchar2, p_pub_tms in date) return xmltype;
      function getCTNData (p_id in number) return clob;
    
    end ctn_pub_cntl_extract_publish;
    /
    
    create or replace package body ctn_pub_cntl_extract_publish is
    
      function getXMLData (p_table_name in varchar2, p_pub_tms in date)
      return xmltype
      is
    
        v_query  varchar2(32767) :=
                 q'{select * from $$TABLE_NAME where record_update_tms <= to_date(:1, 'YYYYMMDDHH24MISS')}';
    
        ctx      dbms_xmlgen.ctxHandle;
        doc      xmltype;
    
      begin
    
        execute immediate 'alter session set nls_date_format = "'||C_DTFORMAT||'"';
        v_query := replace(v_query, '$$TABLE_NAME', dbms_assert.simple_sql_name(p_table_name)); 
    
        ctx := dbms_xmlgen.newContext(v_query);
        dbms_xmlgen.setBindValue(ctx, '1', to_char(p_pub_tms, 'YYYYMMDDHH24MISS'));
        dbms_xmlgen.setRowSetTag(ctx, p_table_name);
        dbms_xmlgen.setNullHandling(ctx, dbms_xmlgen.DROP_NULLS);
        doc := dbms_xmlgen.getXMLType(ctx);
        dbms_xmlgen.closeContext(ctx);
    
        return doc; 
    
      end;
    
      function getCTNData (p_id in number)
      return clob
      is
    
        doc  clob;
    
      begin
    
        select xmlserialize(document
                 xmlelement("PUBLISH"
                 , xmlelement("PUBLISH_HEADER"
                   , xmlforest(
                       'CNT' as "SOURCE_APLCTN_ID"
                     , 'VALUE' as "SOURCE_PRGRM_ID"
                     , 'VALUE' as "SOURCE_CMPNT_ID"
                     , to_char(sysdate, C_DTFORMAT) as "PUBLISH_TMS"
                     )
                   )
                 , xmlelement("PUBLISH_BODY"
                   , getXMLData(t.table_name, t.last_pub_tms)
                   )
                 )
               )
        into doc
        from ctn_pub_cntl t
        where t.ctn_pub_cntl_id = p_id;
    
        return doc;
    
      end;
    
    end ctn_pub_cntl_extract_publish;
    

    Function getXMLData() generates a canonical XML document out of the table that is passed as a parameter.

    Function built getCTNData() code XML "PUBLISH", the document using SQL/XML functions, the getXMLData() call in the process and returns the content serialized as a CLOB.

  • Return by using the function number

    How can I return number using the function.

    Here is my procedure but do not in the name of variable or setting up as a variable...

    create or replace function Calculate_number)
    Number 1 in number,
    Number2 number)
    Return number is
    Start
    declare
    number of result;

    Select number1 + number2 as a result of double;


    Return (result);
    end;

    Hello

    You have not need double a lot in PL/SQL.

    CREATE OR REPLACE FUNCTION Calculate_number
    (
         number1 IN NUMBER,
         number2 IN NUMBER
    )
    RETURN NUMBER
    DETERMINISTIC
    IS
           result number;
    BEGIN
         result := number1 + number2;
    
         RETURN Result;
    END      Calculate_number;
    

    Strored procedures, local variables are declared between statements IS and BEGIN. DECLARE in a stored procedure starts a nested block to BEGIN, with its own local variables, which is rarely necessary. (Nested BEGIN blocks are not so rare, but they almost never have local variables need a nested block. Most people here all variables of the function complete together before the first START.)

    If the function always returns the same value when it is called with the same arguments, then Deniz it as DETERMINISTIC; It might make it faster to use.

    There are many good reasons to use a variable as results, but if you don't happen to have one, then you can do this:

    CREATE OR REPLACE FUNCTION Calculate_number
    (
         number1 IN NUMBER,
         number2 IN NUMBER
    )
    RETURN NUMBER
    DETERMINISTIC
    IS
    BEGIN
         RETURN  number1 + number2;
    END      Calculate_number;
    

    Published by: Frank Kulash, October 22, 2010 12:37
    Fault corrected typo (thanks, HM); Added after the remarks.

    Published by: Frank Kulash, October 22, 2010 13:28

  • multiple number of returning from a function

    I am very new. I need to have a function that you need to return values for a column in a table that can be possiblely the number of tuples in the table. Something like that

    create to replace func (_id number) as return?

    Start
    Select max (phone) in the max_phone of the table where table.id = _id;

    Select the < somelist > phone table where phone = max_phone;

    return < somelist >
    end;

    Any help would be great, thanks

    Hello

    Welcome to OTN

    Create OR Replace Function Get_Phone(pi_id Number) Return Sys_Refcursor Is
       vs_cursor Sys_Refcursor;
    Begin
       Open vs_Cursor For
          SELECT phone
            FROM table_x
           WHERE phone = (SELECT Max(phone)
                            FROM table_x
                           WHERE table_x.id = pi_id);
    
       Return vs_Cursor;
    End;
    

    Kind regards

    Christian Balz

  • Incorrect voltage to a channel with NI9205

    Hello everyone

    I measure 10 tension of cell with a NI 9205 (differential mode, volt min. = 1, maximum voltage = 3).

    Everything works fine, until tensions are higher than 2.7 V. channel 17 (cell number 10), the voltage begins to decrease.

    All the other channels (0-7 and 16) works correctly.

    For example, when the real tension is 2.72, the measure shows 2.64 (and the value is not very stable). The more the voltage of the cell increases more 2.7 V, the more the measure of this cell voltage begins to decrease.

    I also connected the voltage of channel 17 to channel 18, but the problem remains. Both channels show too low voltage (but not exactly the same value).

    My sampling rate is 15, my conversion of clock frequency is 200.

    In addition, I have two NI9217 in my cDAQ-9172 chassis to measure 8 temperatures.

    Everything is measured in a task (10 voltages, temperatures of 2 x 4).

    Any ideas how to fix?

    Thanks and greetings

    Socki

    Socki,

    with 10 cells in a row you are likely well beyond the sides of the 9205 input voltage. Please note that the 9205 offer channel for floor insulation, but not from track to track. The voltage for each channel must remain in +/-10.4 V of the common. With your stack of the cell you are probably larger than this limit and reduced tension that you see is the result of the entry of the 9205 amplifier starts to saturate.

    As a solution, you will probably use a second analog input module and divide your channels in the middle of your stack of the cell.

    Kind regards

    Jochen Klier

    National Instruments

  • Problems of substr (Number)

    Hi all!

    I had a problem and do not understand why of course program could do to avoid the error, but I understand.

    Run the following script to the v_temp value is incorect (03:0) but for the value of v_temp2 is correct(12:12) WHY?

    Helpful and answers guaranteed

    DECLARE 
    v_temp NUMBER(12) :='080120141030';
    v_temp2 NUMBER(12):='281120131212';
    v_temp_v VARCHAR2(50);
     FUNCTION extract_hhmm(p_num NUMBER)
        RETURN VARCHAR2 AS
        v_tmp VARCHAR(5) :=NULL;
        BEGIN
          IF LENGTH(p_num) > 8 THEN 
             v_tmp := SUBSTR(p_num,9,2)||':'||SUBSTR(p_num,11,2);
          ELSE
             v_tmp := NULL;   
          END IF;
          RETURN v_tmp;
          EXCEPTION WHEN OTHERS THEN 
          RETURN NULL; 
        END extract_hhmm;
        
    BEGIN 
    
    
    v_temp_v:=extract_hhmm(v_temp);
    dbms_output.put_line(v_temp_v);
    v_temp_v:=extract_hhmm(v_temp2);
    dbms_output.put_line(v_temp_v);
    END;
    
    
    /*
    OUTPUT WHY ?
    03:0
    12:12
    
    
    */
    

    Hello

    Simply because there is an implicit conversion taking place here. p_num is implicitly converted to number first, and then to varchar2, then ' 080120141030 'becomes 80120141030 and then ' 80120141030'.

    The zero was automatically cut. For v_temp2, it's that there is no such zero non significant.

Maybe you are looking for