How to make a copy of trigger function in postgreSQL pgadmin 4? - sql

I am using postgreSQL with pgAdmin 4 and I have created a database function named "fn_test1()". I want to delete this function and before delete this function, I want to create a backup function named "fn_test1_bk()" . Can anyone help me to do this?

If you really want to use PgAdmin for this, you can browse to your function, right click, properties, change the name and save.

Related

I need help understanding view script

This is a view script, (dbo.Get_Qty_Sum) is a scalar function. I need to understand how the code is combining the scalar function with (c.Schedule_ref, c.Schedule_Line, c.master_part) END) –
Too long for a comment and readability...
If you are using SQL-Server, you need to get the underlying scalar function. Edit your original post question and paste what you find in that. Don't try to post the query as a comment response.
In SQL-Server Management studio, expand the databases folder.
Expand the specific database you are querying against (in case there are multiple databases on your server).
Expand the folder for Programmability
Expand the folder for Scalar-valued Functions
Scroll down to the name of your function "Get_Qty_Sum"
Then right-click, select Script Function as, Drop and Create To, New Query Editor Window.
This will put the entire query in that window for you to look at. THAT is what would be needed to edit and post within your original question. It might even expose to you what your own answer can get, you just did not know how / where it was coming from.

Call a SQL function in Nifi using ExecuteSQL or another processor

I am currently using a function in SQL Server to get the max-value of a certain column. I Need this value to generate a specific number of dummy files to insert flowfiles that are created later on.
Is there a way of calling this function via a nifi-processor?
By using ExecuteSQL I Always get error like unable to execute SQL select query or the column "ab" was not found, when using select ab.functionname() (ab is the loginname of the db)
In SQL Server I can just use select ab.functionname() and get the desired results.
If there is no possible way of calling this function, is there another way to create #flowfiles dummyfiles to reserve this place for them in the DB so that no one else could insert or use this ids (not autoincremt, because it is not possible) while the flowfiles are getting processed?
I tried using $flowfile.count and the Counterprocessor, but this did not solve the Problem.
It should look like: INSERT INTO table (id,nr) values (max(id)+1,anynumber) for every flowfiles, unfortunately the ExecuteSQL is not able to do this.
Think this conversation can help you:
https://community.hortonworks.com/questions/26170/does-executesql-processor-allow-to-execute-stored.html
Gist:
You can use ExecuteScript or ExecuteProcess to call appropriate script. For example for ExecuteProcess just call sqlplus command. Choose type of command "sqlplus". In command arguments set something like: user_id/password#dbname #"script_path/someScript.sql". In someScript.sql you put something like:
execute spname(param)
You can write your own processor :) Of course it's more difficulty and often unnecessary

How to save a view in BigQuery - Standard SQL Dialect

I am trying to save a view using BigQuery's WebUI, which was created in Standard SQL Dialect, but I am getting this error:
Failed to save view. Bad table reference "myDataset.myTable"; table references in standard SQL views require explicit project IDs
Why is this error showing up? How can I fix it? Should the "Table ID" field of the "Save view" dialog include the project id? Or does this error appear because of the query itself? Just in case, the query is running without any problems.
Thanks for your help.
Your view has reference to myDataset.myTable - which is ok when you just run it as a query (for example in Web UI).
But to save it as a view you must fully qualify that reference as below
myProject.myDataset.myTable
So, just add project to that reference
Same reply, in other words
The issue is in this part of query: FROM com.table
When running query, it's fine to not fully specify the name of table like this:
com_company_app_beta_IOS.app_events_20180619
But to save the query as a view the FROM has to be like this:
`company-prod`.com_company_app_beta_IOS.app_events_20180619
You need the backticks around the `company-prod` because the - dash character is unsupported in object names.
The structure in BigQuery look like this:
bigquery ui
I had the same problem.
You'll need to use backticks around the the whole string project.dataset.view/table in both create and select statements:
create view company-prod.com_company_app_beta_IOS.YOUR_VIEW as
select * from company-prod.com_company_app_beta_IOS.app_events_20180619
Use backticks around string project.dataset.view

removeCurrent only delete in datagridview but not in database

I am using vb.net and ms access for database. i have 1 delete button but it not working as I want it to be. it just delete current row in data grid view, it does not delete the data in database. this is my code:
Test123BindingSource.RemoveCurrent()
and i also tried this code. it works on another program i'm developing but didnt work for this program.
Test123BindingSource.RemoveCurrent()
Test123TableAdapter.Update(ABCDEDataSet.Test123)
Does anyone have any ideas how to resolve this? Thank you in advance!
Don't use update Option in Delete Button
but Add an Update button to update the records in Databse
That's What I have done

How to call a big Stored procedure in Qlikview having 3 parameter

I have a stored procedure which contains 3 input parameters with multiple SELECTs and INNER JOINs. I want to Call the stored procedure in QlikView. I followed lots of tutorials, but I make it work.
I am Using OLE DB and I'm trying to call as follows:
SQL CALL [DB NAME].[dbo].[ABC] #_ End-Time ='2012-12-31 00:21:06.550', #_ Start-time = '2012-12-31 00:21:06.550',
#_ Username = 'XYZ';
Is this correct? If not, what are the ways to call stored procedures into Qlikview and what permission do I need for this?
i'm not sure that you checked this thread (http://goo.gl/IiGD2) but it might be useful. Couple of things that i'm noticing from it: there is additional string that need to be added to the connection string "(mode is write)" and also to activate the "Open Databases in Read and Write mode" in qv.
Also make sure that you have sql rights to execute.
Regards!
Stefan
A workaround could be to retrieve the three input variables from a table instead, and update this table from qlikview using SQL insert.
It may be possible to run an store procedure from QlikView, but it is not possible to pull any output you get from it. You should convert that to a function if you want to retrieve any data from QlikView.
Creating a MV is your best course of action, and you will have a better performance.