Skip to content

Instantly share code, notes, and snippets.

@BrunoGiubilei
Created November 4, 2019 12:56
Show Gist options
  • Save BrunoGiubilei/dde881a8f0262de8d4618b68769e5f44 to your computer and use it in GitHub Desktop.
Save BrunoGiubilei/dde881a8f0262de8d4618b68769e5f44 to your computer and use it in GitHub Desktop.
Transforma SQL em variáveis JAVA
SELECT 'private '||(
CASE
WHEN data_type = 'integer' or data_type = 'bigint' THEN 'int'
WHEN data_type = 'timestamp with time zone' or data_type = 'timestamp without time zone' or data_type = 'time without time zone'
or data_type = 'character varying' or data_type = 'character' or data_type = 'char' or data_type = 'date' or data_type = 'text' THEN 'String'
WHEN data_type = 'double precision' or data_type = 'numeric' THEN 'double'
ELSE data_type END)||' '||column_name||';'
FROM information_schema.columns WHERE
table_name = 'nome_da_tabela';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment