Search Results

Search found 14 results on 1 pages for 'mycol'.

Page 1/1 | 1 

  • What are the rules governing how a bind variable can be used in Postgres and where is this defined?

    - by Craig Miles
    I can have a table and function defined as: CREATE TABLE mytable ( mycol integer ); INSERT INTO mytable VALUES (1); CREATE OR REPLACE FUNCTION myfunction (l_myvar integer) RETURNS mytable AS $$ DECLARE l_myrow mytable; BEGIN SELECT * INTO l_myrow FROM mytable WHERE mycol = l_myvar; RETURN l_myrow; END; $$ LANGUAGE plpgsql; In this case l_myvar acts as a bind variable for the value passed when I call: SELECT * FROM myfunction(1); and returns the row where mycol = 1 If I redefine the function as: CREATE OR REPLACE FUNCTION myfunction (l_myvar integer) RETURNS mytable AS $$ DECLARE l_myrow mytable; BEGIN SELECT * INTO l_myrow FROM mytable WHERE mycol IN (l_myvar); RETURN l_myrow; END; $$ LANGUAGE plpgsql; SELECT * FROM myfunction(1); still returns the row where mycol = 1 However, if I now change the function definition to allow me to pass an integer array and try to this array in the IN clause, I get an error: CREATE OR REPLACE FUNCTION myfunction (l_myvar integer[]) RETURNS mytable AS $$ DECLARE l_myrow mytable; BEGIN SELECT * INTO l_myrow FROM mytable WHERE mycol IN (array_to_string(l_myvar, ',')); RETURN l_myrow; END; $$ LANGUAGE plpgsql; Analysis reveals that although: SELECT array_to_string(ARRAY[1, 2], ','); returns 1,2 as expected SELECT * FROM myfunction(ARRAY[1, 2]); returns the error operator does not exist: integer = text at the line: WHERE mycol IN (array_to_string(l_myvar, ',')); If I execute: SELECT * FROM mytable WHERE mycol IN (1,2); I get the expected result. Given that array_to_string(l_myvar, ',') evaluates to 1,2 as shown, why arent these statements equivalent. From the error message it is something to do with datatypes, but doesnt the IN(variable) construct appear to be behaving differently from the = variable construct? What are the rules here? I know that I could build a statement to EXECUTE, treating everything as a string, to achieve what I want to do, so I am not looking for that as a solution. I do want to understand though what is going on in this example. Is there a modification to this approach to make it work, the particular example being to pass in an array of values to build a dynamic IN clause without resorting to EXECUTE? Thanks in advance Craig

    Read the article

  • How can I include DBNull as a value in my strongly typed dataset?

    - by Beska
    I've created a strongly typed dataset (MyDataSet) in my .NET app. For the sake of simplicity, we'll say it has one DataTable (MyDataTable), with one column (MyCol). MyCol has its DataType property set to "System.Int32", and its AllowDBNull property set to "true". I'd like to manually create a new row, and add it to this dataset. I create the row without a problem, with something like: MyDataSet.MyDataTableRow myRow = MySimpleDataSet.MyDataTable.NewItemRow(); Fine. However, when I try to set the value to DBNull: myRow.MyCol = DBNull.Value; I'm told that I can't do it...that it can't cast that to an int. This makes sense, in a way, since I've defined it to be an int...but then how can I get DBNull in there? Am I not supposed to be able to have DBNull in there? Isn't that what the AllowDBNull property is for? I'm obviously missing something fundemental. Can someone help explain what it is? EDIT: I also tried entering "int?" as the DataType, but Visual Studio throws an error when I enter it, saying that "Column requires a valid DataType."

    Read the article

  • Set saxon DocumentBuilderFactoryImpl features using javax.xml interface.

    - by Mycol
    Here what I have. System.setProperty( "javax.xml.parsers.DocumentBuilderFactory", "net.sf.saxon.dom.DocumentBuilderFactoryImpl"); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); //factory.setNamespaceAware(true); //factory.setIgnoringElementContentWhitespace(true); //factory.setValidating(false); //factory.setIgnoringComments(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document xml = builder.parse(file.getAbsolutePath()); Saxon parser doesn't allow me to set the commentet properties: javax.xml.parsers.ParserConfigurationException: Saxon parser does not allow whitespace in element content to be ignored at net.sf.saxon.dom.DocumentBuilderFactoryImpl.newDocumentBuilder(DocumentBuilderFactoryImpl.java:98) I thought i could set those features in other way, like factory.setAttribute(string, bool) factory.setFeature(string, bool) But I can't find anywhere the values for "string". I tried net.sf.saxon.FeatureKeys whitout success. My question is: what's the correct way to do that?

    Read the article

  • How to deal with presence or not of xml namespaces using xslt.

    - by Mycol
    I have some XML/TEI documents, and i'm writing an XSLT 2.0 to extract their content. Almost all TEI documents has no namespace, but one has the default namespace (xmlns="http://www.tei-c.org/ns/1.0"). So all documents has the same aspect, with unqulified tags like <TEI> or <teiHeader>, but if I try to extract the content, all works with "non-namespaced-documents", but nothing (of course) is extracted from the namespaced-document. So i used the attribute xpath-default-namespace="http://www.tei-c.org/ns/1.0" and now (of course) the only document working is the namespaced one. I can't edit documents at all, so what I'm asking is if there's a way to change dynamically the xpath-default-namespace in order to make work xpaths like //teiHeader both with namespaced and non-namespaced documents

    Read the article

  • How to put tags inside an html attribute?

    - by Mycol
    Using xslt i want to create an attribute: <span class="tooltip"> <xsl:attribute name="onmouseover"> <xsl:text>javascript:function(</xsl:text> <span class="label">Aggiunta</span> <xsl:apply-tempaltes/> <xsl:text>)</xsl:text> </xsl:attribute> The problem is that only the pure text is putted inside the attribute, like <span class="tooltip" onmouseover="javascript:function(Aggiunta ...)"> whithout the span tags or the tags that may come from apply-templates. So how can I put html code into an attribute?

    Read the article

  • How to make a NON-LINE based diff between two strings in Java

    - by Mycol
    I have to compare the text content of two xml elements, eg. <p>During lunch he hears strangers whispering, catching the name "Potter" and "Harry", and someone saying You-Know-Who has gone at last. </p> and <p>During dinner he hears strangers whispering, catching the name "Rossi" and "Mario", and someone saying You-Know-Who has gone at first. </p> What I'm looking for is some java libraries to make a diff between the content of paragraphs. All the tools I found makes a line diff. But they're not what I want, simply because i have no lines, but "strings" to compare. What I need is to have a char-based diff: eg. a diff that tells me something like " from the first file, remove char from 8 to 12, add the string "dinner" from char 8."

    Read the article

  • How to call an xslt transform into an xsl stylesheet

    - by Mycol
    I have written an xslt that reads some xml file names and does some operations on them. I use a for-each to work them one-by-one. I have each path inside a parameter $path. But now I would like to output the result of applying an external stylesheet to those files. I would write something like <div> <something like xsl-transform($extern-xslt,$path)> </div> to have the result tree of the transformation inside the main html output. It is possible?

    Read the article

  • Are there java libraries to do a word-based diff?

    - by Mycol
    I have two pieces of text. I would like to make a word-based diff between them (like whe unix utility wdiff does) but with more information in the output (I mean, the character's posizion where the added/delited word starts). I need to do this in Java, so a simple output of the differences (like wdiff) doesn't suite for me: I would like to manipulate objects representing differences.

    Read the article

  • What is the best approach using JDBC for parameterizing an IN clause?

    - by Uri
    Say that I have a query of the form SELECT * FROM MYTABLE WHERE MYCOL in (?) And I want to parameterize the arguments to in. Is there a straightforward way to do this in Java with JDBC, in a way that could work on multiple databases without modifying the SQL itself? The closest question I've found had to do with C#, I'm wondering if there is something different for Java/JDBC.

    Read the article

  • How To Speed Up Adding Column To Large Table In Sql Server

    - by Chris
    I want to add a column to a Sql Server table with about 10M rows. I think this query would eventually finish adding the column I want: alter table T add mycol bit not null default 0 but it's been going for several hours already. Is there any shortcut to get a "not null default 0" column inserted into a large table? Or is this inherently really slow? This is Sql Server 2000. Later on I have to do something similar on Sql Server 2008.

    Read the article

  • forcing Management Studio to use alter table instead of drop/recreate

    - by marco
    Hi! I'm wondering if is there a way to force MSSQL Management Studio to produce a script like this: ALTER TABLE Mytable ADD MyCol bit NOT NULL CONSTRAINT MyColDefault DEFAULT 0 WITH VALUES ALTER TABLE [dbo].Mytable ALTER COLUMN MyCol2 int NULL GO when I alter a very simple property of a column on a table. If I do this in the designer and ask for the produced script, the script doesn't do such simple tasks, but instead copies all the data in a tmp table, drops the original table, renames the tmp table with the original table name. And, of course, drops and recreates every constraint and relationships. Is there any option I can change to change this behaviour? Or, this may be possible, is there some danger I don't see in using the simple ALTER TABLE above? thanks.

    Read the article

  • View all ntext column text in SQL Server Management Studio for SQL CE database

    - by Dave
    I often want to do a "quick check" of the value of a large text column in SQL Server Management Studio (SSMS). The maximum number of characters that SSMS will let you view, in grid results mode, is 65535. (It is even less in text results mode.) Sometimes I need to see something beyond that range. Using SQL Server 2005 databases, I often used the trick of converting it to XML, because SSMS lets you view much larger amounts of text that way: SELECT CONVERT(xml, MyCol) FROM MyTable WHERE ... But now I am using SQL CE, and there is no Xml data type. There is still a "Maximum Characters Retreived XML" value under Options; I suppose this is useful when connecting to other data sources. I know I can just get the full value by running a little console app or something, but is there a way within SSMS to see the entire ntext column value? [Edit] OK, this didn't get much attention the first time around (18 views?!). It's not a huge concern, but maybe I'm just obsessed with it. There has to be some good way around this, doesn't there? So a modest bounty is active. What I am willing to accept as answers, in order from best-to-worst: A solution that works just as easy as the XML trick in SQL CE. That is, a single function (convert, cast, etc.) that does the job. A not-too-invasive way to hack SSMS to get it to display more text in the results. An equivalent SQL query (perhaps something that creatively uses SUBSTRING and generates multiple ad-hoc columns??) to see the results. The solution should work with nvarchar and ntext columns of any length in SQL CE from SSMS. Any ideas?

    Read the article

  • encapsulation in python list (want to use " instead of ')

    - by Codehai
    I have a list of users users["pirates"] and they're stored in the format ['pirate1','pirate2']. If I hand the list over to a def and query for it in MongoDB, it returns data based on the first index (e.g. pirate1) only. If I hand over a list in the format ["pirate1","pirate"], it returns data based on all the elements in the list. So I think there's something wrong with the encapsulation of the elements in the list. My question: can I change the encapsulation from ' to " without replacing every ' on every element with a loop manually? Short Example: aList = list() # get pirate Stuff # users["pirates"] is a list returned by a former query # so e.g. users["pirates"][0] may be peter without any quotes for pirate in users["pirates"]: aList.append(pirate) aVar = pirateDef(aList) print(aVar) the definition: def pirateDef(inputList = list()): # prepare query col = mongoConnect().MYCOL # query for pirates Arrrr pirates = col.find({ "_id" : {"$in" : inputList}} ).sort("_id",1).limit(50) # loop over users userList = list() for person in pirates: # do stuff that has nothing to do with the problem # append user to userlist userList.append(person) return userList If the given list has ' encapsulation it returns: 'pirates': [{'pirate': 'Arrr', '_id': 'blabla'}] If capsulated with " it returns: 'pirates' : [{'_id': 'blabla', 'pirate' : 'Arrr'}, {'_id': 'blabla2', 'pirate' : 'cheers'}] EDIT: I tried figuring out, that the problem has to be in the MongoDB query. The list is handed over to the Def correctly, but after querying pirates only consists of 1 element... Thanks for helping me Codehai

    Read the article

1