How to read BLOB from oracle db? - sql

I'm trying to read BLOB data in the form of string from oracle db using sql developer.
This is the query that I'm using :
select utl_raw.cast_to_varchar2(dbms_lob.substr(BLOB_COL,2000)) from BLOB_TABLE where BLOB_ID= 997600;
But the output what I get is machine readable format and not text.
Any suggestions on how to change this query?

Run the query, just query the BLOB column.
Double click on the cell.
Check the 'text' value.
Voila.

Related

SQL Server select query output shows as "???????"

I got an email from my senior, to update a table column in SQL server.
In the mail they mentioned the data to update.
But when I copied the below mentioned content and used select query in SQL Server it results in "??????" characters.
Landmark : 𝚗𝚎𝚊𝚛 𝚔𝚘𝚙𝚊𝚕 𝚔𝚒𝚍𝚜 𝚌𝚘𝚕𝚕𝚊𝚐𝚎,𝚋𝚑𝚊𝚠𝚛𝚊𝚜𝚕𝚊
select 'Landmark : 𝚗𝚎𝚊𝚛 𝚔𝚘𝚙𝚊𝚕 𝚔𝚒𝚍𝚜 𝚌𝚘𝚕𝚕𝚊𝚐𝚎,𝚋𝚑𝚊𝚠𝚛𝚊𝚜𝚕𝚊'
I tried varbinary, ASCII conversion in SQL server and tried to format the data using word and excel but nothing works for me.
To my knowledge I think the data is in image format.
Please help me with this issue.
Note: I can simply type the content and update, but for my curiosity I want to know how to fix this issue.

Oracle convert blob to string

I would like to convert a blob of an oracle db to an readable string.
I have tried some functions, but none of them worked for me.
In the end I tried to convert the string via sql statement like:
SELECT CONVERT(CAST(blob as BINARY) USING utf8) as blob FROM tablewithblob
Can anyone tell me, what I am doing wrong? The error of the sqldeveloper is "missing right paranthesis. Thanks in advance!
The CONVERT(value USING charset) function is a mysql function, not Oracle
https://www.w3schools.com/sql/func_mysql_convert.asp
Take a look at this instead
https://docs.oracle.com/cd/B28359_01/server.111/b28286/functions027.htm
But it looks like DBMS_LOB is a better way to do what you're doing in Oracle. Go check out How do I get textual contents from BLOB in Oracle SQL

Encrypting the output using select statement on oracle database

Updated question:
I am working with scenario where the source oracle schema do not have a field say "Date of Birth" saved in encrypted format but when using select statement I want output to be in encrypted format. I do not know the version of the oracle to find the appropriate function in the documentations.
I have worked with MySQL and I am familiar with "password()" function.  I am looking for similar function for Oracle in SQL not PL/SQL as I cannot use that in the application I am using it should be one line query to fetch the results. I tried using DBMS_CRYPTO as per the documentation https://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_crypto.htm#i1004271 but I am getting error fetching data on my application could be possible that DB version may not be supporting DBMS_CRYPTO.
Any other suggestion on which function can be used to display non-encrypted field in encrypted format when using select on Oracle(thin) query?

How to store database value in text file. Select statement return null

Hi I am quite new to robot framework, and I am trying to obtain database result via select statement and store into a .txt file.
I am able to connect to my database and execute my select statement, however the return value for my select statement is 'NONE'.
Execute Sql String SELECT BTH_N FROM BAS_BERTH_APPLN_MASTER WHERE ABBR_VSL_M='APL';
Any idea on how to solve the select statement issue and how I can store that value in a .txt file?
Thank you.
Are you using an SQL Script?
If not, you can use the Query Keyword.
https://franz-see.github.io/Robotframework-Database-Library/api/0.5/DatabaseLibrary.html#Query
${result}= Query SELECT BTH_N FROM BAS_BERTH_APPLN_MASTER WHERE ABBR_VSL_M='APL'
A solution to store the result in a .txt file : How to write a variable into a file?

Teradata Sql Assistant not showing text in the query result view

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))