How to pass Datatable as Ref_Cursor into Oracle Procedure? - stored-procedures

How to pass Data table as Ref_Cursor into Oracle Procedure ? I am using ODP.NET and Oracle 10g client in my development box.

Related

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.

Change a FireDAC query SQL string from DataSnap client

I have set up a client connecting to a DataSnap Server in Delphi XE7. I need to send a SQL string created on the client to the server to be executed against a Firebird DB. I am using FireDAC, but I get similar results if I use DB Express.
I have TFDPhysFBDriverLink -> TFDConnection -> TFDQuery -> TDataSetProvider on the server.
I have TSQLConnection -> TDSProviderConnection -> TClientDataSet -> TDataSource -> DBGrid on the client
The TFDQuery seems to require a SQL.Text value at design time. (e.g. select * from Cust_Master) I can send the SQL string (e.g. select * from Proj_Master) back to the server fine and load it into the TFDQuery, and if I check the rows affected before and after I change the SQL.Text, I get the right number of rows returned for the customers and the projects queries. The problem is that on the client side, I only get the results of the design time SQL i.e. customers, not the SQL I sent to the server i.e. projects being displayed in the grid. I do call ClientDataSet.Refresh after sending the SQL to the server.
I need to be able to send various SQL queries back to the server, I can't have them all defined at design time. Am I using the right components to achieve this?
You have to close and reopen the ClientDataSet. A simple Refresh won't do.
You need to set DSServer's lifecycle to Invocation or create the FBQuery directly in the ServerMethods' class function. I recommend the second one though.
Check TDataSetProvider->Options->poAllowCommandText is checked

How to connect Active Reports 7 to use a stored procedures?

How to connect Active Reports 7 to use a stored procedures? I have stored procedures already written, but how do you connect to them to use the data in the tables so that my report is dynamic.
ActiveReports 7 has two different report types, with slightly different ways of using stored procedures.
If you are using a SectionReport (i.e. the traditional form of report that was available in ActiveReports 6) then you can execute a stored procedure via the EXEC SQL command in your query. f.e.
EXEC sp_mysp '<%myparameter%>'
In a PageReport (i.e. the new report type introduced in ActiveReports 7) then you need to set the command type to Stored Procedure and then the query string is set to the name of your stored procedure. If you have any parameters to pass then you can pass them in via the DataSet's parameters page.
In PageReports when working with the ADO.NET based data providers (SQL Server, OLE DB, and Oracle connection types) there is a 1-to-1 correlation between objects in the data source, data set, and parameters in Page Reports and what you see in the related ADO.NET *Connection, *Command, and *Parameter classes. So if you have questions about how those work you can just look at how you would write the same code with the ADO.NET classes.

delphi oracle blob

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.

Resources