Crystal Report: Call stored procedure using sql expression - stored-procedures

Apologies if this shouldn't be asked here, but I'm desperately wanted to know if it's possible to call a stored procedure from sql expression in Crystal Report.
Thank you so much!

You can call a function. Stored procedure does not return anything.

Related

Access Violation on Accessing a UserSession in Intraweb

I'm new to IntraWeb and have a problem.
In order to implement a Login Form, i stored Datasets in the Usersession.
But when it comes to access the Datasets i get an Access Violation Error.
I figured out, that the Useresession is not created. Now i'm a bit confused, because in the Intraweb Documentary it is said, that the Usersession is created automatically by the ServerController.
I access (respectively want to) the Dataset like this
UserSession.Dataset.open;
I use the IntraWeb Trial included in Rad Studio XE5. May that be the Problem?
In case, that this is not the Problem, how can i create a Usersession manually?
Thank you very much
[Edit 13.4.16]
The problem was the Evaluation Version I used. After installing the Full Version my problem vanished. They changed their Usersession.create procedure by adding another Parameter. So make sure you use the actual Version if u have the same Problem:
Thanks for all the responses
You need to create the 'data' inside session
procedure TIWServerController.IWServerControllerBaseNewSession(
ASession: TIWApplication; var VMainForm: TIWAppForm);
begin
ASession.Data := TUserSession.Create;
end;
be aware that in this example
TUserSession
is an user defined class
type
TUserSession = class
public
UserCount: Integer;
end;
take a look at this tutorial which explains how the sessions management is done in IW - http://etutorials.org/Programming/mastering+delphi+7/Part+IV+Delphi+the+Internet+and+a+.NET+Preview/Chapter+21+Web+Programming+with+IntraWeb/Building+IntraWeb+Applications/
or consult the technical documentation provided by atozed.
I tried adding just a comment, apparently I need more points for that.
The answer will be found if you go into the response given by RBA, but here is the short form:
IW does create and manage the user session automatically. The TIWUserSession, however, is only your part of that. In order to have your own data in the session, .Create the TIWUserSession and add it as the .Data of the session. In IWServerControllerBaseNewSession do this with:
ASession.Data := TIWUserSession.Create(nil, ASession);
Note that the ASession parameter of the procedure is the session managed by IW.
In order to access your TIWUserSession, create a procedure in ServerController:
function UserSession: TIWUserSession;
begin
Result := TIWUserSession(WebApplication.Data);
end;
Expose that procedure in the interface section.
Dan
It occurred to me that we might be "solving the wrong problem".
You indicated that this occurred when you were implementing a login form. You also indicated that a break set in WServerControllerBaseNewSession() did not hit.
In ServerController, do you have "AuthBeforeNewSession" set to True? If so, set it to False and see if the behavior changes.
Dan

How to retrieve attribute info from a normal Delphi procedure

The answer to Which language elements can be annotated using attributes language feature of Delphi? suggests that it is possible to add attributes to ordinary procedures and functions. My question is how can one retrieve that information given the string name of the procedure or function?
[myProcAttribute('Some useful info')]
procedure myProc;
begin
// Do something
end;
Given the string 'myProc' I would like to retrieve the associate attribute.
I'm using XE6
The article you link to says:
There's no way of retrieving any sort of RTTI for "unit" level or local variables and procedures, hence no way of retrieving information about attributes.
I believe that this is correct. The documentation lists a number of methods for TRttiContext. These are:
Create
DropContext
FindType
Free
GetPackages
GetType
GetTypes
KeepContext
These give you means to locate types, but not procedures. Once you locate a type you can enumerate its methods, but that's no use to here because you want to find a procedure rather than a method.

How to expose Stored Procedure in Teiid OData

I have created a virtual procedure in JBoss Teiid ,i want to call it using odata protocol.
I have tried to call it by
.....url/odata/PROCEDURE NAME
It is not working .
Can anyone please tell me the corect syntax to call stored procedure in odata.
I believe this will work:
http://127.0.0.1:8080/odata/<vdbname>/FunctionImportName?Parameter1Name='Parameter1Value'&Parameter2Name='Parameter2Value'
Try locahost:8080/odata/vdbname/FunctionInportName(Parameter1Name=Parameter1Value, Parameter2Name=Parameter2Value)

Code sample for freeing advantage database server table

I have a set of tables that were included in an Advantage Database data dictionary. The dictionary is no longer available, and the tables will not open.
I would like to free those tables using code (not the Advantage Data Architect).
The only reference I can find to this is a function listed in the help called ADSDDFreeTable.
The documentation for the function is at this link:
http://devzone.advantagedatabase.com/dz/WebHelp/Advantage11.1/index.html?ace_adsddfreetable.htm
but it does not offer a code sample, and I cannot understand how to use it.
Would anyone be kind enough to show a code sample of how this function is used (with variables, not literals, for file names, etc)
Thanks very much!
Ace.pas defines AdsDDFreeTable as
function AdsDDFreeTable( pucTableName: PAceChar;
pucPassword: PAceChar ):UNSIGNED32; {$IFDEF WIN32}stdcall;{$ENDIF}{$IFDEF LINUX}cdecl;{$ENDIF}
The same Ace.pas defines PAceChar:
type
PAceChar = PAnsiChar;
Therefore, the call to the function should be fairly straightforward:
var
TableName: AnsiString;
begin
TableName := 'C:\Data\MyTable.adt`;
if AdsDDFreeTable(PAnsiChar(TableName), nil) <> ADS_FREETABLEFAILED then
ShowMessage('Table removed from datadictionary')
else
// Call ADSGetLastError to retrieve reason for failure;
end;
In addition to #Ken's solution (+1), there is also a standalone command line utility named freeadt.exe that will free ADT tables from their associated data dictionary. I believe it is installed with Advantage Data Architect.
If you run it from the command line with no parameters, it displays usage information. In general, though, you can give it a folder name (to process all the tables) or a specific file as a parameter.

Get list of object's methods, properties and events?

When trying a new component for which there's no documentation, I need to go through its methods, properties, and events to try to figure out what it can do. Doing this through the IDE's Object Inspector is a bit tedious.
Is there a utility that presents this list in a more readable format?
Thank you.
When I want to know what something can do, I read the source code. The class declaration will contain a succinct list of all the methods and properties, unless there is a lot of inheritance. The definitions will tell you want the methods do.
Another thing is to declare a variable of the type you're interested in, type its name and a period, and then press Ctrl+Space to let Class Completion show you everything you can do.
As the others said, use the source. Also an UML tool will help.
But if you don't want to use this, you can use this procedure (you need Delphi 2010 for this, and be sure to add RTTI to your 'Uses' clause):
procedure DumpProps(aObject: TObject; aList: TStringList);
var
RttiContext: TRttiContext;
RttiType: TRttiType;
I: Integer;
n: integer;
props: TArray<TRttiProperty>;
begin
aList.Clear; //it must be <> nil
RttiType := RttiContext.GetType(aObject.ClassType);
props:=RttiType.GetProperties;
with aList do
begin
Append('');
Append('==========');
Append('Begin Dump');
Append('----------');
for I := Low(props) to High(props) do
begin
try
Append(props[i].Name+': '); //odd construction to see if the Getter blows
n:=Count-1;
Strings[n]:=Strings[n]+props[i].GetValue(aObject).AsString;
except
on E: Exception do
Strings[n]:=Strings[n]+' >>> ERROR! <<< '+E.Message;
end;
end;
end;
end;
The above you can use either at run-time, either if you build a Menu Wizard, you can have your info at design time.
HTH
You can use the Class Browser that comes with GExperts.
I would also recommend to build a Model diagram with the IDE or ModelMaker. It helps to see the visual relations.
In the immortal words of Obi Wan Kenobi -- "Use the source".
There is no substitute for reading and understanding the source code of a component (or anything) to understand what it does and what it is up to.
Source code is the Lingua Franca of programming.
Look at the .hpp that is generated for C++Builder support. It resembles the interface section of a Delphi unit.
I just use code completion. If you can't figure out what the component does from the names of the properties and methods, then it's probably poorly designed anyway, and you're better off not using it. Also, since you're asking the question, I'm guessing you do not have the source. If you don't, again, I wouldn't use the component. You're only storing trouble for yourself.
There is RTTI...

Resources