delphi oracle blob - delphi

how to insert blob data into oracle xe from delphi 7 (ado component)

Check these samples using a TAdoQuery component.
loading the data directly from a file
ADOQuery1.Parameters.AddParameter.Name:='Param1';
ADOQuery1.Parameters.ParamByName('Param1').LoadFromFile('yourfilename',ftBlob);
ADOQuery1.SQL.Add('INSERT INTO TableName (FieldName) VALUES (:Param1)');
ADoQuery1.ExecSQL;
using a Stream to load the data
ADOQuery1.Parameters.AddParameter.Name:='Param1';
ADOQuery1.Parameters.ParamByName('Param1').LoadFromStream(AStream,ftBlob);
ADOQuery1.SQL.Add('INSERT INTO TableName (FieldName) VALUES (:Param1)');
ADoQuery1.ExecSQL;
you must be aware which the Microsoft Oracle oledb driver is not compatible with blob fields try instead using the Oracle OLEDB provider.
As final advice if you can, try using another components to connect to ORACLE like dbexpress, ANYDAC or the ODAC components

Be aware that Oracle has a peculiar way to handle LOBs. It uses "LOB locators" (a sort of handles) to perform operations on LOBs. An INSERT returns a LOB locator that is then used to fill the LOB, for example. That operation could be performed "behind the scenes" by the driver/library used to access Oracle, or may require some coding.

Related

How to fix the DevExpress TcxGrid GridMode using a TSQLDataSet linked to a TSQLQuery?

I'm trying to load about 500k+ data linked to an Oracle DB on my TcxGrid, I want to make the process faster using the GridView "GridMode" property, but I need to do that using a TSQLQuery (DBExpress Component) and it just doesn't work, Gridmode seems inoperable (doesn't load data faster on the Grid, doesn't load custom quantity of records using the "BufferCount" property, etc.)
Here I created a TSQLQuery component and used a query script for my 500k table (for performance purposes I just got 500 values but I need to load 500k+):
TSQLQuery
When I link the TSQLDataSet to the Grid and activate the TSQLQuery it shows all the records from the query, even if the GridMode is TRUE and the GridModeBufferCount is 5
GridWithTSQLQuery
On the other hand, when I use a TQuery, the GridMode just works properly, in this case I had to open SQL Explorer, make the connection and assign that connection to the TQuery DataBase property:
SQLExplorer
Here I show my TQuery with the values mentioned before:
TQuery
And when I activate my TQuery.. voilá:
GridWithTQuery
What I'm doing wrong? or do I need to do more things on my TSQLQuery besides linking it to my dataset and then linking the dataset to the grid?
It's impossible that a very old Tquery can do this and not a newer dbExpress component
Thank you so much guys

How to work on TFDTable(FireDAC) in Delphi XE7?

can some body provide help me to use TFDTable.FireDac is completely new for me. I have used TTable in delphi 2010 for memory database. So i would like to use TFDTable in xe7 for temporary hold.
Well you need to read up on FireDAC generally if you are completely unfamiliar with it, and look at the examples that come with recent versions of Delphi.
But if you just want to know how to copy data from a FireDAC dataset that's connected to a database to an in-memory table, you can do it very simply, like this:
procedure TForm1.btnCopyToMemTableClick(Sender: TObject);
begin
FDMemTable1.Data := FDQuery1.Data;
FDQuery1.Close; // don't need it open any more
end;
Here, FDQuery1 is a TFDQuery, which is similar to a TQuery, in that it has a SQL TStrings property to allow you to specify what Sql query to execute to retrieve the data.

Create a .mdb without MS Access or ADOX

I'm using dephi 2010, which is getting difficult with me about installing the ADOX components. So I was wondering if there is a way to create a .mdb file without the use of the ADOXCatalog.
-Thank you.
Yes, this can be done without using an ADOXCatalog.
Place a TAdoConnection and e.g. a TAdoCommand on a form or datamodule. Set the TAdoCommand's Connection property to the TAdoConnection.
Then, in the AdoConnection's ConnectionString builder, select Microsoft OLE DB Driver for ODBC. Then, follow the ODBC wizard to set up a new MDB database. As you follow that through you will be able to create a File DSN (unless you are running Delphi as adminstrator), select the Access Jet driver, specify the database path (making sure it is somewhere writeable) and name, and then the wizard presents you with a button to click to create the MDB file.
Although it is not in English, there is a video here
https://www.youtube.com/watch?v=E_2hrER9oho
which shows you exactly how to do this. The ODBC connection string wizard should give you the option to create a new datasource and present you with a list like this to choose from:
Set the TAdoCommand's CommandText to something like
create table ATable (AName TEXT(40))
and call its Execute method at r/time to create a one-column table.
Btw, you could equally well use a TAdoQuery instead of the TAdoCommand component using its Sql property instead of the TAdoCommand's CommandTextproperty, and you should be able to use any valid DDL statements to define the tables in the database.

Set up SQL Database table in Delphi with TDBGrid (Unidirectional error)

How can i set the whole table of a database to show in my delphi form? Using TDBGrid i presume; but when I configure the data source (connected to a query) I receive an error message about it being Unidirectional. I've heard about a Clientdataset but that didnt seem to work. Could i have some clear instructions on how to do this please? Thank you in advance, Toby.
You say you are using TSQLQuery. This is one of the dbExpress components which are designed to be Unidirectional only (except the TSimpleDataSet). You either have to connect the TSQLQuery to a TDataSetProvider and TClientDataSet or change your query component to one that will buffer the data locally.
To use TDataSetProvider and TClientDataSet:
Set the DataSet property of TDataSetProvider to the SQLQuery.
Set the ProviderName property of the TClientDataSet to the DataSetProvider.
When the ClientDataset is opened, it will contain the data from your SQLQuery.
Set the DataSet Property of your TDataSource to the ClientDataset so the data can be displayed in your DBGrid.
Since you appear to be new to using databases with Delphi, I would recommend you use a different query component, because using the TDataSetProvider and TClientDataSet can be complicated. I suggest
TSimpleDatSet in dbExpress,
TADOQUery or TADODataset in dbGo,
TQuery in BDE (not recommended),
TFDQuery in FireDAC, or
other third party query components.

Extract query definition from JET database via ADO

I have a program in Delphi 2010 that uses a JET (mdb) database via ADO. I would like to be able to extract the definitions of some of the queries in the database and display them to the user. Is this possible either via SQL, some ADO interface, or by interrogating the database itself (I don't seem to have rights to MSysObjects).
Some of that information is available via ADOX calls. There is an overview of the api with some examples (unfortunately not in Delphi) on the MSDN website.
Basically what you will want to do is to is to import the ADOX type library, and then use the wrapper that is generated for you to access the underlying API. From there its as simple as navigating the hierarchy to get at the data you need.
You will need to access the specific View object, and from there get the command property.
Via DAO, it's pretty easy. You just extract the SQL property of each QueryDef. In DAO from within Access, that would be:
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Set db = DBEngine.OpenDatabase("[path/name of database]")
For Each qdf In db
Debug.Print qdf.SQL
Next qdf
Set qdf = Nothing
db.Close
Set db = Nothing
I don't know how to translate that, but I think it's the simplest method once you're comfortable with using DAO instead of ADOX.
I don't use ADO at all, but I'm guessing that it has a collection of views and the SQL property would work for SELECT queries. However, if you're interested in getting the SQL for all saved QueryDefs, you'd also need to look at the DML queries, so you'd have to look at the stored procedures. I would have to look up the syntax for that, but I'm pretty certain that's how you'd get to the information via ADO.

Resources