This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Deserialize XML object in T-SQL
I got an XML object, and i want to deserialize him into a table using T-SQL.
<Params>
<paramtype type = '1'>
<value> abc</value>
</paramtype>
<paramtype type = '2'>
<value> 123</value>
</paramtype>
</Params>
How can i store all this data into a table like this:
You can get the values like this
select
x.v.value('#type','int') as [type],
x.v.value('.','varchar(50)') as [value]
from
#x.nodes('/Params/paramtype') x(v)
where #x is your XML object.
and insert them into a table with an identity for the ID (or use row_number() to generate one)
Related
I have a custom UDF called getCityStats(string city, double distance) which takes 2 arguments and returns an array of JSON strings ( Objects) as follows
{"zipCode":"90921","mode":3.54}
{"zipCode":"91029","mode":7.23}
{"zipCode":"96928","mode":4.56}
{"zipCode":"90921","mode":6.54}
{"zipCode":"91029","mode":4.43}
{"zipCode":"96928","mode":3.96}
I would like to process them in a KSQL table creation query as
create table city_stats
as
select
zipCode,
avg(mode) as mode
from
(select
getCityStats(city,distance) as (zipCode,mode)
from
city_data_stream
) t
group by zipCode;
In other words can KSQL handle tuple type where an array of Json strings can be processed to return as indicated above in a table creation query?
No, KSQL doesn't currently support the syntax you're suggesting. Whilst KSQL can work with arrays, it doesn't get support any kind of explode function, so you can reference specific index points in the array only.
Feel free to view and upvote if appropriate these issues: #527, #1830, or indeed raise your own if they don't cover what you want to do.
I've done some online reading but can't seem to find an answer to what I'm looking for. It may be because I'm approaching this the wrong way.
I am using Oracle 10g.
I have table xyz with columns:
recID- VARCHAR type
XML- CLOB type
The XML column contains xml and html tags. ie.
<Employee><firstName>John</firstName>
<EmpDesc><![CDATA[<p>I like to live by Ghandi's motto: Be the <strong>change</strong> you want to see</p>]]</EmpDesc>
</Employee>
An index was created:
create index myIndex on xyz(xml) indextype is ctxsys.context
When I perform the query below, I don't get the result I'm expecting, because one of the words is enclosed in html tags.
SELECT * from xyz where contains(xml, 'be the change you want to see')>0;
*Note that the string can exist in any node so inpath may not be a suitable option.
Is there a way to create an index to ignore html tags so that a result is returned?
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Get sum of two columns in one LINQ query without grouping
how to select Max and Count in one call using EF?
Select Max([Column]), Count(*) from [Table]
I think you can fake it grouping by 0. SQL Server will see through that constant group-by and eliminate it. It has no runtime cost.
The question is: Will EF translate this to SQL properly? Given the track record (in contrast to good old trusty LINQ to SQL!) this is in doubt.
Select query doesn't work for JSON in OrientDB. Can someone provide with a working example showcasing two things:
Inserting JSON data correctly
Querying JSON data
Thanks!
1.Use "content" to implement JSON insert.
For Example-
insert into Person content {"name":"nawab","age":25}
for this to run,you must have prior configuration as-
1.Create a Vertex by-
create class Person extends V
2.Then Create Property name and age
create property Person.name string
create property Person.age integer
Here you go! I have been trying to figure this out for a while now and finally got it to work. :)
Run the following sql commands as displayed:
create class EXAMPLE
/* The trick is: Do not 'CREATE' the property with any type */
insert into EXAMPLE (my_prop) values ({"name": "James", "age": 23})
insert into EXAMPLE (my_prop) values ({"name": "Harden", "age": 24})
/* Fetch the fields inside the JSON */
select my_prop.name from example
select my_prop.age from example where my_prop.name like 'James'
I read this example from the book: Getting Started with OrientDB By Claudio Tesoriero
Hope it helps!
This question continues in the OrientDB group here. Have you tried if everything work?
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Reading and writing images to an SQLite DB for iPhone use
How to store pdf,png file in sqlite.
is this possible to store pdf and png file?
Please help me out.
if you have any idea please share with me.
Thanks you,
There is a BLOB data type so I guess you can:
http://www.sqlite.org/datatype3.html
You can store a PDF or PNG file in a BLOB field.
first create the table
create table Blubber ( PK int primary key , BITSINK blob );
then use insert to add the data.
insert into Blubber (PK,BITSINK)
values (1, 'your blob goes here, best to use bind variables though!');
Tell us what language you are using for advice how to use bind variable.
EDIT just saw this is taged iPhone, the language would be the appropriate C dialect (objective c??)