stored-procedures

Data is Null. This method or property cannot be called on Null values

馋奶兔 提交于 2020-06-10 02:08:28
问题 I'm working on an application where one can get information on movies from a database as well as add, update and delete the movies. In the database I have three tables (Movie, Genre and MovieGenre <- stores the movies and their genre/s). Everything works fine besides one thing, and that's when a movie hasn't got any genres (which should be possible). The problem occur in the method below, and the following exception is thrown: Data is Null. This method or property cannot be called on Null

Select columns from function call in sqlalchemy core

匆匆过客 提交于 2020-06-08 20:03:25
问题 In postgresql I have select col1, col2 from my_function() . How can I do that in sqlalchemy core? select(func.my_function()) gives the result as a string, but I want a tuple. 回答1: You'll want to use FunctionElement.alias() and the light weight column(): from sqlalchemy import func, select, column stmt = select([column('col1'), column('col2')]).\ select_from(func.my_function().alias()) The documentation specifically mentions Postgresql as a use case for this construct. The above produces:

Select columns from function call in sqlalchemy core

限于喜欢 提交于 2020-06-08 20:03:01
问题 In postgresql I have select col1, col2 from my_function() . How can I do that in sqlalchemy core? select(func.my_function()) gives the result as a string, but I want a tuple. 回答1: You'll want to use FunctionElement.alias() and the light weight column(): from sqlalchemy import func, select, column stmt = select([column('col1'), column('col2')]).\ select_from(func.my_function().alias()) The documentation specifically mentions Postgresql as a use case for this construct. The above produces:

Can a Postgres Commit Exist in Procedure that has an Exception Block?

余生颓废 提交于 2020-06-08 07:21:11
问题 I am having a difficult time understanding transactions in Postgres. I have a procedure that may encounter an exception. There are parts of the procedure where I might want to commit my work so-far so that it won't be rolled back if an exceptions ensues. I want to have an exception handling block at the end of the procedure where I catch the exception and insert the information from the exception into a logging table. I have boiled the problem down to a simple procedure, below, which fails on

What is wrong with this stored procedure?

感情迁移 提交于 2020-06-06 08:31:45
问题 I keep getting this error for the below MySQL SP any ideas? CREATE PROCEDURE productpricing( OUT pl DECIMAL(8,2), OUT ph DECIMAL(8,2), OUT pa DECIMAL(8,2) ) BEGIN SELECT Min(amount) INTO pl FROM Card Error Code: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 9 0.000 sec DROP PROCEDURE IF EXISTS productpricing; CREATE PROCEDURE productpricing( OUT pl DECIMAL(8,2), OUT ph DECIMAL(8,2), OUT pa

What is wrong with this stored procedure?

青春壹個敷衍的年華 提交于 2020-06-06 08:30:09
问题 I keep getting this error for the below MySQL SP any ideas? CREATE PROCEDURE productpricing( OUT pl DECIMAL(8,2), OUT ph DECIMAL(8,2), OUT pa DECIMAL(8,2) ) BEGIN SELECT Min(amount) INTO pl FROM Card Error Code: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 9 0.000 sec DROP PROCEDURE IF EXISTS productpricing; CREATE PROCEDURE productpricing( OUT pl DECIMAL(8,2), OUT ph DECIMAL(8,2), OUT pa

Add invalid remarks for each invalid records inserted into the invalid table in oracle

大城市里の小女人 提交于 2020-05-30 07:48:28
问题 I have a cursor which inserts the valid data into valid table and invalid data into invalid table based on several criteria. Below is my cursor logic for the same. create or replace PROCEDURE FIP_VAL_INV_DATA AS l_state_name r4g_lb.mantainenceboundary_evw.jiostatename%type; l_maint_zone_code r4g_lb.mantainenceboundary_evw.maintenancezonecode%type; l_maint_zone_name r4g_lb.mantainenceboundary_evw.maintenancezonename%type; l_state_code r4g_lb.mantainenceboundary_evw.jiostatecode%type; begin for

Passing parameters to stored procedure in OBIEE 12c rpd from OBIEE 12c dashboard

大憨熊 提交于 2020-05-30 04:24:21
问题 I am trying to create an OBIEE report using stored procedures. I have created a function in SQL Developer which takes a parameter and returns refCursor as output. I, then, set the following query as default initialization string in physical layer of rpd: Select * from table(pipelined_emp(HR_DATA.GETCURSORS(parameter))) GETCURSORS(parameter) is my function. For now, in place of parameter , I am passing a constant value. While, I wish to pass a value from the OBIEE dashboard, similar to a

How to create a temporary table inside Stored Procedure before opening a cursor?

元气小坏坏 提交于 2020-05-29 11:38:51
问题 I'm trying to create a temporary table within a Stored Procedure to perform multiple operations on it and then execute a select statement. I haven't had success using global temporary tables. When I execute the code below I get an ORA-00942 error (table or view does not exists). I must return the cursor to use it in Spring. Any ideas? PROCEDURE DELETME ( O_CURSOR OUT tCursor, COD_ERROR OUT NUMBER, MSM_ERROR OUT VARCHAR2 ) AS BEGIN execute immediate 'create global temporary table my_temp_table

How to create a temporary table inside Stored Procedure before opening a cursor?

淺唱寂寞╮ 提交于 2020-05-29 11:38:27
问题 I'm trying to create a temporary table within a Stored Procedure to perform multiple operations on it and then execute a select statement. I haven't had success using global temporary tables. When I execute the code below I get an ORA-00942 error (table or view does not exists). I must return the cursor to use it in Spring. Any ideas? PROCEDURE DELETME ( O_CURSOR OUT tCursor, COD_ERROR OUT NUMBER, MSM_ERROR OUT VARCHAR2 ) AS BEGIN execute immediate 'create global temporary table my_temp_table