IBExpert 2021.7.8.1 - Firebird 2.5 database compare stored procedure domain names commented out - firebird

I have IBExpert 2021.7.8.1 and Firebird 2.5
When I perform a database compare on stored procedures, my input and output parameters domain names are removed and replaced with the variable representative. On most occasions the domain is commented out.
Here's a snippet of what the update script looks like:
ALTER PROCEDURE WIP_CURRENT_MONTH_PROCEDURE(
IP_SELECTEDYEAR /* SMALLINT_DOMAIN */ SMALLINT,
IP_SELECTEDMONTH /* SMALLINT_DOMAIN */ SMALLINT,
IP_MONTHSDIFFERENCE /* INTEGER_DOMAIN */ INTEGER,
IP_MAX_MONTHS_REMOVED /* INTEGER_DOMAIN */ INTEGER,
IP_EOM_RUN SMALLINT)
RETURNS (
OP_CONTRACTVALUE /* MONETRY_DOMAIN */ NUMERIC(15,2),
OP_ESTIMATED_COSTS /* MONETRY_DOMAIN */ NUMERIC(15,2),
OP_MECHANICAL_VX_2 /* MONETRY_DOMAIN */ NUMERIC(15,2),
Here's a snippet of what the update script should look like:
ALTER PROCEDURE WIP_CURRENT_MONTH_PROCEDURE(
IP_SELECTEDYEAR SMALLINT_DOMAIN,
IP_SELECTEDMONTH SMALLINT_DOMAIN,
IP_MONTHSDIFFERENCE INTEGER_DOMAIN,
IP_MAX_MONTHS_REMOVED INTEGER_DOMAIN,
IP_EOM_RUN SMALLINT_DOMAIN)
RETURNS (
OP_CONTRACTVALUE MONETRY_DOMAIN,
OP_ESTIMATED_COSTS MONETRY_DOMAIN,
OP_MECHANICAL_VX_2 MONETRY_DOMAIN
Any ideas why this occurs for stored procedures?

Related

PostgreSQL function giving all rows but not in key value pair format?

I have table called users in PostgreSQL.I want to get all users in table from my Laravel application.
I can get from table directly as:
$testData = DB::table('users')->get();
output is:
[{"id":1,"name":"Chris Sevilleja","username":"sevilayha","email":"chris#scotch.io","password":"$2y$08$i\/ATa68ierqRL47ZxHX4EesJGEcdtKPckZs8GDGpYS.IR4aaQn.\/q","created_at":"2016-09-07 09:32:41","updated_at":"2016-09-07 09:32:41"},{"id":2,"name":"Bemagoni chandrashekar","username":"chandrashekar","email":"chandrashekar#zessta.com","password":"$2y$08$QG9JsAerYp3UYpXNNyImhuz\/6hiWv8XpURpJX1uJ.hAm8l1RG2JrC","created_at":"2016-09-07 09:32:41","updated_at":"2016-09-07 09:32:41"},{"id":3,"name":"dwefr","username":"ewre","email":"ewrt#egyfrhgt.com","password":"$2y$08$s2XBZvoAvpEqjjhbx8QPw.eSe5TIuJC25XbaFkTskzAKAGi99QWga","created_at":"2016-09-07 09:34:27","updated_at":"2016-09-07 09:34:27"},{"id":4,"name":"r3t54y6u677i","username":"retrytyu","email":"etyru#dddj.com","password":"$2y$08$Xb0Xm4KwdSwcBSHX0F6ETOWU60X.NO5D7\/uwVv\/xUAXTUS8LSPCLu","created_at":"2016-09-07 09:46:26","updated_at":"2016-09-07 09:46:26"},{"id":5,"name":"r3t45y6u","username":"ertrh","email":"435t4y65#sss.com","password":"$2y$08$36DLu49nZ2YOWtU.c625meiyi3\/fmsHxiTuxIU9z9UcyrbIpFSKKW","created_at":"2016-09-07 10:02:05","updated_at":"2016-09-07 10:02:05"},{"id":6,"name":"ewrtryuyj","username":"ryt","email":"wrewtey#sssks.com","password":"$2y$08$GULHtX3GGXPGgm8gA9yDbeawZlQ5QwD2TX7nrCvEU4j7jrSgPWAQO","created_at":"2016-09-07 10:04:17","updated_at":"2016-09-07 10:04:17"},{"id":7,"name":"chandu","username":"chandu","email":"ch1235hdhd#dhdjd.com","password":"$2y$08$gpAhcl\/Sg.lGvb.zk.I\/m.PfcttGI6OPFMsMxQVm15dYOtQDvIWSG","created_at":"2016-09-07 10:06:18","updated_at":"2016-09-07 10:06:18"},{"id":8,"name":"dewfergt","username":"erwrgf","email":"fgf#dgrf.com","password":"$2y$08$ikYAXV1prZsEj2MPxXM4S.Tqn160Jv25cFOQLghK8ptFiSBaIFGZO","created_at":"2016-09-07 10:07:20","updated_at":"2016-09-07 10:07:20"},{"id":9,"name":"rteryt","username":"wrwter","email":"wretr#gjjd.com","password":"$2y$08$pkOUBl1NlNdBShNWiklya.0zlPzPrEH2edCfvdCiHLnj80GY1sdtm","created_at":"2016-09-08 07:11:46","updated_at":"2016-09-08 07:11:46"},{"id":10,"name":"Raghu","username":"raghu","email":"raghu#gdgdjd.com","password":"$2y$08$m9wke.vvTTZytYw91I4\/q.qxKoCobLOW7dbCvs66xFyJyy2R9phni","created_at":"2016-09-10 10:06:40","updated_at":"2016-09-10 10:06:40"},{"id":11,"name":"wewert","username":"ewretr","email":"ewrtey#vsss.com","password":"$2y$08$IXD0eXYTPPGE1MfALonEFey0lr\/KBMZ0.3AIO3sWVgu7IZdWhXwTG","created_at":"2016-09-12 07:48:58","updated_at":"2016-09-12 07:48:58"}]
Through PostgreSQL function calling:
my PostgreSQL function:
-- Function: public."RegiterUsers2"()
-- DROP FUNCTION public."RegiterUsers2"();
CREATE OR REPLACE FUNCTION public."RegiterUsers2"()
RETURNS SETOF users AS
'select * from users'
LANGUAGE sql VOLATILE
COST 100
ROWS 1000;
ALTER FUNCTION public."RegiterUsers2"()
OWNER TO postgres;
Laravel code:
$allUserData=DB::select('SELECT public."RegiterUsers2"()')
output:
[{"RegiterUsers2":"(1,\"Chris Sevilleja\",sevilayha,chris#scotch.io,$2y$08$i\/ATa68ierqRL47ZxHX4EesJGEcdtKPckZs8GDGpYS.IR4aaQn.\/q,\"2016-09-07 09:32:41\",\"2016-09-07 09:32:41\")"},{"RegiterUsers2":"(2,\"Bemagoni chandrashekar\",chandrashekar,chandrashekar#zessta.com,$2y$08$QG9JsAerYp3UYpXNNyImhuz\/6hiWv8XpURpJX1uJ.hAm8l1RG2JrC,\"2016-09-07 09:32:41\",\"2016-09-07 09:32:41\")"},{"RegiterUsers2":"(3,dwefr,ewre,ewrt#egyfrhgt.com,$2y$08$s2XBZvoAvpEqjjhbx8QPw.eSe5TIuJC25XbaFkTskzAKAGi99QWga,\"2016-09-07 09:34:27\",\"2016-09-07 09:34:27\")"},{"RegiterUsers2":"(4,r3t54y6u677i,retrytyu,etyru#dddj.com,$2y$08$Xb0Xm4KwdSwcBSHX0F6ETOWU60X.NO5D7\/uwVv\/xUAXTUS8LSPCLu,\"2016-09-07 09:46:26\",\"2016-09-07 09:46:26\")"},{"RegiterUsers2":"(5,r3t45y6u,ertrh,435t4y65#sss.com,$2y$08$36DLu49nZ2YOWtU.c625meiyi3\/fmsHxiTuxIU9z9UcyrbIpFSKKW,\"2016-09-07 10:02:05\",\"2016-09-07 10:02:05\")"},{"RegiterUsers2":"(6,ewrtryuyj,ryt,wrewtey#sssks.com,$2y$08$GULHtX3GGXPGgm8gA9yDbeawZlQ5QwD2TX7nrCvEU4j7jrSgPWAQO,\"2016-09-07 10:04:17\",\"2016-09-07 10:04:17\")"},{"RegiterUsers2":"(7,chandu,chandu,ch1235hdhd#dhdjd.com,$2y$08$gpAhcl\/Sg.lGvb.zk.I\/m.PfcttGI6OPFMsMxQVm15dYOtQDvIWSG,\"2016-09-07 10:06:18\",\"2016-09-07 10:06:18\")"},{"RegiterUsers2":"(8,dewfergt,erwrgf,fgf#dgrf.com,$2y$08$ikYAXV1prZsEj2MPxXM4S.Tqn160Jv25cFOQLghK8ptFiSBaIFGZO,\"2016-09-07 10:07:20\",\"2016-09-07 10:07:20\")"},{"RegiterUsers2":"(9,rteryt,wrwter,wretr#gjjd.com,$2y$08$pkOUBl1NlNdBShNWiklya.0zlPzPrEH2edCfvdCiHLnj80GY1sdtm,\"2016-09-08 07:11:46\",\"2016-09-08 07:11:46\")"},{"RegiterUsers2":"(10,Raghu,raghu,raghu#gdgdjd.com,$2y$08$m9wke.vvTTZytYw91I4\/q.qxKoCobLOW7dbCvs66xFyJyy2R9phni,\"2016-09-10 10:06:40\",\"2016-09-10 10:06:40\")"},{"RegiterUsers2":"(11,wewert,ewretr,ewrtey#vsss.com,$2y$08$IXD0eXYTPPGE1MfALonEFey0lr\/KBMZ0.3AIO3sWVgu7IZdWhXwTG,\"2016-09-12 07:48:58\",\"2016-09-12 07:48:58\")"}]
I need like this
{"id":1,
"name":"Chris Sevilleja",
"username":"sevilayha",
"email":"chris#scotch.io",
"password":"$2y$08$i\/ATa68ierqRL47ZxHX4EesJGEcdtKPckZs8GDGpYS.IR4aaQn",
"created_at":"2016-09-07 09:32:41",
"updated_at":"2016-09-07 09:32:41"},
so what is wrong with postgres function and how can I get like above one.
When you call a function returning many columns and you want each one, you must call in the form of:
SELECT col1, col2, ... FROM function(...)
Or:
SELECT * FROM function(...)
So in your case you simple want:
$allUserData=DB::select('SELECT * FROM public."RegiterUsers2"()')

Creating user defined function for firebird 2.5 with c++builder 2010

I tried to create a simple user defined function (UDF) for Firebird 2.5 with C++ Builder 2010 but I don't manage to get it to work in Firebird.
Creating a DLL project with default setting in C++ Builder 2010.
Adding a unit with my example UDF including "ibase.h" and "ib_util.h":
extern "C" __declspec(dllexport) int __stdcall MYFUNC ( int i )
{
int result = 2 * i;
return result;
}
Building the DLL FBUDFMBD.dll in path C:\Program Files (x86)\Firebird\Firebird_2_5\UDF
Registering my UDF via IBExpert in a sample db with
DECLARE EXTERNAL FUNCTION F_MYFUNC
INTEGER
RETURNS INTEGER
ENTRY_POINT 'MYFUNC' MODULE_NAME 'FBUDFMBD';
Calling the UDF with
select F_MYFUNC( 3 ) from RDB$DATABASE;
results in error message
Invalid token.
invalid request BLR at offset 36.
function F_MYFUNC is not defined.
module name or entrypoint could not be found.
With the tool GExperts - PE Information I can see my UDF as DLL-Export MYFUNC ordinal $1 and entry point $1538.
What I am doing wrong, Firebird can't register my DLL and its UDF correctly?
Is there anything in my DLL project to change regarding to default compiler options?
Thanks a lot! I got it by your help.
top 2: Corrected C++-Code is:
extern "C" __declspec(dllexport) int MYFUNC ( int * val )
{
int result = 2 * *val;
return result;
}
Pay attention to reference call of the input parameter.
top 4: Register the UDF in a firebird 2.5 db by
DECLARE EXTERNAL FUNCTION F_MYFUNC
INTEGER
RETURNS INTEGER BY VALUE
ENTRY_POINT '_MYFUNC' MODULE_NAME 'FBUDFMBD';
Pay attention to the leading underscore at the function name!
top 5: select F_MYFUNC( 3 ) from RDB$DATABASE; works really fine!
In Delphi, you can write cdecl and not stdcall
i.e
function ExisteBase(const aBase:PChar):Integer; cdecl;
Not
function ExisteBase(const aBase:PChar):Integer; stdcall;
Maybe on C++ __cdecl
I hope I helped in some

Getting a value from stored procedure within a stored procedure

I have a stored procedure which returns an XML file. At the moment some calculations are done in XSL but I would like to do these within the database using another stored procedure. (adding the result of that calculation to the XML)
ALTER PROCEDURE [dbo].[app_Get_Phone_And_Tariffs]
-- Add the parameters for the stored procedure here
#phone nvarchar(150)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT
PB.UID as '#phoneid',
PB.Short_Title as '#title',
PB.Description as '#desc',
PB.Camera as '#camera',
PB.Storage as '#storage',
PB.Screen_Size as '#screensize',
PB.OS as '#os',
PB.Processor as '#chip',
PB.Image1 as '#image',
PB.Trade_Price as '#tradeprice',
(SELECT
TB.UID as '#tariffid',
TB.Tariff_Name as '#name',
TB.Carrier as '#network',
TB.Inclusive_Minutes as '#mins',
TB.Inclusive_Texts as '#texts',
TB.Inclusive_Data as '#data',
TB.Monthly_Cost as '#monthly',
TB.Commission as '#comm',
(TB.Commission - PB.Trade_Price) as '#upfront'
FROM dbo.Tariff_Base TB
WHERE TB.Active = 1 AND TB.Type = 1
FOR XML PATH('tariff'), TYPE
),
(SELECT
OP.GP_Margin as '#gpmargin'
FROM dbo.Options OP
FOR XML PATH('options'), TYPE
)
FROM dbo.Phone_Base PB
WHERE PB.Friendly_URL_Name = #phone AND PB.Active = 1
FOR XML PATH('detail'), TYPE
END
What I want to do is:
In the inner select (TB) is to call another SP lets call it "calculate" passing 2 variables (TB.Commission and PB.Trade_Price) for the sum
Calculate will return a value i.e. #hp to the stored procedure which can be added/used in the XML List.
Can this be done in SQL Server 2014/T-SQL?
No. But you could do it with a function. See the MSDN documentation, especially example A.
Something like this (untested):
CREATE FUNCTION dbo.Calculate (#Comission float, #TradePrice float)
RETURNS float
WITH EXECUTE AS CALLER
AS
BEGIN
DECLARE #SumVal float;
SET #SumVal = #Commission + # TradeValue;
RETURN(#SumVal);
END;
GO
--In your sub-query
SELECT values, dbo.Calculate(TB.Commission, PB.Trade_Price) AS A_Sum
FROM ...;

like with nvarchar is not working correctly?

Using Microsoft SQL Server 2012 - 11.0.5058.0 (X64) Express Edition (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1) (Hypervisor)
with that creation/fill script :
CREATE TABLE tbl (col CHAR (32) )
insert into tbl values ('test')
Those kind of statements :
declare #var varchar(32) = 'test'
delete from tbl where col like #var
or
delete from tbl where col like 'test'
actually delete the line but why this one :
declare #nvar nvarchar(32) = 'test'
delete from tbl where col like #nvar
do not delete the line ?
According to this page... https://msdn.microsoft.com/en-us/library/ms179859.aspx
When you use Unicode data (nchar or nvarchar data types) with LIKE,
trailing blanks are significant;
Since you are using CHAR data type with length 32, the actual data stored is "test" + 28 spaces.
In your comparison, you are mixing CHAR and nvarchar. Because of the differing data types, SQL Server converts the CHAR data type to NCHAR to perform the comparison.
If you change the data type of the column to VARCHAR, your code works. You could also change your code to:
delete from tbl where col like #nvar + '%'

Query to check whether table is journaled in DB2

I am new to db2.
Is there a query to check whether a table is journaled in DB2 or not. if it is journaled what is the name of the journal.
I found this query: Find all journals in library MJATST.
SELECT * FROM TABLE (QSYS2.OBJECT_STATISTICS('MJATST ','JRN') ) AS X
but i couldn't find something similar to tables in schema.
I'm not aware of any and a quick search of the likely catalogs didn't turn up a way.
http://www-01.ibm.com/support/knowledgecenter/ssw_ibm_i_71/db2/rbafzcatalog.htm
The journal information is available in the Retrieve Object Description (QUSROBJD) API
http://www-01.ibm.com/support/knowledgecenter/ssw_ibm_i_71/apis/qusrobjd.htm
You could wrap that API in a UDF.
The following is an example of a CLLE source that can be used at least as far back as v5r3 [no advantage is taken of newer CL support to make the code more succinct] to create a bound ILE CL *PGM object that is invoked as a scalar function [as was previously] defined to the SQL by the CREATE FUNCTION shown in the block comments preceding the CL source; a very simple test-suite verified the functionality:
/* create function jrnOfDBF */
/* ( table_name varchar(128) */
/* , table_libr varchar( 10) */
/* ) returns char(20) */
/* language PLI -- a lie to allow VARCHAR inputs */
/* specific jrnOfDBF */
/* not deterministic */
/* no sql returns null on null input */
/* disallow parallel not fenced no external action */
/* parameter style SQL */
/* external name jrnOfDBF */
/* */
/* CRTBNDCL PGM(JRNOFDBF) SRCMBR(..following_source..) */
/* */
pgm (&tblnam &tbllib +
&rtnval &rtnind &sqlste &udfnam &specnm &diagmg)
dcl &tblnam *char 130
dcl &tbllib *char 12
dcl &rtnval *char 20
dcl &rtnind *int 2
dcl &sqlste *char 5
dcl &udfnam *char 141
dcl &specnm *char 130
dcl &diagmg *char 72
/* Pgm Vars */
dcl &lngnam *char 128
dcl &lnglib *char 10
dcl &dbflib *char 10
dcl &dbfobj *char 10
dcl &jrnsts *char 1
dcl &jrnlib *char 10
dcl &jrnobj *char 10
dcl &strlen *int 4
dcl &qualnm *char 20
monmsg cpf0000 exec(goto badthing)
main:
chgvar &strlen (%bin(&tbllib 1 2))
chgvar &lnglib (%sst(&tbllib 3 &strlen))
chgvar &strlen (%bin(&tblnam 1 2))
chgvar &lngnam (%sst(&tblnam 3 &strlen))
call qdbrtvsn (&qualnm &lngnam &strlen &lnglib x'0000000000000000')
/* 1 Qualified object name Output Char( 20) */
/* 2 Long object name Input Char(128) */
/* 3 Length of long object name Input Binary(4) */
/* 4 Library name Input Char( 10) */
/* 5 Error code I/O Char( * ) */
chgvar &dbflib (%sst(&qualnm 11 10))
chgvar &dbfobj (%sst(&qualnm 01 10))
rtvobjd &dbflib/&dbfobj *file aspdev(*) +
jrnsts(&jrnsts) jrn(&jrnobj) jrnlib(&jrnlib)
if (&jrnsts *eq '1') then(do)
chgvar &rtnval (&jrnobj *cat &jrnlib) /* qualified name of jrn */
enddo
/* else &rtnval is already blanks */
chgvar &rtnind 0
mainend:
return
badthing:
chgvar &rtnind -1
chgvar &sqlste 'JRN99'
chgvar &diagmg 'Unable to retrieve Obj Info; see joblog'
sndpgmmsg *n cpf9898 qcpfmsg &diagmg tomsgq(*topgmq) topgmq(*prv) +
msgtype(*diag)
goto mainend
endpgm
An example invocation of the function:
select jrnOfDBF('SYSROUTINES', 'QSYS2') from qsys2.qsqptabl
What the interactive Start SQL (STRSQL) display report would show:
....+....1....+....2
JRNOFDBF
QSQJRN QSYS2
******** End of data ********
Note: The value of blanks being returned is indicative of either currently not journaled or never journaled, whereas any non-blank value should be the qualified-name of the journal in the standard form of: '10bytObjNm10bytLibNm'
I used DSPFD command for the file(table).. It specifics bunch of info about the file(table)..
MBJRNL -(N/Y) whether table has journal associated with it
if Y then you can get journal info from following column else this column will be null
MBJRNM - Journal Name
MBJRLB - Journal Schema
hope this helps anyone looking for something similar!!