I am working with existing project, and I am found a sql query with sql-function like
SELECT * FROM money WHERE amount = float_convert(0.1);
This Query is Working Properly, But I want to see and edit the function float_convert();
I am already tried SHOW FUNCTION STATUS,
It's only showing functions status, I need to view the function definition.
SHOW CREATE FUNCTION float_convert
or
SHOW CREATE VIEW float_convert
perhaps ?
Related
I am trying to create a view that calls a procedure at initiation to compute 2 variables to be used in the WHERE clause. The query runs but will not save as a view as it appears procedure calls are not allowed. I researched this and found some suggestions about using a Function, but in trying that, I get errors that dynamic SQL is not allowed in a function.
Is there a way to do what I am attempting?
Code snippet:
CALL p_GetOutlierLimits('ROI_Imputed_Percent','DB1',#ClassicLowerROIPct, #ClassicUpperROIPct);
CALL p_GetOutlierLimits('576_VMC_Sol_Savings_Pct','DB2',#vmctcoLower149Pct, #vmctcoUpper149Pct);
USE Database;
SELECT
{CODE}
from TABLE
WHERE ROI_Imputed_Percent BETWEEN #ClassicLowerROIPct AND #ClassicUpperROIPct;
I found another way to do this by removing the calls from the view and just performing them from another procedure that accesses the view.
I have a procedure on MySQL that returns two results and I need to show this on Delphi but I didn't find how to pass for each result.
Here is how appear on DBForge when I execute, I want this on delphi too, show Query1 and Query2 in a TTabControl.
How to go through this queries and get the name of the query like: Query1,Query2?
You don't say what DB interface lib you're using, like FireDAC, Zeos, or something else.
You're going to issue something like a dbxyz.ExecSQL() call and check for some results.
It sounds like you're expecting to get back multiple records in the result set. Using a TTabControl, you'd simply create a list of tabs like "Result-1", "Result-2", and so on, depending on how many records you get back. (They're results, not queries.) You could select the first one by default.
When another tab is clicked, use the control's TabIndex property to select the corresponding result from the result set, then format up the data in that result and display it in whatever format you're using below the tabs.
There's so little detail you've given that it's impossible to show any code for anything other than the tab control's OnChange handler that will use the TabIndex property to find the desired result set. But this is the overall approach I'd take for this using the TTabControl.
I solve the problem with the command
var
tab: TTabItem;
stringGrid: TStringGrid;
repeat
tab:= TTabItem.Create(nil);
tab.Parent:= tabcontrol1;
tab.Text:= query.Fields.Fields[0].FieldName; //the table name
stringGrid:= TStringGrid.Create(Self);
stringGrid.Parent:= tab;
stringGrid.Align:= TAlignLayout.Client;
for I := 1 to query.FieldCount-1 do
begin
stringGrid.AddObject(TStringColumn.Create(stringGrid));
stringGrid.Columns[i-1].Header:= query.Fields.Fields[i].FieldName;
query.First;
for j := 0 to query.RecordCount-1 do
begin
stringGrid.cells[i-1, j]:= query.Fields.Fields[i].value;
query.Next;
end;
end;
stringGrid.RowCount:= j;
until not query.openNext;
well I'm working with yii2 and I have , in the database schema , two tables (user and places) and they are related together via an intermediary table(junction table), i looked what is the best way to get those places that has been created by the user who is currently loged in the application. There are many ways to do it , but I use the next one:
In the User model I made a function called getPlaces():
public function getPlaces(){
return $this->hasMany(Place::className(),['id'=>'id_place'])
->viaTable('OwnerAdmins',['id_user' => 'id']);
}
and then I call this function and I pass the result to the view, the weird is that that does not show any places , Iam not getting it no error either , so when I look into the log in the database I can see the next:
SELECT * FROM ....... WHERE 0=1
well, obviously that wont display any data , but the weird there is 0=1 , i could not find what is going on with that. I have run "grep -lir "0=1" appDirectory" but it seems to be something else, does anyone know what is going on?
In Yii2, WHERE 0=1 is the result of an empty IN condition.
This simply means that your user model do not have any OwnerAdmins => the query to fetch places will have an empty IN condition.
OK, in good old fashioned PHP MVC, I might use a model to hit the DB, send info to my PHP controller that I pass on to the View. In the View, I might take that info (say i ajax'ed my controller for the info) and create a table or ul to display the data returned.
I've had trouble finding any modern (ver 6.1 is what i'm on) tutorial to show me how to preform this action in typo3.
Can anyone just "steer" me in the right direction? Perhaps provide an example via answer, or some links to further information that may compare it down to "old fashioned MVC"?
Extension has been suggested, but I'd like to know the very base process of what I'm asking before I try writing some extension, unless the extension is the only way. Although, my table is now on the SAME DB my typo3 is on, so shouldn't there be some command to just simply call my table and get the rows? Maybe send them to a ###sub-part###?
You can use a typoscript cObj content and the select option together with the function render_obj when your table name is like the typo3 nameing convention. The select pulls the record from the table and pass it to the render_obj function. It's a function that can apply to all cObj and iterate over the entire selection. stdWrap works only on the entire cObj. When you need to work through each record you need the render_obj function. For example:
10 = CONTENT
10 {
select {
pidInList = 1
where = colpos=1
orderBy = sorting
}
table = tt_content
renderObj.stdWrap.wrap = <li>|</li>
renderObj.stdWrap.required = 1
}
10.stdWrap.wrap = <ul>|</ul>
This gives you an unorderd list from the tt_content table with pid=1 and the content from the far left column.
If I have the following query, is it possible to be able to run a function inside? Let's say I want to add WHERE zip_code = user_distance(zip_code)?
I want to take data from each row and run it through a function before actually selecting it.
#posts = Listing.find_by_sql(["SELECT * FROM listings WHERE industry = ? && ", current_user.industry])
If you are mainly looking to get this working and not worrying so much about performance (because going straight to the SQL is faster than going through ActiveRecord) then you could do:
listings = []
Listing.all.each do |listing|
listings << listing if user_distance(listing.zip_code)
end
So, it will go through each listing and add it to that array if the user_distance method returns true (or however it is set up).
Another thing you could do is set up a stored procedure ("stored proc") on your database that takes in a zip code and returns what it is you want (i.e, does the same thing as user_distance), and that user defined variable max_distance could be in a database table so it's accessible to your stored procedure. Then you could call that stored proc from the SQL and still be able to pass in the zip_code of each row.