Using Parameters with Oracle Packages. ODP .NET - oracle10g

I have an Oracle function that returns a record set.
I introduced parameters to the Oracle function and this is causing the front-end code to go haywire.
Here's my front-end code.
OracleCommand od = oc.CreateCommand();
od.CommandType = System.Data.CommandType.Text;
od.CommandText = " select * from table(pkg_fetchPOInfo.getPORowsTable(:1,:2))";
//od.CommandText = "pkg_fetchPOInfo.getPORowsTable";
//od.CommandType = System.Data.CommandType.TableDirect;
OracleParameter op1 = new OracleParameter();
op1.ParameterName = "1";
op1.OracleDbType = OracleDbType.Varchar2;
op1.Direction = System.Data.ParameterDirection.Input;
op1.Size = 6;
op1.Value = strPONumber;
od.Parameters.Add(op1);
OracleParameter op2 = new OracleParameter();
op2.ParameterName = "2";
op2.OracleDbType = OracleDbType.Varchar2;
op2.Direction = System.Data.ParameterDirection.Input;
op2.Size = 3;
op2.Value = "US";
od.Parameters.Add(op2);
If I execute the query in the front-end SQLPLUS, I get a recordset.
This code works if I remove the parameters from the package and the front-end code.
select * from table(pkg_fetchPOInfo.getPORowsTable('1007446','US')); --works in SQLPLUS.
select * from table(pkg_fetchPOInfo.getPORowsTable()); --works in both places.
Am I assigning the parameters incorrectly?

Package Definition:
CREATE OR REPLACE
PACKAGE TESTP AS
function TESTPIPE(nr in number, nr2 in number) return varchartabletype pipelined;
END TESTP;
CREATE OR REPLACE
PACKAGE BODY TESTP AS
function TESTPIPE(nr in number, nr2 in number) return varchartabletype pipelined AS
CURSOR TESTPIPE_cur
IS
SELECT (level + 1) datam
FROM dual
connect by level < nr;
vtt varchartabletype ;
BEGIN
OPEN TESTPIPE_cur;
LOOP
FETCH testpipe_cur
BULK COLLECT INTO vtt LIMIT nr2;
FOR indx IN 1 .. vtt.COUNT
LOOP
Pipe Row ( vtt( indx ) ) ;
END LOOP;
EXIT WHEN testpipe_cur%NOTFOUND;
END LOOP;
END TESTPIPE;
END TESTP;
.NET Code:
public static void pipeTest()
{
String conString = GetConnectionString();
OracleConnection _conn = new OracleConnection(conString);
_conn.Open();
OracleCommand oCmd = new OracleCommand();
oCmd.CommandText = "begin open :crs for Select * from table(testp.testpipe(:nr,:nr2)); end;";
oCmd.CommandType = CommandType.Text ;
oCmd.Connection = _conn;
OracleParameter crs = new OracleParameter();
crs.OracleDbType = OracleDbType.RefCursor;
crs.Direction = ParameterDirection.Output;
crs.ParameterName = "crs";
oCmd.Parameters.Add(crs);
OracleParameter nr = new OracleParameter();
nr.OracleDbType = OracleDbType.Int64;
nr.Direction = ParameterDirection.Input ;
nr.ParameterName = "nr";
nr.Value = 25;
oCmd.Parameters.Add(nr);
OracleParameter nr2 = new OracleParameter();
nr2.OracleDbType = OracleDbType.Int64;
nr2.Direction = ParameterDirection.Input;
nr2.ParameterName = "nr2";
nr2.Value = 10;
oCmd.Parameters.Add(nr2);
using (OracleDataReader MyReader = oCmd.ExecuteReader())
{
int ColumnCount = MyReader.FieldCount;
// get the data and add the row
while (MyReader.Read())
{
String s = MyReader.GetOracleValue(0).ToString();
Console.WriteLine(string.Format("i={0}", s));
}
}
Console.ReadLine();
}

Related

Apex Test Class failing on second asserEquals statement

Test Class failing on asserEqual:
I am trying to use this Test Class to test a isBefore && isInsert or IsUpdate Trigger but the test is failing on second assertEquals statement (end of the code, trying to compare return of SOQL Query:
I don't know why this is taking because I am doing a few simple inserts to test my Trigger.
Complete code:
#isTest
private class Test_Triggers{
static testMethod void Test_Triggers() {
Account acc = new Account();
acc.Name = 'sacasac';
insert acc;
Account contateste0 = new Account();
contateste0.Name = 'GRANITOS E MARMORES MACHADO LTDA EPP';
contateste0.Phone = '(27)3727-2929';
insert contateste0;
Contact contatoTeste = new Contact();
contatoTeste.FirstName = 'TITANIUM';
contatoTeste.LastName = 'TITANIUM';
contatoTeste.Phone = '3329-4053';
contatoTeste.MobilePhone = '27999970208';
contatoTeste.Email = 'gmmcontabil#gmail.com';
contatoTeste.AccountId = contateste0.Id;
insert contatoTeste;
Case novoCaso = new Case();
novoCaso.Subject = 'assunto';
novoCaso.Description = 'obs';
novoCaso.AccountId = contateste0.Id;
novoCaso.ContactId = contatoTeste.Id;
novoCaso.Origin = 'Portal';
insert novoCaso;
Opportunity novaOpp = new Opportunity();
novaOpp.AccountId = contateste0.Id;
novaOpp.Amount = 4200;
novaOpp.Name = '4200';
novaOpp.StageName = 'Pré_Oportunidade';
novaOpp.CloseDate = Date.today();
insert novaOpp;
Id idMeta = Schema.SObjectType.Meta__c.getRecordTypeInfosByName().get('CORE').getRecordTypeId();
Id idMeta2 = Schema.SObjectType.Meta__c.getRecordTypeInfosByName().get('NOVO').getRecordTypeId();
Meta__c meta01 = new Meta__c();
meta01.Data__c = Date.today();
meta01.Id_Usuario__c = UserInfo.getUserId();
meta01.Id_Conta__c = contateste0.Id;
meta01.RecordTypeId = idMeta;
meta01.Valor__c = 53161;
insert meta01;
System.assertEquals(53161, meta01.Valor__c);
Ordem_de_venda__c ordem = new Ordem_de_venda__c();
ordem.Oportunidade__c = novaOpp.Id;
ordem.Conta_Principal__c = acc.Id;
ordem.Pagador__c = acc.Id;
ordem.Data_de_vencimento__c = System.today().addDays(2);
ordem.Id_Meta__c = meta01.Id;
ordem.Tipo__c = 'Serviço';
insert ordem;
List<AggregateResult> aggregateOrdensVenda = [SELECT Id_Meta__c, sum(Valor_faturado__c) total, sum(VlrFor__c) forecast FROM Ordem_de_venda__c WHERE Id_Meta__c =:meta01.Id GROUP BY Id_Meta__c];
//This is failing because SOQL s returning nothing
system.assertEquals(1,aggregateOrdensVenda.size());
}
}```

Creating OBX segments from multiple DB rows

I have a DB source which I am transforming into HL7. In the transform, I have a step to connect to the database and retrieve rows for OBX segments, there can be no rows or multiple rows.
I'm successfully getting all the values, but I'm having trouble getting them written into OBX segments. They're all the same, and all the last row retrieved.
Database values:
OBX3 OBX5
Test123 This is a new referral
Test456 Person
Test789 Anxiety
The result I'm getting in the message is:
OBX|0||Test789||Anxiety
OBX|1||Test789||Anxiety
OBX|2||Test789||Anxiety
Code:
var erefID = msg['erefid'].toString();
var dbConn = DatabaseConnectionFactory.createDatabaseConnection(driver,address,username,password);
var sql = "SELECT OBX3,OBX5 from table where column =" + erefID;
var results = dbConn.executeCachedQuery(sql);
var resultSize = results.size();
logger.info('query results ' + results);
logger.info('result size ' +resultSize);
var obx3 = "";
var obx5 = "";
while(results.next()){
var i=0
obx3 = results.getString(1);
logger.info('obx3 ' + obx3);
obx5 = results.getString(2);
logger.info('obx5 '+obx5);
while(i<resultSize)
{
createSegment('OBX', tmp,i);
tmp['OBX'][i]['OBX.1']['OBX.1.1'] = i;
tmp['OBX'][i]['OBX.3']['OBX.3.1'] = obx3;
tmp['OBX'][i]['OBX.5']['OBX.5.1'] = obx5;
i++;
}
}
dbConn.close();
Switched around the while statements, works now
while(i<resultSize){
var i=0
obx3 = results.getString(1);
logger.info('obx3 ' + obx3);
obx5 = results.getString(2);
logger.info('obx5 '+obx5);
while(results.next()){
createSegment('OBX', tmp,i);
tmp['OBX'][i]['OBX.1']['OBX.1.1'] = i;
tmp['OBX'][i]['OBX.3']['OBX.3.1'] = obx3;
tmp['OBX'][i]['OBX.5']['OBX.5.1'] = obx5;
i++;
}
}

Can't add TaxService to QBO with .NET SDK

How do I create a tax rate in QBO using API v3 and the TaxService resource? When I try to add it the same way as I would any other object, Visual Studio gives me this error: "The type 'Intuit.Ipp.Data.TaxService' cannot be used as type parameter 'T' in the generic type or method Intuit.Ipp.DataService.DataService.Add(T)'. There is no implicit reference conversion from 'Intuit.Ipp.Data.TaxService' to 'Intuit.Ipp.Data.IEntity'."
Here's the code:
Intuit.Ipp.Data.TaxService ts = new Intuit.Ipp.Data.TaxService();
// Populate fields here...
DataService ds = new DataService(ServiceContext);
Intuit.Ipp.Data.TaxService newTs = ds.Add<Intuit.Ipp.Data.TaxService>(ts);
Use GlobalTaxService endpoint and JSON format only. Try this code:
GlobalTaxService taxSvc = new GlobalTaxService(context);
Intuit.Ipp.Data.TaxService taxCodetobeAdded = new Data.TaxService();
taxCodetobeAdded.TaxCode = "taxC_" + Guid.NewGuid().ToString("N");
QueryService<TaxAgency> taxagency = new QueryService<TaxAgency>(context);
TaxAgency taxagencyResult = taxagency.ExecuteIdsQuery("select * from TaxAgency").FirstOrDefault<TaxAgency>();
List<TaxRateDetails> lstTaxRate = new List<TaxRateDetails>();
TaxRateDetails taxdetail1 = new TaxRateDetails();
taxdetail1.TaxRateName = "taxR1_" + Guid.NewGuid().ToString("N");
taxdetail1.RateValue = 3m;
taxdetail1.RateValueSpecified = true;
taxdetail1.TaxAgencyId = taxagencyResult.Id.ToString();
taxdetail1.TaxApplicableOn = TaxRateApplicableOnEnum.Sales;
taxdetail1.TaxApplicableOnSpecified = true;
lstTaxRate.Add(taxdetail1);
TaxRateDetails taxdetail2 = new TaxRateDetails();
taxdetail2.TaxRateName = "taxR2_" + Guid.NewGuid().ToString("N");
taxdetail2.RateValue = 2m;
taxdetail2.RateValueSpecified = true;
taxdetail2.TaxAgencyId = taxagencyResult.Id.ToString();
taxdetail2.TaxApplicableOn = TaxRateApplicableOnEnum.Sales;
taxdetail2.TaxApplicableOnSpecified = true;
lstTaxRate.Add(taxdetail2);
//TaxRateDetails taxdetail3 = new TaxRateDetails();
//taxdetail3.TaxRateName = "rate298";
//taxdetail3.TaxRateId = "2";
//lstTaxRate.Add(taxdetail3);
taxCodetobeAdded.TaxRateDetails = lstTaxRate.ToArray();
Intuit.Ipp.Data.TaxService taxCodeAdded = taxSvc.AddTaxCode(taxCodetobeAdded);

attempt to index global 'physics' (a nil value)

I'm new with corona/lua and i'm i can't find a solution to this thing. I'm trying to spawn a object that fall from top to down and should stop at the bottom of the screen. Then i'll create the touch event etc etc..
but for now the problem is that i recieve this error:
attempt to index global 'physics' (a nil value)
and objects ofc doesn't fall down.
here is my code:
-----------------------------------------------------------------------------------------
--
-- main.lua
--
-----------------------------------------------------------------------------------------
local buttonY = display.contentWidth * 0.02
local buttonWidth = display.contentWidth * 0.1
local buttonHeight = display.contentWidth * 0.1
background = display.newImage("graphics/background.jpg")
local localGroup = display.newGroup()
local spawnTable = {}
function spawnLattina(params)
local object = display.newImage(params.image, params.buttonX,50);
object.objTable = params.objTable;
object.index = #object.objTable+1;
object.name = "object:".. object.index;
--fisica
if params.hasBody then
object.density = params.density or 0;
object.friction = params.friction or 0;
object.bounce = params.bounce or 0;
object.isSensor = params.isSensor or false;
object.bodyType = params.bodyType or "dynamic";
print(object.density .. " Friction: ".. object.friction .."bodyType: "..object.bodyType)
physics.addBody(object, object.bodyType,
{density = object.density,
friction = object.friction,
bounce = object.bounce}
)
end
object.group = params.group or nil
object.group:insert(object)
object.objTable[object.index] = object
return object
end
for i = 1, 2 do
local spawns = spawnLattina(
{
image = "graphics/lattina.png",
objTable = spawnTable,
buttonX = math.random(50,480),
hasBody = true,
density = 0,
friction = 12,
bodyType = "static",
group = localGroup,
}
)
end
You haven't started the physics engine. Write the following lines on the top of your class:
local physics = require "physics"
physics.start()
Keep Coding.................. :)

How to search multi keywork in linq query

i have this code in homepage
CheckBox[] ch= new CheckBox[12];
ch[0] = ChkContextA;
ch[1]= ChkContextB;
ch[2]= ChkContextC;
ch[3]= ChkContextD;
ch[4]= ChkContextE;
ch[5]= ChkContextF;
ch[6]= ChkContextG;
ch[7]= ChkContextH;
ch[8]= ChkContextI;
ch[9]= ChkContextJ;
ch[10]= ChkContextK;
ch[11]= ChiContextL;
for (int i = 0; i < 11; i++)
if (ch[i].Checked) search += ch[i].Text + " ";
Response.Redirect("SearchEstate.aspx?content="+search);
and this code in SearchEstate
var content = Request.QueryString["content"];
RealEstateEntities db = new RealEstateEntities();
var query = from O in db.Owners
join E in db.Estates on O.OwnerID equals E.OwnerID
join P in db.Properties on E.PropertyID equals P.PropertyID
where P.Facilities.Contains(content)
select new
{
regdate = E.RegisterDate,
region = E.Region,
Estype = E.EstateType,
Fac = P.Facilities,
deal = P.DealType,
price = P.TotalCost,
img = E.Picture,
addrss = O.Address,
area = P.Area,
tel = P.TellNum,
bed = P.RoomNum,
park = P.ParikingNum
};
Repeater2.DataSource = query.OrderByDescending(x => x.regdate);
Repeater2.DataBind();
when user checked some checkbox "content" for example have this value:
SearchEstate.aspx?content=ContextB ContextE ContextJ
I Want search this values in Facility field in db
How can I do this? (Sorry for my bad English)
I have the feeling your are looking for something along the lines of this query:
var content = Request.QueryString["content"];
string[] contentArray = content.Split(' ');
//...
var query = //...
where P.Facilities.Any(f => contentArray.Contains(f.FacilityName))
//...
(or instead of FacilityName some other property of Facility)
But I am not sure.