Search
 
SCRIPT & CODE EXAMPLE
 

SQL

check psql validity function

CREATE OR REPLACE FUNCTION is_sql(sql text) returns boolean
    language plpgsql
AS
$$
DECLARE
    exception_message text;
    exception_context text;
BEGIN
    BEGIN
        EXECUTE E'DO $IS_SQL$ BEGIN
RETURN;
' || trim(trailing E'; 
' from sql) || E';
END; $IS_SQL$;';
    EXCEPTION WHEN syntax_error THEN
        GET STACKED DIAGNOSTICS
            exception_message = MESSAGE_TEXT,
            exception_context = PG_EXCEPTION_CONTEXT;
        RAISE NOTICE '%', exception_context;
        RAISE NOTICE '%', exception_message;
        RETURN FALSE;
    END;
    RETURN TRUE;
END
$$;

-- TEST
SELECT is_sql('SELECTx'), is_sql('SELECT x');
Comment

PREVIOUS NEXT
Code Example
Sql :: connecting to my cloud sql server with c# 
Sql :: ring MySQL execute a query on the database then print the result. 
Sql :: umgebungsvariable setzen für mysql 8 
Sql :: difference between nvl and nvl2 in oracle 
Sql :: set default value now() date 
Sql :: sakila database erd postgresql 
Sql :: closure in sql 
Sql :: dataframe lambda elif 
Sql :: sqlites studio red exclamation mark when poening databse 
Sql :: crear usuario oracle 
Sql :: sql $ symbol usage 
Sql :: add two days to current date in sql when creating tables 
Sql :: which lock mode is not available in sql 
Sql :: sql values that contains certain multiple ids 
Sql :: sum over partition by postgresql 
Sql :: mysql create user if not exists 
Sql :: power bi connect to postgresql 
Sql :: "Edad en Oracle" 
Sql :: export all stored procedures to .sql files 
Sql :: mysql docker image arjun 
Sql :: insert data 
Sql :: export data from excel to sql server 
Sql :: how to insert multiple values in a single column in sql 
Sql :: insert into table with only identity column 
Sql :: add 10 to all numbers in a column sql 
Sql :: kill mysqld_safe process mariadb 
Csharp :: how to load the active scene unity 
Csharp :: c# store byte array as string 
Csharp :: how to get ip address in c# 
Csharp :: create or update in laaravel 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =