I have a SQL database where one of the value is a XML string.
Now I'm trying to write a search function to check is it xml string contains a searchstring.
Standard SQL command would be like this:
SELECT
[ID], [DisplayName], [XML_String],
[CreatedTime], [ModifiedTime]
FROM
[Simple_SQL_DB].[dbo].[Simple_Table]
WHERE
CAST(XML_String AS nvarchar(max)) LIKE "%SearchString%"
FROM
Simple_Table
ORDER BY
ModifiedTime DESC)
ORDER BY Displayname
I tried something like this:
private SimpleTableEntities db = new SimpleTableEntities ();
var query = db.Simple_Table
.Where(w => w.XML_String.Cast<string>().Contains("%SearchString%"))
.OrderByDescending(x => x.ModifiedTime);
Unfortunately I get this error:
System.ArgumentException: 'DbExpressionBinding requires an input expression with a collection ResultType.
Can somebody help me to write a correct query?
I am trying to get the values in "ID" column of DOORS and I am currently doing this
string ostr=richtext_identifier(o)
When I try to print ostr, in some modules I get just the ID(which is what I want). But in other modules I will get values like "{\rtf1\ansi\ansicpg1256\deff0\nouicompat{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}{\f1\froman\fcharset0 Times New Roman;}} {*\generator Riched20 10.0.17134}\viewkind4\uc1 \pard\f0\fs20\lang1033 SS_\f1\fs24 100\par } " This is the RTF value and I am wondering what the best way is to strip this formatting and get just the value.
Perhaps there is another way to go about this that I am not thinking of as well. Any help would be appreciated.
So the ID column of DOORS is actually a composite- DOORS builds it out of the Module level attribute 'Prefix' and the Object level attribute 'Absolute Number'.
If you wish to grab this value in the future, I would do the following (using your variables)
string ostr = ( module ( o ) )."Prefix" o."Absolute Number" ""
This is opposed to the following, which (despite seeming to be a valid attribute in the insert column dialog) WILL NOT WORK.
string ostr = o."Object Identifier" ""
Hope this helps!
Comment response: You should not need the module name for the code to work. I tested the following successfully on DOORS 9.6.1.10:
Object o = current
string ostr = ( module ( o ) )."Prefix" o."Absolute Number" ""
print ostr
Another solution is to use the identifier function, which takes an Object as input parameter, and returns the identifier as a plain (not RTF) string:
Declaration
string identifier(Object o)
Operation
Returns the identifier, which is a combination of absolute number and module prefix, of object o as a string.
The optimal solution somewhat depends on your underlying requirement for retrieving the object ID.
I have something copied in clipboard that looks like this:
ID Name Last Name Type DOB Payment
123 Joe Doe N 05-15-75 500
Need to assign the below values to variables?
I tried this:
Dim firstclipboardtext As String
firstclipboardtext = My.Computer.Clipboard.GetText
Dim firstdictionary As New Dictionary(Of String, String)
if firstdictionary.contains("a") then
id = "b" (which would be the value of the a key)
end if
I am trying to figure out since yesterday why my table creation is not working. Since I can't link my Impala to my Hbase I can't make queries on my twitter stream :/
Do I need a special JAR like Hive for the SerDe properties ?
Here is my command:
CREATE EXTERNAL TABLE HB_IMPALA_TWEETS (
id int,
id_str string,
text string,
created_at timestamp,
geo_latitude double,
geo_longitude double,
user_screen_name string,
user_location string,
user_followers_count string,
user_profile_image_url string
)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES (
"hbase.columns.mapping" =
":key,tweet:id_str,tweet:text,tweet:created_at,tweet:geo_latitude,tweet:geo_longitude, user:screen_name,user:location,user:followers_count,user:profile_image_url"
)
TBLPROPERTIES("hbase.table.name" = "tweets");
But I got an error on: the strored by:
Query: create EXTERNAL TABLE HB_IMPALA_TWEETS ( id int, id_str string, text string, created_at timestamp, geo_latitude double, geo_longitude double, user_screen_name string, user_location string, user_followers_count string, user_profile_image_url string ) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ( "hbase.columns.mapping" = ":key,tweet:id_str,tweet:text,tweet:created_at,tweet:geo_latitude,tweet:geo_longitude, user:screen_name,user:location,user:followers_count,user:profile_image_url" ) TBLPROPERTIES("hbase.table.name" = "tweets")
ERROR: AnalysisException: Syntax error in line 1:
...image_url string ) STORED BY 'org.apache.hadoop.hive.h...
Encountered: BY
Expected: AS
CAUSED BY: Exception: Syntax error
For info, I followed this page:
https://github.com/AronMacDonald/Twitter_Hbase_Impala/blob/master/README.md
Thanks for helping me :)
Well, it seems that Impala still not support the SerDe (serialization/deserialisation).
"You create the tables on the Impala side using the Hive shell,
because the Impala CREATE TABLE statement currently does not support
custom SerDes and some other syntax needed for these tables: You
designate it as an HBase table using the STORED BY
'org.apache.hadoop.hive.hbase.HBaseStorageHandler' clause on the Hive
CREATE TABLE statement."
So, just run the command on the hive shell, or hue hive, then, in impala, type 'invalidate metadata', and then you can see your table with a 'show tables'.
So for this part the problem seems solved.
So, I'm doing like that at my controller action:
json_document = JSON(params) (json gem)
If I print json_document it gives me a Json like that:
{"createdAt":"Mar 6, 2012 6:12:54 PM","id":177139718620856322,"text":"#rgjunio where?","source":"web","isTruncated":false,"inReplyToStatusId":177139644012572673, ...
But when I try to access it:
tweet = Complaint.find_by_twitter_status json_document["inReplyToStatusId"]
i get the following error:
can't convert ActiveSupport::HashWithIndifferentAccess into String
So i tried another way using symbols:
tweet = Complaint.find_by_twitter_status json_document[:inReplyToStatusId]
but it gives me the error:
TypeError (can't convert Symbol into Integer)
Any idea?
Update:
If I use params[:inReplyToStatusId] isntead I got the following:
ActiveRecord::StatementInvalid (PG::Error: ERROR: operator does not exist: character varying = bigint
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
SELECT "complaints".* FROM "complaints" WHERE "complaints"."twitter_status" = 177144980450721794 LIMIT 1):
Try:
params[:inReplyToStatusId].to_s