How to insert array to Firebird table field using sql? - sql

I have that table:
create table t_place(
f_plc_timefrom time,
f_plc_timeto time,
f_plc_minute_cost Decimal(18,4)[24]
);
So, I can create array field, but I don't know, how can I fill in this array field in SQL code. I tryed to find way in many sources, but I could find nothing. I need your help.

AFAIK one can work with arrays only via API, there is no SQL syntax for that.

There is virtually no array support in Firebird in the query and procedural language. As ain says there is only some support via the API. Removal of the array functionality is on the table as well. See also ticket CORE-710.

Related

calling values in a database using column name in sqlite

I have a sqlite database with rows of planets name and column having the mass, radius and so on.
Is there a way to call the mass of earth in the form as Earth.mass or something similar in python?
I have very little knowledge of SQL as I have just started out learning SQL just for this project, so sorry if this is a silly question.
The Python SQLite module has a connection object that has a row factory attribute. But don't just blindly copy the example given! Instead, follow their advice, and use the provided Row class.

GridGain/ Ignite query list data type

I'm trying to figure out how to work with a list datatype in a Gridgain query, I have an object which has a field
#QuerySqlField private final List<Integer> expertGroupIds; that I can receive during selects but I can't manage to create an update query on the list, and can't find anywhere what is the correct syntax while working from the Gridgain sqlline client.
Also, what I'm finally trying to achieve is to have a select query that will find all objects where expertGroupIds has at least one element similar to a list receive as a parameter (basically I need to check if the 2 lists have any intersections)
Thanks for your help!
You can't is the short answer. There's no way to filter (a WHERE clause) or update it from SQL.
But you can if you normalise it, as you would with a traditional relational database.

SQL correct Uppercase and Lowercase in mixed text

I have a database with lots of text that are all in capital letters and now should be converted into normal lower/upper case writing. This applies to technical stuff, for example
CIRCUIT BREAKER(D)480Y/277VAC,1.5A,2POL
This should be written circuit breaker(D)480Y/277VAC,1.5A,2POL
I think the only Approach is to have a list of word with the correct spelling and then do something like a Search & Replace.
Does anybody can give me a clue to Approach this in MS SQL?
You could do one of two things -
Write a simple script (in whichever language you are comfortable - eg: php, perl, python etc.,) that reads the columns from the DB, does the case-conversion and updates the values back into the DB.
The advantage of this would be that you will have greater flexibility and control on what you want to modify and how you wish to do it.
For this solution to work, you may need to maintain a dict/hash in the script, having the mapping of upper-case to lower-case keyword mapping.
The second probable solution, if you do not wish to write a separate script, would be to create a SQL function instead, that reads the corresponding rows/columns that need to be updated, performs the case-conversion and writes/updates it back into the DB.
This might be slightly inefficient, depending on how you implement the function. But it takes away the dependency of writing another script for you.
For this solution to work, you may need to maintain another table having the mapping of upper-case to lower-case keyword mapping.
Whichever you are more comfortable with.
Create a mapping table for dictionary. It could be temporary table within a session. Load the table with values and use this temporary table for your update. If you want this to be permanant solution to handle new rows coming in, then have permanent table.
CREATE TABLE #dictionaryMap(sourceValue NVARCHAR(4000), targetValue NVARCHAR(4000));
CREATE TABLE #tableForUpdate(Term NVARCHAR(4000));
INSERT INTO #dictionaryMap
VALUES ('%BREAKER%','breaker'),('%CIRCUIT%','circuit');
INSERT INTO #tableForUpdate
VALUES ('CIRCUIT BREAKER(D)480Y/277VAC,1.5A,2POL');
Perform the UPDATE to #tableForUpdate using WhileLoop in TSQL, using #dictionaryMap.

How to execute a sql query in jscript/jscript.NET

First at all sorry for my English, this is not my native language. So.
I want to execute a SQL query in a script to get some data. I don't know if it's possible and if so, how to make it. To summarize :
The script add a button in M3 Smart Office (a ERP). I already done that.
When i select a row in a M3 function (like an article, or a client) i want to take and send his ID (and some other data) to a website.
They're is a lot of function in M3. In each function, they're are some field who contains a data. One of them contain the ID of the object (An article, a client,...). What i want to do, is to get this ID. The problem is that the field who contains the ID doesn't have the same name in all the function. So, i have two solutions :
Do a lot of if/elseif. Like "if it's such function, take such field". But if I (or somebody else) want to add a combination function/field later i (or somebody else ;) )need to do that in the script. It's not practical.
Create a sql table wich contain all the combination function/field. Then is the script, i do a sql query and i get all the data that the script need.
So here the situation. Maybe you have ideas to do that otherwise (without sql) and i take it !
Please see this in depth tutorial from the 4guysfromrolla site:
Server-Side JScript Objects

How to update an SQLite database with a search and replace query?

My SQL knowledge is very limited, specially about SQLite, although I believe this is will be some sort of generic query... Or maybe not because of the search and replace...
I have this music database in SQLite that has various fields of course but the important ones here the "media_item_id" and "content_url".
Here's an example of a "content_url":
file:///c:/users/nazgulled/music/band%20albums/devildriver/%5b2003%5d%20devildriver/08%20-%20what%20does%20it%20take%20(to%20be%20a%20man).mp3
I'm looking for a query that will search for entries like those, where "content_url" follows that pattern and replace it (the "content_url") with something else.
For instance, a generic "content_url" can be this:
file:///c:/users/nazgulled/music/band%20albums/BAND_NAME/ALBUM_NAME/SONG_NAME.mp3
And I want to replace all these entries with:
file:///c:/users/nazgulled/music/bands/studio%20albums/BAND_NAME/ALBUM_NAME/SONG_NAME.mp3
How can I do it in one query?
P.S: I'm using Firefox SQLite Manager (couldn't find a better and free alternative for Windows).
You are probably looking for the replace function.
For example,
update table_name set
content_url = replace(content_url, 'band%20albums', 'bands/studio%20albums')
where
content_url like '%nazgulled/music/band_20albums/%';
More documentation at http://sqlite.org/lang_corefunc.html