I want to insert a variety of SQL queries into a Trino table as a VARCHAR.
There are a multitude of items that throw errors for example single quotes, keywords like "table" being a column name, -- SQL comments that throw errors when Trino is reading the SQL INSERT query.
Is there a data type where I can just dump string type data that may contain things like keywords, SQL comments, single quotes? Trying VARCHAR doesn't seem to be the answer.
I have confirmed that the view returns the correct data when on the SQL Server. But when pulling the raw view through Oracle some of the string columns only contain 1 character for each record, while other columns are fully populated.
Does anyone know what could cause this issue?
The fields that had cutoff characters were NVARCHAR(50). Apparently, Oracle does not pull NVARCHARs correctly from SQL Server. Casting them as VARCHAR(50) in the SQL Server view solved the problem.
I am exploring oracle 12c for storing json data in a json aware clob column named METADATA. My existing data in that column looks something like this:
{
"com.xyz.abc.key": {
"key_a": "value_a",
"key_b": ["value_b_1", "value_b_2", "value_c_2"]
}
}
The problem is that if I were to construct a query using JSON_VALUE
JSON_VALUE(METADATA ,'$.com.xyz.abc.key.key_a')
then I rightly get null as result as oracle will interpret a different json path. I tried escaping characters but that also doesn't work.
I went through oracle's whitepaper on this topic but it doesn't cover this case.
I need help in correctly constructing my SQL/JSON query in this case.
Edit
Solution : '$."com.xyz.abc.key".key_a' is the correct way for doing this.
When I run a select query on an informix database using Teradata Sql Assistant all the text fields are null. But when I use another database manager like DBeaver, using a select query on the same table, I get values in the text fields. Has anyone else encountered this issue? if yes, how did you fixed it?
Thanks for the help!
I had similar issues today, try converting the text column to varchar in your select.
SELECT CAST(txt_column As VARCHAR(8000))
I've converted a bunch of DML (INSERT/UPDATE/DELETE) queries from Oracle into PostgreSQL and now I need to check whether they produce the same set of rows, i.e. that delete removes the same rows, assuming the oracle and postgresql databases contain the same data initially, update updates the same rows etc. On PostgreSQL side, I can use the returning clause with DML statements, i.e.
INSERT INTO test(id, name) VALUES(42, 'foo') RETURNING *;
What's good about the statement above is that I can prepend 'returning *' to any DML statement without knowing the structure or even the name of the table it's executed against and just get all rows like it's a select statement.
However, it seems to be not that shiny on the Oracle side. According to the documentation, Oracle 8i (the one I'm working with) supports RETURNING clause, but it has to store the result into variables and there seem to be no obvious way to get all result columns instead of manually specifying the column name.
Hence, the question is if there is an oracle statement (or sequence of statements) to emulate PostgreSQL 'returning *' without hard-coding table or column names. In other words, is there a way to write an Oracle function like this:
fn('INSERT INTO test(id, name) VALUES(42, ''foo'')')
It should return the set of rows inserted (or modified in the generic case) by the SQL statement.
Update:
I actually found a very similar question (for the conversion from SQL server, not PostgreSQL, into Oracle). Still, I'd love to hear a more simple answer to that if possible.
I could imagine a solution involving EXECUTE IMMEDIATE, RETURNING, and REF CURSOR, but clearly it will be far from simple. I've previously found solutions such as this one, involving XML to problems where records of arbitrary type are to be used. They're quite freaky, to say the least. I guess you'll have to resort to running two separate queries... Specifically, with Oracle 8i, I'm afraid you won't even be able to profit from most of those features.
In short, I don't think there is any SQL construct as powerful as Postgres ... RETURNING clause in Oracle.
It's not currently possible, especially in an old version of Oracle such as 8i. See this answer to a similar question.