Determine datatypes in recordset

I know how to determine the datatypes of an existing table in
MS SQL Server (via sp_columns), but for any given recordset, is
there a way to determine datatypes? Users will submit arbitrary
SQL, so I'll have no idea what tables are referenced unless I parse
a complicated SQL statement.

bmwm3smg,
I sure hope
arbitrary SQL doesn't include delete or drop statements..
Try the queryColumnTypes function. It might help.
http://www.cflib.org/udf.cfm?ID=1411

Similar Messages

  • How to determine whether a recordset is Empty or not ?

    Please see my snippet code below :
    <%     
         String sql="";
         String username="CDS";
         try
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                Connection con = DriverManager.getConnection("jdbc:odbc:Employees","","");
                Statement stmt = con.createStatement();
                ResultSet rs=null;
                   sql = "Select * from Employee where code='" + username + "'";
                   rs = stmt.executeQuery(sql);
                   rs.next();
                   if (rs==null)
                   %>
                        <jsp:forward page="Login.jsp?msg=Username not recognized"></jsp:forward>     
                   <%     
                else
                   %>
                        <jsp:forward page="Login.jsp?msg=Halo"></jsp:forward>
                   <%
              catch(ClassNotFoundException e)
                   out.println("Driver not found");
                    catch(SQLException e2)
                            out.println(e2.getMessage());
                            out.println("<BR>");
                            out.println("Wrong SQL Statement");
                            out.println("<BR>");
                            out.println(sql);
                            out.println("<BR>");
         %>How to determine whether a recordset has no result ?
    From the above code, i use if (rs==null) and that's not worked.
    Help me, guys.

    ResultSet rs = stmt.executeQuery(sql);
    if (rs.next()) {
    %>
        <jsp:forward page="Login.jsp?msg=Halo"/>
    <%
    } else {
    %>
        <jsp:forward page="Login.jsp?msg=Username not > recognized"/>
    <%
    }

  • Determine datatype

    Hii,
    i am trying write some code to transfer data from csv file to a database.
    my problem is to determine the datatype of various column values in the csv file. I read the csv file column wise and have to determine what datatype each col. contains, so to map it to correct type for creating tables in the DB.
    Can someone provide me any reference for determining datatype of a col. value read from csv file, (my google search couldn't yield exact results); i can't figure out how should i determine the type of each column data
    thanks

    bit confused now, here is an example csv file
    21.10.2003;6;0.99;Feb 96;1
    22.10.2003;5;0.99;Feb 66;1
    23.10.2003;10;0.99;Feb 34;1
    24.10.2003;3;1;02. Jun;1i parse the values and each value can be returned as
    String[]
    nothing can said for sure, how to determine whether
    its int, or float or date :-|
    best way: is to let user decide it?I would say so yes. If you have a particular format that you know in advance you can code for that.... but to dynamically identify the column type??
    It will be tricky. For example look at the dates. How many SimpleDateFormats are you going to try to parse before giving up and concluding that it is a String or even a number. (Because a database timestamp column will look just like a number)
    And for numerics... it's an even bigger nightmare. Because first you can look for decimal places... but is the column signed or unsigned? What about the size of the field... what if the first few rows are all ones and twos and the last row has a number like 10786568769.
    I just don't see how you can practically code for EVERY situation.
    Look even at what an existing tool like Access does. It makes some guesses but often you have to tell it or convert the data after it has loaded it as strings.

  • Receiver Determination for differnet recordsets

    hi
    i 'm reading some files into the xi with the file adapter and content conversion. the result is a incoming message with some recordsets looking like this:
    MY_MT
      Record
        Row
          FieldA
          FieldB
        /Row
        Row
          FieldA
          FieldB
        /Row
      /Record
    /MY_MT
    my data is in fieldA and a flag for the receiver in fieldB (fieldB = 1 then send row to receiver 1, fieldB = 2 -> receiver 2).
    at configuration i created a receiver determination where i setup 2 different receiver services and then created a condition:
    MY_MT/Record/Row/fieldB = 1 for receiver 1
    MY_MT/Record/Row/fieldB = 2 for receiver 2
    a message like below is send to both receivers, but i just want to send all Rows with fieldB = 1 to receiver 1.
    MY_MT
      Record
        Row
          DATA
          1
        /Row
        Row
          DATA
          2
        /Row
      /Record
    MY_MT
    Is this possible?
    greets
    J.

    Hi
    As par current configuration settings, your choosing a reciver on the basis of flag.
    But same input is given to both recivers.
    What you want is hust separate the content based on flag.
    Two options:
    Conditional reciver:-
    Use two different mapping program for the same.
    In first mapping choose all DAta whose flag is one,
    and in another mapping
    Choose all the data whose flag is two.
    and wonder you will get two different outputs depending on your flag.
    Use multimapping:
    Instead of going for two mapping programs, just go for single mapping program, and just go through the blog
    /people/narendra.jain/blog/2005/12/30/various-multi-mappings-and-optimizing-their-implementation-in-integration-processes-bpm-in-xi
    Go for message instance level mapping, It is easy and one time work.....
    and wonder you will get output as
    MY_MT
    Record 
      Row   
      DATA    
    1
       /Row 
    /RecordMY_MT
    MY_MT
    Record
      Row   
      DATA    
    2  
    /Row 
    /RecordMY_MT
    Cheers
    Regards
    Piyush

  • Can I determine datatype of a control from it's reference??

        that's pretty much the question...
    for example.  if I'm using an dynamic event structure, and an event fires....  I'd like to use the control ref that is given in the event structure to determine what type of control (numeric, boolean, array, etc.) changed...
    is this possible...
    more simply, if I have a reference to a control, can I determine it's type?
    thanks
    -z   

    Thank you Darren,
        I should be more specific.  Is there any way to accomplish what I will describe below?
    I have an event structure fire on an dynamic event.  The eventData node (on the left of the structure) has several outputs including "CtlRef" and "NewVal".  For a dynamic event, the data is of type varient and must be cast into the proper type using the  "Varient to Data" function.  Unfortunately, this requires that I put a constant in the code that is equivalent to the actual data type and wire it to the "Varient to Data" function....  What I would prefer is to somehow use the "CtlRef" value and wire that into the top of the "Varient to Data" function in order to properly cast the data.
    ideas?
    thanks
    -z

  • How to determine number of records in recordset returned by stored procedure?

    In TestStand 3.0 I am calling an SQL stored procedure where the stored
    procedure returns a recordset. Everything appears to work (I can
    iterate through the recordset and see that the data is valid).
    However, I can not figure out how to easilly determine how many
    records are actually in the recordset. Unlike the 'Open SQL
    Statement' step, in the 'Data Operation' step that actually invokes
    the stored procedure, there is no 'Number of Records Selected' option
    to specify a TestStand variable to accept this value. I know I could
    iterate through the returned recordset incrementing a counter until a
    Fetch fails, but for larger recordsets, traversing the table multiple
    times would be quite time consuming
    . I am hoping to avoid this if
    possible. Is there an easier way to get the number of records in a
    recordset returned from a stored procedure call?
    Bob

    Bob -
    The cursor type of the ADO Recordset object affects whether the number of records can be determined. The Recordset.RecordCount property will return -1 for a forward-only cursor; the actual count for a static or keyset cursor; and either -1 or the actual count for a dynamic cursor, depending on the data source.
    Because ADO does not let me set the cursor type for command objects which is what a stored procedure requires, it is up to the data source to determine the type of cursor and the support for record count.
    Scott Richardson (NI)
    Scott Richardson
    National Instruments

  • Reciever file adapter configuration for Deep structure

    Hi Experts,
                     I have a idoc to file scenario in which i used a data type for file in below format:
    DT_Test
    -->Recordset(0.unbounded)
    >E21DPU1(0.unbounded)
    >field1
    >field2
    >E21DPU5(0.unbounded)
    >filed 3
    >filed 4
    >E21DP03(0.unbounded)
    >filed 5
    >filed 6
    Here DT_test is datatype name,Recordset is a structure name which contain E21DPU1, E21DPU5,E21DPO3 stucture inside it.Now,E21DPU5 and E21DPO3 structures are under E21DPU1.
    I am confused in creating content conversion parameters i.e what we have to mention in Recordset Stucture .
    I used E21DPU1,,E21DPU5,,E21DP03,* .should it work for deep structure.
    Thanks
    Deepak

    Hi,
    file adapter does not handle 2 level deep structures
    the easiest way to do it now is to go for abap or java mapping
    and create a line for each of the output lines and handle this in the file adapter
    so like <line> </line>
    <line>E21DPU1(0.unbounded) with fields </line>
    <line>E21DPU5(0.unbounded) with fields </line>
    <line> etc. </line>
    Regards,
    Michal Krawczyk

  • Receiver FCC Problem

    Hi all,
    My Scenario is IDOC to File.
    My Requirment is to produce the Sample Text File as
    f1*f2*f3
    f4*f5*f6
    f7*f8*f9
    f4*f5*f6
    f7*f8*f9
    f4*f5*f6
    f7*f8*f9
    Here Body1, Body2 Values are coming in alternative side.
    Based on the Occurences of E1MARAM Segments, We should have as many as Body1 , Body2 Values repeated as an alternative node.
    But I am getting the Output as
    f1*f2*f3
    f4*f5*f6
    f4*f5*f6
    f4*f5*f6
    f7*f8*f9
    f7*f8*f9
    f7*f8*f9
    Here Body1,Body2 Values are grouped together.
    I Created the Datatype as
    RecordSet
        Header    1-1
          f1,f2,f3
        Body1     0-unbounded
          f4,f5,f6
        Body2     0-unbounded
          f7,f8,f9
        Is there Any Possible Solution to have Alternate Segments Body1,Body Values in text File.
    Thanks
    Gabriel

    Hi Gabriel,
    Change the Structure in data type as
    RecordSet
        Header    1-1
          f1,f2,f3
        Body         0-unbounded
          Body1     0-1
           f4,f5,f6
          Body2     0-1
           f7,f8,f9
    so that you can get alternative values, as Body repeats as many times as your condition is true.
    in FCC, provide the RecordSet Structure as Header,Body1,Body2
    Thanks & Regards,
    Pragathi.

  • Dreamwever CS5 ERROR server behavior panel cannot determine wheter "command" or "recordset (Query)"

    i get this error whenever i open pages created in CS4. ive tried deleting the cache file... deleting the entire configuration folder and letting DW re build it.. nothing... error still there. how can i turn it off? i also cant seem to find the "edit server behaviors" button.. double click? well DW freaks out with that aswell... yes i know i have some insanely hand edited code.. basically use DW as notepad replacement.. with extra features like having the option of "add recordset" then going and editing it to my liking.
    the error
    [quote]
    The server behavior panel cannot determine whether "command" or "recordset (Query)" is applied to your page. Please select edit Server Behaviors and change one of the two behaviors to ensure that each is uniquely identifiable.
    [/quote]
    this is a total show stopper for me.. im going to have to go back to a previous version cant click "ok" every time i open a page.. and every time i follow a include file.
    development ASP
    Dreamweaver CS5
    Question.. how to disable the error message from popping up? i'll take my chances with hand editing the recordset / command by hand if i need it changed.

    this is bleh... having to resort back to CS4..
    is there any way to legaly go back to cs4 dreamweaver but still use the other cs5 applications?

  • The Server Behavior panel cannot determine whether "Command" or "Recordset (Query)" ...

    Suddenly getting this goofball message in DW5.5 on Win7:
    "The Server Behavior panel cannot determine whether "Command" or "Recordset (Query)" is applied to your page. Please select Edit Server Behaviors and change one of the two behaviors to ensure that each is uniquely identifiable."
    Crazy thing is, it only happens on my workstation.
    DW5.5 on my laptop opens the same .asp pages without this crazy message popping up.
    Anybody know what the issue is?

    I'd suggest that no answer means no answer yet. The person who can help may not have been on the forum the day the post was made.
    That said, I'm starting to suspect that the cause must be an extension. Both boxes have the same version of DW and the same OS but both don't have the exact same extensions installed. Will play around and see what happens.

  • To Determine Unicode Datatype encoding

    Hi,
    Going through the Oracle documentation found that Oracle Unicode datatype (NCHAR or NVARCHAR2) supports AL16UTF16 and UTF8 Unicode encodings.
    Is there a way to determine which encoding is being used by Oracle Unicode datatypes thorugh OCI interface?
    Thanks,
    Sachin

    That's a rather hard problem. You would, realistically, either have to make a bunch of simplifying assumptions based on the data or you would want to buy a commercial tool that does character set detection.
    There are a number of different ways to encode Unicode (UTF-8, UTF-16, UTF-32, USC-2, etc.) and a number of different versions of the Unicode standard. UTF-8 is one of the more common ways to encode Unicode. But it is popular precisely because the first 127 characters (which is the majority of what you'd find in English text) are encoded identically to 7-bit ASCII. Depending on the size and contents of the document, it may not be possible to determine whether the data is encoded in 7-bit ASCII, UTF-8, or one of the various single-byte character sets that are built off of 7-bit ASCII (ISO 8859-15, Windows-1252, ISO 8859-1, etc).
    Depending on how many different character sets you are trying to distinguish between, you'd have to look for binary values that are valid in one character set and not in another.
    Justin

  • Error "codepage could not be determined for the receiver-system"

    Hi,
    we use the idoc-adapter to send message from mySAP ERP to PI.
    All worked fine.
    So, this morning I have changed the datatype of the messageId from "char" to "int" in mySAP ERP in the customizing menue (install param). So, no message received in SAP PI.
    When I start transction "we05" in mySAPERP" I get the following error:
    "codepage could not be determined for the receiver-system" status 02.
    I have changed the datatyp to "char" but the same probleme
    Can anybody help me please?
    Regards
    Stefan

    This error shouldn't occur unless there is some modification at the OS level codepages.
    Please check the entried in the RFC destination for connecting to the XI system. Unicode settings.
    Regards,
    Prateek

  • Using long vs. clob datatype with Oracle 8.1.7 and interMedia

    I am trying to determine the best datatype to use for a column I
    wish to search using the interMedia contains() function. I am
    developing a 100% java application using Oracle 8.1.7 on Linux.
    I'd prefer to use the standard JDBC API's for PreparedStatement,
    and not have to use Oracle extensions if possible. I've
    discovered that there are limitations in the support for LOB's
    in Oracle's 100% java driver. The PreparedStatement methods
    like setAsciiStream() and setCharacterStream() are documented to
    have flaws that may result in the corruption of data. I have
    also noticed that socket exceptions sometimes occur when a large
    amount of data is transferred. If I use the long datatype for
    my table column, the setCharacterStream() method seems to
    transfer the data correctly. When I try to search this column
    using the interMedia contains() function, I get strange
    results. If I run my search on Oracle 8.1.6 for Windows, the
    results seem to be correct. If I run the same search on Oracle
    8.1.7 for Linux, the results are usually incorrect. The same
    searches seem to work correctly on both boxes when I change the
    column type from long to clob. Using the clob type may not be
    an option for me since the standard JDBC API's to transfer data
    into internal clob fields are broken, and I may need to stick
    with standard JDBC API's. My customer wishes to purchase a
    version of Oracle for Linux that will allow us to implement the
    search capability he requires. Any guidance would be greatly
    appreciated.

    I've finally solved it!
    I downloaded the following jre from blackdown:
    jre118_v3-glibc-2.1.3-DYNMOTIF.tar.bz2
    It's the only one that seems to work (and god, have I tried them all!)
    I've no idea what the DYNMOTIF means (apart from being something to do with Motif - but you don't have to be a linux guru to work that out ;)) - but, hell, it works.
    And after sitting in front of this machine for 3 days trying to deal with Oracle's, frankly PATHETIC install, that's so full of holes and bugs, that's all I care about..
    The one bundled with Oracle 8.1.7 doesn't work with Linux redhat 6.2EE.
    Don't oracle test their software?
    Anyway I'm happy now, and I'm leaving this in case anybody else has the same problem.
    Thanks for everyone's help.

  • Help with multiple recordsets and pulling an ID value (ASP)

    I started this discussion when first developing my project and posted on the General Tab.  I have figured out that issue (trying to get my Insert to work in ASP) but now am having trouble retrieving an ID value.  It should be simple.  I want to insert a new record into a single table and want to create a unique ID field.  I am using SQL Server and tried the Identity setting but won't be able to have admin privileges which are required to set the ID.  So, I'd like to just take the ID value from the last record and just add '1' to it to get a new unique ID manually. My INSERT portion was working, so I just decided to query the records to retrieve the last CatalogID and add '1' to get my new ID.  But it's not working!  I tried opening both a command and a recordset, but get various errors on invalid command use. 
    Any help would be great!  I'm new to all of this!
    I've posted a code snippet of what I thought I should do:
    <%LANGUAGE = “VBSCRIPT” CODEPAGE=”65001”%)
    <!--#include file=”Connections/CapConnect.asp”” -->
    <%
    If (Cstr(Request(“MM_insert”)) = “form1”) Then
                    Dim MM_editCmd
                    Dim MM_Lookup
                    Dim NextCatalogID
                    Set MM_Lookup = Server.CreateObject (“ADOB.Recordset”)
                    MM_Lookup.ActiveConnection = MM_CapConnect_STRING
                    MM_Liikup.Source = “Select CatalogID From dbo.tblCatalogItems ORDERBY CatalogID Ascending”
                    MMLookup.Open
                    MM_Lookup.MoveLast
                    NextCatalogID = MM_Lookup.Fields(“CatalogID”) + 1   'this is supposed to be my new ID value
                    Set MM_Lookup = Nothing
                    Set MM_editCmd = Server.CreateObject(“ADOB.Command”)
                    MM_editCmd.ActiveConnection = MM_CapConnect_STRING
                    MM_editcmd.CommandText = “INSET INTO dbo.tblCatalogItems (CatalogID, ModelName, Description, POCName, [POCPhone]) VALUES (NextCatalogID, ?,?,?,?)
                    MM_editcmd.Prepared = True
                    MM_edit.Parameters.Append MM_editcmd.CreateParameter(“param2”, 202, 1, 100, Request.Form(“modelname”) )
                  MM_edit.Parameters.Append MM_editcmd.CreateParameter(“param3”, 202, 1, 300, Request.Form(“Description”) )
    [Subject line edited by moderator to add server model]

    Ok, you've got lots of problems. First, explain again why you are not able to modify the CatologID to be an identity column? What is the datatype of that column now?
    Next, you are going about selecting your recordset incorrectly. If you are just looking for the last value inserted, there is no need to return all values to the recordset. Just select the max value:
    MM_Liikup.Source = “Select MAX (CatalogID) From dbo.tblCatalogItems”
    Next, you have a typo in your insert statement "“INSET INTO" should be "INSERT INTO"
    Next, your CommandText is wrong. There is no ending quote, and NextCatalogID will be treated as a string literal, not a variable. Use a ? placeholder for it and use the CreateParameter method to populate it.
    Next, your command text includes 4 placeholder, but you are only populating 2.
    But even when you get this to work it will be problematic. What happens when 2 users execute this at the same time? They both read the same value for the max record and increment by one, but the first will succeed and the second will fail. That's why it is always better to use an auto increment (Identity) column.

  • How do I copy recordsets from one database table to another?

    I am using the Database Connectivity Toolset, and would like to copy either one recordset or multiple recordsets from one Access table to a table in a different database. I would like to do it directly with the data in variant form, but I can't get it to work. I can get it to work(on a small test table) if I first convert my source variant data to a cluster, then insert that into the other database table. My real database has many items with a variety of date types. Can I copy directly variant to variant?

    Is it necessary to read all the data back into LabVIEW first? The reason I'm asking is that it is much more efficient to just use SQL statements to get the data you need and write that directly to the second database. I did a quick Google search on it and came up with lots of responses on what the correct syntax is for setting that up. Using an SQL command to copy the data back and forth is analogous to copying data from one file to another using the Copy file function rather than reading the entire contents of the file, converting the file string to the data arrays, converting back to a string, and then writing it back to another file.
    Chapter 5 of the Database Connectivity Toolset User Manual describes how to execute SQL queries.
    If you do need to actually
    see the data in LabVIEW first, then the only way to get it back into the other database is to convert those variants to LV datatypes and then cluster those values again and write them back out to the second database.

Maybe you are looking for

  • How to find if a Purchase order is in change mode

    Hi Experts,                  I am struck with a problem in my pr po approval web dynpro application. Using this application users can approve a po, but if the same po is being editing by some one at the same time, we should display an error message.

  • Live video input into thunderbolt 2?

    For an AV job, I used to have a video camera plugged into the Firewire 400 port on a Mac Mini (mid 2012) into a program called ProPresenter for live video feed. I recently upgraded to the Mac Pro (Late 2013). There's no Firewire port, so I have two a

  • Please tell me why error is comming in select query

    Hello Experts... please tell me why the error is comming at mblnr in s_mblnr.and also tell me the solution for the same.   SELECT a~mblnr          a~bwart          a~matnr          a~werks          a~lifnr          a~menge          b~budat          I

  • Showing pictures iphone 4 only portrait mode

    Hi, when I look at pictures in my Ipone 4 they only show up in portrait mode. It vill not work "turning the phone" showing the pictures in landscape. This goes as well for writing sms etc, only possible in portrait mode. ANy idea about the problem an

  • Jrickit 8.1 not running in SuSE Pro v8.1

    Hello: When trying to execute java -version in my just installed JRockit 8.1 on SuSE 8.1 Pro, I receive an error messaging related to a missing libbfd.so shared file, mentioning that there is no suuport for pthreads on this distribution. What can I d