stored-functions

Fatal Error while calling MySQL stored function from PHP using MySQLi

最后都变了- 提交于 2020-01-05 15:26:01
问题 Server details: PHP v5.3.5 Using MySQLi library client api version: mysqlnd 5.0.7-dev - 091210 - $Revision: 304625 $ MySQL Server v5.5.9 I have a stored function in MySQL called f_get_owner_locations( _in int ). It constructs a text variable that holds the locations of whichever condos a specific owner owns. If I run a SELECT f_get_owner_locations( 3 ); from the MySQL command line, it does what it's supposed to do and returns one row: +----------------------------+ | f_get_owner_locations( 3

Fatal Error while calling MySQL stored function from PHP using MySQLi

左心房为你撑大大i 提交于 2020-01-05 15:24:22
问题 Server details: PHP v5.3.5 Using MySQLi library client api version: mysqlnd 5.0.7-dev - 091210 - $Revision: 304625 $ MySQL Server v5.5.9 I have a stored function in MySQL called f_get_owner_locations( _in int ). It constructs a text variable that holds the locations of whichever condos a specific owner owns. If I run a SELECT f_get_owner_locations( 3 ); from the MySQL command line, it does what it's supposed to do and returns one row: +----------------------------+ | f_get_owner_locations( 3

Returning multiple values from an Oracle 12c function

此生再无相见时 提交于 2020-01-05 09:36:12
问题 I am writing a function in Oracle 12c (and it has to be a function) that should return 3 values, order_line.o_id , a variable total that I create in the function, and a discounted_amount variable that I create in the function. I have gotten my function to create the discounted_amount variable and return it but I am not sure how to get it to return these other two values. CREATE OR replace FUNCTION DiscountsReport (input_o_id IN REAL) RETURN REAL IS output_o_id NUMBER; total REAL; discounted

Can I call a stored procedure in jdbc which returns a table using mysql?

寵の児 提交于 2020-01-05 06:39:29
问题 I'm new to using jdbc to execute mysql stored procedures. My question is that is it possible to call an stored procedure which returns a table in jdbc? I searched a lot and I know I can return a certain number of parameters using registerOutParameter using procedures, but how about a whole table with several rows?! I hope it's not a redundant post. 回答1: Yes. It's possible to call a MySQL stored procedure to return a resultset using JDBC. Examples provided here: https://docs.oracle.com/javase

What is the proper if clause syntax for a MySQL stored function?

牧云@^-^@ 提交于 2020-01-04 04:38:06
问题 I am brand new to MySQL, so I apologize if some of this is relatively elementary. I'm trying to write a stored function to round a digit to a certain number of significant figures. I have a function which, in theory, should work - I consulted another helpful StackOverflow to nail down the logic (Round to n Significant Figures in SQL). However, numbers between 1 and -1 (excluding 0, because I threw in the edge case catch) fail to round appropriately; for instance, a call of sfround(

Postgresql Create Trigger Before Deleting A Row

不问归期 提交于 2020-01-01 19:37:10
问题 so i have these two tables: Table user columns: id,name,surname, password,token,earnedmoney Table addlisting columns: id, user_fk,price,date_added Here is my problem: I would like to create a trigger so that when I delete a listing from the table addlisting, the price of the listing gets added to the column "earnedmoney" which is in the table user. Could somebody help me? Thank you! 回答1: CREATE OR REPLACE FUNCTION add_money() RETURNS trigger AS $$BEGIN UPDATE "user" SET earnedmoney =

Optimizing a stored function call in SELECT and WHERE clauses

心已入冬 提交于 2020-01-01 09:29:28
问题 I have an SQL query with the following structure: SELECT *, storedfunc(param, table.field) as f FROM table WHERE storedfunc(param, table.field) < value ORDER BY storedfunc(param, table.field); Is there a way to optimize this eliminating several function calls? Or does MySQL perform such optimization behind the scene? In fact the function is declared as deterministic. I need also to mention that the function params are partially from selected table's columns. I changed the example slightly to

Stored Procedure to Open and Read a text file

♀尐吖头ヾ 提交于 2019-12-30 09:09:17
问题 I am looking for a stored procedure code that will open a text file, read in several thousand lines, and add the code to a table in the database. Is there a simple way to implement this in T-SQL? 回答1: If the file is ready to load "as-is" (no data transformations or complex mappings required), you can use the Bulk Insert command: CREATE PROC dbo.uspImportTextFile AS BULK INSERT Tablename FROM 'C:\ImportFile.txt' WITH ( FIELDTERMINATOR ='|', FIRSTROW = 2 ) http://msdn.microsoft.com/en-us

Value or Numeric error in a function and I can't detect where I have gone wrong Oracle

假装没事ソ 提交于 2019-12-25 18:52:04
问题 I have a function written in SQL developer and every time I want to execute I get value or numeric error and I simply cannot get where I have gone wrong. This is my code so if someone can give me some tips on where my mistake is hidden I would be grateful. The types that are used in the code are defined and mostly consist of varchar objects and tables of objects and I am properly putting them as an input variable. I am getting frustrated with that error because I have written similar function

Value or Numeric error in a function and I can't detect where I have gone wrong Oracle

北战南征 提交于 2019-12-25 18:51:50
问题 I have a function written in SQL developer and every time I want to execute I get value or numeric error and I simply cannot get where I have gone wrong. This is my code so if someone can give me some tips on where my mistake is hidden I would be grateful. The types that are used in the code are defined and mostly consist of varchar objects and tables of objects and I am properly putting them as an input variable. I am getting frustrated with that error because I have written similar function