Streaming data (to LONG) from a String?

I have a (long) String-object which I should save into my
database. Because the db maps that String into type LONG, I have
to stream the string into the db. How can I make a stream out of
a String? I could save it to a temporary file and open a
FileInputStream but there has to be a better solution. Class
StringBufferInputStream is deprecated, StringReader doesn't
work...
Tommi
null

Robert Greig (guest) wrote:
: I am trying to stream data to a LONG column. I'm using Oracle
: Server 7.3.2.3.0 on AIX and JDBC driver 8.0.4 on Windows NT 4
: SP5.
I tried it with the old 7.3.x JDBC driver and it works fine. I
also noticed after further testing that it sometimes worked
with the 8.0.4 driver. Looks like a bug in the 8.0.4 driver or
some wacky incompatibility.
null

Similar Messages

  • Streaming data to LONG columns in Oracle 7.3.2.3.0

    I am trying to stream data to a LONG column. I'm using Oracle
    Server 7.3.2.3.0 on AIX and JDBC driver 8.0.4 on Windows NT 4
    SP5.
    I include sample tables/programs at the end, but here's the
    summary of what's happening:
    I'm creating a byte array of length 2500. If I use
    setAsciiStream I get the following exception when I execute the
    prepared statement:
    java.sql.SQLException: Data size bigger than max size for this
    type
    at oracle.jdbc.dbaccess.DBError.check_error(DBError.java)
    at oracle.jdbc.ttc7.TTCItem.setArrayData(TTCItem.java)
    at oracle.jdbc.driver.OraclePreparedStatement.setItem
    (OraclePreparedStat
    ement.java)
    at
    oracle.jdbc.driver.OraclePreparedStatement.setAsciiStream
    (OraclePrepa
    redStatement.java)
    at TestOracle.main(TestOracle.java:26)
    If I use setBinaryStream I get this exception:
    java.sql.SQLException: ORA-01461: can bind a LONG value only for
    insert into a LONG column
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7
    (TTC7Protocol.java)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch
    (TTC7Protocol.java)
    at oracle.jdbc.driver.OracleStatement.doExecuteOther
    (OracleStatement.jav
    a)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithBatch
    (OracleStatement
    .java)
    at oracle.jdbc.driver.OracleStatement.doExecute
    (OracleStatement.java)
    at
    oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout
    (OracleStateme
    nt.java)
    at
    oracle.jdbc.driver.OraclePreparedStatement.executeUpdate
    (OraclePrepar
    edStatement.java)
    at oracle.jdbc.driver.OraclePreparedStatement.execute
    (OraclePreparedStat
    ement.java)
    at TestOracle.main(TestOracle.java:27)
    My Oracle7 manual states that LONG columns can store 2GB of text.
    I tried the above with LONG RAW columns and it worked fine.
    Can anyone explain why I get this error? I've tried it with
    different sizes and when the data is <2000 bytes it works fine
    for LONG columns.
    My table is simple:
    create table TestLongs (key INTEGER PRIMARY KEY, data LONG);
    My Java code is also very simple:
    public class TestOracle
    public static void main(String[] args)
    Connection con = null;
    PreparedStatement pstmt = null;
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    con = DriverManager.getConnection(
    "jdbc:oracle:thin:@itchy:1526:test",
    "System", "<OMITTED>");
    byte[] data = new byte[2500];
    for (int i=0; i< 2500; i++)
    data[i] = 53;
    String sql = "INSERT INTO TestLongs (key, data)
    VALUES(1, ?)";
    pstmt = con.prepareStatement(sql);
    ByteArrayInputStream bis = new ByteArrayInputStream
    (data);
    pstmt.setAsciiStream(1, bis, data.length);
    pstmt.execute();
    catch (SQLException e)
    System.err.println("An error occurred with the
    database: " + e);
    e.printStackTrace();
    catch (Exception e)
    System.err.println("Oracle JDBC driver not found." +
    e);
    e.printStackTrace();
    finally
    try
    if (pstmt != null)
    pstmt.close();
    if (con != null)
    con.close();
    catch (SQLException e)
    System.err.println("Unable to close
    statement/connection.");
    null

    Robert Greig (guest) wrote:
    : I am trying to stream data to a LONG column. I'm using Oracle
    : Server 7.3.2.3.0 on AIX and JDBC driver 8.0.4 on Windows NT 4
    : SP5.
    I tried it with the old 7.3.x JDBC driver and it works fine. I
    also noticed after further testing that it sometimes worked
    with the 8.0.4 driver. Looks like a bug in the 8.0.4 driver or
    some wacky incompatibility.
    null

  • Streaming data into LONG results in ORA-24307

    I am migrating an application to a new environment. During testing I am receiving the following error when trying to insert a record into an Oracle 8.1.7.4 table:
    Error saving report: update BlobPiece osetpi(): ORA-24307: invalid length for piece
    The table has a column defined as LONG. I am using a prepared staement and setAsciiStream to perform the insert. I have been able to determine that the error happens when the data being streamed exceeds 4000 bytes (i.e. 4001 bytes).
    Connection to the table is made by using a datasource with the ORACLE_OCI driver. If I change the connection to use an Oracle thin driver, the insert is performed (code provided below).
    I would prefere not to change the connection method if possible. Any help resolving this problem would be appreciated. Thanks.
    Here is the insert code being used:
    public void create(SavedReportImpl report, String userId)
    throws ReportManagerException {
    StringBuffer sql = new StringBuffer();
    // NOTE: Must utilize a prepared statement since this insert contains
    // an Oracle Long column type
    java.sql.PreparedStatement statement = null;
    String modelCd = report.getModel().getModelCd().toUpperCase();
    if (modelCd.length() != 7) {
    modelCd = " " + modelCd;
    sql.append("INSERT ");
    sql.append("INTO ");
    sql.append("PRCT012 ");
    sql.append("(");
    sql.append("MODL_YR_NBR, ");
    sql.append("PRICE_CD, ");
    sql.append("MDSNG_MODL_DESGTR, ");
    sql.append("EFFECTIVE_DT, ");
    sql.append("REPORT_TP, ");
    sql.append("REPORT_SUBTP, ");
    sql.append("RESTRICTION, ");
    sql.append("PRICE_DESC, ");
    sql.append("VEHICLE_LINE, ");
    sql.append("MODL_DESC, ");
    sql.append("CURRENCY_CD, ");
    sql.append("CURRENCY_NM, ");
    sql.append("SOP_INDCTR, ");
    sql.append("LAST_UPDT_USERID, ");
    sql.append("LAST_UPDT_TMSTM, ");
    sql.append("REPORT_HTML_STRING) ");
    sql.append("VALUES (" );
    sql.append("'" + report.getModel().getModelYear() + "', ");
    sql.append("'" + report.getPriceCd().toUpperCase() + "', ");
    sql.append("'" + modelCd + "', ");
    sql.append("'" + dateFormatter.formatDatetoDBDateString(report.getEffectiveDate()) + "', ");
    sql.append(report.getReportType() + ", ");
    sql.append(report.getReportSubtype() + ", ");
    if (report.getModel().getRestriction() == null || report.getModel().getRestriction().length() == 0) {
    sql.append("NULL, ");
    } else {
    sql.append("'" + report.getModel().getRestriction().toUpperCase() + "', ");
    sql.append("'" + report.getPriceCdDescription() + "', ");
    sql.append("'" + report.getModel().getVehicleLine().toUpperCase() + "', ");
    sql.append("'" + report.getModel().getDescription() + "', ");
    sql.append("'" + report.getCurrency().getCurrencyCd().toUpperCase() + "', ");
    sql.append("'" + report.getCurrency().getCurrencyNm() + "', ");
    sql.append(report.isSOP() ? "'Y', " : "'N', ");
    sql.append("'" + userId.toUpperCase() + "', ");
    sql.append("'" + dateFormatter.formatDatetoDBDateTimeString(new java.util.Date()) + "', ");
    sql.append("?) "); // LONG COLUMN TO BIND
    //NOTE: only bind one column when there is an ORACLE LONG
    try {
    statement = connection.prepareStatement(sql.toString());     
    String html = com.eds.csdd.util.StringUtils.replaceAll(report.getHTML(), "'", "''");
    byte[] bytes = html.getBytes();
    java.io.InputStream is = new java.io.ByteArrayInputStream(bytes);
    statement.setAsciiStream(1, is, bytes.length);
    int resultCode = statement.executeUpdate();
    } catch (java.sql.SQLException sqle) {
    throw new ReportManagerException(sqle.getMessage());
    } catch (Exception e) {
    e.printStackTrace();
    throw new ReportManagerException(e.getMessage());                    
    } finally {                                   
    if (statement != null) {
    try { statement.close(); } catch (java.sql.SQLException re) {}
    Here is the connection code using the datasource:
    public java.sql.Connection getConnection(String dataSourceName) throws java.sql.SQLException {
    javax.naming.InitialContext               dsCTX          = null;
    javax.sql.DataSource               ds1          = null;
    java.sql.Connection                    conn          = null;
    String dataSource = rte.getProperty(dataSourceName, "datasource","datasourcenotfound");
    try {
         dsCTX = new javax.naming.InitialContext();
         ds1 = (javax.sql.DataSource)dsCTX.lookup("java:comp/env/" + dataSource);
    } catch (javax.naming.NamingException e){
         throw new java.sql.SQLException("Naming Exception:" + e.getMessage());
    if (ds1 == null)
         throw new java.sql.SQLException("datasource not provided");
    else
         conn = ds1.getConnection();
    return conn;
    Here is the connection code using the thin driver:
    public java.sql.Connection getConnection(String dataSourceName) throws java.sql.SQLException {
    java.sql.DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
    // open a connection to the database
    java.sql.Connection conn = java.sql.DriverManager.getConnection (
                             "jdbc:oracle:thin:@###.##.###.###:1521:SID",
                             "userid",
                             "password");
    return conn;
    }

    Robert Greig (guest) wrote:
    : I am trying to stream data to a LONG column. I'm using Oracle
    : Server 7.3.2.3.0 on AIX and JDBC driver 8.0.4 on Windows NT 4
    : SP5.
    I tried it with the old 7.3.x JDBC driver and it works fine. I
    also noticed after further testing that it sometimes worked
    with the 8.0.4 driver. Looks like a bug in the 8.0.4 driver or
    some wacky incompatibility.
    null

  • Dynamic Variable name (for int/long) from a String variable

    Hi,
    I want to give a int/long variable name from a String.
    for ex.
    String str = lookup + "Id";
    lookup is a String variable coming from XML. Now, for instance lookup="name". So str = "nameId".
    Now I want to create a int/long variable by nameId.
    Could anybody tell me the way how to do. Please don't tell to use MAP.
    Edited by: Shah on Dec 5, 2007 3:26 PM

    Well you can't. Use a Map.
    The compiler translates variable names into slot numbers, either within an object or withing the local "stack frame" and these slot numbers are assigned names at compile time. No new slots can be created at run time. Java is not Basic.
    Reflection allows you to find existing field names and methods (not local variables), so it's possible to map, for example, XML attribute names to field names or setters in an object but the names have to be known at compile time.

  • What's the best way to extract data (a substring) from a string?

    Hi,
    I have a field being returned from a function call and the data looks like this:
    sfaqwe4|89uuuroeoi0|kjg3j90493  (It's data...pipe...data...pipe...data)
    What is the best technique to use to extract the middle set of data between the two pipes?
    Is the any prewritten method to separate the data, or do I have to loop thru the field looking for the pipes, etc.?
    Thanks for your help,
    Andy

    <<Copy paste from http://careerabap.blogspot.com/2009_08_01_archive.html - user notified, points removed>>
    Hi,
    The WRITE statement is what we use to substring a field. The syntax is as follows:
    WRITE fieldname+starting_position(field_length) to variable
    The fieldname is the source (or input). The plus sign precedes the starting position of the substring.  The first position in the string is 0. Immediately after (no space) comes the length of the substring you are going to use. You can also substring the variable that you are writing the string to (the target).
    You can also use function module 'STRING_SPLIT_AT_POSITION'.
    Best Regards,
    Edited by: nihad omerbegovic on Dec 14, 2009 3:03 PM
    Edited by: Matt on Dec 20, 2009 4:13 PM

  • Can I use AppleTV to stream data (music, pictures) from a NAS and use an iPad as a remotecontrol via WLAN?

    I want to use in my home the NAS as Central-Storage for music and pictures, and send that data via AppleTV on my stereo or TV. The whole I want to control with an iPad (or iPhone), which I will use as a remote control via Wi-Fi. Is this possibel?

    Yes, you can use a network storage device for the storage of your content and use it on the Apple TV, but only as part of your iTunes library. So if your question is whether or not you can do this without using your computer or iTunes the answer is no.

  • Select data as table from xml string using xquery.

    Hi ,
    I have this xml 
    declare @xml xml
    set @xml =' <StudentsData>
    <StudentData>
    <id>1</id>
    <subjects>
    <subject>
    <subid>1</subid>
    <marks>30</marks>
    </subject>
    <subject>
    <subid>2</subid>
    <marks>40</marks>
    </subject>
    </subjects>
    </StudentData>
    <StudentData>
    <id>2</id>
    <subjects>
    <subject>
    <subid>1</subid>
    <marks>30</marks>
    </subject>
    <subject>
    <subid>2</subid>
    <marks>40</marks>
    </subject>
    </subjects>
    </StudentData>
    </StudentsData>'
    select @xml
    I wan the output to be shown as
    id subid marks
    1 1 30
    1 2 40
    2 1 30
    2 2 40
    how can i do this using XQUERY in sqlserver ?.
    Thanks in advance for any help.

    how can i do this using XQUERY in sqlserver ?
    Sure you can and it's easy:
    declare @xml xml
    set @xml =' <StudentsData>
    <StudentData>
    <id>1</id>
    <subjects>
    <subject>
    <subid>1</subid>
    <marks>30</marks>
    </subject>
    <subject>
    <subid>2</subid>
    <marks>40</marks>
    </subject>
    </subjects>
    </StudentData>
    <StudentData>
    <id>2</id>
    <subjects>
    <subject>
    <subid>1</subid>
    <marks>30</marks>
    </subject>
    <subject>
    <subid>2</subid>
    <marks>40</marks>
    </subject>
    </subjects>
    </StudentData>
    </StudentsData>'
    select students.Rows.value('subid[1]', 'int') AS id
    ,students.Rows.value('marks[1]', 'int') AS marks
    FROM @xml.nodes('/StudentsData/StudentData/subjects/subject') AS students(Rows)
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • JAXB: Read XML data from a String?

    Hi,
    I get XML data not from file but as a string and I wanted to use JAXB to parse it and get my Java Objects.
    The unmarshall methods wants an "InputStream", but "StringBufferInputStream" is deprecated, so that I don't know a way to use my String as InputStream.
    Can someone give me a hint other then writing the data in a file first?

    Hi FrankSch,
    The unmarshall methods wants an "InputStream", but
    "StringBufferInputStream" is deprecated, so that I
    don't know a way to use my String as InputStream.
    Can someone give me a hint other then writing the data
    in a file first?Yes, the class StringBufferInputStream is deprecated, and the deprecation notice reads:
    Deprecated. This class does not properly convert characters into bytes. As of JDK 1.1, the preferred way to create a stream from a string is via the StringReader class.
    The JDK API usually mentions an alternative to the deprecated method/class and in this case, you should use java.io.StringReader. It has one constructor and should suite you nicely:
    StringReader(String s) That way, you get an InputStream object; you can now use JAXB.
    Hope this helps,
    -ike, .si

  • Streaming data from cRIO

    Hi everybody,
    This is quite a general question and I am looking for some pointers\opinions\suggestions.
    I want to stream data from several channels at diffferent rates from my cRIO to the host PC. As far as I can see there are three options:
    1)  Use a network shared variable (NSV) for each channel and read them in a loop on the host PC.
    2)  Use one NSV which uses a cluster of an enum and variant. In this case the enum specifies which channel (and therefore data type) the packet contains and the variant contains the data.
    3)  Use STM to stream the data over the network using TCP/IP
    These are my questions/thoughts:
    1)  not very scaleable as each NSV has to be read individually also just seems messy!
    2)  Seems nice and clean and scaleable, multiplexes the data into one channel. I am aware NSVs are not quite as efficient as directly using STM TCP/IP  BUT... is there an additional (significant) overhead converting all the data to variant?
    3) According to the documentation on NSVs using TCP/IP is the fastest way to stream the data. This method seems to offer the same avantages as (2) - clean, multiplexes the data. BUT it does add complexity in developing the cod. Also the data is still flattened to string, is this much different than converting to a variant?
    THE QUESTION: is method (2) a reasonable compromise if the absolute highest data rates are not required?
    Many thanks,
    Steve.

    Hi Steve,
    I have been looking into this problem for you. It seems that each of the three options you highlighted could be used to achieve your goal though since you want to stream multiple channels method 1 would be highly inefficient and therefore should not be considered for this application. I would suggest that method 3 which uses TCP/IP to stream the data over the network is the optimal solution in this case though as you have alluded to, this does add a level of complexity. If you decide to pursue this option I have found a really useful link provides more details about this methodology and a LabVIEW example which should help you get started with the coding. I have also found this link to a forum which may be of interest to you (especially the final post by Kurt).
    I would also like to add that I completely agree with Brian K, in that I believe method 2 is a very acceptable compromise, especially if high data rates are not necessary. 
    I hope this helps.
    Best Regards,
    Christian Hartshorne
    Applications Engineering
    National Instruments

  • Retrieve data from a string.

    I want to write a SQL script to retreive data between the third "|" and the forth "|" from a string:
    Example:
    String = 'H000319|VI|12|20000|20000|4201840007403429,09/2008,442667,,|'
    The result should be 20000.
    String = 'H000319|HK|0|11860|11860||'
    The result should be 11860.
    Many thanks!

    With INSTR you can search for the n'th occurence of a character like this:
    select substr('H000319|HK|0|11860|11860||'
                 , instr('H000319|HK|0|11860|11860||', '|', 1, 3 ) + 1
                 , length('H000319|HK|0|11860|11860||') - instr('H000319|HK|0|11860|11860||', '|', 1, 4 ) - 2
                ) from dual

  • Conversion failed when converting date and/or time from character string

    Hi experts,
    I'm trying running a query in Microsoft Query but it gives the following error message:
    "conversion failed when converting date and/or time from character string"
    when asks me the data I'm inserting 31-01-2014
    i've copy the query form the forum:
    SELECT T1.CardCode, T1.CardName, T1.CreditLine, T0.RefDate, T0.Ref1 'Document Number',
         CASE  WHEN T0.TransType=13 THEN 'Invoice'
              WHEN T0.TransType=14 THEN 'Credit Note'
              WHEN T0.TransType=30 THEN 'Journal'
              WHEN T0.TransType=24 THEN 'Receipt'
              END AS 'Document Type',
         T0.DueDate, (T0.Debit- T0.Credit) 'Balance'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')<=-1),0) 'Future'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>=0 and DateDiff(day, T0.DueDate,'[%1]')<=30),0) 'Current'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>30 and DateDiff(day, T0.DueDate,'[%1]')<=60),0) '31-60 Days'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>60 and DateDiff(day, T0.DueDate,'[%1]')<=90),0) '61-90 Days'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>90 and DateDiff(day, T0.DueDate,'[%1]')<=120),0) '91-120 Days'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>=121),0) '121+ Days'
    FROM JDT1 T0 INNER JOIN OCRD T1 ON T0.ShortName = T1.CardCode
    WHERE (T0.MthDate IS NULL OR T0.MthDate > ?) AND T0.RefDate <= ? AND T1.CardType = 'C'
    ORDER BY T1.CardCode, T0.DueDate, T0.Ref1

    Hi,
    The above error appears due to date format is differnt from SAP query generator and SQL server.
    So you need convert all date in above query to SQL server required format.
    Try to convert..let me know if not possible.
    Thanks & Regards,
    Nagarajan

  • Trying to get a date value from a string

    Hi All,
    I'm not sure I am doing this right, so I figured I would ask the experts...
    I have built a file upload page that is working the way I need it, but I have found that I need to determine the date from the uploaded file name. I tried to create a PL/SQL computation and do some substr / instr to the filename, but I'm not getting it as I get "ORA-01843: not a valid month" error. Here is the code I'm trying:
    declare
      v_underscore  integer;
      v_date            varchar2(15);  --have also tried using date datatype...
    begin
      v_underscore := INSTR(:P20_EXPRESS,'_',1,1);
      v_date := to_date(substr(:P20_EXPRESS,v_underscore + 1,6),'YYMMDD');
      return v_date;
    end;And here is a sample filename:
    F15047/proc_10607161001.csv
    Is this the best way to achive what I'm trying to do?
    Thanks,
    Corey

    Hi,
    v_underscore := INSTR(:P20_EXPRESS,'_',1,1);
    v_date := to_date(substr(:P20_EXPRESS,v_underscore + 1,6),'YYMMDD');What this is saying is:
    Get the position of the "_" character
    Move to the next character to the right (which is a "1" in your case)
    Get 6 characters (106071) from the string value
    Convert them to a date using the format 'YYMMDD'
    This results in:
    Year: 10
    Month: 60
    Day: 71
    Which of course is not valid.
    For example:
    select
      substr('F15047/proc_10607161001.csv', instr('F15047/proc_10607161001.csv', '_', 1, 1) + 1, 6)
    from
      dual;
    SUBSTR
    106071It looks like you want to move two positions to the right rather than a single position:
    select
      substr('F15047/proc_10607161001.csv', instr('F15047/proc_10607161001.csv', '_', 1, 1) + 2, 6)
    from
      dual;
    SUBSTR
    060716Hope that helps a bit,
    Mark

  • Error "Conversion failed when converting date and/or time from character string" to execute one query in sql 2008 r2, run ok in 2005.

    I have  a table-valued function that run in sql 2005 and when try to execute in sql 2008 r2, return the next "Conversion failed when converting date and/or time from character string".
    USE [Runtime]
    GO
    /****** Object:  UserDefinedFunction [dbo].[f_Pinto_Graf_P_Opt]    Script Date: 06/11/2013 08:47:47 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE   FUNCTION [dbo].[f_Pinto_Graf_P_Opt] (@fechaInicio datetime, @fechaFin datetime)  
    -- Declaramos la tabla "@Produc_Opt" que será devuelta por la funcion
    RETURNS @Produc_Opt table ( Hora datetime,NSACOS int, NSACOS_opt int)
    AS  
    BEGIN 
    -- Crea el Cursor
    DECLARE cursorHora CURSOR
    READ_ONLY
    FOR SELECT DateTime, Value FROM f_PP_Graficas ('Pinto_CON_SACOS',@fechaInicio, @fechaFin,'Pinto_PRODUCTO')
    -- Declaracion de variables locales
    DECLARE @produc_opt_hora int
    DECLARE @produc_opt_parc int
    DECLARE @nsacos int
    DECLARE @time_parc datetime
    -- Inicializamos VARIABLES
    SET @produc_opt_hora = (SELECT * FROM f_Valor (@fechaFin,'Pinto_PRODUC_OPT'))
    -- Abre y se crea el conjunto del cursor
    OPEN cursorHora
    -- Comenzamos los calculos 
    FETCH NEXT FROM cursorHora INTO @time_parc,@nsacos
    /************  BUCLE WHILE QUE SE VA A MOVER A TRAVES DEL CURSOR  ************/
    WHILE (@@fetch_status <> -1)
    BEGIN
    IF (@@fetch_status = -2)
    BEGIN
    -- Terminamos la ejecucion 
    BREAK
    END
    -- REALIZAMOS CÁLCULOS
    SET @produc_opt_parc = (SELECT dbo.f_P_Opt_Parc (@fechaInicio,@time_parc,@produc_opt_hora))
    -- INSERTAMOS VALORES EN LA TABLA
    INSERT @Produc_Opt VALUES (@time_parc,@nsacos, @produc_opt_parc)
    -- Avanzamos el cursor
    FETCH NEXT FROM cursorHora INTO @time_parc,@nsacos
    END
    /************  FIN DEL BUCLE QUE SE MUEVE A TRAVES DEL CURSOR  ***************/
    -- Cerramos el cursor
    CLOSE cursorHora
    -- Liberamos  los cursores
    DEALLOCATE cursorHora
    RETURN 
    END

    You can search the forums for that error message and find previous discussions - they all boil down to the same problem.  Somewhere in your query that calls this function, the code invoked implicitly converts from string to date/datetime.  In general,
    this works in any version of sql server if the runtime settings are correct for the format of the string data.  The fact that it works in one server and not in another server suggests that the query executes with different settings - and I'll assume for
    the moment that the format of the data involved in this conversion is consistent within the database/resultset and consistent between the 2 servers. 
    I suggest you read Tibor's guide to the datetime datatype (via the link to his site below) first - then go find the actual code that performs this conversion.  It may not be in the function you posted, since that function also executes other functions. 
    You also did not post the query that calls this function, so this function may not, in fact, be the source of the problem at all. 
    Tibor's site

  • SAP query error - 1). [Microsoft][SQL Server Native Client 10.0][SQL Server]Conversion failed when converting date and/or time from character string.  'Received Alerts' (OAIB)

    SAP query error - 1). [Microsoft][SQL Server Native Client 10.0][SQL Server]Conversion failed when converting date and/or time from character string.  'Received Alerts' (OAIB)
    SELECT    
    CASE WHEN T0.DocStatus = 'O' THEN 'OPEN'
    WHEN T0.DocStatus = 'C' THEN 'CLOSED'  END  AS 'Document Status',
    T0.DocDate AS 'Posting Date',
    T0.DocNum AS 'Doc.No',
    T0.NumAtCard,
    T0.TransId AS 'Trans. No.',
    T0.Comments AS 'Remarks',
    T0.CardCode AS 'Offset Acct',
    T0.CardName AS 'Offset Acct Name',
    sum(T0.DocTotal) + (T0.WTSum) as 'DocTotal',
    T3.DueDate AS 'Cheque Date',
    T3.CheckSum AS 'Amount'
    FROM         ODPO AS T0 LEFT OUTER JOIN
                          VPM2 AS T1 ON T0.ObjType = T1.InvType AND T0.DocEntry = T1.DocEntry LEFT OUTER JOIN
         OVPM AS T2 ON T2.DocEntry = T1.DocNum LEFT OUTER JOIN
                          VPM1 AS T3 ON T2.DocEntry = T3.DocNum
    where T0.DocDate>='[%0]' and T0.DocDate<='[%1]'

    Hi,
    Try this:
    SELECT   
    CASE WHEN T0.DocStatus = 'O' THEN 'OPEN'
    WHEN T0.DocStatus = 'C' THEN 'CLOSED'  END  AS 'Document Status',
    T0.DocDate AS 'Posting Date',
    T0.DocNum AS 'Doc.No',
    T0.NumAtCard,
    T0.TransId AS 'Trans. No.',
    T0.Comments AS 'Remarks',
    T0.CardCode AS 'Offset Acct',
    T0.CardName AS 'Offset Acct Name',
    sum(T0.DocTotal) + (T0.WTSum) as 'DocTotal',
    T3.DueDate AS 'Cheque Date',
    T3.CheckSum AS 'Amount'
    FROM         ODPO  T0 LEFT OUTER JOIN
                          VPM2  T1 ON T0.ObjType = T1.InvType AND T0.DocEntry = T1.DocEntry
    LEFT OUTER JOIN
         OVPM  T2 ON T2.DocEntry = T1.DocNum LEFT OUTER JOIN
                          VPM1  T3 ON T2.DocEntry = T3.DocNum
    where T0.DocDate >= '[%0]' and T0.DocDate <='[%1]'
    group by T0.DocStatus,T0.DocDate ,
    T0.DocNum ,
    T0.NumAtCard,
    T0.TransId ,
    T0.Comments ,
    T0.CardCode,
    T0.CardName ,
    T0.WTSum ,
    T3.DueDate ,
    T3.CheckSum
    Thanks & Regards,
    Nagarajan

  • Stream data from a subvi to the main vi

    Hi
    I’m wondering if someone can help me. I’m trying to stream data from a sub vi to the main vi without opening and closing the sub vi continuously. The data also needs to be extracted from a while loop within the sub vi.  background info: The sub vi controls a photomultipler tube, which once it is on it is best kept on. The PMT signal is generated in while loop of the sub vi. Attached are some basic vis showing what I’m trying to do.
    Thanks
    Attachments:
    Main page.vi ‏11 KB
    test2.vi ‏13 KB

    If you are streaming measurements continously I would consider using a circular buffer instead of the queued producer/consumer approach.
    Check out this implementataion of such a buffer, use only this if your DAQ device does not have an internal circular buffer.
    https://decibel.ni.com/content/docs/DOC-20403
    Alternatively if you are using a DAQmx device, consider using the device buffer for sharing DAQ data between loops.
    Br,
    /Roger

Maybe you are looking for