CREATE COMPUTE MODULE TestFlow_Compute1
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyMessageHeaders();
--CALL CopyEntireMessage();
SET OutputRoot.EmailOutputHeader.To = 'abcd123#gmail.com';
SET OutputRoot.EmailOutputHeader.From = 'xyz456#gmail.com';
SET OutputLocalEnvironment.Destination.Email.SMTPServer ='smtpout.secureserver.net:25';
DECLARE sid INTEGER InputRoot.XMLNSC.emp.eid;
DECLARE track CHARACTER InputRoot.XMLNSC.emp.etid;
DECLARE sname CHARACTER InputRoot.XMLNSC.emp.ename;
DECLARE sorg CHARACTER InputRoot.XMLNSC.emp.eorg;
DECLARE ssal INTEGER InputRoot.XMLNSC.emp.esal;
SET OutputRoot.XMLNSC.Data.Result.cty=PASSTHRU('SELECT city from ITGDB.mssusr14.collector where targetid='||track TO Database.mss);
SET OutputRoot.XMLNSC.Data.Result.id1=sid;
SET OutputRoot.XMLNSC.Data.Result.nme=sname;
SET OutputRoot.XMLNSC.Data.Result.or=sorg;
SET OutputRoot.XMLNSC.Data.Result.sl=ssal;
RETURN TRUE;
END;
CREATE PROCEDURE CopyMessageHeaders() BEGIN
DECLARE I INTEGER 1;
DECLARE J INTEGER;
SET J = CARDINALITY(InputRoot.*[]);
WHILE I < J DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I = I + 1;
END WHILE;
END;
CREATE PROCEDURE CopyEntireMessage() BEGIN
SET OutputRoot = InputRoot;
END;
END MODULE;
I used above esql code to send data to email output node, but it is not propagating.Could you please suggest me what is the mistake in the code?
I don't see a PROPAGATE call.
PROPAGATE TO TERMINAL 'out' DELETE NONE;
For Example. Hopefully this helps get you moving. I've also had to RETURN FALSE; rather than TRUE to prevent an additional message over the terminal.
Related
I am writing which component will run through the array like ['form1.Button1', 'form1.memo1', 'form1'] - like
And put the showms2 handler on it (form1.Button1.onclick: = showms2)
var
comp: array of Tcomponent;
met: Tmethod;
start off
setlength (comp, Lines.Count);
for i: = 0 to Lines.Count-1 do
start off
comp [i]: = (FindComponent (Lines.Names [i]) as TControl);
met: = GetMethodProp (comp [i], 'OnClick');
meth.Code: = form1.MethodAddress ('showms2');
met.Data: = 0;
// When splitting into elements, nothing happens, is there an alternative?
FindComponent() does not work the way you are using it. You need to specify only the name of a component that is directly owned by the component being searched, you can't specify a chain of components, ie Form1.FindComponent('Form1.Button1') won't ever work, but Form1.FindComponent('Button1') will work, if Form1 owns Button1.
Also, if you are going to set both TMethod.Code and TMethod.Data then calling GetMethodProp() is completely redundant and should be removed.
Also, you need to use SetMethodProp() to actually assign the TMethod to the target event.
Try this instead:
var
comp: TComponent;
met: TMethod;
i: Integer;
begin
for i := 0 to Lines.Count-1 do
begin
comp := FindComponent(Lines.Names[i]);
if comp <> nil then
begin
if IsPublishedProp(comp, 'OnClick') then
begin
meth.Code := Form1.MethodAddress('showms2');
meth.Data := Form1;
SetMethodProp(comp, 'OnClick', met);
end;
end;
end;
end;
I have a FDQuery that feeds data to a grid.
When the user clicks on a column I want the grid to order on that column.
Because I want to be able to sort on multiple columns, I cannot use the autosort option of the grid.
I tried the following code in my proof of concept.
However it does not work.
procedure TForm31.JvDBGrid1TitleBtnClick(Sender: TObject; ACol: Integer;
Field: TField);
const
sDesc = 1;
sASC = 2;
sNone = 0;
var
i: integer;
SortClause: string;
AField: TField;
AIndex: TFDIndex;
begin
case Field.Tag of
sDesc: Field.Tag:= sASC;
sASC: Field.Tag:= sNone;
sNone: Field.Tag:= sDesc;
end;
SortClause:= '';
FDQuery1.Indexes.BeginUpdate;
try
FDQuery1.Indexes.Clear;
for i:= 0 to JvDBGrid1.Columns.Count - 1 do begin
AField:= JvDBGrid1.Columns[i].Field;
if AField.Tag <> sNone then begin
AIndex:= FDQuery1.Indexes.Add;
AIndex.Name:= AField.FieldName;
AIndex.Fields:= AField.FieldName;
//AIndex.Options:= [soNoCase, soNullFirst, soDescNullLast, soDescending, soUnique, soPrimary, soNoSymbols]
case AField.Tag of
sDESC: AIndex.Options:= [soDescNullLast];
sASC: AIndex.Options:= [];
end;
AIndex.Active:= true;
end;
end;
finally
FDQuery1.Indexes.EndUpdate;
FDQuery1.Refresh;
end;
end;
It does not matter whether the Query already has an order by clause or not.
What am I doing wrong?
P.S. I'd rather not resort to constructing a custom order by clause but I know that's an option.
I think you may be missing a step, namely setting the FDQuery's IndexName to the name of the added index. Apparently. setting the added index's Active property is insufficient.
The following works fine for me against the MS Sql Server pubs database Authors table:
procedure TForm1.AddFDIndex;
var
AIndex : TFDIndex;
begin
AIndex := FDQuery1.Indexes.Add;
AIndex.Name := 'ByCityThenlname';
AIndex.Fields := 'city;au_lname';
AIndex.Active := True;
FDQuery1.IndexName := AIndex.Name;
end;
Btw, I'm not sure what your code is supposed to do if more than one column is tagged to be included in the index, but I'll leave that to you ;=)
I was wondering if you could help.
I'm at my wits end with this.
I want to create a function that will take one parameter.
Here is my code. I keep getting the error when run:
Error(3,19): PLS-00103: Encountered the symbol ";" when expecting one of thefollowing:
begin function pragma procedure subtype type current cursor delete exists prior external language
Code
set serveroutput on;
CREATE OR REPLACE FUNCTION CheckBookType (
p_book_type TITLES.CATEGORY
) RETURN BOOLAN IS;
BEGIN
IF (p_book_type = 'business') THEN
return true;
ELSE
return false;
END IF;
RETURN v_ReturnValue;
END CheckBookType;
Least verbose solution:
CREATE OR REPLACE FUNCTION CheckBookType (
p_book_type IN TITLES.CATEGORY%type
) RETURN BOOLEAN
IS
BEGIN
return p_book_type = 'business';
END CheckBookType;
Let's see the issues line by line in your code :
set serveroutput on;
It doesn't make any harm, but I don't see how it helps or is required in the context.
p_book_type TITLES.CATEGORY is wrong, since you need to specify that it is a constrained data type using the %TYPE attribute. The correct way is
p_book_type TITLES.CATEGORY%TYPE
Already mentioned above by others, the datatype of return value should be BOOLEAN. and you don't have to put semi-colon after "IS".
The variable to return the boolean value is NOT declared.
v_ReturnValue BOOLEAN;
Remember, using BOOLEAN data type as return will NOT let you use the function in SQL. Since, boolean is NOT a SQL data type. Boolean is PL/SQL data type. You could only use the function in PL/SQL and NOT in SQL.
Your function would look like :
Quite verbose.
CREATE OR replace FUNCTION Checkbooktype (p_book_type titles.category%TYPE)
RETURN BOOLEAN
IS
v_returnvalue BOOLEAN;
BEGIN
IF ( p_book_type = 'business' ) THEN
v_returnvalue:= TRUE;
ELSE
v_returnvalue:= FALSE;
END IF;
RETURN v_returnvalue;
END checkbooktype;
/
Or, without and ELSE, taking return default as FALSE.
Less verbose.
CREATE OR replace FUNCTION Checkbooktype (p_book_type titles.category%TYPE)
RETURN BOOLEAN
IS
v_returnvalue BOOLEAN;
BEGIN
v_returnvalue:= FALSE;
IF ( p_book_type = 'business' ) THEN
v_returnvalue:= TRUE;
END IF;
RETURN v_returnvalue;
END checkbooktype;
/
#APC's solution is least verbose.
1.this is my code i want to read a record from a text file into array in pascal my program is about making a hotel helper and i already have a text file with the data of the hotel then i should read it from the text file and store it in array .. but i am facing error 103 exit code (file not open).... any help Please . :)
program Hotel1(input,output);
const max =10; MaxFloor =10;
type
Date = record
day :1..31;
month:1..12;
year:integer;
end;
Booking = record
Guest:string[20];
S_Date:date;
E_date:date;
end;
Booking_Mat= array[1..max] of Booking;
History_Booking = record
B_num:integer;
B_Mat:Booking_Mat;
end;
Room = record
Num:integer;
Bed_num:integer;
Price:integer;
Status:Boolean;
H:History_Booking;
end;
Data = record
Ro:Room;
m:integer;
end;
Data_mat= array [1..max] of Data;
Procedure Read_Data(filename:string; var table:Data_mat);
var df:text; i,j :integer;
n,m,num,GN:integer;
Bed_num,Price:integer;
f:text;
s,e:Date;
Gname:string[20];
ok:boolean;
a:Data_mat;
c:char;
Begin
writeln('Reading ',filename,' records into array.... ');
assign(df,filename);
reset(df);
i:=0;
while (not eof) do
begin
i:=i+1;
Read (f,num);
a[i].Ro.num:=num;
Read (f,Bed_num);
a[i].Ro.Bed_num:=Bed_num;
Read (f,Price);
a[i].Ro.Price:=Price;
Read(f,c);
if (c ='Y') then
a[i].Ro.status:= true
else
a[i].Ro.status:= false;
readln;
End; {while eof}
close(df);
End; {Read_Data}
You've declared two variables of type Text, (df and f) in your var block.
You open df with these lines:
assign(df,filename);
reset(df);
You then read from f (which is not the file you opened above) in several lines, such as this one:
Read (f, num);
It's interesting to note that you actually manage to close the file you really opened, even though you never use it in your loop:
close(df);
The solution to all of these issues is to delete the declaration of either f or df, and then fix the compiler errors you get by correcting the code to use the remaining text variable. (Two important lessons here are
Only declare the variables you actually need.
Use the variables you declare.
Your loop is also invalid, because you're using while not eof with no file provided for which to test the end. Your loop should read while not Eof(df) do instead.
It's also much better to follow the typical naming convention of prefixing types with a T. It makes it clear that it's a type and not a variable, and allows you to read the code more easily. For instance, I'd change your definition of Data to TRoomData, and change the other type declarations accordingly. Here's an example - note that TRoomData now has a field (member) named Room of type TRoom:
TRoomData = record
Room: TRoom;
m: Integer;
end;
TRoom is defined as
TRoom = record
Num: Integer;
Bed_num: Integer;
Price: Integer;
Status: Boolean;
H: THistory_Booking;
end;
And so forth. This allows you to write code more clearly:
var
RoomData: TRoomData;
begin
RoomData.Room.Num := 1;
RoomData.Room.Price := 50;
// etc.
end;
With all that being said, your file does not contain text, and therefore you're using the wrong file type by using df: Text in the first place. You should use a File of TRoomData, allowing you to read and write entire records at a time. Here's an example of doing so:
var
DF: File of TRoomData;
RoomData: TRoomData;
i: Integer;
const
DataFileName = 'D:\TempFiles\RoomData.dat';
Writing it:
// Put some data into the record
RoomData.Room.Num := 1;
RoomData.Room.Bed_num := 1;
RoomData.Room.Price := 40;
RoomData.Room.Status := True;
RoomData.Room.H.B_num := 1;
for i := 1 to Max do
begin
RoomData.Room.H.B_Mat[1].Guest := Format('Guest %d', [i]);
RoomData.Room.H.B_Mat[1].S_Date.Year := 2014;
RoomData.Ro.H.B_Mat[1].S_Date.Month := i;
RoomData.Ro.H.B_Mat[1].S_Date.Day := i;
end;
// Write it out to the file
AssignFile(DF, DataFileName);
try
Rewrite(DF);
Write(DF, RoomData);
finally
CloseFile(DF);
end;
Reading it back in:
AssignFile(DF, DataFileName);
try
Reset(DF);
Read(DF, RoomData);
finally
CloseFile(DF);
end;
(Or, better yet: If the version of Pascal you're using supports it, move away from the old file I/O routines and start using TFileStream instead.)
Last but not least, learn to properly format your code. It makes it much easier to debug and maintain, and it's much easier to read when you can follow the execution path clearly.
I am using ADO.Net to call a stored procedure in an Oracle database. The stored procedure has an out parameter that is a NVARCHAR2. Here is the stored procedure:
CREATE OR replace PROCEDURE VALIDATE_Bin (
machine_dump_name IN NVARCHAR2,
lpn IN NVARCHAR2,
result OUT NUMBER,
message OUT NVARCHAR2)
IS
BEGIN
IF lpn LIKE 'A%' THEN
result := 1;
message := NULL;
ELSE
IF lpn IS NULL THEN
result := 0;
message := 'Failed Read';
ELSE
result := 0;
message := 'Invalid Barcode';
END IF;
END IF;
END;
And here is the c# code to fill in the parameters of the command:
command.Parameters.Add(new OracleParameter("machine_dumper_name",OracleType.NVarChar){Value = "My Dumper"});
command.Parameters.Add(new OracleParameter("lpn", OracleType.NVarChar) { Value ="XYZ1234"});
var resultParam = new OracleParameter("result", OracleType.Number) { Direction = ParameterDirection.Output};
command.Parameters.Add(resultParam);
var messageParam = new OracleParameter("message", OracleType.NVarChar) { Direction = ParameterDirection.Output};
command.Parameters.Add(messageParam);
command.ExecuteNonQuery();
If I execute it like this I get the exception:
System.Exception: Parameter 'message': No size set for variable length data type: String.
No worries I think. Oracle expects a string length on the "message" parameter. So I add a size parameter on the "message" parameter:
var messageParam = new OracleParameter("message", OracleType.NVarChar, 255) { Direction = ParameterDirection.Output};
and then when I run it I get this System.Data.OracleClient.OracleException:
PLS-00306: wrong number or types of arguments in call to 'VALIDATE_Bin'
How the heck am I supposed to call this procedure and get the message out? I think this problem is specific to string data types. Is this a bug? Or am I doing something wrong?
Try
var messageParam = new OracleParameter("message", OracleDbType.NVarchar2,UInt16.MaxValue) { Direction = ParameterDirection.Output};
messageParam.Value = DbNull.Value
After reading one of #psaraj12's comments I realized the problem parameter may not be the "message" parameter after all. After eliminating variables from the stored procedure one by one I discovered a mis-match in parameter names. In the procedure:
machine_dump_name IN NVARCHAR2,
and in the C# code:
new OracleParameter("machine_dumper_name",OracleType.NVarChar)
Thank you for all your ideas everyone! When I used the actual name of the parameter (machine_DUMP_name) everything worked perfectly!